Show errors instead of hiding them due to an earlier error
This commit is contained in:
parent
5ace12c409
commit
90ec6f847f
@ -6,6 +6,7 @@ fn defining(a: &str) -> Ty<'_> { a }
|
||||
fn assert_static<'a: 'static>() {}
|
||||
//~^ WARN: unnecessary lifetime parameter `'a`
|
||||
fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() }
|
||||
//~^ ERROR: lifetime may not live long enough
|
||||
}
|
||||
|
||||
mod test_higher_kinded_lifetime_param {
|
||||
@ -14,14 +15,14 @@ fn defining(a: &str) -> Ty<'_> { a }
|
||||
fn assert_static<'a: 'static>() {}
|
||||
//~^ WARN: unnecessary lifetime parameter `'a`
|
||||
fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() }
|
||||
//~^ ERROR: lifetime may not live long enough
|
||||
}
|
||||
|
||||
mod test_higher_kinded_lifetime_param2 {
|
||||
fn assert_static<'a: 'static>() {}
|
||||
//~^ WARN: unnecessary lifetime parameter `'a`
|
||||
fn test<'a>() { assert_static::<'a>() }
|
||||
// no error because all the other errors happen first and then we abort before
|
||||
// emitting an error here.
|
||||
//~^ ERROR: lifetime may not live long enough
|
||||
}
|
||||
|
||||
mod test_type_param {
|
||||
@ -29,14 +30,14 @@ mod test_type_param {
|
||||
fn defining<A>(s: A) -> Ty<A> { s }
|
||||
fn assert_static<A: 'static>() {}
|
||||
fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
|
||||
//~^ ERROR: parameter type `A` may not live long enough
|
||||
}
|
||||
|
||||
mod test_type_param_static {
|
||||
type Ty<A> = impl Sized + 'static;
|
||||
//~^ ERROR: the parameter type `A` may not live long enough
|
||||
fn defining<A: 'static>(s: A) -> Ty<A> { s }
|
||||
fn assert_static<A: 'static>() {}
|
||||
fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
|
||||
mod test_implied_from_fn_sig {
|
||||
type Opaque<T: 'static> = impl Sized;
|
||||
fn defining<T: 'static>() -> Opaque<T> {}
|
||||
fn assert_static<T: 'static>() {}
|
||||
fn test<T>(_: Opaque<T>) { assert_static::<T>(); }
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -7,7 +7,7 @@ LL | fn assert_static<'a: 'static>() {}
|
||||
= help: you can use the `'static` lifetime directly, in place of `'a`
|
||||
|
||||
warning: unnecessary lifetime parameter `'a`
|
||||
--> $DIR/implied_lifetime_wf_check3.rs:14:22
|
||||
--> $DIR/implied_lifetime_wf_check3.rs:15:22
|
||||
|
|
||||
LL | fn assert_static<'a: 'static>() {}
|
||||
| ^^
|
||||
@ -15,24 +15,44 @@ LL | fn assert_static<'a: 'static>() {}
|
||||
= help: you can use the `'static` lifetime directly, in place of `'a`
|
||||
|
||||
warning: unnecessary lifetime parameter `'a`
|
||||
--> $DIR/implied_lifetime_wf_check3.rs:20:22
|
||||
--> $DIR/implied_lifetime_wf_check3.rs:22:22
|
||||
|
|
||||
LL | fn assert_static<'a: 'static>() {}
|
||||
| ^^
|
||||
|
|
||||
= help: you can use the `'static` lifetime directly, in place of `'a`
|
||||
|
||||
error[E0310]: the parameter type `A` may not live long enough
|
||||
--> $DIR/implied_lifetime_wf_check3.rs:35:18
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/implied_lifetime_wf_check3.rs:8:43
|
||||
|
|
||||
LL | type Ty<A> = impl Sized + 'static;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
|
||||
LL | fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() }
|
||||
| -- lifetime `'a` defined here ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/implied_lifetime_wf_check3.rs:17:46
|
||||
|
|
||||
LL | fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() }
|
||||
| -- lifetime `'a` defined here ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/implied_lifetime_wf_check3.rs:24:21
|
||||
|
|
||||
LL | fn test<'a>() { assert_static::<'a>() }
|
||||
| -- ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
|
||||
error[E0310]: the parameter type `A` may not live long enough
|
||||
--> $DIR/implied_lifetime_wf_check3.rs:32:41
|
||||
|
|
||||
LL | fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
|
||||
| ^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
|
||||
|
|
||||
help: consider adding an explicit lifetime bound...
|
||||
|
|
||||
LL | type Ty<A: 'static> = impl Sized + 'static;
|
||||
LL | fn test<A: 'static>() where Ty<A>: 'static { assert_static::<A>() }
|
||||
| +++++++++
|
||||
|
||||
error: aborting due to previous error; 3 warnings emitted
|
||||
error: aborting due to 4 previous errors; 3 warnings emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0310`.
|
||||
|
@ -0,0 +1,11 @@
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
mod test_type_param_static {
|
||||
type Ty<A> = impl Sized + 'static;
|
||||
//~^ ERROR: the parameter type `A` may not live long enough
|
||||
fn defining<A: 'static>(s: A) -> Ty<A> { s }
|
||||
fn assert_static<A: 'static>() {}
|
||||
fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,14 @@
|
||||
error[E0310]: the parameter type `A` may not live long enough
|
||||
--> $DIR/implied_lifetime_wf_check4_static.rs:4:18
|
||||
|
|
||||
LL | type Ty<A> = impl Sized + 'static;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
|
||||
|
|
||||
help: consider adding an explicit lifetime bound...
|
||||
|
|
||||
LL | type Ty<A: 'static> = impl Sized + 'static;
|
||||
| +++++++++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0310`.
|
Loading…
Reference in New Issue
Block a user