Skip to content

Commit

Permalink
Point only at generic arguments when they are unexpected
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jan 26, 2021
1 parent 7907345 commit 2e846d6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
10 changes: 9 additions & 1 deletion compiler/rustc_parse/src/parser/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,15 @@ impl<'a> Parser<'a> {
maybe_whole!(self, NtPath, |path| {
if style == PathStyle::Mod && path.segments.iter().any(|segment| segment.args.is_some())
{
self.struct_span_err(path.span, "unexpected generic arguments in path").emit();
self.struct_span_err(
path.segments
.iter()
.filter_map(|segment| segment.args.as_ref())
.map(|arg| arg.span())
.collect::<Vec<_>>(),
"unexpected generic arguments in path",
)
.emit();
}
path
});
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-43424.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: unexpected generic arguments in path
--> $DIR/issue-43424.rs:10:4
--> $DIR/issue-43424.rs:10:10
|
LL | m!(inline<u8>);
| ^^^^^^^^^^
| ^^^^

error: aborting due to previous error

3 changes: 3 additions & 0 deletions src/test/ui/span/import-ty-params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ fn f1() {
fn f2() {
import! { a::b::c::S<> } //~ ERROR unexpected generic arguments in path
}
fn f3() {
import! { a::b<>::c<u8>::S<> } //~ ERROR unexpected generic arguments in path
}

fn main() {}
16 changes: 11 additions & 5 deletions src/test/ui/span/import-ty-params.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
error: unexpected generic arguments in path
--> $DIR/import-ty-params.rs:14:15
--> $DIR/import-ty-params.rs:14:25
|
LL | import! { a::b::c::S<u8> }
| ^^^^^^^^^^^^^^
| ^^^^

error: unexpected generic arguments in path
--> $DIR/import-ty-params.rs:17:15
--> $DIR/import-ty-params.rs:17:25
|
LL | import! { a::b::c::S<> }
| ^^^^^^^^^^^^
| ^^

error: aborting due to 2 previous errors
error: unexpected generic arguments in path
--> $DIR/import-ty-params.rs:20:19
|
LL | import! { a::b<>::c<u8>::S<> }
| ^^ ^^^^ ^^

error: aborting due to 3 previous errors

8 changes: 4 additions & 4 deletions src/test/ui/span/visibility-ty-params.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: unexpected generic arguments in path
--> $DIR/visibility-ty-params.rs:6:5
--> $DIR/visibility-ty-params.rs:6:6
|
LL | m!{ S<u8> }
| ^^^^^
| ^^^^

error[E0577]: expected module, found struct `S`
--> $DIR/visibility-ty-params.rs:6:5
Expand All @@ -11,10 +11,10 @@ LL | m!{ S<u8> }
| ^^^^^ not a module

error: unexpected generic arguments in path
--> $DIR/visibility-ty-params.rs:10:9
--> $DIR/visibility-ty-params.rs:10:10
|
LL | m!{ m<> }
| ^^^
| ^^

error: aborting due to 3 previous errors

Expand Down

0 comments on commit 2e846d6

Please sign in to comment.