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

Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
08a8de8
Add keywords item into the sidebar
GuillaumeGomez Jul 25, 2019
f3a3290
Account for maybe_whole_expr in range patterns.
Centril Jul 30, 2019
87e73c1
Remove redundant method with const variable resolution
varkor Jul 31, 2019
01f97c3
Unify Github issue links in diagnostics
eupn Jul 26, 2019
1ef1e7f
Bless ui test files
eupn Jul 26, 2019
7336626
Apply suggestions from review by varkor
eupn Jul 30, 2019
804f0f3
Unify spanned and non-spanned Attribute ctors
Mark-Simulacrum Jul 30, 2019
0a42bad
Remove AttrId from Attribute constructors
Mark-Simulacrum Jul 30, 2019
b2c5065
Remove Span argument from ExtCtxt::attribute
Mark-Simulacrum Jul 30, 2019
f78bf50
Remove span argument from mk_attr_{inner,outer}
Mark-Simulacrum Jul 30, 2019
c9bd4a0
Replace a few Attribute constructors with mk_attr
Mark-Simulacrum Jul 30, 2019
0f98581
Replace AstBuilder with inherent methods
Mark-Simulacrum Jul 31, 2019
d4227f6
Use Ident::new over setting span position via builder
Mark-Simulacrum Jul 31, 2019
c146344
Decode AttrId via mk_attr_id
Mark-Simulacrum Jul 30, 2019
3f461f5
cleanup StringReader fields
matklad Jul 31, 2019
6551285
Address review comments.
Centril Jul 31, 2019
49c9b22
Rollup merge of #62971 - GuillaumeGomez:keyword-sidebar, r=nobody
Centril Jul 31, 2019
07675af
Rollup merge of #63008 - eupn:consistent-see-issue, r=varkor
Centril Jul 31, 2019
2955448
Rollup merge of #63122 - Centril:fix-63115, r=petrochenkov
Centril Jul 31, 2019
7baf870
Rollup merge of #63146 - Mark-Simulacrum:clean-attr, r=petrochenkov
Centril Jul 31, 2019
28461b6
Rollup merge of #63153 - varkor:remove-resolve_const_var, r=cramertj
Centril Jul 31, 2019
cb4c25b
Rollup merge of #63170 - matklad:cleanup-fields, r=petrochenkov
Centril Jul 31, 2019
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
9 changes: 3 additions & 6 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ macro_rules! maybe_whole_expr {
$p.token.span, ExprKind::Block(block, None), ThinVec::new()
));
}
// N.B: `NtIdent(ident)` is normalized to `Ident` in `fn bump`.
_ => {},
};
}
Expand Down Expand Up @@ -2756,12 +2757,7 @@ impl<'a> Parser<'a> {
// can't continue an expression after an ident
token::Ident(name, is_raw) => token::ident_can_begin_expr(name, t.span, is_raw),
token::Literal(..) | token::Pound => true,
token::Interpolated(ref nt) => match **nt {
token::NtIdent(..) | token::NtExpr(..) |
token::NtBlock(..) | token::NtPath(..) => true,
_ => false,
},
_ => false
_ => t.is_whole_expr(),
};
let cannot_continue_expr = self.look_ahead(1, token_cannot_continue_expr);
if cannot_continue_expr {
Expand Down Expand Up @@ -3728,6 +3724,7 @@ impl<'a> Parser<'a> {
self.token.is_path_start() // e.g. `MY_CONST`;
|| self.token == token::Dot // e.g. `.5` for recovery;
|| self.token.can_begin_literal_or_bool() // e.g. `42`.
|| self.token.is_whole_expr()
}

// Helper function to decide whether to parse as ident binding
Expand Down
13 changes: 13 additions & 0 deletions src/libsyntax/parse/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,19 @@ impl Token {
false
}

/// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
/// That is, is this a pre-parsed expression dropped into the token stream
/// (which happens while parsing the result of macro expansion)?
crate fn is_whole_expr(&self) -> bool {
if let Interpolated(ref nt) = self.kind {
if let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtIdent(..) | NtBlock(_) = **nt {
return true;
}
}

false
}

/// Returns `true` if the token is either the `mut` or `const` keyword.
crate fn is_mutability(&self) -> bool {
self.is_keyword(kw::Mut) ||
Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/parser/issue-63115-range-pat-interpolated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// check-pass

#![feature(exclusive_range_pattern)]

#![allow(ellipsis_inclusive_range_patterns)]

fn main() {
macro_rules! mac_expr {
($e:expr) => {
if let 2...$e = 3 {}
if let 2..=$e = 3 {}
if let 2..$e = 3 {}
}
}
mac_expr!(4);
}
28 changes: 28 additions & 0 deletions src/test/ui/parser/recover-range-pats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,31 @@ fn inclusive2_to() {
//~| ERROR `...` range patterns are deprecated
//~| ERROR mismatched types
}

fn with_macro_expr_var() {
macro_rules! mac2 {
($e1:expr, $e2:expr) => {
let $e1..$e2;
let $e1...$e2;
//~^ ERROR `...` range patterns are deprecated
let $e1..=$e2;
}
}

mac2!(0, 1);

macro_rules! mac {
($e:expr) => {
let ..$e; //~ ERROR `..X` range patterns are not supported
let ...$e; //~ ERROR `...X` range patterns are not supported
//~^ ERROR `...` range patterns are deprecated
let ..=$e; //~ ERROR `..=X` range patterns are not supported
let $e..; //~ ERROR `X..` range patterns are not supported
let $e...; //~ ERROR `X...` range patterns are not supported
//~^ ERROR `...` range patterns are deprecated
let $e..=; //~ ERROR `X..=` range patterns are not supported
}
}

mac!(0);
}
83 changes: 82 additions & 1 deletion src/test/ui/parser/recover-range-pats.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,60 @@ error: `...X` range patterns are not supported
LL | if let ....3 = 0 {}
| ^^^^^ help: try using the minimum value for the type: `MIN...0.3`

error: `..X` range patterns are not supported
--> $DIR/recover-range-pats.rs:139:17
|
LL | let ..$e;
| ^^ help: try using the minimum value for the type: `MIN..0`
...
LL | mac!(0);
| -------- in this macro invocation

error: `...X` range patterns are not supported
--> $DIR/recover-range-pats.rs:140:17
|
LL | let ...$e;
| ^^^ help: try using the minimum value for the type: `MIN...0`
...
LL | mac!(0);
| -------- in this macro invocation

error: `..=X` range patterns are not supported
--> $DIR/recover-range-pats.rs:142:17
|
LL | let ..=$e;
| ^^^ help: try using the minimum value for the type: `MIN..=0`
...
LL | mac!(0);
| -------- in this macro invocation

error: `X..` range patterns are not supported
--> $DIR/recover-range-pats.rs:143:19
|
LL | let $e..;
| ^^ help: try using the maximum value for the type: `0..MAX`
...
LL | mac!(0);
| -------- in this macro invocation

error: `X...` range patterns are not supported
--> $DIR/recover-range-pats.rs:144:19
|
LL | let $e...;
| ^^^ help: try using the maximum value for the type: `0...MAX`
...
LL | mac!(0);
| -------- in this macro invocation

error: `X..=` range patterns are not supported
--> $DIR/recover-range-pats.rs:146:19
|
LL | let $e..=;
| ^^^ help: try using the maximum value for the type: `0..=MAX`
...
LL | mac!(0);
| -------- in this macro invocation

error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:41:13
|
Expand Down Expand Up @@ -316,6 +370,33 @@ error: `...` range patterns are deprecated
LL | if let ....3 = 0 {}
| ^^^ help: use `..=` for an inclusive range

error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:129:20
|
LL | let $e1...$e2;
| ^^^ help: use `..=` for an inclusive range
...
LL | mac2!(0, 1);
| ------------ in this macro invocation

error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:140:17
|
LL | let ...$e;
| ^^^ help: use `..=` for an inclusive range
...
LL | mac!(0);
| -------- in this macro invocation

error: `...` range patterns are deprecated
--> $DIR/recover-range-pats.rs:144:19
|
LL | let $e...;
| ^^^ help: use `..=` for an inclusive range
...
LL | mac!(0);
| -------- in this macro invocation

error[E0029]: only char and numeric types are allowed in range patterns
--> $DIR/recover-range-pats.rs:19:12
|
Expand Down Expand Up @@ -532,7 +613,7 @@ LL | if let ....3 = 0 {}
= note: expected type `{integer}`
found type `{float}`

error: aborting due to 76 previous errors
error: aborting due to 85 previous errors

Some errors have detailed explanations: E0029, E0308.
For more information about an error, try `rustc --explain E0029`.