Use revisions for NLL in generator
This commit is contained in:
parent
12a2d7967c
commit
62806f7536
@ -1,5 +1,5 @@
|
|||||||
error: implementation of `Foo` is not general enough
|
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);
|
LL | assert_foo(gen);
|
||||||
| ^^^^^^^^^^ implementation of `Foo` is not general enough
|
| ^^^^^^^^^^ 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`
|
= note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef`
|
||||||
|
|
||||||
error: implementation of `Foo` is not general enough
|
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);
|
LL | assert_foo(gen);
|
||||||
| ^^^^^^^^^^ implementation of `Foo` is not general enough
|
| ^^^^^^^^^^ 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`
|
= note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef`
|
||||||
|
|
||||||
error: implementation of `Foo` is not general enough
|
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);
|
LL | assert_foo(gen);
|
||||||
| ^^^^^^^^^^ implementation of `Foo` is not general enough
|
| ^^^^^^^^^^ 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`
|
= note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2`
|
||||||
|
|
||||||
error: implementation of `Foo` is not general enough
|
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);
|
LL | assert_foo(gen);
|
||||||
| ^^^^^^^^^^ implementation of `Foo` is not general enough
|
| ^^^^^^^^^^ implementation of `Foo` is not general enough
|
@ -1,31 +1,31 @@
|
|||||||
error[E0716]: temporary value dropped while borrowed
|
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);
|
LL | let a = A(&mut true, &mut true, No);
|
||||||
| ^^^^ - temporary value is freed at the end of this statement
|
| ^^^^ - temporary value is freed at the end of this statement
|
||||||
| |
|
| |
|
||||||
| creates a temporary which is freed while still in use
|
| creates a temporary which is freed while still in use
|
||||||
LL | yield;
|
...
|
||||||
LL | assert_foo(a);
|
LL | assert_foo(a);
|
||||||
| - borrow later used here
|
| - borrow later used here
|
||||||
|
|
|
|
||||||
= note: consider using a `let` binding to create a longer lived value
|
= note: consider using a `let` binding to create a longer lived value
|
||||||
|
|
||||||
error[E0716]: temporary value dropped while borrowed
|
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);
|
LL | let a = A(&mut true, &mut true, No);
|
||||||
| ^^^^ - temporary value is freed at the end of this statement
|
| ^^^^ - temporary value is freed at the end of this statement
|
||||||
| |
|
| |
|
||||||
| creates a temporary which is freed while still in use
|
| creates a temporary which is freed while still in use
|
||||||
LL | yield;
|
...
|
||||||
LL | assert_foo(a);
|
LL | assert_foo(a);
|
||||||
| - borrow later used here
|
| - borrow later used here
|
||||||
|
|
|
|
||||||
= note: consider using a `let` binding to create a longer lived value
|
= note: consider using a `let` binding to create a longer lived value
|
||||||
|
|
||||||
error: implementation of `Foo` is not general enough
|
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);
|
LL | assert_foo(gen);
|
||||||
| ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
| ^^^^^^^^^^^^^^^ 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`
|
= note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef`
|
||||||
|
|
||||||
error: implementation of `Foo` is not general enough
|
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);
|
LL | assert_foo(gen);
|
||||||
| ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough
|
| ^^^^^^^^^^^^^^^ 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(generators)]
|
||||||
#![feature(auto_traits)]
|
#![feature(auto_traits)]
|
||||||
#![feature(negative_impls)]
|
#![feature(negative_impls)]
|
||||||
@ -30,7 +34,7 @@ fn main() {
|
|||||||
};
|
};
|
||||||
assert_foo(gen);
|
assert_foo(gen);
|
||||||
//~^ ERROR implementation of `Foo` is not general enough
|
//~^ 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
|
// Allow impls which matches any lifetime
|
||||||
let x = &OnlyFooIfRef(No);
|
let x = &OnlyFooIfRef(No);
|
||||||
@ -44,10 +48,12 @@ fn main() {
|
|||||||
// Disallow impls which relates lifetimes in the generator interior
|
// Disallow impls which relates lifetimes in the generator interior
|
||||||
let gen = || {
|
let gen = || {
|
||||||
let a = A(&mut true, &mut true, No);
|
let a = A(&mut true, &mut true, No);
|
||||||
|
//[nll]~^ temporary value dropped while borrowed
|
||||||
|
//[nll]~| temporary value dropped while borrowed
|
||||||
yield;
|
yield;
|
||||||
assert_foo(a);
|
assert_foo(a);
|
||||||
};
|
};
|
||||||
assert_foo(gen);
|
assert_foo(gen);
|
||||||
//~^ ERROR not general enough
|
//~^ 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
|
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 {
|
LL | fn dangle(x: &mut i32) -> &'static mut i32 {
|
||||||
| -------- this data with an anonymous lifetime `'_`...
|
| -------- this data with an anonymous lifetime `'_`...
|
@ -1,5 +1,5 @@
|
|||||||
error: lifetime may not live long enough
|
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 {
|
LL | fn dangle(x: &mut i32) -> &'static mut i32 {
|
||||||
| - let's call the lifetime of this reference `'1`
|
| - 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)]
|
#![feature(generators, generator_trait)]
|
||||||
use std::ops::{Generator, GeneratorState};
|
use std::ops::{Generator, GeneratorState};
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
@ -6,11 +10,12 @@ fn dangle(x: &mut i32) -> &'static mut i32 {
|
|||||||
let mut g = || {
|
let mut g = || {
|
||||||
yield;
|
yield;
|
||||||
x
|
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 {
|
loop {
|
||||||
match Pin::new(&mut g).resume(()) {
|
match Pin::new(&mut g).resume(()) {
|
||||||
GeneratorState::Complete(c) => return c,
|
GeneratorState::Complete(c) => return c,
|
||||||
|
//[nll]~^ ERROR lifetime may not live long enough
|
||||||
GeneratorState::Yielded(_) => (),
|
GeneratorState::Yielded(_) => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/resume-arg-late-bound.rs:15:5
|
--> $DIR/resume-arg-late-bound.rs:19:5
|
||||||
|
|
|
|
||||||
LL | test(gen);
|
LL | test(gen);
|
||||||
| ^^^^ lifetime mismatch
|
| ^^^^ lifetime mismatch
|
||||||
@ -7,7 +7,7 @@ LL | test(gen);
|
|||||||
= note: expected type `for<'a> Generator<&'a mut bool>`
|
= note: expected type `for<'a> Generator<&'a mut bool>`
|
||||||
found type `Generator<&mut bool>`
|
found type `Generator<&mut bool>`
|
||||||
note: the required lifetime does not necessarily outlive the anonymous lifetime #1 defined here
|
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| {
|
LL | let gen = |arg: &mut bool| {
|
||||||
| _______________^
|
| _______________^
|
||||||
@ -16,13 +16,13 @@ LL | | *arg = true;
|
|||||||
LL | | };
|
LL | | };
|
||||||
| |_____^
|
| |_____^
|
||||||
note: the lifetime requirement is introduced here
|
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>) {}
|
LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/resume-arg-late-bound.rs:15:5
|
--> $DIR/resume-arg-late-bound.rs:19:5
|
||||||
|
|
|
|
||||||
LL | test(gen);
|
LL | test(gen);
|
||||||
| ^^^^ lifetime mismatch
|
| ^^^^ lifetime mismatch
|
||||||
@ -30,7 +30,7 @@ LL | test(gen);
|
|||||||
= note: expected type `for<'a> Generator<&'a mut bool>`
|
= note: expected type `for<'a> Generator<&'a mut bool>`
|
||||||
found type `Generator<&mut bool>`
|
found type `Generator<&mut bool>`
|
||||||
note: the anonymous lifetime #1 defined here doesn't meet the lifetime requirements
|
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| {
|
LL | let gen = |arg: &mut bool| {
|
||||||
| _______________^
|
| _______________^
|
||||||
@ -39,7 +39,7 @@ LL | | *arg = true;
|
|||||||
LL | | };
|
LL | | };
|
||||||
| |_____^
|
| |_____^
|
||||||
note: the lifetime requirement is introduced here
|
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>) {}
|
LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {}
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
@ -1,5 +1,5 @@
|
|||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/resume-arg-late-bound.rs:15:5
|
--> $DIR/resume-arg-late-bound.rs:19:5
|
||||||
|
|
|
|
||||||
LL | test(gen);
|
LL | test(gen);
|
||||||
| ^^^^^^^^^ one type is more general than the other
|
| ^^^^^^^^^ one type is more general than the other
|
||||||
@ -7,7 +7,7 @@ LL | test(gen);
|
|||||||
= note: expected type `for<'a> Generator<&'a mut bool>`
|
= note: expected type `for<'a> Generator<&'a mut bool>`
|
||||||
found type `Generator<&mut bool>`
|
found type `Generator<&mut bool>`
|
||||||
note: the lifetime requirement is introduced here
|
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>) {}
|
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
|
//! Tests that we cannot produce a generator that accepts a resume argument
|
||||||
//! with any lifetime and then stores it across a `yield`.
|
//! with any lifetime and then stores it across a `yield`.
|
||||||
|
|
||||||
@ -14,5 +18,5 @@ fn main() {
|
|||||||
};
|
};
|
||||||
test(gen);
|
test(gen);
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
//~| ERROR mismatched types
|
//[base]~^^ ERROR mismatched types
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user