File tree Expand file tree Collapse file tree 8 files changed +67
-45
lines changed Expand file tree Collapse file tree 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> {
17761776
17771777 pub fn parse_path_common ( & mut self , style : PathStyle , enable_warning : bool )
17781778 -> 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+ } ) ;
17801786
17811787 let lo = self . meta_var_span . unwrap_or ( self . span ) ;
17821788 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 {
2121}
2222
2323fn 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
2525}
2626fn 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
2828}
2929
3030fn 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
33 |
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+ | ^^^^^^^^^^ ^^^^
66
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
99 |
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+ | ^^^^^^^^^^ ^^
1212
1313error: aborting due to 2 previous errors
1414
Original file line number Diff line number Diff line change @@ -16,16 +16,6 @@ macro_rules! m {
1616
1717fn main ( ) {
1818 foo :: < T > !( ) ;
19- //~^ ERROR generic arguments in macro path
20- //~| ERROR generic arguments in macro path
21- //~| ERROR generic arguments in macro path
2219 foo:: <>!( ) ;
23- //~^ ERROR generic arguments in macro path
24- //~| ERROR generic arguments in macro path
25- //~| ERROR generic arguments in macro path
2620 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
3121}
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+
113error: generic arguments in macro path
214 --> $DIR/macro-ty-params.rs:18:8
315 |
41618 | foo::<T>!();
517 | ^^^^^
618
719error: generic arguments in macro path
8- --> $DIR/macro-ty-params.rs:22 :8
20+ --> $DIR/macro-ty-params.rs:19 :8
921 |
10- 22 | foo::<>!();
22+ 19 | foo::<>!();
1123 | ^^^^
1224
1325error: generic arguments in macro path
14- --> $DIR/macro-ty-params.rs:26 :15
26+ --> $DIR/macro-ty-params.rs:20 :15
1527 |
16- 26 | m!(MyTrait<>);
28+ 20 | m!(MyTrait<>);
1729 | ^^
1830
19- error: aborting due to 3 previous errors
31+ error: aborting due to 5 previous errors
2032
Original file line number Diff line number Diff line change @@ -13,11 +13,11 @@ macro_rules! m {
1313}
1414
1515struct S < T > ( T ) ;
16- m ! { S <u8 > } //~ ERROR generic arguments in visibility path
16+ m ! { S <u8 > } //~ ERROR unexpected generic arguments in path
1717//~^ ERROR expected module, found struct `S`
1818
1919mod m {
20- m ! { m<> } //~ ERROR generic arguments in visibility path
20+ m ! { m<> } //~ ERROR unexpected generic arguments in path
2121}
2222
2323fn 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
93 |
10- 20 | m!{ m< > } //~ ERROR generic arguments in visibility path
11- | ^^
4+ 16 | m!{ S<u8 > } //~ ERROR unexpected generic arguments in path
5+ | ^^^ ^^
126
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
159 |
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+ | ^^^
2012
21- error: aborting due to 3 previous errors
13+ error: aborting due to 2 previous errors
2214
You can’t perform that action at this time.
0 commit comments