Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
91cf0e7
Don't requery the param_env of a union
matthewjasper Jan 30, 2020
570c161
Remove unnecessary features in rustc_ty
matthewjasper Jan 30, 2020
3973322
Add IS_MANUALLY_DROP to AdtFlags
matthewjasper Jan 30, 2020
d196521
Improve needs_drop query
matthewjasper Jan 30, 2020
d20646b
Address review comments
matthewjasper Jan 31, 2020
465b862
Use correct `ParamEnv` in `Instance::resolve`
matthewjasper Feb 1, 2020
6bf2cc2
Avoid instantiating many `Parser` structs in `generic_extension`.
nnethercote Feb 4, 2020
f840a95
Remove the `Cow` from `Directory`.
nnethercote Feb 5, 2020
2a13b24
Change condition ordering in `parse_tt`.
nnethercote Feb 5, 2020
3998249
remove unnecessary local variable assignment in context manager
chrissimpkins Feb 8, 2020
19aaf63
PEP8 format spacing
chrissimpkins Feb 8, 2020
6ce8d2b
PEP8 format spacing
chrissimpkins Feb 8, 2020
adde3d4
PEP8 format spacing
chrissimpkins Feb 8, 2020
60889d4
remove unnecessary semicolons
chrissimpkins Feb 8, 2020
e30dd86
PEP8 format spacing
chrissimpkins Feb 8, 2020
f38e270
remove unnecessary sys import
chrissimpkins Feb 8, 2020
d366343
PEP8 format spacing
chrissimpkins Feb 8, 2020
a53f45f
PEP8 format spacing, split import statements
chrissimpkins Feb 8, 2020
8d04b95
remove unnecessary import statement
chrissimpkins Feb 8, 2020
85e3661
PEP8 format spacing, remove unnecessary local variable assignment
chrissimpkins Feb 8, 2020
814aa06
PEP8 format spacing
chrissimpkins Feb 8, 2020
9b10fc4
remove unnecessary import statement, PEP8 format spacing
chrissimpkins Feb 8, 2020
77d158d
shorten comment blocks to < 100 characters
chrissimpkins Feb 8, 2020
3eb5241
Apply suggestions from code review
matthewjasper Feb 9, 2020
842938a
cache adt_drop_tys
matthewjasper Feb 9, 2020
202d401
miri: simplify singed operator overflow detection
RalfJung Feb 9, 2020
28f85c6
bring back extra check for int_min%-1
RalfJung Feb 9, 2020
7d2f6ae
miri: equip unary_op with overflow detection
RalfJung Feb 8, 2020
ae23f70
const-prop: use overflowing_unary_op for overflowing checking of unar…
RalfJung Feb 9, 2020
b434d7e
add test that checks overflows on arithmetic operators
RalfJung Feb 10, 2020
1ddb050
div/rem overflow tests: also test i128
RalfJung Feb 10, 2020
d6c5a04
some more tests for i128 oveflow behavior
RalfJung Feb 10, 2020
b8893df
preallocate 2 Vecs in traits; tweak WfPredicates::normalize
ljedrz Feb 10, 2020
9e78ce0
handle TerminatorKind::Yield by returning Err(Unpromotable)
chrissimpkins Feb 10, 2020
75afd0b
use `dyn Trait` more in tests
Centril Feb 10, 2020
fc3ecb2
add issue 69017 test
chrissimpkins Feb 10, 2020
8d79921
parser: Remove `Parser::prev_token_kind`
petrochenkov Feb 10, 2020
25de80a
Remove common usage pattern from `AllocRef`
TimDiekmann Feb 10, 2020
97d1f8d
Add missing `_zeroed` varants to `AllocRef`
TimDiekmann Feb 10, 2020
53b16fb
add main function to issue-69017 test
chrissimpkins Feb 10, 2020
c561d23
remove outdated comment
RalfJung Feb 10, 2020
c38b4b6
Specify opt-level in test
matthewjasper Feb 10, 2020
6575abc
Don't rustfmt the vendor directory.
ehuss Feb 11, 2020
98b3d21
Rollup merge of #68679 - matthewjasper:needs-type-op, r=varkor
jonas-schievink Feb 11, 2020
2125b06
Rollup merge of #68848 - nnethercote:hasten-macro-parsing, r=petroche…
jonas-schievink Feb 11, 2020
7b4772a
Rollup merge of #68947 - chrissimpkins:python-fmt, r=alexcrichton
jonas-schievink Feb 11, 2020
98e8d78
Rollup merge of #69002 - RalfJung:miri-op-overflow, r=oli-obk,wesleyw…
jonas-schievink Feb 11, 2020
cede9c1
Rollup merge of #69022 - ljedrz:traits_tweak_vecs, r=petrochenkov
jonas-schievink Feb 11, 2020
fc25e05
Rollup merge of #69026 - TimDiekmann:common-usage, r=Amanieu
jonas-schievink Feb 11, 2020
9e72cc8
Rollup merge of #69027 - TimDiekmann:zeroed-alloc, r=Amanieu
jonas-schievink Feb 11, 2020
ff8d628
Rollup merge of #69031 - Centril:dyntest, r=eddyb
jonas-schievink Feb 11, 2020
3cf7cd8
Rollup merge of #69032 - chrissimpkins:ice-yield-println-#69017, r=pe…
jonas-schievink Feb 11, 2020
8fcb1a3
Rollup merge of #69034 - petrochenkov:notokind, r=Centril
jonas-schievink Feb 11, 2020
4f1f2b5
Rollup merge of #69047 - ehuss:rustfmt-vendor, r=Centril
jonas-schievink Feb 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 12 additions & 17 deletions src/librustc_parse/parser/expr.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::pat::{GateOr, PARAM_EXPECTED};
use super::ty::{AllowPlus, RecoverQPath};
use super::{BlockMode, Parser, PathStyle, PrevTokenKind, Restrictions, TokenType};
use super::{BlockMode, Parser, PathStyle, Restrictions, TokenType};
use super::{SemiColonMode, SeqSep, TokenExpectType};
use crate::maybe_recover_from_interpolated_ty_qpath;

