Use revisions or ignore-compare-mode-nll for NLL in generic-associated-types

This commit is contained in:
Jack Huey 2022-05-21 15:33:42 -04:00
parent 62806f7536
commit 0fbb315be7
10 changed files with 26 additions and 44 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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() {

View file

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

View file

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

View file

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

View file

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