mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-23 12:23:22 +00:00
Auto merge of #97258 - jackh726:nll-revisions, r=cjgillot
Move remaining tests with NLL differences to revisions Based on #97206 I've already filed issues for any important differences that I've spotted: #97252 #97253 #97256 #97267 There is a lot here, but each commit is self-contained as a separate directory. I can split into separate PRs as wanted or needed.
This commit is contained in:
commit
07e7b4346c
src/test/ui
associated-type-bounds
implied-region-constraints.base.stderrimplied-region-constraints.nll.stderrimplied-region-constraints.rs
associated-types
associated-types-eq-hr.base.stderrassociated-types-eq-hr.nll.stderrassociated-types-eq-hr.rsassociated-types-project-from-hrtb-in-fn-body.base.stderrassociated-types-project-from-hrtb-in-fn-body.nll.stderrassociated-types-project-from-hrtb-in-fn-body.rsassociated-types-subtyping-1.base.stderrassociated-types-subtyping-1.nll.stderrassociated-types-subtyping-1.rs
cache
project-fn-ret-contravariant-nll.krisskross.stderrproject-fn-ret-contravariant-nll.rsproject-fn-ret-contravariant-nll.transmute.stderrproject-fn-ret-contravariant.krisskross.nll.stderrproject-fn-ret-contravariant.krisskross.stderrproject-fn-ret-contravariant.ok.stderrproject-fn-ret-contravariant.oneuse.stderrproject-fn-ret-contravariant.rsproject-fn-ret-contravariant.transmute.nll.stderrproject-fn-ret-contravariant.transmute.stderrproject-fn-ret-invariant-nll.krisskross.stderrproject-fn-ret-invariant-nll.oneuse.stderrproject-fn-ret-invariant-nll.rsproject-fn-ret-invariant-nll.transmute.stderrproject-fn-ret-invariant.krisskross.stderrproject-fn-ret-invariant.ok.stderrproject-fn-ret-invariant.oneuse.stderrproject-fn-ret-invariant.rsproject-fn-ret-invariant.transmute.stderr
higher-ranked-projection.badbase.stderrhigher-ranked-projection.badnll.stderrhigher-ranked-projection.good.stderrhigher-ranked-projection.rsasync-await
issue-76547.base.stderrissue-76547.nll.stderrissue-76547.rs
issues
issue-62097.base.stderrissue-62097.nll.stderrissue-62097.rsissue-63388-1.base.stderrissue-63388-1.nll.stderrissue-63388-1.rsissue-72312.base.stderrissue-72312.nll.stderrissue-72312.rs
multiple-lifetimes
borrowck
borrowck-reborrow-from-shorter-lived-andmut.base.stderrborrowck-reborrow-from-shorter-lived-andmut.nll.stderrborrowck-reborrow-from-shorter-lived-andmut.rstwo-phase-nonrecv-autoref.base.stderrtwo-phase-nonrecv-autoref.nll.stderrtwo-phase-nonrecv-autoref.rs
closure-expected-type
closures
closure-bounds-static-cant-capture-borrowed.base.stderrclosure-bounds-static-cant-capture-borrowed.nll.stderrclosure-bounds-static-cant-capture-borrowed.rs
closure-expected-type
const-generics
error-codes
fn
implied-bounds-unnorm-associated-type.base.stderrimplied-bounds-unnorm-associated-type.nll.stderrimplied-bounds-unnorm-associated-type.rs
generator
auto-trait-regions.base.stderrauto-trait-regions.nll.stderrauto-trait-regions.rsgenerator-region-requirements.base.stderrgenerator-region-requirements.nll.stderrgenerator-region-requirements.rsresume-arg-late-bound.base.stderrresume-arg-late-bound.nll.stderrresume-arg-late-bound.rs
generic-associated-types
extended
projection-type-lifetime-mismatch.base.stderrprojection-type-lifetime-mismatch.nll.stderrprojection-type-lifetime-mismatch.rstrait-objects.base.stderrtrait-objects.extended.nll.stderrtrait-objects.extended.stderrtrait-objects.rshigher-rank-trait-bounds
hr-subtype
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/implied-region-constraints.rs:17:64
|
||||
--> $DIR/implied-region-constraints.rs:21:64
|
||||
|
|
||||
LL | fn _bad_st<'a, 'b, T>(x: St<'a, 'b, T>)
|
||||
| ------------- this type is declared with multiple lifetimes...
|
||||
@ -8,7 +8,7 @@ LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0;
|
||||
| ^^^^^ ...but data with one lifetime flows into the other here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/implied-region-constraints.rs:38:72
|
||||
--> $DIR/implied-region-constraints.rs:43:72
|
||||
|
|
||||
LL | fn _bad_en7<'a, 'b, T>(x: En7<'a, 'b, T>)
|
||||
| -------------- this type is declared with multiple lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/implied-region-constraints.rs:17:56
|
||||
--> $DIR/implied-region-constraints.rs:21:56
|
||||
|
|
||||
LL | fn _bad_st<'a, 'b, T>(x: St<'a, 'b, T>)
|
||||
| -- -- lifetime `'b` defined here
|
||||
@ -12,7 +12,7 @@ LL | let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0;
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/implied-region-constraints.rs:38:64
|
||||
--> $DIR/implied-region-constraints.rs:43:64
|
||||
|
|
||||
LL | fn _bad_en7<'a, 'b, T>(x: En7<'a, 'b, T>)
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
#![feature(associated_type_bounds)]
|
||||
|
||||
trait Tr1 { type As1; }
|
||||
@ -15,7 +19,8 @@ where
|
||||
{
|
||||
// This should fail because `T: 'b` is not implied from `WF(St<'a, 'b, T>)`.
|
||||
let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0;
|
||||
//~^ ERROR lifetime mismatch [E0623]
|
||||
//[base]~^ ERROR lifetime mismatch [E0623]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
enum En7<'a, 'b, T> // `<T::As1 as Tr2>::As2: 'a` is implied.
|
||||
@ -36,7 +41,8 @@ where
|
||||
En7::V0(x) => {
|
||||
// Also fails for the same reason as above:
|
||||
let _failure_proves_not_implied_outlives_region_b: &'b T = &x;
|
||||
//~^ ERROR lifetime mismatch [E0623]
|
||||
//[base]~^ ERROR lifetime mismatch [E0623]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
},
|
||||
En7::V1(_) => {},
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
|
||||
--> $DIR/associated-types-eq-hr.rs:87:5
|
||||
--> $DIR/associated-types-eq-hr.rs:91:5
|
||||
|
|
||||
LL | foo::<UintStruct>();
|
||||
| ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
|
||||
|
|
||||
note: expected this to be `&isize`
|
||||
--> $DIR/associated-types-eq-hr.rs:26:14
|
||||
--> $DIR/associated-types-eq-hr.rs:30:14
|
||||
|
|
||||
LL | type A = &'a usize;
|
||||
| ^^^^^^^^^
|
||||
= note: expected reference `&isize`
|
||||
found reference `&usize`
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/associated-types-eq-hr.rs:45:36
|
||||
--> $DIR/associated-types-eq-hr.rs:49:36
|
||||
|
|
||||
LL | fn foo<T>()
|
||||
| --- required by a bound in this
|
||||
@ -21,20 +21,20 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>,
|
||||
| ^^^^^^^^^^^^^ required by this bound in `foo`
|
||||
|
||||
error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
|
||||
--> $DIR/associated-types-eq-hr.rs:91:5
|
||||
--> $DIR/associated-types-eq-hr.rs:95:5
|
||||
|
|
||||
LL | bar::<IntStruct>();
|
||||
| ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
|
||||
|
|
||||
note: expected this to be `&usize`
|
||||
--> $DIR/associated-types-eq-hr.rs:14:14
|
||||
--> $DIR/associated-types-eq-hr.rs:18:14
|
||||
|
|
||||
LL | type A = &'a isize;
|
||||
| ^^^^^^^^^
|
||||
= note: expected reference `&usize`
|
||||
found reference `&isize`
|
||||
note: required by a bound in `bar`
|
||||
--> $DIR/associated-types-eq-hr.rs:52:36
|
||||
--> $DIR/associated-types-eq-hr.rs:56:36
|
||||
|
|
||||
LL | fn bar<T>()
|
||||
| --- required by a bound in this
|
||||
@ -43,7 +43,7 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x usize>,
|
||||
| ^^^^^^^^^^^^^ required by this bound in `bar`
|
||||
|
||||
error: implementation of `TheTrait` is not general enough
|
||||
--> $DIR/associated-types-eq-hr.rs:96:5
|
||||
--> $DIR/associated-types-eq-hr.rs:100:5
|
||||
|
|
||||
LL | tuple_one::<Tuple>();
|
||||
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
||||
@ -52,7 +52,7 @@ LL | tuple_one::<Tuple>();
|
||||
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
|
||||
|
||||
error: implementation of `TheTrait` is not general enough
|
||||
--> $DIR/associated-types-eq-hr.rs:96:5
|
||||
--> $DIR/associated-types-eq-hr.rs:100:5
|
||||
|
|
||||
LL | tuple_one::<Tuple>();
|
||||
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
||||
@ -61,7 +61,7 @@ LL | tuple_one::<Tuple>();
|
||||
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
|
||||
|
||||
error: implementation of `TheTrait` is not general enough
|
||||
--> $DIR/associated-types-eq-hr.rs:102:5
|
||||
--> $DIR/associated-types-eq-hr.rs:106:5
|
||||
|
|
||||
LL | tuple_two::<Tuple>();
|
||||
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
||||
@ -70,7 +70,7 @@ LL | tuple_two::<Tuple>();
|
||||
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
|
||||
|
||||
error: implementation of `TheTrait` is not general enough
|
||||
--> $DIR/associated-types-eq-hr.rs:102:5
|
||||
--> $DIR/associated-types-eq-hr.rs:106:5
|
||||
|
|
||||
LL | tuple_two::<Tuple>();
|
||||
| ^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
||||
@ -79,7 +79,7 @@ LL | tuple_two::<Tuple>();
|
||||
= note: ...but it actually implements `TheTrait<(&'2 isize, &'2 isize)>`, for some specific lifetime `'2`
|
||||
|
||||
error: implementation of `TheTrait` is not general enough
|
||||
--> $DIR/associated-types-eq-hr.rs:112:5
|
||||
--> $DIR/associated-types-eq-hr.rs:116:5
|
||||
|
|
||||
LL | tuple_four::<Tuple>();
|
||||
| ^^^^^^^^^^^^^^^^^^^ implementation of `TheTrait` is not general enough
|
@ -1,18 +1,18 @@
|
||||
error[E0271]: type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
|
||||
--> $DIR/associated-types-eq-hr.rs:87:5
|
||||
--> $DIR/associated-types-eq-hr.rs:91:5
|
||||
|
|
||||
LL | foo::<UintStruct>();
|
||||
| ^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <UintStruct as TheTrait<&'x isize>>::A == &'x isize`
|
||||
|
|
||||
note: expected this to be `&isize`
|
||||
--> $DIR/associated-types-eq-hr.rs:26:14
|
||||
--> $DIR/associated-types-eq-hr.rs:30:14
|
||||
|
|
||||
LL | type A = &'a usize;
|
||||
| ^^^^^^^^^
|
||||
= note: expected reference `&isize`
|
||||
found reference `&usize`
|
||||
note: required by a bound in `foo`
|
||||
--> $DIR/associated-types-eq-hr.rs:45:36
|
||||
--> $DIR/associated-types-eq-hr.rs:49:36
|
||||
|
|
||||
LL | fn foo<T>()
|
||||
| --- required by a bound in this
|
||||
@ -21,20 +21,20 @@ LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>,
|
||||
| ^^^^^^^^^^^^^ required by this bound in `foo`
|
||||
|
||||
error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
|
||||
--> $DIR/associated-types-eq-hr.rs:91:5
|
||||
--> $DIR/associated-types-eq-hr.rs:95:5
|
||||
|
|
||||
LL | bar::<IntStruct>();
|
||||
| ^^^^^^^^^^^^^^^^ type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
|
||||
|
|
||||
note: expected this to be `&usize`
|
||||
--> $DIR/associated-types-eq-hr.rs:14:14
|
||||
--> $DIR/associated-types-eq-hr.rs:18:14
|
||||
|
|
||||
LL | type A = &'a isize;
|
||||
| ^^^^^^^^^
|
||||
= note: expected reference `&usize`
|
||||
found reference `&isize`
|
||||
note: required by a bound in `bar`
|
||||
--> $DIR/associated-types-eq-hr.rs:52:36
|
||||
--> $DIR/associated-types-eq-hr.rs:56:36
|
||||
|
|
||||
LL | fn bar<T>()
|
||||
| --- required by a bound in this
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
// Check testing of equality constraints in a higher-ranked context.
|
||||
|
||||
pub trait TheTrait<T> {
|
||||
@ -94,14 +98,14 @@ pub fn call_bar() {
|
||||
|
||||
pub fn call_tuple_one() {
|
||||
tuple_one::<Tuple>();
|
||||
//~^ ERROR implementation of `TheTrait` is not general enough
|
||||
//~| ERROR implementation of `TheTrait` is not general enough
|
||||
//[base]~^ ERROR implementation of `TheTrait` is not general enough
|
||||
//[base]~| ERROR implementation of `TheTrait` is not general enough
|
||||
}
|
||||
|
||||
pub fn call_tuple_two() {
|
||||
tuple_two::<Tuple>();
|
||||
//~^ ERROR implementation of `TheTrait` is not general enough
|
||||
//~| ERROR implementation of `TheTrait` is not general enough
|
||||
//[base]~^ ERROR implementation of `TheTrait` is not general enough
|
||||
//[base]~| ERROR implementation of `TheTrait` is not general enough
|
||||
}
|
||||
|
||||
pub fn call_tuple_three() {
|
||||
@ -110,7 +114,7 @@ pub fn call_tuple_three() {
|
||||
|
||||
pub fn call_tuple_four() {
|
||||
tuple_four::<Tuple>();
|
||||
//~^ ERROR implementation of `TheTrait` is not general enough
|
||||
//[base]~^ ERROR implementation of `TheTrait` is not general enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:40
|
||||
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:40
|
||||
|
|
||||
LL | x: <I as Foo<&'a isize>>::A,
|
||||
| --------- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:29
|
||||
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:29
|
||||
|
|
||||
LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
|
||||
| -- -- lifetime `'b` defined here
|
||||
@ -12,7 +12,7 @@ LL | let z: I::A = if cond { x } else { y };
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:22:40
|
||||
--> $DIR/associated-types-project-from-hrtb-in-fn-body.rs:26:40
|
||||
|
|
||||
LL | fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
// Check projection of an associated type out of a higher-ranked
|
||||
// trait-bound in the context of a function body.
|
||||
|
||||
@ -20,7 +24,9 @@ fn bar<'a, 'b, I : for<'x> Foo<&'x isize>>(
|
||||
{
|
||||
// x and y here have two distinct lifetimes:
|
||||
let z: I::A = if cond { x } else { y };
|
||||
//~^ ERROR lifetime mismatch
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/associated-types-subtyping-1.rs:26:38
|
||||
--> $DIR/associated-types-subtyping-1.rs:31:38
|
||||
|
|
||||
LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T)
|
||||
| ----- ----- these two types are declared with different lifetimes...
|
||||
@ -8,7 +8,7 @@ LL | let _c: <T as Trait<'b>>::Type = a;
|
||||
| ^ ...but data from `y` flows into `x` here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/associated-types-subtyping-1.rs:35:38
|
||||
--> $DIR/associated-types-subtyping-1.rs:41:38
|
||||
|
|
||||
LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T)
|
||||
| ----- ----- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/associated-types-subtyping-1.rs:24:12
|
||||
--> $DIR/associated-types-subtyping-1.rs:28:12
|
||||
|
|
||||
LL | fn method2<'a,'b,T>(x: &'a T, y: &'b T)
|
||||
| -- -- lifetime `'b` defined here
|
||||
@ -12,7 +12,7 @@ LL | let a: <T as Trait<'a>>::Type = make_any();
|
||||
= help: consider adding the following bound: `'b: 'a`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/associated-types-subtyping-1.rs:35:13
|
||||
--> $DIR/associated-types-subtyping-1.rs:41:13
|
||||
|
|
||||
LL | fn method3<'a,'b,T>(x: &'a T, y: &'b T)
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
#![allow(unused_variables)]
|
||||
|
||||
fn make_any<T>() -> T { loop {} }
|
||||
@ -22,8 +26,10 @@ fn method2<'a,'b,T>(x: &'a T, y: &'b T)
|
||||
{
|
||||
// Note that &'static T <: &'a T.
|
||||
let a: <T as Trait<'a>>::Type = make_any();
|
||||
//[nll]~^ ERROR lifetime may not live long enough
|
||||
let b: <T as Trait<'b>>::Type = make_any();
|
||||
let _c: <T as Trait<'b>>::Type = a; //~ ERROR E0623
|
||||
let _c: <T as Trait<'b>>::Type = a;
|
||||
//[base]~^ ERROR E0623
|
||||
}
|
||||
|
||||
fn method3<'a,'b,T>(x: &'a T, y: &'b T)
|
||||
@ -32,7 +38,9 @@ fn method3<'a,'b,T>(x: &'a T, y: &'b T)
|
||||
// Note that &'static T <: &'a T.
|
||||
let a: <T as Trait<'a>>::Type = make_any();
|
||||
let b: <T as Trait<'b>>::Type = make_any();
|
||||
let _c: <T as Trait<'a>>::Type = b; //~ ERROR E0623
|
||||
let _c: <T as Trait<'a>>::Type = b;
|
||||
//[base]~^ ERROR E0623
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn method4<'a,'b,T>(x: &'a T, y: &'b T)
|
||||
|
25
src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.krisskross.stderr
vendored
Normal file
25
src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.krisskross.stderr
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/project-fn-ret-contravariant-nll.rs:51:5
|
||||
|
|
||||
LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
| ------- ------------------
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
...
|
||||
LL | (a, b)
|
||||
| ^ ...but data from `y` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/project-fn-ret-contravariant-nll.rs:51:8
|
||||
|
|
||||
LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
| ------- ------------------
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
...
|
||||
LL | (a, b)
|
||||
| ^ ...but data from `x` is returned here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0623`.
|
55
src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.rs
vendored
Normal file
55
src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.rs
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
#![feature(unboxed_closures)]
|
||||
|
||||
// Test for projection cache. We should be able to project distinct
|
||||
// lifetimes from `foo` as we reinstantiate it multiple times, but not
|
||||
// if we do it just once. In this variant, the region `'a` is used in
|
||||
// an contravariant position, which affects the results.
|
||||
|
||||
// revisions: ok oneuse transmute krisskross
|
||||
//[ok] check-pass
|
||||
//[oneuse] check-pass
|
||||
|
||||
// ignore-compare-mode-nll
|
||||
// FIXME(nll): When stabilizing, this test should replace `project-fn-ret-contravariant.rs`
|
||||
// The two would normally be just revisions, but this test uses revisions heavily, so splitting into
|
||||
// a separate test is just easier.
|
||||
|
||||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
fn foo<'a>() -> &'a u32 { loop { } }
|
||||
|
||||
fn bar<T>(t: T, x: T::Output) -> T::Output
|
||||
where T: FnOnce<()>
|
||||
{
|
||||
t()
|
||||
}
|
||||
|
||||
#[cfg(ok)] // two instantiations: OK
|
||||
fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
let a = bar(foo, x);
|
||||
let b = bar(foo, y);
|
||||
(a, b)
|
||||
}
|
||||
|
||||
#[cfg(oneuse)] // one instantiation: OK (surprisingly)
|
||||
fn baz<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
let f /* : fn() -> &'static u32 */ = foo; // <-- inferred type annotated
|
||||
let a = bar(f, x); // this is considered ok because fn args are contravariant...
|
||||
let b = bar(f, y); // ...and hence we infer T to distinct values in each call.
|
||||
(a, b)
|
||||
}
|
||||
|
||||
#[cfg(transmute)] // one instantiations: BAD
|
||||
fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
|
||||
bar(foo, x) //[transmute]~ ERROR E0759
|
||||
}
|
||||
|
||||
#[cfg(krisskross)] // two instantiations, mixing and matching: BAD
|
||||
fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
let a = bar(foo, y);
|
||||
let b = bar(foo, x);
|
||||
(a, b) //[krisskross]~ ERROR lifetime mismatch [E0623]
|
||||
//[krisskross]~^ ERROR lifetime mismatch [E0623]
|
||||
}
|
||||
|
||||
fn main() { }
|
11
src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.transmute.stderr
vendored
Normal file
11
src/test/ui/associated-types/cache/project-fn-ret-contravariant-nll.transmute.stderr
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/project-fn-ret-contravariant-nll.rs:44:8
|
||||
|
|
||||
LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
|
||||
| ------- this data with lifetime `'a`...
|
||||
LL | bar(foo, x)
|
||||
| ^^^ - ...is used and required to live as long as `'static` here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0759`.
|
@ -1,30 +0,0 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/project-fn-ret-contravariant.rs:45:4
|
||||
|
|
||||
LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
...
|
||||
LL | (a, b)
|
||||
| ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
|
||||
|
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/project-fn-ret-contravariant.rs:45:4
|
||||
|
|
||||
LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
...
|
||||
LL | (a, b)
|
||||
| ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
|
||||
|
|
||||
= help: consider adding the following bound: `'b: 'a`
|
||||
|
||||
help: `'a` and `'b` must be the same: replace one with the other
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/project-fn-ret-contravariant.rs:45:5
|
||||
--> $DIR/project-fn-ret-contravariant.rs:52:5
|
||||
|
|
||||
LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
| ------- ------------------
|
||||
@ -10,7 +10,7 @@ LL | (a, b)
|
||||
| ^ ...but data from `y` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/project-fn-ret-contravariant.rs:45:8
|
||||
--> $DIR/project-fn-ret-contravariant.rs:52:8
|
||||
|
|
||||
LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
| ------- ------------------
|
||||
|
@ -1,8 +0,0 @@
|
||||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/project-fn-ret-contravariant.rs:50:1
|
||||
|
|
||||
LL | fn main() { }
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,8 +0,0 @@
|
||||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/project-fn-ret-contravariant.rs:50:1
|
||||
|
|
||||
LL | fn main() { }
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![feature(unboxed_closures)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
// Test for projection cache. We should be able to project distinct
|
||||
// lifetimes from `foo` as we reinstantiate it multiple times, but not
|
||||
@ -7,6 +6,14 @@
|
||||
// an contravariant position, which affects the results.
|
||||
|
||||
// revisions: ok oneuse transmute krisskross
|
||||
//[ok] check-pass
|
||||
//[oneuse] check-pass
|
||||
|
||||
// ignore-compare-mode-nll
|
||||
// FIXME(nll): When stabilizing, this test should be replaced with
|
||||
// `project-fn-ret-contravariant-nll.rs` The two would normally be just
|
||||
// revisions, but this test uses revisions heavily, so splitting into
|
||||
// a separate test is just easier.
|
||||
|
||||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
@ -46,5 +53,4 @@ fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
|
||||
//[krisskross]~^ ERROR lifetime mismatch [E0623]
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { } //[ok,oneuse]~ ERROR fatal error triggered by #[rustc_error]
|
||||
fn main() { }
|
||||
|
@ -1,10 +0,0 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/project-fn-ret-contravariant.rs:38:4
|
||||
|
|
||||
LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
|
||||
| -- lifetime `'a` defined here
|
||||
LL | bar(foo, x)
|
||||
| ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/project-fn-ret-contravariant.rs:38:8
|
||||
--> $DIR/project-fn-ret-contravariant.rs:45:8
|
||||
|
|
||||
LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
|
||||
| ------- this data with lifetime `'a`...
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/project-fn-ret-invariant.rs:56:5
|
||||
--> $DIR/project-fn-ret-invariant-nll.rs:63:5
|
||||
|
|
||||
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
@ -15,7 +15,7 @@ LL | (a, b)
|
||||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/project-fn-ret-invariant.rs:56:5
|
||||
--> $DIR/project-fn-ret-invariant-nll.rs:63:5
|
||||
|
|
||||
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
| -- -- lifetime `'b` defined here
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/project-fn-ret-invariant.rs:39:13
|
||||
--> $DIR/project-fn-ret-invariant-nll.rs:46:13
|
||||
|
|
||||
LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
@ -15,7 +15,7 @@ LL | let a = bar(f, x);
|
||||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/project-fn-ret-invariant.rs:40:13
|
||||
--> $DIR/project-fn-ret-invariant-nll.rs:47:13
|
||||
|
|
||||
LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
| -- -- lifetime `'b` defined here
|
68
src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.rs
vendored
Normal file
68
src/test/ui/associated-types/cache/project-fn-ret-invariant-nll.rs
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
#![feature(unboxed_closures)]
|
||||
// Test for projection cache. We should be able to project distinct
|
||||
// lifetimes from `foo` as we reinstantiate it multiple times, but not
|
||||
// if we do it just once. In this variant, the region `'a` is used in
|
||||
// an invariant position, which affects the results.
|
||||
|
||||
// revisions: ok oneuse transmute krisskross
|
||||
//[ok] check-pass
|
||||
|
||||
// compile-flags: -Z borrowck=mir
|
||||
// ignore-compare-mode-nll
|
||||
// FIXME(nll): When stabilizing, this test should replace with `project-fn-ret-invariant.rs`
|
||||
// The two would normally be just revisions, but this test uses revisions heavily, so splitting into
|
||||
// a separate test is just easier.
|
||||
|
||||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
struct Type<'a> {
|
||||
// Invariant
|
||||
data: PhantomData<fn(&'a u32) -> &'a u32>,
|
||||
}
|
||||
|
||||
fn foo<'a>() -> Type<'a> {
|
||||
loop {}
|
||||
}
|
||||
|
||||
fn bar<T>(t: T, x: T::Output) -> T::Output
|
||||
where
|
||||
T: FnOnce<()>,
|
||||
{
|
||||
t()
|
||||
}
|
||||
|
||||
#[cfg(ok)] // two instantiations: OK
|
||||
fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
let a = bar(foo, x);
|
||||
let b = bar(foo, y);
|
||||
(a, b)
|
||||
}
|
||||
|
||||
#[cfg(oneuse)] // one instantiation: BAD
|
||||
fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
let f = foo; // <-- No consistent type can be inferred for `f` here.
|
||||
let a = bar(f, x); //[oneuse]~ ERROR lifetime may not live long enough
|
||||
let b = bar(f, y); //[oneuse]~ ERROR lifetime may not live long enough
|
||||
(a, b)
|
||||
}
|
||||
|
||||
#[cfg(transmute)] // one instantiations: BAD
|
||||
fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> {
|
||||
// Cannot instantiate `foo` with any lifetime other than `'a`,
|
||||
// since it is provided as input.
|
||||
|
||||
bar(foo, x) //[transmute]~ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
#[cfg(krisskross)] // two instantiations, mixing and matching: BAD
|
||||
fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
let a = bar(foo, y);
|
||||
let b = bar(foo, x);
|
||||
(a, b)
|
||||
//[krisskross]~^ ERROR lifetime may not live long enough
|
||||
//[krisskross]~| ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/project-fn-ret-invariant.rs:49:5
|
||||
--> $DIR/project-fn-ret-invariant-nll.rs:56:5
|
||||
|
|
||||
LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> {
|
||||
| -- lifetime `'a` defined here
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/project-fn-ret-invariant.rs:54:22
|
||||
--> $DIR/project-fn-ret-invariant.rs:60:22
|
||||
|
|
||||
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
| -------- --------------------
|
||||
@ -9,7 +9,7 @@ LL | let a = bar(foo, y);
|
||||
| ^ ...but data from `x` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/project-fn-ret-invariant.rs:56:9
|
||||
--> $DIR/project-fn-ret-invariant.rs:62:9
|
||||
|
|
||||
LL | fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
| -------- --------------------
|
||||
|
@ -1,8 +0,0 @@
|
||||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/project-fn-ret-invariant.rs:60:1
|
||||
|
|
||||
LL | fn main() {}
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/project-fn-ret-invariant.rs:40:20
|
||||
--> $DIR/project-fn-ret-invariant.rs:46:20
|
||||
|
|
||||
LL | fn baz<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
| -------- --------------------
|
||||
|
@ -1,11 +1,17 @@
|
||||
#![feature(unboxed_closures)]
|
||||
#![feature(rustc_attrs)]
|
||||
// Test for projection cache. We should be able to project distinct
|
||||
// lifetimes from `foo` as we reinstantiate it multiple times, but not
|
||||
// if we do it just once. In this variant, the region `'a` is used in
|
||||
// an invariant position, which affects the results.
|
||||
|
||||
// revisions: ok oneuse transmute krisskross
|
||||
//[ok] check-pass
|
||||
|
||||
// ignore-compare-mode-nll
|
||||
// FIXME(nll): When stabilizing, this test should be replaced with `project-fn-ret-invariant-nll.rs`
|
||||
// The two would normally be just revisions, but this test uses revisions heavily, so splitting into
|
||||
// a separate test is just easier.
|
||||
|
||||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
@ -56,6 +62,4 @@ fn transmute<'a, 'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
(a, b) //[krisskross]~ ERROR E0623
|
||||
}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() {}
|
||||
//[ok]~^ ERROR fatal error triggered by #[rustc_error]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0759]: `x` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/project-fn-ret-invariant.rs:49:9
|
||||
--> $DIR/project-fn-ret-invariant.rs:55:9
|
||||
|
|
||||
LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> {
|
||||
| -------- this data with lifetime `'a`...
|
||||
@ -8,7 +8,7 @@ LL | bar(foo, x)
|
||||
| ^^^ - ...is used and required to live as long as `'static` here
|
||||
|
|
||||
note: `'static` lifetime requirement introduced by the return type
|
||||
--> $DIR/project-fn-ret-invariant.rs:45:37
|
||||
--> $DIR/project-fn-ret-invariant.rs:51:37
|
||||
|
|
||||
LL | fn baz<'a, 'b>(x: Type<'a>) -> Type<'static> {
|
||||
| ^^^^^^^ `'static` requirement introduced here
|
||||
|
@ -0,0 +1,17 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/higher-ranked-projection.rs:25:5
|
||||
|
|
||||
LL | foo(());
|
||||
| ^^^ lifetime mismatch
|
||||
|
|
||||
= note: expected reference `&'a ()`
|
||||
found reference `&()`
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/higher-ranked-projection.rs:16:33
|
||||
|
|
||||
LL | where for<'a> &'a T: Mirror<Image=U>
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
@ -0,0 +1,17 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/higher-ranked-projection.rs:25:5
|
||||
|
|
||||
LL | foo(());
|
||||
| ^^^^^^^ one type is more general than the other
|
||||
|
|
||||
= note: expected reference `&'a ()`
|
||||
found reference `&()`
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/higher-ranked-projection.rs:16:33
|
||||
|
|
||||
LL | where for<'a> &'a T: Mirror<Image=U>
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
@ -1,8 +0,0 @@
|
||||
error: fatal error triggered by #[rustc_error]
|
||||
--> $DIR/higher-ranked-projection.rs:24:1
|
||||
|
|
||||
LL | fn main() {
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,6 +1,7 @@
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
// revisions: good bad
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: good badbase badnll
|
||||
//[good] check-pass
|
||||
// [badnll]compile-flags: -Zborrowck=mir
|
||||
|
||||
trait Mirror {
|
||||
type Image;
|
||||
@ -10,7 +11,7 @@ impl<T> Mirror for T {
|
||||
type Image = T;
|
||||
}
|
||||
|
||||
#[cfg(bad)]
|
||||
#[cfg(any(badbase, badnll))]
|
||||
fn foo<U, T>(_t: T)
|
||||
where for<'a> &'a T: Mirror<Image=U>
|
||||
{}
|
||||
@ -20,8 +21,8 @@ fn foo<U, T>(_t: T)
|
||||
where for<'a> &'a T: Mirror<Image=&'a U>
|
||||
{}
|
||||
|
||||
#[rustc_error]
|
||||
fn main() { //[good]~ ERROR fatal error triggered by #[rustc_error]
|
||||
fn main() {
|
||||
foo(());
|
||||
//[bad]~^ ERROR mismatched types
|
||||
//[badbase]~^ ERROR mismatched types
|
||||
//[badnll]~^^ ERROR mismatched types
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/issue-76547.rs:20:13
|
||||
--> $DIR/issue-76547.rs:24:13
|
||||
|
|
||||
LL | async fn fut(bufs: &mut [&mut [u8]]) {
|
||||
| ---------------- these two types are declared with different lifetimes...
|
||||
@ -7,7 +7,7 @@ LL | ListFut(bufs).await
|
||||
| ^^^^ ...but data from `bufs` flows into `bufs` here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/issue-76547.rs:34:14
|
||||
--> $DIR/issue-76547.rs:39:14
|
||||
|
|
||||
LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
|
||||
| ---------------- these two types are declared with different lifetimes...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-76547.rs:20:13
|
||||
--> $DIR/issue-76547.rs:24:13
|
||||
|
|
||||
LL | async fn fut(bufs: &mut [&mut [u8]]) {
|
||||
| - - let's call the lifetime of this reference `'2`
|
||||
@ -9,7 +9,7 @@ LL | ListFut(bufs).await
|
||||
| ^^^^ this usage requires that `'1` must outlive `'2`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-76547.rs:34:14
|
||||
--> $DIR/issue-76547.rs:39:14
|
||||
|
|
||||
LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
|
||||
| - - let's call the lifetime of this reference `'2`
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
// Test for diagnostic improvement issue #76547
|
||||
// edition:2018
|
||||
|
||||
@ -18,7 +22,8 @@ impl<'a> Future for ListFut<'a> {
|
||||
|
||||
async fn fut(bufs: &mut [&mut [u8]]) {
|
||||
ListFut(bufs).await
|
||||
//~^ ERROR lifetime mismatch
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
pub struct ListFut2<'a>(&'a mut [&'a mut [u8]]);
|
||||
@ -32,7 +37,8 @@ impl<'a> Future for ListFut2<'a> {
|
||||
|
||||
async fn fut2(bufs: &mut [&mut [u8]]) -> i32 {
|
||||
ListFut2(bufs).await
|
||||
//~^ ERROR lifetime mismatch
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,13 +1,14 @@
|
||||
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/issue-62097.rs:12:31
|
||||
--> $DIR/issue-62097.rs:16:31
|
||||
|
|
||||
LL | pub async fn run_dummy_fn(&self) {
|
||||
| ^^^^^ this data with an anonymous lifetime `'_`...
|
||||
LL |
|
||||
LL | foo(|| self.bar()).await;
|
||||
| --- ...is used and required to live as long as `'static` here
|
||||
|
|
||||
note: `'static` lifetime requirement introduced by this bound
|
||||
--> $DIR/issue-62097.rs:4:19
|
||||
--> $DIR/issue-62097.rs:8:19
|
||||
|
|
||||
LL | F: FnOnce() + 'static
|
||||
| ^^^^^^^
|
@ -1,5 +1,5 @@
|
||||
error[E0373]: closure may outlive the current function, but it borrows `self`, which is owned by the current function
|
||||
--> $DIR/issue-62097.rs:13:13
|
||||
--> $DIR/issue-62097.rs:18:13
|
||||
|
|
||||
LL | foo(|| self.bar()).await;
|
||||
| ^^ ---- `self` is borrowed here
|
||||
@ -7,7 +7,7 @@ LL | foo(|| self.bar()).await;
|
||||
| may outlive borrowed value `self`
|
||||
|
|
||||
note: function requires argument type to outlive `'static`
|
||||
--> $DIR/issue-62097.rs:13:9
|
||||
--> $DIR/issue-62097.rs:18:9
|
||||
|
|
||||
LL | foo(|| self.bar()).await;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
@ -17,13 +17,14 @@ LL | foo(move || self.bar()).await;
|
||||
| ++++
|
||||
|
||||
error[E0521]: borrowed data escapes outside of associated function
|
||||
--> $DIR/issue-62097.rs:13:9
|
||||
--> $DIR/issue-62097.rs:18:9
|
||||
|
|
||||
LL | pub async fn run_dummy_fn(&self) {
|
||||
| -----
|
||||
| |
|
||||
| `self` is a reference that is only valid in the associated function body
|
||||
| let's call the lifetime of this reference `'1`
|
||||
LL |
|
||||
LL | foo(|| self.bar()).await;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
// edition:2018
|
||||
async fn foo<F>(fun: F)
|
||||
where
|
||||
@ -9,8 +13,11 @@ where
|
||||
struct Struct;
|
||||
|
||||
impl Struct {
|
||||
pub async fn run_dummy_fn(&self) { //~ ERROR E0759
|
||||
pub async fn run_dummy_fn(&self) {
|
||||
//[base]~^ ERROR E0759
|
||||
foo(|| self.bar()).await;
|
||||
//[nll]~^ ERROR closure may outlive the current function
|
||||
//[nll]~| ERROR borrowed data escapes outside of associated function
|
||||
}
|
||||
|
||||
pub fn bar(&self) {}
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/issue-63388-1.rs:14:9
|
||||
--> $DIR/issue-63388-1.rs:19:9
|
||||
|
|
||||
LL | &'a self, foo: &dyn Foo
|
||||
| -------- this parameter and the return type are declared with different lifetimes...
|
||||
LL | ) -> &dyn Foo
|
||||
| --------
|
||||
LL | {
|
||||
...
|
||||
LL | foo
|
||||
| ^^^ ...but data from `foo` is returned here
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-63388-1.rs:13:5
|
||||
--> $DIR/issue-63388-1.rs:17:5
|
||||
|
|
||||
LL | async fn do_sth<'a>(
|
||||
| -- lifetime `'a` defined here
|
||||
@ -7,7 +7,9 @@ LL | &'a self, foo: &dyn Foo
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
LL | ) -> &dyn Foo
|
||||
LL | / {
|
||||
LL | |
|
||||
LL | | foo
|
||||
LL | |
|
||||
LL | | }
|
||||
| |_____^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'1`
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
// edition:2018
|
||||
|
||||
struct Xyz {
|
||||
@ -11,7 +15,9 @@ impl Xyz {
|
||||
&'a self, foo: &dyn Foo
|
||||
) -> &dyn Foo
|
||||
{
|
||||
foo //~ ERROR lifetime mismatch
|
||||
//[nll]~^ ERROR lifetime may not live long enough
|
||||
foo
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/issue-72312.rs:10:24
|
||||
--> $DIR/issue-72312.rs:14:24
|
||||
|
|
||||
LL | pub async fn start(&self) {
|
||||
| ^^^^^ this data with an anonymous lifetime `'_`...
|
||||
@ -8,12 +8,12 @@ LL | &self;
|
||||
| ----- ...is used here...
|
||||
|
|
||||
note: ...and is required to live as long as `'static` here
|
||||
--> $DIR/issue-72312.rs:13:9
|
||||
--> $DIR/issue-72312.rs:20:9
|
||||
|
|
||||
LL | require_static(async move {
|
||||
| ^^^^^^^^^^^^^^
|
||||
note: `'static` lifetime requirement introduced by this bound
|
||||
--> $DIR/issue-72312.rs:2:22
|
||||
--> $DIR/issue-72312.rs:6:22
|
||||
|
|
||||
LL | fn require_static<T: 'static>(val: T) -> T {
|
||||
| ^^^^^^^
|
@ -1,5 +1,5 @@
|
||||
error[E0521]: borrowed data escapes outside of associated function
|
||||
--> $DIR/issue-72312.rs:13:24
|
||||
--> $DIR/issue-72312.rs:20:24
|
||||
|
|
||||
LL | pub async fn start(&self) {
|
||||
| -----
|
||||
@ -9,6 +9,10 @@ LL | pub async fn start(&self) {
|
||||
...
|
||||
LL | require_static(async move {
|
||||
| ________________________^
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | &self;
|
||||
LL | | });
|
||||
| | ^
|
||||
|
@ -1,17 +1,28 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
// edition:2018
|
||||
fn require_static<T: 'static>(val: T) -> T {
|
||||
//~^ NOTE 'static` lifetime requirement introduced by this bound
|
||||
//[base]~^ NOTE 'static` lifetime requirement introduced by this bound
|
||||
val
|
||||
}
|
||||
|
||||
struct Problem;
|
||||
|
||||
impl Problem {
|
||||
pub async fn start(&self) { //~ ERROR E0759
|
||||
//~^ NOTE this data with an anonymous lifetime `'_`
|
||||
//~| NOTE in this expansion of desugaring of `async` block or function
|
||||
require_static(async move { //~ NOTE ...and is required to live as long as `'static` here
|
||||
&self; //~ NOTE ...is used here...
|
||||
pub async fn start(&self) {
|
||||
//[base]~^ ERROR E0759
|
||||
//[base]~| NOTE this data with an anonymous lifetime `'_`
|
||||
//[base]~| NOTE in this expansion of desugaring of `async` block or function
|
||||
//[nll]~^^^^ NOTE let's call
|
||||
//[nll]~| NOTE `self` is a reference
|
||||
require_static(async move {
|
||||
//[base]~^ NOTE ...and is required to live as long as `'static` here
|
||||
//[nll]~^^ ERROR borrowed data escapes
|
||||
//[nll]~| NOTE `self` escapes
|
||||
//[nll]~| NOTE argument requires
|
||||
&self; //[base]~ NOTE ...is used here...
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,18 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ret-impl-trait-one.rs:10:85
|
||||
--> $DIR/ret-impl-trait-one.rs:14:85
|
||||
|
|
||||
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
|
||||
| ______________________________________________________------_____-------------------_^
|
||||
| | |
|
||||
| | this parameter and the return type are declared with different lifetimes...
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | (a, b)
|
||||
LL | | }
|
||||
| |_^ ...but data from `a` is returned here
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
--> $DIR/ret-impl-trait-one.rs:16:80
|
||||
--> $DIR/ret-impl-trait-one.rs:21:80
|
||||
|
|
||||
LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> {
|
||||
| ____________________________________--__________________________________________^
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/ret-impl-trait-one.rs:10:85
|
||||
--> $DIR/ret-impl-trait-one.rs:14:85
|
||||
|
|
||||
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
|
||||
| ________________________________--__--_______________________________________________^
|
||||
@ -7,6 +7,7 @@ LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trai
|
||||
| | | lifetime `'b` defined here
|
||||
| | lifetime `'a` defined here
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | (a, b)
|
||||
LL | | }
|
||||
| |_^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
|
||||
@ -14,7 +15,7 @@ LL | | }
|
||||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
|
||||
--> $DIR/ret-impl-trait-one.rs:16:80
|
||||
--> $DIR/ret-impl-trait-one.rs:21:80
|
||||
|
|
||||
LL | async fn async_ret_impl_trait1<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> {
|
||||
| ____________________________________--__________________________________________^
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
// edition:2018
|
||||
|
||||
// Test that a feature gate is needed to use `impl Trait` as the
|
||||
@ -8,7 +12,8 @@ impl<T> Trait<'_> for T { }
|
||||
|
||||
// Fails to recognize that both 'a and 'b are mentioned and should thus be accepted
|
||||
async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
|
||||
//~^ ERROR lifetime mismatch
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
(a, b)
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:9:5
|
||||
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:13:5
|
||||
|
|
||||
LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> {
|
||||
| ------------- -----
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:9:5
|
||||
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:13:5
|
||||
|
|
||||
LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
// Test that assignments to an `&mut` pointer which is found in a
|
||||
// borrowed (but otherwise non-aliasable) location is illegal.
|
||||
|
||||
@ -7,7 +11,8 @@ struct S<'a> {
|
||||
|
||||
fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> {
|
||||
S { pointer: &mut *p.pointer }
|
||||
//~^ ERROR lifetime mismatch
|
||||
//[base]~^ ERROR lifetime mismatch
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
93
src/test/ui/borrowck/two-phase-nonrecv-autoref.base.stderr
Normal file
93
src/test/ui/borrowck/two-phase-nonrecv-autoref.base.stderr
Normal file
@ -0,0 +1,93 @@
|
||||
error[E0499]: cannot borrow `*f` as mutable more than once at a time
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:51:11
|
||||
|
|
||||
LL | f(f(10));
|
||||
| - ^ second mutable borrow occurs here
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
| first borrow later used by call
|
||||
|
||||
error[E0382]: use of moved value: `f`
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:58:11
|
||||
|
|
||||
LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
|
||||
| - move occurs because `f` has type `Box<F>`, which does not implement the `Copy` trait
|
||||
LL | f(f(10));
|
||||
| - ^ value used here after move
|
||||
| |
|
||||
| value moved here
|
||||
|
||||
error[E0499]: cannot borrow `*f` as mutable more than once at a time
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:63:11
|
||||
|
|
||||
LL | f(f(10));
|
||||
| - ^ second mutable borrow occurs here
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
| first borrow later used by call
|
||||
|
||||
error[E0382]: use of moved value: `f`
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:70:11
|
||||
|
|
||||
LL | fn twice_ten_oo(f: Box<dyn FnOnce(i32) -> i32>) {
|
||||
| - move occurs because `f` has type `Box<dyn FnOnce(i32) -> i32>`, which does not implement the `Copy` trait
|
||||
LL | f(f(10));
|
||||
| - ^ value used here after move
|
||||
| |
|
||||
| value moved here
|
||||
|
||||
error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:108:27
|
||||
|
|
||||
LL | double_access(&mut a, &a);
|
||||
| ------------- ------ ^^ immutable borrow occurs here
|
||||
| | |
|
||||
| | mutable borrow occurs here
|
||||
| mutable borrow later used by call
|
||||
|
||||
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:133:7
|
||||
|
|
||||
LL | i[i[3]] = 4;
|
||||
| --^----
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
| mutable borrow later used here
|
||||
|
|
||||
help: try adding a local storing this...
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:133:7
|
||||
|
|
||||
LL | i[i[3]] = 4;
|
||||
| ^^^^
|
||||
help: ...and then using that local here
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:133:5
|
||||
|
|
||||
LL | i[i[3]] = 4;
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:139:7
|
||||
|
|
||||
LL | i[i[3]] = i[4];
|
||||
| --^----
|
||||
| | |
|
||||
| | immutable borrow occurs here
|
||||
| mutable borrow occurs here
|
||||
| mutable borrow later used here
|
||||
|
|
||||
help: try adding a local storing this...
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:139:7
|
||||
|
|
||||
LL | i[i[3]] = i[4];
|
||||
| ^^^^
|
||||
help: ...and then using that local here
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:139:5
|
||||
|
|
||||
LL | i[i[3]] = i[4];
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0382, E0499, E0502.
|
||||
For more information about an error, try `rustc --explain E0382`.
|
@ -8,7 +8,7 @@ LL | f(f(10));
|
||||
| first borrow later used by call
|
||||
|
||||
error[E0382]: use of moved value: `f`
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:59:11
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:58:11
|
||||
|
|
||||
LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
|
||||
| - move occurs because `f` has type `Box<F>`, which does not implement the `Copy` trait
|
||||
@ -18,7 +18,7 @@ LL | f(f(10));
|
||||
| value moved here
|
||||
|
||||
error[E0499]: cannot borrow `*f` as mutable more than once at a time
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:65:11
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:63:11
|
||||
|
|
||||
LL | f(f(10));
|
||||
| - ^ second mutable borrow occurs here
|
||||
@ -27,7 +27,7 @@ LL | f(f(10));
|
||||
| first borrow later used by call
|
||||
|
||||
error[E0382]: use of moved value: `f`
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:73:11
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:70:11
|
||||
|
|
||||
LL | fn twice_ten_oo(f: Box<dyn FnOnce(i32) -> i32>) {
|
||||
| - move occurs because `f` has type `Box<dyn FnOnce(i32) -> i32>`, which does not implement the `Copy` trait
|
||||
@ -37,7 +37,7 @@ LL | f(f(10));
|
||||
| value moved here
|
||||
|
||||
error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:112:27
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:108:27
|
||||
|
|
||||
LL | double_access(&mut a, &a);
|
||||
| ------------- ------ ^^ immutable borrow occurs here
|
||||
@ -46,7 +46,7 @@ LL | double_access(&mut a, &a);
|
||||
| mutable borrow later used by call
|
||||
|
||||
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:138:7
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:133:7
|
||||
|
|
||||
LL | i[i[3]] = 4;
|
||||
| --^----
|
||||
@ -56,18 +56,18 @@ LL | i[i[3]] = 4;
|
||||
| mutable borrow later used here
|
||||
|
|
||||
help: try adding a local storing this...
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:138:7
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:133:7
|
||||
|
|
||||
LL | i[i[3]] = 4;
|
||||
| ^^^^
|
||||
help: ...and then using that local here
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:138:5
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:133:5
|
||||
|
|
||||
LL | i[i[3]] = 4;
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:143:7
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:139:7
|
||||
|
|
||||
LL | i[i[3]] = i[4];
|
||||
| --^----
|
||||
@ -77,12 +77,12 @@ LL | i[i[3]] = i[4];
|
||||
| mutable borrow later used here
|
||||
|
|
||||
help: try adding a local storing this...
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:143:7
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:139:7
|
||||
|
|
||||
LL | i[i[3]] = i[4];
|
||||
| ^^^^
|
||||
help: ...and then using that local here
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:143:5
|
||||
--> $DIR/two-phase-nonrecv-autoref.rs:139:5
|
||||
|
|
||||
LL | i[i[3]] = i[4];
|
||||
| ^^^^^^^
|
||||
|
@ -1,4 +1,4 @@
|
||||
// revisions: nll
|
||||
// revisions: base nll
|
||||
//[nll]compile-flags: -Z borrowck=mir
|
||||
|
||||
//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-beyond-autoref
|
||||
@ -49,30 +49,26 @@ fn overloaded_call_traits() {
|
||||
|
||||
fn twice_ten_sm<F: FnMut(i32) -> i32>(f: &mut F) {
|
||||
f(f(10));
|
||||
//[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//~^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
}
|
||||
fn twice_ten_si<F: Fn(i32) -> i32>(f: &mut F) {
|
||||
f(f(10));
|
||||
}
|
||||
fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
|
||||
f(f(10));
|
||||
//[nll]~^ ERROR use of moved value: `f`
|
||||
//[g2p]~^^ ERROR use of moved value: `f`
|
||||
//~^ ERROR use of moved value: `f`
|
||||
}
|
||||
|
||||
fn twice_ten_om(f: &mut dyn FnMut(i32) -> i32) {
|
||||
f(f(10));
|
||||
//[nll]~^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//[g2p]~^^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
//~^ ERROR cannot borrow `*f` as mutable more than once at a time
|
||||
}
|
||||
fn twice_ten_oi(f: &mut dyn Fn(i32) -> i32) {
|
||||
f(f(10));
|
||||
}
|
||||
fn twice_ten_oo(f: Box<dyn FnOnce(i32) -> i32>) {
|
||||
f(f(10));
|
||||
//[nll]~^ ERROR use of moved value: `f`
|
||||
//[g2p]~^^ ERROR use of moved value: `f`
|
||||
//~^ ERROR use of moved value: `f`
|
||||
}
|
||||
|
||||
twice_ten_sm(&mut |x| x + 1);
|
||||
@ -110,8 +106,7 @@ fn coerce_unsized() {
|
||||
|
||||
// This is not okay.
|
||||
double_access(&mut a, &a);
|
||||
//[nll]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
|
||||
//[g2p]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
|
||||
//~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502]
|
||||
|
||||
// But this is okay.
|
||||
a.m(a.i(10));
|
||||
@ -136,12 +131,14 @@ impl IndexMut<i32> for I {
|
||||
fn coerce_index_op() {
|
||||
let mut i = I(10);
|
||||
i[i[3]] = 4;
|
||||
//[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
//~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
// Shoud be accepted with g2p
|
||||
|
||||
i[3] = i[4];
|
||||
|
||||
i[i[3]] = i[4];
|
||||
//[nll]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
//~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502]
|
||||
// Shoud be accepted with g2p
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expect-fn-supply-fn.rs:16:52
|
||||
--> $DIR/expect-fn-supply-fn.rs:20:52
|
||||
|
|
||||
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
| ^^^^^^^^^^^ lifetime mismatch
|
||||
@ -7,18 +7,18 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
= note: expected fn pointer `fn(&u32)`
|
||||
found fn pointer `fn(&'x u32)`
|
||||
note: the anonymous lifetime #1 defined here...
|
||||
--> $DIR/expect-fn-supply-fn.rs:16:48
|
||||
--> $DIR/expect-fn-supply-fn.rs:20:48
|
||||
|
|
||||
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: ...does not necessarily outlive the lifetime `'x` as defined here
|
||||
--> $DIR/expect-fn-supply-fn.rs:13:36
|
||||
--> $DIR/expect-fn-supply-fn.rs:17:36
|
||||
|
|
||||
LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expect-fn-supply-fn.rs:16:52
|
||||
--> $DIR/expect-fn-supply-fn.rs:20:52
|
||||
|
|
||||
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
| ^^^^^^^^^^^ lifetime mismatch
|
||||
@ -26,18 +26,18 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
= note: expected fn pointer `fn(&u32)`
|
||||
found fn pointer `fn(&'x u32)`
|
||||
note: the lifetime `'x` as defined here...
|
||||
--> $DIR/expect-fn-supply-fn.rs:13:36
|
||||
--> $DIR/expect-fn-supply-fn.rs:17:36
|
||||
|
|
||||
LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
|
||||
| ^^
|
||||
note: ...does not necessarily outlive the anonymous lifetime #1 defined here
|
||||
--> $DIR/expect-fn-supply-fn.rs:16:48
|
||||
--> $DIR/expect-fn-supply-fn.rs:20:48
|
||||
|
|
||||
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expect-fn-supply-fn.rs:32:52
|
||||
--> $DIR/expect-fn-supply-fn.rs:38:52
|
||||
|
|
||||
LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
|
||||
| ^^^^^^^^ one type is more general than the other
|
||||
@ -46,7 +46,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
|
||||
found fn pointer `for<'r> fn(&'r u32)`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expect-fn-supply-fn.rs:39:53
|
||||
--> $DIR/expect-fn-supply-fn.rs:45:53
|
||||
|
|
||||
LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
|
||||
| ^^^^^^^^^^^ one type is more general than the other
|
||||
@ -55,7 +55,7 @@ LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
|
||||
found fn pointer `fn(&'x u32)`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expect-fn-supply-fn.rs:48:53
|
||||
--> $DIR/expect-fn-supply-fn.rs:54:53
|
||||
|
|
||||
LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
|
||||
| ^^^^^^^ one type is more general than the other
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/expect-fn-supply-fn.rs:16:49
|
||||
--> $DIR/expect-fn-supply-fn.rs:20:49
|
||||
|
|
||||
LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
|
||||
| -- lifetime `'x` defined here
|
||||
@ -11,7 +11,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
| requires that `'1` must outlive `'x`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/expect-fn-supply-fn.rs:16:49
|
||||
--> $DIR/expect-fn-supply-fn.rs:20:49
|
||||
|
|
||||
LL | fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
|
||||
| -- lifetime `'x` defined here
|
||||
@ -20,7 +20,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
| ^ requires that `'x` must outlive `'static`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expect-fn-supply-fn.rs:32:49
|
||||
--> $DIR/expect-fn-supply-fn.rs:38:49
|
||||
|
|
||||
LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
|
||||
| ^ one type is more general than the other
|
||||
@ -29,7 +29,7 @@ LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
|
||||
found fn pointer `fn(&u32)`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expect-fn-supply-fn.rs:39:50
|
||||
--> $DIR/expect-fn-supply-fn.rs:45:50
|
||||
|
|
||||
LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
|
||||
| ^ one type is more general than the other
|
||||
@ -38,7 +38,7 @@ LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
|
||||
found fn pointer `for<'r> fn(&'r u32)`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expect-fn-supply-fn.rs:48:50
|
||||
--> $DIR/expect-fn-supply-fn.rs:54:50
|
||||
|
|
||||
LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
|
||||
| ^ one type is more general than the other
|
||||
|
@ -1,3 +1,7 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn with_closure_expecting_fn_with_free_region<F>(_: F)
|
||||
where
|
||||
F: for<'a> FnOnce(fn(&'a u32), &i32),
|
||||
@ -14,8 +18,10 @@ fn expect_free_supply_free_from_fn<'x>(x: &'x u32) {
|
||||
// Here, the type given for `'x` "obscures" a region from the
|
||||
// expected signature that is bound at closure level.
|
||||
with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
|
||||
//~^ ERROR mismatched types
|
||||
//~| ERROR mismatched types
|
||||
//[base]~^ ERROR mismatched types
|
||||
//[base]~| ERROR mismatched types
|
||||
//[nll]~^^^ ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn expect_free_supply_free_from_closure() {
|
||||
|
@ -1,22 +1,24 @@
|
||||
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:9
|
||||
|
|
||||
LL | fn foo(x: &()) {
|
||||
| --- this data with an anonymous lifetime `'_`...
|
||||
LL | bar(|| {
|
||||
| _________^
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | let _ = x;
|
||||
LL | | })
|
||||
| |_____^ ...is used here...
|
||||
|
|
||||
note: ...and is required to live as long as `'static` here
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5
|
||||
|
|
||||
LL | bar(|| {
|
||||
| ^^^
|
||||
note: `'static` lifetime requirement introduced by this bound
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:1:39
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:39
|
||||
|
|
||||
LL | fn bar<F>(blk: F) where F: FnOnce() + 'static {
|
||||
| ^^^^^^^
|
@ -1,5 +1,5 @@
|
||||
error[E0521]: borrowed data escapes outside of function
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5
|
||||
|
|
||||
LL | fn foo(x: &()) {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
@ -7,6 +7,8 @@ LL | fn foo(x: &()) {
|
||||
| `x` is a reference that is only valid in the function body
|
||||
LL | / bar(|| {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | let _ = x;
|
||||
LL | | })
|
||||
| | ^
|
||||
@ -15,19 +17,21 @@ LL | | })
|
||||
| argument requires that `'1` must outlive `'static`
|
||||
|
||||
error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:9
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:9
|
||||
|
|
||||
LL | bar(|| {
|
||||
| ^^ may outlive borrowed value `x`
|
||||
LL |
|
||||
...
|
||||
LL | let _ = x;
|
||||
| - `x` is borrowed here
|
||||
|
|
||||
note: function requires argument type to outlive `'static`
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
|
||||
--> $DIR/closure-bounds-static-cant-capture-borrowed.rs:9:5
|
||||
|
|
||||
LL | / bar(|| {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | let _ = x;
|
||||
LL | | })
|
||||
| |______^
|
||||
|
@ -1,9 +1,15 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
fn bar<F>(blk: F) where F: FnOnce() + 'static {
|
||||
}
|
||||
|
||||
fn foo(x: &()) {
|
||||
bar(|| {
|
||||
//~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[nll]~^^ ERROR borrowed data escapes
|
||||
//[nll]~| ERROR closure may outlive
|
||||
let _ = x;
|
||||
})
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expect-region-supply-region-2.rs:14:33
|
||||
--> $DIR/expect-region-supply-region-2.rs:18:33
|
||||
|
|
||||
LL | closure_expecting_bound(|x: &'x u32| {
|
||||
| ^^^^^^^ lifetime mismatch
|
||||
@ -7,7 +7,7 @@ LL | closure_expecting_bound(|x: &'x u32| {
|
||||
= note: expected reference `&u32`
|
||||
found reference `&'x u32`
|
||||
note: the anonymous lifetime #1 defined here...
|
||||
--> $DIR/expect-region-supply-region-2.rs:14:29
|
||||
--> $DIR/expect-region-supply-region-2.rs:18:29
|
||||
|
|
||||
LL | closure_expecting_bound(|x: &'x u32| {
|
||||
| _____________________________^
|
||||
@ -19,13 +19,13 @@ LL | | f = Some(x);
|
||||
LL | | });
|
||||
| |_____^
|
||||
note: ...does not necessarily outlive the lifetime `'x` as defined here
|
||||
--> $DIR/expect-region-supply-region-2.rs:9:30
|
||||
--> $DIR/expect-region-supply-region-2.rs:13:30
|
||||
|
|
||||
LL | fn expect_bound_supply_named<'x>() {
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/expect-region-supply-region-2.rs:14:33
|
||||
--> $DIR/expect-region-supply-region-2.rs:18:33
|
||||
|
|
||||
LL | closure_expecting_bound(|x: &'x u32| {
|
||||
| ^^^^^^^ lifetime mismatch
|
||||
@ -33,12 +33,12 @@ LL | closure_expecting_bound(|x: &'x u32| {
|
||||
= note: expected reference `&u32`
|
||||
found reference `&'x u32`
|
||||
note: the lifetime `'x` as defined here...
|
||||
--> $DIR/expect-region-supply-region-2.rs:9:30
|
||||
--> $DIR/expect-region-supply-region-2.rs:13:30
|
||||
|
|
||||
LL | fn expect_bound_supply_named<'x>() {
|
||||
| ^^
|
||||
note: ...does not necessarily outlive the anonymous lifetime #1 defined here
|
||||
--> $DIR/expect-region-supply-region-2.rs:14:29
|
||||
--> $DIR/expect-region-supply-region-2.rs:18:29
|
||||
|
|
||||
LL | closure_expecting_bound(|x: &'x u32| {
|
||||
| _____________________________^
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/expect-region-supply-region-2.rs:14:30
|
||||
--> $DIR/expect-region-supply-region-2.rs:18:30
|
||||
|
|
||||
LL | fn expect_bound_supply_named<'x>() {
|
||||
| -- lifetime `'x` defined here
|
||||
@ -10,7 +10,7 @@ LL | closure_expecting_bound(|x: &'x u32| {
|
||||
| requires that `'1` must outlive `'x`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/expect-region-supply-region-2.rs:14:30
|
||||
--> $DIR/expect-region-supply-region-2.rs:18:30
|
||||
|
|
||||
LL | fn expect_bound_supply_named<'x>() {
|
||||
| -- lifetime `'x` defined here
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
fn closure_expecting_bound<F>(_: F)
|
||||
@ -12,8 +16,10 @@ fn expect_bound_supply_named<'x>() {
|
||||
// Here we give a type annotation that `x` should be free. We get
|
||||
// an error because of that.
|
||||
closure_expecting_bound(|x: &'x u32| {
|
||||
//~^ ERROR mismatched types
|
||||
//~| ERROR mismatched types
|
||||
//[base]~^ ERROR mismatched types
|
||||
//[base]~| ERROR mismatched types
|
||||
//[nll]~^^^ ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR lifetime may not live long enough
|
||||
|
||||
// Borrowck doesn't get a chance to run, but if it did it should error
|
||||
// here.
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: conflicting implementations of trait `SadBee` for type `for<'a> fn(&'a ())`
|
||||
--> $DIR/invariant.rs:14:1
|
||||
--> $DIR/invariant.rs:18:1
|
||||
|
|
||||
LL | impl SadBee for for<'a> fn(&'a ()) {
|
||||
| ---------------------------------- first implementation here
|
||||
@ -13,7 +13,7 @@ LL | impl SadBee for fn(&'static ()) {
|
||||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/invariant.rs:27:5
|
||||
--> $DIR/invariant.rs:31:5
|
||||
|
|
||||
LL | v
|
||||
| ^ one type is more general than the other
|
@ -1,5 +1,5 @@
|
||||
warning: conflicting implementations of trait `SadBee` for type `for<'a> fn(&'a ())`
|
||||
--> $DIR/invariant.rs:14:1
|
||||
--> $DIR/invariant.rs:18:1
|
||||
|
|
||||
LL | impl SadBee for for<'a> fn(&'a ()) {
|
||||
| ---------------------------------- first implementation here
|
||||
@ -13,7 +13,7 @@ LL | impl SadBee for fn(&'static ()) {
|
||||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/invariant.rs:27:5
|
||||
--> $DIR/invariant.rs:31:5
|
||||
|
|
||||
LL | v
|
||||
| ^ one type is more general than the other
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
#![feature(generic_const_exprs)]
|
||||
#![allow(incomplete_features)]
|
||||
use std::marker::PhantomData;
|
||||
|
@ -1,72 +1,72 @@
|
||||
error[E0490]: a value of type `&'b ()` is borrowed for too long
|
||||
--> $DIR/E0490.rs:2:20
|
||||
--> $DIR/E0490.rs:6:20
|
||||
|
|
||||
LL | let x: &'a _ = &y;
|
||||
| ^^
|
||||
|
|
||||
note: the type is valid for the lifetime `'a` as defined here
|
||||
--> $DIR/E0490.rs:1:6
|
||||
--> $DIR/E0490.rs:5:6
|
||||
|
|
||||
LL | fn f<'a, 'b>(y: &'b ()) {
|
||||
| ^^
|
||||
note: but the borrow lasts for the lifetime `'b` as defined here
|
||||
--> $DIR/E0490.rs:1:10
|
||||
--> $DIR/E0490.rs:5:10
|
||||
|
|
||||
LL | fn f<'a, 'b>(y: &'b ()) {
|
||||
| ^^
|
||||
|
||||
error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
|
||||
--> $DIR/E0490.rs:2:20
|
||||
--> $DIR/E0490.rs:6:20
|
||||
|
|
||||
LL | let x: &'a _ = &y;
|
||||
| ^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'b` as defined here...
|
||||
--> $DIR/E0490.rs:1:10
|
||||
--> $DIR/E0490.rs:5:10
|
||||
|
|
||||
LL | fn f<'a, 'b>(y: &'b ()) {
|
||||
| ^^
|
||||
note: ...so that the type `&'b ()` is not borrowed for too long
|
||||
--> $DIR/E0490.rs:2:20
|
||||
--> $DIR/E0490.rs:6:20
|
||||
|
|
||||
LL | let x: &'a _ = &y;
|
||||
| ^^
|
||||
note: but, the lifetime must be valid for the lifetime `'a` as defined here...
|
||||
--> $DIR/E0490.rs:1:6
|
||||
--> $DIR/E0490.rs:5:6
|
||||
|
|
||||
LL | fn f<'a, 'b>(y: &'b ()) {
|
||||
| ^^
|
||||
note: ...so that reference does not outlive borrowed content
|
||||
--> $DIR/E0490.rs:2:20
|
||||
--> $DIR/E0490.rs:6:20
|
||||
|
|
||||
LL | let x: &'a _ = &y;
|
||||
| ^^
|
||||
|
||||
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
|
||||
--> $DIR/E0490.rs:2:20
|
||||
--> $DIR/E0490.rs:6:20
|
||||
|
|
||||
LL | let x: &'a _ = &y;
|
||||
| ^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'b` as defined here...
|
||||
--> $DIR/E0490.rs:1:10
|
||||
--> $DIR/E0490.rs:5:10
|
||||
|
|
||||
LL | fn f<'a, 'b>(y: &'b ()) {
|
||||
| ^^
|
||||
note: ...so that the expression is assignable
|
||||
--> $DIR/E0490.rs:2:20
|
||||
--> $DIR/E0490.rs:6:20
|
||||
|
|
||||
LL | let x: &'a _ = &y;
|
||||
| ^^
|
||||
= note: expected `&'a &()`
|
||||
found `&'a &'b ()`
|
||||
note: but, the lifetime must be valid for the lifetime `'a` as defined here...
|
||||
--> $DIR/E0490.rs:1:6
|
||||
--> $DIR/E0490.rs:5:6
|
||||
|
|
||||
LL | fn f<'a, 'b>(y: &'b ()) {
|
||||
| ^^
|
||||
note: ...so that the reference type `&'a &()` does not outlive the data it points at
|
||||
--> $DIR/E0490.rs:2:12
|
||||
--> $DIR/E0490.rs:6:12
|
||||
|
|
||||
LL | let x: &'a _ = &y;
|
||||
| ^^^^^
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/E0490.rs:2:12
|
||||
--> $DIR/E0490.rs:6:12
|
||||
|
|
||||
LL | fn f<'a, 'b>(y: &'b ()) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
@ -11,7 +11,7 @@ LL | let x: &'a _ = &y;
|
||||
= help: consider adding the following bound: `'b: 'a`
|
||||
|
||||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/E0490.rs:2:20
|
||||
--> $DIR/E0490.rs:6:20
|
||||
|
|
||||
LL | fn f<'a, 'b>(y: &'b ()) {
|
||||
| -- lifetime `'a` defined here
|
||||
|
@ -1,8 +1,14 @@
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn f<'a, 'b>(y: &'b ()) {
|
||||
let x: &'a _ = &y;
|
||||
//~^ E0490
|
||||
//~| E0495
|
||||
//~| E0495
|
||||
//[base]~^ E0490
|
||||
//[base]~| E0495
|
||||
//[base]~| E0495
|
||||
//[nll]~^^^^ lifetime may not live long enough
|
||||
//[nll]~| E0597
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/implied-bounds-unnorm-associated-type.rs:14:5
|
||||
--> $DIR/implied-bounds-unnorm-associated-type.rs:18:5
|
||||
|
|
||||
LL | fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str {
|
||||
| ------- ----------
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/implied-bounds-unnorm-associated-type.rs:14:5
|
||||
--> $DIR/implied-bounds-unnorm-associated-type.rs:18:5
|
||||
|
|
||||
LL | fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
// check-fail
|
||||
// See issue #91068. Types in the substs of an associated type can't be implied
|
||||
// to be WF, since they don't actually have to be constructed.
|
||||
@ -11,7 +15,9 @@ impl<T> Trait for T {
|
||||
}
|
||||
|
||||
fn f<'a, 'b>(s: &'b str, _: <&'a &'b () as Trait>::Type) -> &'a str {
|
||||
s //~ ERROR lifetime mismatch [E0623]
|
||||
s
|
||||
//[base]~^ ERROR lifetime mismatch [E0623]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: implementation of `Foo` is not general enough
|
||||
--> $DIR/auto-trait-regions.rs:31:5
|
||||
--> $DIR/auto-trait-regions.rs:35:5
|
||||
|
|
||||
LL | assert_foo(gen);
|
||||
| ^^^^^^^^^^ implementation of `Foo` is not general enough
|
||||
@ -8,7 +8,7 @@ LL | assert_foo(gen);
|
||||
= note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef`
|
||||
|
||||
error: implementation of `Foo` is not general enough
|
||||
--> $DIR/auto-trait-regions.rs:31:5
|
||||
--> $DIR/auto-trait-regions.rs:35:5
|
||||
|
|
||||
LL | assert_foo(gen);
|
||||
| ^^^^^^^^^^ implementation of `Foo` is not general enough
|
||||
@ -17,7 +17,7 @@ LL | assert_foo(gen);
|
||||
= note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef`
|
||||
|
||||
error: implementation of `Foo` is not general enough
|
||||
--> $DIR/auto-trait-regions.rs:50:5
|
||||
--> $DIR/auto-trait-regions.rs:56:5
|
||||
|
|
||||
LL | assert_foo(gen);
|
||||
| ^^^^^^^^^^ implementation of `Foo` is not general enough
|
||||
@ -26,7 +26,7 @@ LL | assert_foo(gen);
|
||||
= note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2`
|
||||
|
||||
error: implementation of `Foo` is not general enough
|
||||
--> $DIR/auto-trait-regions.rs:50:5
|
||||
--> $DIR/auto-trait-regions.rs:56:5
|
||||
|
|
||||
LL | assert_foo(gen);
|
||||
| ^^^^^^^^^^ implementation of `Foo` is not general enough
|
@ -1,31 +1,31 @@
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/auto-trait-regions.rs:46:24
|
||||
--> $DIR/auto-trait-regions.rs:50:24
|
||||
|
|
||||
LL | let a = A(&mut true, &mut true, No);
|
||||
| ^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| creates a temporary which is freed while still in use
|
||||
LL | yield;
|
||||
...
|
||||
LL | assert_foo(a);
|
||||
| - borrow later used here
|
||||
|
|
||||
= note: consider using a `let` binding to create a longer lived value
|
||||
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/auto-trait-regions.rs:46:35
|
||||
--> $DIR/auto-trait-regions.rs:50:35
|
||||
|
|
||||
LL | let a = A(&mut true, &mut true, No);
|
||||
| ^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| creates a temporary which is freed while still in use
|
||||
LL | yield;
|
||||
...
|
||||
LL | assert_foo(a);
|
||||
| - borrow later used here
|
||||
|
|
||||
= note: consider using a `let` binding to create a longer lived value
|
||||
|
||||
error: implementation of `Foo` is not general enough
|
||||
--> $DIR/auto-trait-regions.rs:31:5
|
||||
--> $DIR/auto-trait-regions.rs:35:5
|
||||
|
|
||||
LL | assert_foo(gen);
|
||||
| ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
||||
@ -34,7 +34,7 @@ LL | assert_foo(gen);
|
||||
= note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef`
|
||||
|
||||
error: implementation of `Foo` is not general enough
|
||||
--> $DIR/auto-trait-regions.rs:50:5
|
||||
--> $DIR/auto-trait-regions.rs:56:5
|
||||
|
|
||||
LL | assert_foo(gen);
|
||||
| ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
#![feature(generators)]
|
||||
#![feature(auto_traits)]
|
||||
#![feature(negative_impls)]
|
||||
@ -30,7 +34,7 @@ fn main() {
|
||||
};
|
||||
assert_foo(gen);
|
||||
//~^ ERROR implementation of `Foo` is not general enough
|
||||
//~| ERROR implementation of `Foo` is not general enough
|
||||
//[base]~^^ ERROR implementation of `Foo` is not general enough
|
||||
|
||||
// Allow impls which matches any lifetime
|
||||
let x = &OnlyFooIfRef(No);
|
||||
@ -44,10 +48,12 @@ fn main() {
|
||||
// Disallow impls which relates lifetimes in the generator interior
|
||||
let gen = || {
|
||||
let a = A(&mut true, &mut true, No);
|
||||
//[nll]~^ temporary value dropped while borrowed
|
||||
//[nll]~| temporary value dropped while borrowed
|
||||
yield;
|
||||
assert_foo(a);
|
||||
};
|
||||
assert_foo(gen);
|
||||
//~^ ERROR not general enough
|
||||
//~| ERROR not general enough
|
||||
//[base]~^^ ERROR not general enough
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/generator-region-requirements.rs:8:9
|
||||
--> $DIR/generator-region-requirements.rs:12:9
|
||||
|
|
||||
LL | fn dangle(x: &mut i32) -> &'static mut i32 {
|
||||
| -------- this data with an anonymous lifetime `'_`...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/generator-region-requirements.rs:13:51
|
||||
--> $DIR/generator-region-requirements.rs:17:51
|
||||
|
|
||||
LL | fn dangle(x: &mut i32) -> &'static mut i32 {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
#![feature(generators, generator_trait)]
|
||||
use std::ops::{Generator, GeneratorState};
|
||||
use std::pin::Pin;
|
||||
@ -6,11 +10,12 @@ fn dangle(x: &mut i32) -> &'static mut i32 {
|
||||
let mut g = || {
|
||||
yield;
|
||||
x
|
||||
//~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
};
|
||||
loop {
|
||||
match Pin::new(&mut g).resume(()) {
|
||||
GeneratorState::Complete(c) => return c,
|
||||
//[nll]~^ ERROR lifetime may not live long enough
|
||||
GeneratorState::Yielded(_) => (),
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/resume-arg-late-bound.rs:15:5
|
||||
--> $DIR/resume-arg-late-bound.rs:19:5
|
||||
|
|
||||
LL | test(gen);
|
||||
| ^^^^ lifetime mismatch
|
||||
@ -7,7 +7,7 @@ LL | test(gen);
|
||||
= note: expected type `for<'a> Generator<&'a mut bool>`
|
||||
found type `Generator<&mut bool>`
|
||||
note: the required lifetime does not necessarily outlive the anonymous lifetime #1 defined here
|
||||
--> $DIR/resume-arg-late-bound.rs:11:15
|
||||
--> $DIR/resume-arg-late-bound.rs:15:15
|
||||
|
|
||||
LL | let gen = |arg: &mut bool| {
|
||||
| _______________^
|
||||
@ -16,13 +16,13 @@ LL | | *arg = true;
|
||||
LL | | };
|
||||
| |_____^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/resume-arg-late-bound.rs:8:17
|
||||
--> $DIR/resume-arg-late-bound.rs:12:17
|
||||
|
|
||||
LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/resume-arg-late-bound.rs:15:5
|
||||
--> $DIR/resume-arg-late-bound.rs:19:5
|
||||
|
|
||||
LL | test(gen);
|
||||
| ^^^^ lifetime mismatch
|
||||
@ -30,7 +30,7 @@ LL | test(gen);
|
||||
= note: expected type `for<'a> Generator<&'a mut bool>`
|
||||
found type `Generator<&mut bool>`
|
||||
note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements
|
||||
--> $DIR/resume-arg-late-bound.rs:11:15
|
||||
--> $DIR/resume-arg-late-bound.rs:15:15
|
||||
|
|
||||
LL | let gen = |arg: &mut bool| {
|
||||
| _______________^
|
||||
@ -39,7 +39,7 @@ LL | | *arg = true;
|
||||
LL | | };
|
||||
| |_____^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/resume-arg-late-bound.rs:8:17
|
||||
--> $DIR/resume-arg-late-bound.rs:12:17
|
||||
|
|
||||
LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/resume-arg-late-bound.rs:15:5
|
||||
--> $DIR/resume-arg-late-bound.rs:19:5
|
||||
|
|
||||
LL | test(gen);
|
||||
| ^^^^^^^^^ one type is more general than the other
|
||||
@ -7,7 +7,7 @@ LL | test(gen);
|
||||
= note: expected type `for<'a> Generator<&'a mut bool>`
|
||||
found type `Generator<&mut bool>`
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/resume-arg-late-bound.rs:8:17
|
||||
--> $DIR/resume-arg-late-bound.rs:12:17
|
||||
|
|
||||
LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
//! Tests that we cannot produce a generator that accepts a resume argument
|
||||
//! with any lifetime and then stores it across a `yield`.
|
||||
|
||||
@ -14,5 +18,5 @@ fn main() {
|
||||
};
|
||||
test(gen);
|
||||
//~^ ERROR mismatched types
|
||||
//~| ERROR mismatched types
|
||||
//[base]~^^ ERROR mismatched types
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
error[E0276]: impl has stricter requirements than trait
|
||||
--> $DIR/lending_iterator.rs:14:45
|
||||
|
|
||||
LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self;
|
||||
| ------------------------------------------------------------------------ definition of `from_iter` from trait
|
||||
...
|
||||
LL | fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) -> Self {
|
||||
| ^^^^^^^^^^^^ impl has extra requirement `I: 'x`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0276`.
|
@ -1,5 +1,5 @@
|
||||
error[E0276]: impl has stricter requirements than trait
|
||||
--> $DIR/lending_iterator.rs:14:45
|
||||
--> $DIR/lending_iterator.rs:16:45
|
||||
|
|
||||
LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self;
|
||||
| ------------------------------------------------------------------------ definition of `from_iter` from trait
|
||||
@ -8,7 +8,7 @@ LL | fn from_iter<I: for<'x> LendingIterator<Item<'x> = A>>(mut iter: I) ->
|
||||
| ^^^^^^^^^^^^ impl has extra requirement `I: 'x`
|
||||
|
||||
error[E0311]: the parameter type `Self` may not live long enough
|
||||
--> $DIR/lending_iterator.rs:35:9
|
||||
--> $DIR/lending_iterator.rs:37:9
|
||||
|
|
||||
LL | <B as FromLendingIterator<A>>::from_iter(self)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -16,7 +16,7 @@ LL | <B as FromLendingIterator<A>>::from_iter(self)
|
||||
= help: consider adding an explicit lifetime bound `Self: 'a`...
|
||||
= note: ...so that the type `Self` will meet its required lifetime bounds...
|
||||
note: ...that is required by this bound
|
||||
--> $DIR/lending_iterator.rs:10:45
|
||||
--> $DIR/lending_iterator.rs:12:45
|
||||
|
|
||||
LL | fn from_iter<T: for<'x> LendingIterator<Item<'x> = A>>(iter: T) -> Self;
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -1,3 +1,5 @@
|
||||
// FIXME(nll): this is experimental anyways, don't really care about the output
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base extended
|
||||
//[base] check-fail
|
||||
//[extended] check-pass
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:17:7
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:21:7
|
||||
|
|
||||
LL | fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &'static () {
|
||||
| ------------------------------- this data with an anonymous lifetime `'_`...
|
||||
@ -9,7 +9,7 @@ LL | x.m()
|
||||
| ...is used and required to live as long as `'static` here
|
||||
|
||||
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:22:7
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:27:7
|
||||
|
|
||||
LL | fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () {
|
||||
| -- this data with an anonymous lifetime `'_`...
|
||||
@ -19,7 +19,7 @@ LL | x.m()
|
||||
| ...is used and required to live as long as `'static` here
|
||||
|
||||
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:27:7
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:33:7
|
||||
|
|
||||
LL | fn h(x: &()) -> &'static () {
|
||||
| --- this data with an anonymous lifetime `'_`...
|
@ -1,5 +1,5 @@
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:17:5
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:21:5
|
||||
|
|
||||
LL | fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &'static () {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
@ -7,7 +7,7 @@ LL | x.m()
|
||||
| ^^^^^ returning this value requires that `'1` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:22:5
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:27:5
|
||||
|
|
||||
LL | fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
@ -15,7 +15,7 @@ LL | x.m()
|
||||
| ^^^^^ returning this value requires that `'1` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:27:5
|
||||
--> $DIR/projection-type-lifetime-mismatch.rs:33:5
|
||||
|
|
||||
LL | fn h(x: &()) -> &'static () {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
|
@ -1,3 +1,7 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
||||
pub trait X {
|
||||
@ -15,17 +19,20 @@ impl X for () {
|
||||
|
||||
fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &'static () {
|
||||
x.m()
|
||||
//~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () {
|
||||
x.m()
|
||||
//~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn h(x: &()) -> &'static () {
|
||||
x.m()
|
||||
//~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[base]~^ ERROR `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement [E0759]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0038]: the trait `StreamingIterator` cannot be made into an object
|
||||
--> $DIR/trait-objects.rs:14:21
|
||||
--> $DIR/trait-objects.rs:16:21
|
||||
|
|
||||
LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `StreamingIterator` cannot be made into an object
|
||||
|
|
||||
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
|
||||
--> $DIR/trait-objects.rs:8:10
|
||||
--> $DIR/trait-objects.rs:10:10
|
||||
|
|
||||
LL | trait StreamingIterator {
|
||||
| ----------------- this trait cannot be made into an object...
|
||||
|
@ -1,17 +0,0 @@
|
||||
error[E0521]: borrowed data escapes outside of function
|
||||
--> $DIR/trait-objects.rs:16:5
|
||||
|
|
||||
LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
|
||||
| - - let's call the lifetime of this reference `'1`
|
||||
| |
|
||||
| `x` is a reference that is only valid in the function body
|
||||
LL |
|
||||
LL | x.size_hint().0
|
||||
| ^^^^^^^^^^^^^
|
||||
| |
|
||||
| `x` escapes the function body here
|
||||
| argument requires that `'1` must outlive `'static`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0521`.
|
@ -1,5 +1,5 @@
|
||||
error[E0621]: explicit lifetime required in the type of `x`
|
||||
--> $DIR/trait-objects.rs:16:7
|
||||
--> $DIR/trait-objects.rs:18:7
|
||||
|
|
||||
LL | fn min_size(x: &mut dyn for<'a> StreamingIterator<Item<'a> = &'a i32>) -> usize {
|
||||
| ------------------------------------------------------ help: add explicit lifetime `'a` to the type of `x`: `&'a mut (dyn StreamingIterator<for<'a> Item = &'a i32> + 'a)`
|
||||
|
@ -1,3 +1,5 @@
|
||||
// FIXME(nll): this is experimental anyways, don't really care about the output
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: base extended
|
||||
|
||||
#![feature(generic_associated_types)]
|
||||
|
@ -1,11 +1,11 @@
|
||||
error[E0477]: the type `&'a V` does not fulfill the required lifetime
|
||||
--> $DIR/issue-59311.rs:17:5
|
||||
--> $DIR/issue-59311.rs:21:5
|
||||
|
|
||||
LL | v.t(|| {});
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: type must satisfy the static lifetime as required by this binding
|
||||
--> $DIR/issue-59311.rs:15:24
|
||||
--> $DIR/issue-59311.rs:19:24
|
||||
|
|
||||
LL | for<'a> &'a V: T + 'static,
|
||||
| ^^^^^^^
|
@ -1,13 +1,13 @@
|
||||
error: higher-ranked lifetime error
|
||||
--> $DIR/issue-59311.rs:17:5
|
||||
--> $DIR/issue-59311.rs:21:5
|
||||
|
|
||||
LL | v.t(|| {});
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: could not prove [closure@$DIR/issue-59311.rs:17:9: 17:14] well-formed
|
||||
= note: could not prove [closure@$DIR/issue-59311.rs:21:9: 21:14] well-formed
|
||||
|
||||
error: higher-ranked lifetime error
|
||||
--> $DIR/issue-59311.rs:17:9
|
||||
--> $DIR/issue-59311.rs:21:9
|
||||
|
|
||||
LL | v.t(|| {});
|
||||
| ^^^^^
|
||||
|
@ -6,6 +6,10 @@
|
||||
// an error, but the regression test is here to ensure
|
||||
// that it does not ICE. See discussion on #74889 for details.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
pub trait T {
|
||||
fn t<F: Fn()>(&self, _: F) {}
|
||||
}
|
||||
@ -14,7 +18,10 @@ pub fn crash<V>(v: &V)
|
||||
where
|
||||
for<'a> &'a V: T + 'static,
|
||||
{
|
||||
v.t(|| {}); //~ ERROR: `&'a V` does not fulfill the required lifetime
|
||||
v.t(|| {});
|
||||
//[base]~^ ERROR: `&'a V` does not fulfill the required lifetime
|
||||
//[nll]~^^ ERROR: higher-ranked lifetime error
|
||||
//[nll]~| ERROR: higher-ranked lifetime error
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -0,0 +1,20 @@
|
||||
error: implementation of `Parser` is not general enough
|
||||
--> $DIR/issue-71955.rs:49:5
|
||||
|
|
||||
LL | foo(bar, "string", |s| s.len() == 5);
|
||||
| ^^^ implementation of `Parser` is not general enough
|
||||
|
|
||||
= note: `for<'a> fn(&'a str) -> (&'a str, &'a str) {bar}` must implement `Parser<'0>`, for any lifetime `'0`...
|
||||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1`
|
||||
|
||||
error: implementation of `Parser` is not general enough
|
||||
--> $DIR/issue-71955.rs:53:5
|
||||
|
|
||||
LL | foo(baz, "string", |s| s.0.len() == 5);
|
||||
| ^^^ implementation of `Parser` is not general enough
|
||||
|
|
||||
= note: `for<'a> fn(&'a str) -> (&'a str, Wrapper<'a>) {baz}` must implement `Parser<'0>`, for any lifetime `'0`...
|
||||
= note: ...but it actually implements `Parser<'1>`, for some specific lifetime `'1`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-71955.rs:54:5
|
||||
--> $DIR/issue-71955.rs:49:5
|
||||
|
|
||||
LL | foo(bar, "string", |s| s.len() == 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
@ -7,18 +7,18 @@ LL | foo(bar, "string", |s| s.len() == 5);
|
||||
= note: expected type `for<'r, 's> FnOnce<(&'r &'s str,)>`
|
||||
found type `for<'r> FnOnce<(&'r &str,)>`
|
||||
note: this closure does not fulfill the lifetime requirements
|
||||
--> $DIR/issue-71955.rs:54:24
|
||||
--> $DIR/issue-71955.rs:49:24
|
||||
|
|
||||
LL | foo(bar, "string", |s| s.len() == 5);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-71955.rs:34:9
|
||||
--> $DIR/issue-71955.rs:29:9
|
||||
|
|
||||
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-71955.rs:54:5
|
||||
--> $DIR/issue-71955.rs:49:5
|
||||
|
|
||||
LL | foo(bar, "string", |s| s.len() == 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
@ -26,18 +26,18 @@ LL | foo(bar, "string", |s| s.len() == 5);
|
||||
= note: expected type `FnOnce<(&&str,)>`
|
||||
found type `for<'r> FnOnce<(&'r &str,)>`
|
||||
note: this closure does not fulfill the lifetime requirements
|
||||
--> $DIR/issue-71955.rs:54:24
|
||||
--> $DIR/issue-71955.rs:49:24
|
||||
|
|
||||
LL | foo(bar, "string", |s| s.len() == 5);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-71955.rs:34:44
|
||||
--> $DIR/issue-71955.rs:29:44
|
||||
|
|
||||
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool
|
||||
| ^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-71955.rs:58:5
|
||||
--> $DIR/issue-71955.rs:53:5
|
||||
|
|
||||
LL | foo(baz, "string", |s| s.0.len() == 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
@ -45,18 +45,18 @@ LL | foo(baz, "string", |s| s.0.len() == 5);
|
||||
= note: expected type `for<'r, 's> FnOnce<(&'r Wrapper<'s>,)>`
|
||||
found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
|
||||
note: this closure does not fulfill the lifetime requirements
|
||||
--> $DIR/issue-71955.rs:58:24
|
||||
--> $DIR/issue-71955.rs:53:24
|
||||
|
|
||||
LL | foo(baz, "string", |s| s.0.len() == 5);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-71955.rs:34:9
|
||||
--> $DIR/issue-71955.rs:29:9
|
||||
|
|
||||
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-71955.rs:58:5
|
||||
--> $DIR/issue-71955.rs:53:5
|
||||
|
|
||||
LL | foo(baz, "string", |s| s.0.len() == 5);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
@ -64,12 +64,12 @@ LL | foo(baz, "string", |s| s.0.len() == 5);
|
||||
= note: expected type `FnOnce<(&Wrapper<'_>,)>`
|
||||
found type `for<'r> FnOnce<(&'r Wrapper<'_>,)>`
|
||||
note: this closure does not fulfill the lifetime requirements
|
||||
--> $DIR/issue-71955.rs:58:24
|
||||
--> $DIR/issue-71955.rs:53:24
|
||||
|
|
||||
LL | foo(baz, "string", |s| s.0.len() == 5);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
note: the lifetime requirement is introduced here
|
||||
--> $DIR/issue-71955.rs:34:44
|
||||
--> $DIR/issue-71955.rs:29:44
|
||||
|
|
||||
LL | F2: FnOnce(&<F1 as Parser>::Output) -> bool
|
||||
| ^^^^
|
||||
|
@ -1,13 +1,8 @@
|
||||
// ignore-compare-mode-nll
|
||||
// revisions: migrate nll
|
||||
// revisions: base nll
|
||||
// [nll]compile-flags: -Zborrowck=mir
|
||||
|
||||
// check-fail
|
||||
|
||||
// Since we are testing nll (and migration) explicitly as a separate
|
||||
// revisions, don't worry about the --compare-mode=nll on this test.
|
||||
|
||||
// ignore-compare-mode-nll
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
trait Parser<'s> {
|
||||
@ -52,11 +47,11 @@ fn main() {
|
||||
}
|
||||
|
||||
foo(bar, "string", |s| s.len() == 5);
|
||||
//[migrate]~^ ERROR implementation of `Parser` is not general enough
|
||||
//[base]~^ ERROR implementation of `Parser` is not general enough
|
||||
//[nll]~^^ ERROR mismatched types
|
||||
//[nll]~| ERROR mismatched types
|
||||
foo(baz, "string", |s| s.0.len() == 5);
|
||||
//[migrate]~^ ERROR implementation of `Parser` is not general enough
|
||||
//[base]~^ ERROR implementation of `Parser` is not general enough
|
||||
//[nll]~^^ ERROR mismatched types
|
||||
//[nll]~| ERROR mismatched types
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/hr-subtype.rs:45:13
|
||||
--> $DIR/hr-subtype-nll.rs:60:13
|
||||
|
|
||||
LL | gimme::<$t1>(None::<$t2>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user