Use revisions for NLL in generator

This commit is contained in:
Jack Huey 2022-05-21 15:26:58 -04:00
parent 12a2d7967c
commit 62806f7536
9 changed files with 39 additions and 24 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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(_) => (),
}
}

View File

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

View File

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

View File

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