File tree 8 files changed +67
-45
lines changed
8 files changed +67
-45
lines changed Original file line number Diff line number Diff line change @@ -1776,7 +1776,13 @@ impl<'a> Parser<'a> {
1776
1776
1777
1777
pub fn parse_path_common ( & mut self , style : PathStyle , enable_warning : bool )
1778
1778
-> PResult < ' a , ast:: Path > {
1779
- maybe_whole ! ( self , NtPath , |x| x) ;
1779
+ maybe_whole ! ( self , NtPath , |path| {
1780
+ if style == PathStyle :: Mod &&
1781
+ path. segments. iter( ) . any( |segment| segment. parameters. is_some( ) ) {
1782
+ self . diagnostic( ) . span_err( path. span, "unexpected generic arguments in path" ) ;
1783
+ }
1784
+ path
1785
+ } ) ;
1780
1786
1781
1787
let lo = self . meta_var_span . unwrap_or ( self . span ) ;
1782
1788
let mut segments = Vec :: new ( ) ;
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ #![ allow( unused) ]
12
+
13
+ macro_rules! m {
14
+ ( $attr_path: path) => {
15
+ #[ $attr_path]
16
+ fn f( ) { }
17
+ }
18
+ }
19
+
20
+ m ! ( inline<u8 >) ; //~ ERROR: unexpected generic arguments in path
21
+
22
+ fn main ( ) { }
Original file line number Diff line number Diff line change @@ -21,10 +21,10 @@ macro_rules! import {
21
21
}
22
22
23
23
fn f1 ( ) {
24
- import ! { a:: b:: c:: S <u8 > } //~ ERROR generic arguments in import path
24
+ import ! { a:: b:: c:: S <u8 > } //~ ERROR unexpected generic arguments in path
25
25
}
26
26
fn f2 ( ) {
27
- import ! { a:: b:: c:: S <> } //~ ERROR generic arguments in import path
27
+ import ! { a:: b:: c:: S <> } //~ ERROR unexpected generic arguments in path
28
28
}
29
29
30
30
fn main ( ) { }
Original file line number Diff line number Diff line change 1
- error: generic arguments in import path
2
- --> $DIR/import-ty-params.rs:24:25
1
+ error: unexpected generic arguments in path
2
+ --> $DIR/import-ty-params.rs:24:15
3
3
|
4
- 24 | import! { a::b::c::S<u8> } //~ ERROR generic arguments in import path
5
- | ^^^^
4
+ 24 | import! { a::b::c::S<u8> } //~ ERROR unexpected generic arguments in path
5
+ | ^^^^^^^^^^ ^^^^
6
6
7
- error: generic arguments in import path
8
- --> $DIR/import-ty-params.rs:27:25
7
+ error: unexpected generic arguments in path
8
+ --> $DIR/import-ty-params.rs:27:15
9
9
|
10
- 27 | import! { a::b::c::S<> } //~ ERROR generic arguments in import path
11
- | ^^
10
+ 27 | import! { a::b::c::S<> } //~ ERROR unexpected generic arguments in path
11
+ | ^^^^^^^^^^ ^^
12
12
13
13
error: aborting due to 2 previous errors
14
14
Original file line number Diff line number Diff line change @@ -16,16 +16,6 @@ macro_rules! m {
16
16
17
17
fn main ( ) {
18
18
foo :: < T > !( ) ;
19
- //~^ ERROR generic arguments in macro path
20
- //~| ERROR generic arguments in macro path
21
- //~| ERROR generic arguments in macro path
22
19
foo:: <>!( ) ;
23
- //~^ ERROR generic arguments in macro path
24
- //~| ERROR generic arguments in macro path
25
- //~| ERROR generic arguments in macro path
26
20
m ! ( MyTrait <>) ;
27
- //~^ ERROR generic arguments in macro path
28
- //~| ERROR generic arguments in macro path
29
- //~| ERROR generic arguments in macro path
30
- //~| ERROR generic arguments in macro path
31
21
}
Original file line number Diff line number Diff line change
1
+ error: unexpected generic arguments in path
2
+ --> $DIR/macro-ty-params.rs:20:8
3
+ |
4
+ 20 | m!(MyTrait<>);
5
+ | ^^^^^^^^^
6
+
7
+ error: unexpected generic arguments in path
8
+ --> $DIR/macro-ty-params.rs:20:8
9
+ |
10
+ 20 | m!(MyTrait<>);
11
+ | ^^^^^^^^^
12
+
1
13
error: generic arguments in macro path
2
14
--> $DIR/macro-ty-params.rs:18:8
3
15
|
4
16
18 | foo::<T>!();
5
17
| ^^^^^
6
18
7
19
error: generic arguments in macro path
8
- --> $DIR/macro-ty-params.rs:22 :8
20
+ --> $DIR/macro-ty-params.rs:19 :8
9
21
|
10
- 22 | foo::<>!();
22
+ 19 | foo::<>!();
11
23
| ^^^^
12
24
13
25
error: generic arguments in macro path
14
- --> $DIR/macro-ty-params.rs:26 :15
26
+ --> $DIR/macro-ty-params.rs:20 :15
15
27
|
16
- 26 | m!(MyTrait<>);
28
+ 20 | m!(MyTrait<>);
17
29
| ^^
18
30
19
- error: aborting due to 3 previous errors
31
+ error: aborting due to 5 previous errors
20
32
Original file line number Diff line number Diff line change @@ -13,11 +13,11 @@ macro_rules! m {
13
13
}
14
14
15
15
struct S < T > ( T ) ;
16
- m ! { S <u8 > } //~ ERROR generic arguments in visibility path
16
+ m ! { S <u8 > } //~ ERROR unexpected generic arguments in path
17
17
//~^ ERROR expected module, found struct `S`
18
18
19
19
mod m {
20
- m ! { m<> } //~ ERROR generic arguments in visibility path
20
+ m ! { m<> } //~ ERROR unexpected generic arguments in path
21
21
}
22
22
23
23
fn main ( ) { }
Original file line number Diff line number Diff line change 1
- error: generic arguments in visibility path
2
- --> $DIR/visibility-ty-params.rs:16:6
3
- |
4
- 16 | m!{ S<u8> } //~ ERROR generic arguments in visibility path
5
- | ^^^^
6
-
7
- error: generic arguments in visibility path
8
- --> $DIR/visibility-ty-params.rs:20:10
1
+ error: unexpected generic arguments in path
2
+ --> $DIR/visibility-ty-params.rs:16:5
9
3
|
10
- 20 | m!{ m< > } //~ ERROR generic arguments in visibility path
11
- | ^^
4
+ 16 | m!{ S<u8 > } //~ ERROR unexpected generic arguments in path
5
+ | ^^^ ^^
12
6
13
- error[E0577]: expected module, found struct `S`
14
- --> $DIR/visibility-ty-params.rs:16:5
7
+ error: unexpected generic arguments in path
8
+ --> $DIR/visibility-ty-params.rs:20:9
15
9
|
16
- 16 | m!{ S<u8> } //~ ERROR generic arguments in visibility path
17
- | -^^^^
18
- | |
19
- | did you mean `m`?
10
+ 20 | m!{ m<> } //~ ERROR unexpected generic arguments in path
11
+ | ^^^
20
12
21
- error: aborting due to 3 previous errors
13
+ error: aborting due to 2 previous errors
22
14
You can’t perform that action at this time.
0 commit comments