mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-03 05:27:36 +00:00

The SCCs of the region graph are not a reliable heuristic to use for blaming an interesting constraint for diagnostics. For region errors, if the outlived region is `'static`, or the involved types are invariant in their lifetiems, there will be cycles in the constraint graph containing both the target region and the most interesting constraints to blame. To get better diagnostics in these cases, this commit removes that heuristic.
153 lines
8.0 KiB
Plaintext
153 lines
8.0 KiB
Plaintext
error: lifetime may not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:8:5
|
|
|
|
|
LL | pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> {
|
|
| -- -- has type `VaListImpl<'1>`
|
|
| |
|
|
| lifetime `'f` defined here
|
|
LL | ap
|
|
| ^^ function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'f`
|
|
|
|
|
= note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant
|
|
= note: the struct `VaListImpl<'f>` is invariant over the parameter `'f`
|
|
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
|
|
|
error: lifetime may not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:8:5
|
|
|
|
|
LL | pub unsafe extern "C" fn no_escape0<'f>(_: usize, ap: ...) -> VaListImpl<'f> {
|
|
| -- -- has type `VaListImpl<'1>`
|
|
| |
|
|
| lifetime `'f` defined here
|
|
LL | ap
|
|
| ^^ function was supposed to return data with lifetime `'f` but it is returning data with lifetime `'1`
|
|
|
|
|
= note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant
|
|
= note: the struct `VaListImpl<'f>` is invariant over the parameter `'f`
|
|
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
|
|
|
error: lifetime may not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:14:5
|
|
|
|
|
LL | pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaListImpl<'static> {
|
|
| -- has type `VaListImpl<'1>`
|
|
LL | ap
|
|
| ^^ returning this value requires that `'1` must outlive `'static`
|
|
|
|
|
= note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant
|
|
= note: the struct `VaListImpl<'f>` is invariant over the parameter `'f`
|
|
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
|
|
|
error: lifetime may not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:18:31
|
|
|
|
|
LL | let _ = ap.with_copy(|ap| ap);
|
|
| --- ^^ returning this value requires that `'1` must outlive `'2`
|
|
| | |
|
|
| | return type of closure is VaList<'2, '_>
|
|
| has type `VaList<'1, '_>`
|
|
|
|
error: lifetime may not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:22:5
|
|
|
|
|
LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
|
|
| ------- ------- has type `VaListImpl<'2>`
|
|
| |
|
|
| has type `&mut VaListImpl<'1>`
|
|
LL | *ap0 = ap1;
|
|
| ^^^^ assignment requires that `'1` must outlive `'2`
|
|
|
|
|
= note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant
|
|
= note: the struct `VaListImpl<'f>` is invariant over the parameter `'f`
|
|
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
|
|
|
error: lifetime may not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:22:5
|
|
|
|
|
LL | pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
|
|
| ------- ------- has type `VaListImpl<'2>`
|
|
| |
|
|
| has type `&mut VaListImpl<'1>`
|
|
LL | *ap0 = ap1;
|
|
| ^^^^ assignment requires that `'2` must outlive `'1`
|
|
|
|
|
= note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant
|
|
= note: the struct `VaListImpl<'f>` is invariant over the parameter `'f`
|
|
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
|
|
|
error: lifetime may not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:28:5
|
|
|
|
|
LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
|
|
| ------- ------- has type `VaListImpl<'2>`
|
|
| |
|
|
| has type `&mut VaListImpl<'1>`
|
|
LL | ap0 = &mut ap1;
|
|
| ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
|
|
|
|
|
= note: requirement occurs because of a mutable reference to `VaListImpl<'_>`
|
|
= note: mutable references are invariant over their type parameter
|
|
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
|
|
|
error: lifetime may not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:28:5
|
|
|
|
|
LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
|
|
| ------- ------- has type `VaListImpl<'2>`
|
|
| |
|
|
| has type `&mut VaListImpl<'1>`
|
|
LL | ap0 = &mut ap1;
|
|
| ^^^^^^^^^^^^^^ assignment requires that `'2` must outlive `'1`
|
|
|
|
|
= note: requirement occurs because of a mutable reference to `VaListImpl<'_>`
|
|
= note: mutable references are invariant over their type parameter
|
|
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
|
|
|
error[E0597]: `ap1` does not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:28:11
|
|
|
|
|
LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
|
|
| - ------- binding `ap1` declared here
|
|
| |
|
|
| let's call the lifetime of this reference `'3`
|
|
LL | ap0 = &mut ap1;
|
|
| ------^^^^^^^^
|
|
| | |
|
|
| | borrowed value does not live long enough
|
|
| assignment requires that `ap1` is borrowed for `'3`
|
|
...
|
|
LL | }
|
|
| - `ap1` dropped here while still borrowed
|
|
|
|
error: lifetime may not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:35:5
|
|
|
|
|
LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
|
|
| ------- ------- has type `VaListImpl<'2>`
|
|
| |
|
|
| has type `&mut VaListImpl<'1>`
|
|
LL | *ap0 = ap1.clone();
|
|
| ^^^^ assignment requires that `'2` must outlive `'1`
|
|
|
|
|
= note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant
|
|
= note: the struct `VaListImpl<'f>` is invariant over the parameter `'f`
|
|
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
|
|
|
error: lifetime may not live long enough
|
|
--> $DIR/variadic-ffi-4.rs:35:12
|
|
|
|
|
LL | pub unsafe extern "C" fn no_escape5(_: usize, mut ap0: &mut VaListImpl, mut ap1: ...) {
|
|
| ------- ------- has type `VaListImpl<'2>`
|
|
| |
|
|
| has type `&mut VaListImpl<'1>`
|
|
LL | *ap0 = ap1.clone();
|
|
| ^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
|
|
|
|
|
= note: requirement occurs because of the type `VaListImpl<'_>`, which makes the generic argument `'_` invariant
|
|
= note: the struct `VaListImpl<'f>` is invariant over the parameter `'f`
|
|
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
|
|
|
error: aborting due to 11 previous errors
|
|
|
|
For more information about this error, try `rustc --explain E0597`.
|