Continue parsing after lifetime in incorrect location

This commit is contained in:
Esteban Küber 2019-01-11 19:41:43 -08:00
parent 5c67ba615c
commit fc4b54157f
6 changed files with 55 additions and 7 deletions

View File

@ -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.

View File

@ -3,4 +3,6 @@ fn main() {
.map(|x| x * 2)
.collect::<Vec<'a, usize, 'b>>()
//~^ ERROR lifetime parameters must be declared prior to type parameters
//~| ERRROR use of undeclared lifetime name
//~| ERRROR use of undeclared lifetime name
}

View File

@ -2,7 +2,20 @@ error: lifetime parameters must be declared prior to type parameters
--> $DIR/issue-14303-fncall.rs:4:31
|
LL | .collect::<Vec<'a, usize, 'b>>()
| ^^
| ^^ 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::<Vec<'a, usize, 'b>>()
| ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/issue-14303-fncall.rs:4:31
|
LL | .collect::<Vec<'a, usize, 'b>>()
| ^^ undeclared lifetime
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0261`.

View File

@ -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() {}

View File

@ -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`.

View File

@ -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