Expand Down Expand Up @@ -166,17 +166,10 @@ impl<'a> Parser<'a> {

self.expected_tokens.push(TokenType::Operator);
while let Some(op) = self.check_assoc_op() {
// Adjust the span for interpolated LHS to point to the `$lhs` token and not to what
// it refers to. Interpolated identifiers are unwrapped early and never show up here
// as `PrevTokenKind::Interpolated` so if LHS is a single identifier we always process
// it as "interpolated", it doesn't change the answer for non-interpolated idents.
let lhs_span = match (self.prev_token_kind, &lhs.kind) {
(PrevTokenKind::Interpolated, _) => self.prev_span,
(PrevTokenKind::Ident, &ExprKind::Path(None, ref path))
if path.segments.len() == 1 =>
{
self.prev_span
}
// Adjust the span for interpolated LHS to point to the `$lhs` token
// and not to what it refers to.
let lhs_span = match self.unnormalized_prev_token().kind {
TokenKind::Interpolated(..) => self.prev_span,
_ => lhs.span,
};

Expand Down Expand Up @@ -535,11 +528,13 @@ impl<'a> Parser<'a> {
expr: PResult<'a, P<Expr>>,
) -> PResult<'a, (Span, P<Expr>)> {
expr.map(|e| {
if self.prev_token_kind == PrevTokenKind::Interpolated {
(self.prev_span, e)
} else {
(e.span, e)
}
(
match self.unnormalized_prev_token().kind {
TokenKind::Interpolated(..) => self.prev_span,
_ => e.span,
},
e,
)
})
}

Expand Down
38 changes: 6 additions & 32 deletions src/librustc_parse/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath {
};
}

#[derive(Debug, Clone, Copy, PartialEq)]
enum PrevTokenKind {
DocComment,
Comma,
Plus,
Interpolated,
Eof,
Ident,
BitOr,
Other,
}

#[derive(Clone)]
pub struct Parser<'a> {
pub sess: &'a ParseSess,
Expand All @@ -114,9 +102,6 @@ pub struct Parser<'a> {
/// Preferable use is through the `unnormalized_prev_token()` getter.
/// Use span from this token if you need to concatenate it with some neighbouring spans.
unnormalized_prev_token: Option<Token>,
/// Equivalent to `prev_token.kind` in simplified form.
/// FIXME: Remove in favor of `(unnormalized_)prev_token().kind`.
prev_token_kind: PrevTokenKind,
/// Equivalent to `unnormalized_prev_token().span`.
/// FIXME: Remove in favor of `(unnormalized_)prev_token().span`.
pub prev_span: Span,
Expand Down Expand Up @@ -395,7 +380,6 @@ impl<'a> Parser<'a> {
unnormalized_token: None,
prev_token: Token::dummy(),
unnormalized_prev_token: None,
prev_token_kind: PrevTokenKind::Other,
prev_span: DUMMY_SP,
restrictions: Restrictions::empty(),
recurse_into_file_modules,
Expand Down Expand Up @@ -522,10 +506,11 @@ impl<'a> Parser<'a> {
self.bump();
Ok(Ident::new(name, span))
}
_ => Err(if self.prev_token_kind == PrevTokenKind::DocComment {
self.span_fatal_err(self.prev_span, Error::UselessDocComment)
} else {
self.expected_ident_found()
_ => Err(match self.prev_token.kind {
TokenKind::DocComment(..) => {
self.span_fatal_err(self.prev_span, Error::UselessDocComment)
}
_ => self.expected_ident_found(),
}),
}
}
Expand Down Expand Up @@ -907,7 +892,7 @@ impl<'a> Parser<'a> {

/// Advance the parser by one token.
pub fn bump(&mut self) {
if self.prev_token_kind == PrevTokenKind::Eof {
if self.prev_token.kind == TokenKind::Eof {
// Bumping after EOF is a bad sign, usually an infinite loop.
let msg = "attempted to bump the parser past EOF (may be stuck in a loop)";
self.span_bug(self.token.span, msg);
Expand All @@ -919,16 +904,6 @@ impl<'a> Parser<'a> {
self.unnormalized_prev_token = self.unnormalized_token.take();

// Update fields derived from the previous token.
self.prev_token_kind = match self.prev_token.kind {
token::DocComment(..) => PrevTokenKind::DocComment,
token::Comma => PrevTokenKind::Comma,
token::BinOp(token::Plus) => PrevTokenKind::Plus,
token::BinOp(token::Or) => PrevTokenKind::BitOr,
token::Interpolated(..) => PrevTokenKind::Interpolated,
token::Eof => PrevTokenKind::Eof,
token::Ident(..) => PrevTokenKind::Ident,
_ => PrevTokenKind::Other,
};
self.prev_span = self.unnormalized_prev_token().span;

self.expected_tokens.clear();
Expand All @@ -948,7 +923,6 @@ impl<'a> Parser<'a> {
self.unnormalized_prev_token = self.unnormalized_token.take();

// Update fields derived from the previous token.
self.prev_token_kind = PrevTokenKind::Other;
self.prev_span = self.unnormalized_prev_token().span.with_hi(span.lo());

self.expected_tokens.clear();
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_parse/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::diagnostics::Error;
use super::expr::LhsExpr;
use super::pat::GateOr;
use super::path::PathStyle;
use super::{BlockMode, Parser, PrevTokenKind, Restrictions, SemiColonMode};
use super::{BlockMode, Parser, Restrictions, SemiColonMode};
use crate::maybe_whole;
use crate::DirectoryOwnership;

Expand Down Expand Up @@ -190,7 +190,7 @@ impl<'a> Parser<'a> {
/// Also error if the previous token was a doc comment.
fn error_outer_attrs(&self, attrs: &[Attribute]) {
if !attrs.is_empty() {
if self.prev_token_kind == PrevTokenKind::DocComment {
if matches!(self.prev_token.kind, TokenKind::DocComment(..)) {
self.span_fatal_err(self.prev_span, Error::UselessDocComment).emit();
} else if attrs.iter().any(|a| a.style == AttrStyle::Outer) {
self.struct_span_err(self.token.span, "expected statement after outer attribute")
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_parse/parser/ty.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::item::ParamCfg;
use super::{Parser, PathStyle, PrevTokenKind, TokenType};
use super::{Parser, PathStyle, TokenType};

use crate::{maybe_recover_from_interpolated_ty_qpath, maybe_whole};

Expand All @@ -14,7 +14,7 @@ use syntax::ast::{
};
use syntax::ast::{Mac, Mutability};
use syntax::ptr::P;
use syntax::token::{self, Token};
use syntax::token::{self, Token, TokenKind};

/// Any `?` or `?const` modifiers that appear at the start of a bound.
struct BoundModifiers {
Expand Down Expand Up @@ -196,7 +196,7 @@ impl<'a> Parser<'a> {
let mut trailing_plus = false;
let (ts, trailing) = self.parse_paren_comma_seq(|p| {
let ty = p.parse_ty()?;
trailing_plus = p.prev_token_kind == PrevTokenKind::Plus;
trailing_plus = p.prev_token.kind == TokenKind::BinOp(token::Plus);
Ok(ty)
})?;

Expand Down Expand Up @@ -320,7 +320,7 @@ impl<'a> Parser<'a> {
fn parse_impl_ty(&mut self, impl_dyn_multi: &mut bool) -> PResult<'a, TyKind> {
// Always parse bounds greedily for better error recovery.
let bounds = self.parse_generic_bounds(None)?;
*impl_dyn_multi = bounds.len() > 1 || self.prev_token_kind == PrevTokenKind::Plus;
*impl_dyn_multi = bounds.len() > 1 || self.prev_token.kind == TokenKind::BinOp(token::Plus);
Ok(TyKind::ImplTrait(ast::DUMMY_NODE_ID, bounds))
}

Expand All @@ -340,7 +340,7 @@ impl<'a> Parser<'a> {
self.bump(); // `dyn`
// Always parse bounds greedily for better error recovery.
let bounds = self.parse_generic_bounds(None)?;
*impl_dyn_multi = bounds.len() > 1 || self.prev_token_kind == PrevTokenKind::Plus;
*impl_dyn_multi = bounds.len() > 1 || self.prev_token.kind == TokenKind::BinOp(token::Plus);
Ok(TyKind::TraitObject(bounds, TraitObjectSyntax::Dyn))
}

Expand Down