Vadim Petrochenkov
136db2235a
hygiene: ExpnInfo -> ExpnData
...
For naming consistency with everything else in this area
2019-08-15 20:41:45 +03:00
Vadim Petrochenkov
74190a5e1c
syntax_pos: Remove the duplicate global edition
...
It was introduced to avoid going through `hygiene_data`, but now it's read only once, when `ParseSess` is created, so going through a lock is ok.
2019-08-15 20:41:45 +03:00
Vadim Petrochenkov
1a447738b8
hygiene: Merge ExpnInfo and InternalExpnData
2019-08-15 20:41:45 +03:00
Vadim Petrochenkov
73dee258c1
hygiene: Remove Options from functions returning ExpnInfo
...
The expansion info is not optional and should always exist
2019-08-15 20:39:27 +03:00
Vadim Petrochenkov
6cb28b6617
Ident::with_empty_ctxt -> Ident::with_dummy_span
...
`Ident` has had a full span rather than just a `SyntaxContext` for a long time now.
2019-08-15 20:39:26 +03:00
Vadim Petrochenkov
67d6ce4206
syntax_pos: NO_EXPANSION/SyntaxContext::empty() -> SyntaxContext::root()
...
For consistency with `ExpnId::root`.
Also introduce a helper `Span::with_root_ctxt` for creating spans with `SyntaxContext::root()` context
2019-08-15 20:38:12 +03:00
Vadim Petrochenkov
dfcbe75900
syntax_pos: Introduce a helper for checking whether a span comes from expansion
2019-08-15 20:38:12 +03:00
Vadim Petrochenkov
a6182711ef
Remove Spanned from {ast,hir}::FieldPat
2019-08-15 12:31:50 +03:00
Vadim Petrochenkov
433b1e36e1
Remove Spanned from ast::Mac
2019-08-15 11:45:28 +03:00
Vadim Petrochenkov
73d2da0894
Remove Spanned from mk_name_value_item_str and expr_to_spanned_string
2019-08-15 11:44:22 +03:00
Mazdak Farrokhzad
ad44d42750
Rollup merge of #63543 - c410-f3r:variant, r=c410-f3r
...
Merge Variant and Variant_
Extracted from #63468 .
2019-08-14 22:56:29 +02:00
Mazdak Farrokhzad
d4ecc6f5c0
Rollup merge of #63542 - c410-f3r:node_ids, r=petrochenkov
...
Add NodeId for Arm, Field and FieldPat
Extracted from #63468
2019-08-14 22:56:28 +02:00
Mazdak Farrokhzad
83cd4e3211
Rollup merge of #63537 - petrochenkov:novisit, r=alexcrichton
...
expand: Unimplement `MutVisitor` on `MacroExpander`
Each call to `fully_expand_fragment` is something unique, interesting, and requiring attention.
It represents a "root" of expansion and its use means that something unusual is happening, like eager expansion or expansion performed outside of the primary expansion pass.
So, it shouldn't hide under a generic visitor call.
Also, from all the implemented visitor methods only two were actually used.
cc https://github.com/rust-lang/rust/pull/63468#discussion_r313504119
2019-08-14 22:56:27 +02:00
Mazdak Farrokhzad
409df9b530
Rollup merge of #63528 - petrochenkov:anyany, r=estebank
...
syntax: Remove `DummyResult::expr_only`
The effect is that if a built-in macro both returns an erroneous AST fragment and is used in unexpected position, then the incorrect position error won't be reported.
This combination of two errors should be rare and isn't worth an extra field that makes people ask questions in comments.
(There wasn't even a test making sure it worked.)
Addresses https://github.com/rust-lang/rust/pull/63468#discussion_r313504644
r? @estebank
2019-08-14 22:56:25 +02:00
Mazdak Farrokhzad
aaeff01446
Rollup merge of #63490 - Centril:cleanup-pat-parser, r=petrochenkov
...
libsyntax: cleanup and refactor `pat.rs`
A smaller refactoring & cleanup of `pat.rs` (best read commit by commit).
r? @petrochenkov
2019-08-14 22:56:21 +02:00
Mazdak Farrokhzad
7178cf5f97
Rollup merge of #62984 - nathanwhit:extra_semi_lint, r=varkor
...
Add lint for excess trailing semicolons
Closes #60876 .
A caveat (not necessarily a negative, but something to consider) with this implementation is that excess semicolons after return/continue/break now also cause an 'unreachable statement' warning.
For the following example:
```
fn main() {
extra_semis();
}
fn extra_semis() -> i32 {
let mut sum = 0;;;
for i in 0..10 {
if i == 5 {
continue;;
} else if i == 9 {
break;;
} else {
sum += i;;
}
}
return sum;;
}
```
The output is:
```
warning: unnecessary trailing semicolons
--> src/main.rs:5:21
|
5 | let mut sum = 0;;;
| ^^ help: remove these semicolons
|
= note: `#[warn(redundant_semicolon)]` on by default
warning: unnecessary trailing semicolon
--> src/main.rs:8:22
|
8 | continue;;
| ^ help: remove this semicolon
warning: unnecessary trailing semicolon
--> src/main.rs:10:19
|
10 | break;;
| ^ help: remove this semicolon
warning: unnecessary trailing semicolon
--> src/main.rs:12:22
|
12 | sum += i;;
| ^ help: remove this semicolon
warning: unnecessary trailing semicolon
--> src/main.rs:15:16
|
15 | return sum;;
| ^ help: remove this semicolon
warning: unreachable statement
--> src/main.rs:8:22
|
8 | continue;;
| ^
|
= note: `#[warn(unreachable_code)]` on by default
warning: unreachable statement
--> src/main.rs:10:19
|
10 | break;;
| ^
warning: unreachable statement
--> src/main.rs:15:16
|
15 | return sum;;
| ^
```
2019-08-14 22:56:18 +02:00
Caio
6a42b0b28d
Merge Variant and Variant_
2019-08-14 14:47:01 -03:00
Mazdak Farrokhzad
a8bb3756b6
Rollup merge of #63530 - ehuss:typo-statemement, r=centril
...
Fix typo in error message.
2019-08-14 04:18:57 +02:00
Mazdak Farrokhzad
43f4990fc4
Rollup merge of #63508 - estebank:compromice, r=petrochenkov
...
Do not ICE when synthesizing spans falling inside unicode chars
Fix https://github.com/rust-lang/rust/issues/61226 .
2019-08-14 04:18:51 +02:00
Mazdak Farrokhzad
c824839471
Rollup merge of #63475 - iluuu1994:issue-62632, r=Centril
...
Bring back suggestion for splitting `<-` into `< -`
Closes #62632
2019-08-14 04:18:42 +02:00
Mazdak Farrokhzad
76bd7d62d6
Rollup merge of #63459 - eddyb:issue-63430, r=petrochenkov
...
syntax: account for CVarArgs being in the argument list.
Fixes #63430 by testing for `1` argument (the `CVarArgs` itself) instead of `0`.
Note that the error has basically been impossible to trigger since the change that caused #63430 , so perhaps we need an audit of untested errors.
Also, this check probably belongs in AST validation/HIR lowering, but I'd rather fix it in place for now.
r? @petrochenkov cc @dlrobertson
2019-08-14 04:18:40 +02:00
Caio
9348af8396
Add NodeId for Arm, Field and FieldPat
2019-08-13 22:42:10 -03:00
Vadim Petrochenkov
d416ebeb6e
expand: Unimplement MutVisitor on MacroExpander
...
Each call to `fully_expand_fragment` is something unique, interesting, and requiring attention.
It represents a "root" of expansion and its use means that something unusual is happening, like eager expansion or expansion performed outside of the primary expansion pass.
So, it shouldn't be hide under a generic visitor call.
Also, from all the implemented visitor methods only two were actually used.
2019-08-14 02:35:01 +03:00
Vadim Petrochenkov
0d29142aad
expand: expand_fragment -> fully_expand_fragment
2019-08-14 01:59:14 +03:00
Eric Huss
643ddfaaa8
Apply Centril's suggestion
...
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-08-13 15:09:11 -07:00
Esteban Küber
84e202e6b3
review comments
2019-08-13 11:35:49 -07:00
Eric Huss
ea1a9a0e2b
Fix typo in error message.
2019-08-13 11:21:09 -07:00
Vadim Petrochenkov
376636e517
syntax: Remove DummyResult::expn_only
2019-08-13 20:53:49 +03:00
Esteban Küber
d824edfc2c
Do not ICE when synthesizing spans falling inside unicode chars
2019-08-12 23:31:13 -07:00
nathanwhit
71415ef9bd
Parse excess semicolons as empty stmts for linting
2019-08-12 10:14:07 -04:00
Eduard-Mihai Burtescu
34dcca20e5
syntax: account for CVarArgs being in the argument list.
2019-08-12 15:28:10 +03:00
Mazdak Farrokhzad
c8fc4c106c
extract parse_pat_{tuple_}struct + recover_one_fewer_dotdot
2019-08-12 12:50:44 +02:00
Mazdak Farrokhzad
ddf734deb2
extract fatal_unexpected_non_pat
2019-08-12 12:50:44 +02:00
Mazdak Farrokhzad
37f37a5df1
parser/pat: minor misc cleanup
2019-08-12 12:50:44 +02:00
Mazdak Farrokhzad
49740b792d
extract parse_pat_range_starting_with_lit
2019-08-12 12:50:44 +02:00
Mazdak Farrokhzad
e6f980f9b8
extract parse_pat_range_starting_with_path
2019-08-12 12:50:44 +02:00
Mazdak Farrokhzad
e32bd69d0f
extract parse_pat_mac_invoc
2019-08-12 12:50:44 +02:00
Mazdak Farrokhzad
231da7e044
extract ban_pat_range_if_ambiguous
2019-08-12 12:50:44 +02:00
Mazdak Farrokhzad
3b651330e0
extract recover_pat_ident_mut_first
2019-08-12 12:50:44 +02:00
Mazdak Farrokhzad
33f53d699c
Rollup merge of #63449 - petrochenkov:builtinagain, r=eddyb
...
resolve: Remove remaining special cases from built-in macros
Edition and definition sites of the macros are now also taken from the `#[rustc_builtin_macro]` definitions in `libcore`.
---
The edition switch may be a breaking change for `Rustc{Encodable,Decodable}` derives if they are used in combination with the unstable crate `serialize` from sysroot like this
```rust
extern crate serialize;
use serialize as rustc_serialize;
#[derive(RustcEncodable)]
struct S;
```
(see the updated `ui-fulldeps` tests).
2019-08-12 10:58:18 +02:00
Ilija Tovilo
91af5c2daf
Bring back suggestion for splitting <- into < -
...
Closes #62632
2019-08-12 10:46:34 +02:00
Mazdak Farrokhzad
c69b3ede8a
extract parse_pat_tuple_or_parens
2019-08-12 09:28:49 +02:00
Mazdak Farrokhzad
90793c0f12
extract parse_pat_deref
2019-08-12 09:28:49 +02:00
Mazdak Farrokhzad
a4af9d1ac2
parse_pat_with_range_pat: remove unnecessary assignments.
2019-08-12 09:28:49 +02:00
Mazdak Farrokhzad
bcfcbfc923
parser: {check,expect}_lifetime into ty.rs
2019-08-11 20:46:34 +02:00
Mazdak Farrokhzad
385d07f359
parser: move into generics.rs
2019-08-11 20:44:09 +02:00
Mazdak Farrokhzad
d6d93b3d82
parser: move into stmt.rs
2019-08-11 20:32:29 +02:00
Mazdak Farrokhzad
28db7c5968
parser: move parse_fn_block_decl into expr.rs
2019-08-11 20:04:09 +02:00
Mazdak Farrokhzad
848ec4aa3c
parser: move parse_ident_or_underscore into item.rs
2019-08-11 20:00:38 +02:00
Mazdak Farrokhzad
3dbfbafe3e
parser: split into {ty, path}.rs
2019-08-11 19:59:27 +02:00