diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ae0296f839c..f5a4e2779aa 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5329,8 +5329,12 @@ impl<'a> Parser<'a> { // Parse lifetime argument. args.push(GenericArg::Lifetime(self.expect_lifetime())); if seen_type || seen_binding { - self.span_err(self.prev_span, - "lifetime parameters must be declared prior to type parameters"); + self.struct_span_err( + self.prev_span, + "lifetime parameters must be declared prior to type parameters" + ) + .span_label(self.prev_span, "must be declared prior to type parameters") + .emit(); } } else if self.check_ident() && self.look_ahead(1, |t| t == &token::Eq) { // Parse associated type binding. diff --git a/src/test/ui/parser/issue-14303-fncall.rs b/src/test/ui/parser/issue-14303-fncall.rs index f5894349e15..aa39fe52819 100644 --- a/src/test/ui/parser/issue-14303-fncall.rs +++ b/src/test/ui/parser/issue-14303-fncall.rs @@ -3,4 +3,6 @@ fn main() { .map(|x| x * 2) .collect::>() //~^ ERROR lifetime parameters must be declared prior to type parameters + //~| ERRROR use of undeclared lifetime name + //~| ERRROR use of undeclared lifetime name } diff --git a/src/test/ui/parser/issue-14303-fncall.stderr b/src/test/ui/parser/issue-14303-fncall.stderr index 1cc82f523c4..fa2deafb673 100644 --- a/src/test/ui/parser/issue-14303-fncall.stderr +++ b/src/test/ui/parser/issue-14303-fncall.stderr @@ -2,7 +2,20 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-fncall.rs:4:31 | LL | .collect::>() - | ^^ + | ^^ must be declared prior to type parameters -error: aborting due to previous error +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/issue-14303-fncall.rs:4:20 + | +LL | .collect::>() + | ^^ undeclared lifetime +error[E0261]: use of undeclared lifetime name `'b` + --> $DIR/issue-14303-fncall.rs:4:31 + | +LL | .collect::>() + | ^^ undeclared lifetime + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/parser/issue-14303-path.rs b/src/test/ui/parser/issue-14303-path.rs index f61cb6b8dd6..67102249f63 100644 --- a/src/test/ui/parser/issue-14303-path.rs +++ b/src/test/ui/parser/issue-14303-path.rs @@ -1,4 +1,7 @@ fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} //~^ ERROR lifetime parameters must be declared prior to type parameters +//~| ERROR failed to resolve: use of undeclared type or module `mymodule` +//~| ERROR use of undeclared lifetime name `'b` +//~| ERROR use of undeclared lifetime name `'c` fn main() {} diff --git a/src/test/ui/parser/issue-14303-path.stderr b/src/test/ui/parser/issue-14303-path.stderr index 3de8a169c69..4c968fceb9d 100644 --- a/src/test/ui/parser/issue-14303-path.stderr +++ b/src/test/ui/parser/issue-14303-path.stderr @@ -2,7 +2,33 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/issue-14303-path.rs:1:37 | LL | fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} - | ^^ + | ^^ must be declared prior to type parameters -error: aborting due to previous error +error: lifetime parameters must be declared prior to type parameters + --> $DIR/issue-14303-path.rs:1:41 + | +LL | fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} + | ^^ must be declared prior to type parameters +error[E0433]: failed to resolve: use of undeclared type or module `mymodule` + --> $DIR/issue-14303-path.rs:1:18 + | +LL | fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} + | ^^^^^^^^ use of undeclared type or module `mymodule` + +error[E0261]: use of undeclared lifetime name `'b` + --> $DIR/issue-14303-path.rs:1:37 + | +LL | fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'c` + --> $DIR/issue-14303-path.rs:1:41 + | +LL | fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {} + | ^^ undeclared lifetime + +error: aborting due to 5 previous errors + +Some errors occurred: E0261, E0433. +For more information about an error, try `rustc --explain E0261`. diff --git a/src/test/ui/traits/trait-object-vs-lifetime.stderr b/src/test/ui/traits/trait-object-vs-lifetime.stderr index 20218c19e45..00f8164caa4 100644 --- a/src/test/ui/traits/trait-object-vs-lifetime.stderr +++ b/src/test/ui/traits/trait-object-vs-lifetime.stderr @@ -2,7 +2,7 @@ error: lifetime parameters must be declared prior to type parameters --> $DIR/trait-object-vs-lifetime.rs:16:25 | LL | let _: S<'static +, 'static>; - | ^^^^^^^ + | ^^^^^^^ must be declared prior to type parameters error[E0224]: at least one non-builtin trait is required for an object type --> $DIR/trait-object-vs-lifetime.rs:11:23