Point only at generic arguments when they are unexpected

This commit is contained in:
Esteban Küber 2020-12-01 00:40:28 -08:00
parent 7907345e58
commit 2e846d6f61
5 changed files with 29 additions and 12 deletions

View file

@ -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
});