Skip to content

Commit

Permalink
Use revisions for NLL in issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jackh726 committed May 22, 2022
1 parent b7c192e commit b391b32
Show file tree
Hide file tree
Showing 48 changed files with 159 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/issue-10291.rs:3:9
--> $DIR/issue-10291.rs:7:9
|
LL | x
| ^
|
note: ...the reference is valid for the anonymous lifetime #1 defined here...
--> $DIR/issue-10291.rs:2:69
--> $DIR/issue-10291.rs:6:69
|
LL | drop::<Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
| _____________________________________________________________________^
LL | | x
LL | |
LL | |
LL | | }));
| |_____^
note: ...but the borrowed content is only valid for the lifetime `'x` as defined here
--> $DIR/issue-10291.rs:1:9
--> $DIR/issue-10291.rs:5:9
|
LL | fn test<'x>(x: &'x isize) {
| ^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-10291.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-10291.rs:3:9
--> $DIR/issue-10291.rs:7:9
|
LL | fn test<'x>(x: &'x isize) {
| -- lifetime `'x` defined here
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/issues/issue-10291.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

fn test<'x>(x: &'x isize) {
drop::<Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
x //~ ERROR E0312
x
//[base]~^ ERROR E0312
//[nll]~^^ ERROR lifetime may not live long enough
}));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0621]: explicit lifetime required in the type of `cont`
--> $DIR/issue-13058.rs:14:26
--> $DIR/issue-13058.rs:18:26
|
LL | fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
| -- help: add explicit lifetime `'r` to the type of `cont`: `&'r T`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-13058.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0621]: explicit lifetime required in the type of `cont`
--> $DIR/issue-13058.rs:14:21
--> $DIR/issue-13058.rs:18:21
|
LL | fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
| -- help: add explicit lifetime `'r` to the type of `cont`: `&'r T`
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/issues/issue-13058.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

use std::ops::Range;

trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0621]: explicit lifetime required in the type of `lexer`
--> $DIR/issue-15034.rs:17:25
--> $DIR/issue-15034.rs:21:25
|
LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> {
| ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-15034.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0621]: explicit lifetime required in the type of `lexer`
--> $DIR/issue-15034.rs:17:9
--> $DIR/issue-15034.rs:21:9
|
LL | pub fn new(lexer: &'a mut Lexer) -> Parser<'a> {
| ------------- help: add explicit lifetime `'a` to the type of `lexer`: `&'a mut Lexer<'a>`
Expand Down
4 changes: 4 additions & 0 deletions src/test/ui/issues/issue-15034.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

pub struct Lexer<'a> {
input: &'a str,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
--> $DIR/issue-16683.rs:4:14
--> $DIR/issue-16683.rs:8:14
|
LL | self.a();
| ^
|
note: first, the lifetime cannot outlive the anonymous lifetime defined here...
--> $DIR/issue-16683.rs:3:10
--> $DIR/issue-16683.rs:7:10
|
LL | fn b(&self) {
| ^^^^^
note: ...so that reference does not outlive borrowed content
--> $DIR/issue-16683.rs:4:9
--> $DIR/issue-16683.rs:8:9
|
LL | self.a();
| ^^^^
note: but, the lifetime must be valid for the lifetime `'a` as defined here...
--> $DIR/issue-16683.rs:1:9
--> $DIR/issue-16683.rs:5:9
|
LL | trait T<'a> {
| ^^
note: ...so that the types are compatible
--> $DIR/issue-16683.rs:4:14
--> $DIR/issue-16683.rs:8:14
|
LL | self.a();
| ^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-16683.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-16683.rs:4:9
--> $DIR/issue-16683.rs:8:9
|
LL | trait T<'a> {
| -- lifetime `'a` defined here
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/issues/issue-16683.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

trait T<'a> {
fn a(&'a self) -> &'a bool;
fn b(&self) {
self.a(); //~ ERROR cannot infer
self.a();
//[base]~^ ERROR cannot infer
//[nll]~^^ ERROR lifetime may not live long enough
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0759]: `value` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
--> $DIR/issue-16922.rs:4:14
--> $DIR/issue-16922.rs:8:14
|
LL | fn foo<T: Any>(value: &T) -> Box<dyn Any> {
| -- this data with an anonymous lifetime `'_`...
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-16922.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-16922.rs:4:5
--> $DIR/issue-16922.rs:8:5
|
LL | fn foo<T: Any>(value: &T) -> Box<dyn Any> {
| - let's call the lifetime of this reference `'1`
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/issues/issue-16922.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

use std::any::Any;

fn foo<T: Any>(value: &T) -> Box<dyn Any> {
Box::new(value) as Box<dyn Any> //~ ERROR E0759
Box::new(value) as Box<dyn Any>
//[base]~^ ERROR E0759
//[nll]~^^ ERROR lifetime may not live long enough
}

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/issue-17728.rs:15:28
--> $DIR/issue-17728.rs:19:28
|
LL | fn attemptTraverse(&self, room: &Room, directionStr: &str) -> Result<&Room, &str> {
| ----- -------------------
Expand All @@ -16,7 +16,7 @@ LL | fn attemptTraverse<'a>(&'a self, room: &'a Room, directionStr: &str) ->
| ++++ ++ ++

error[E0308]: `match` arms have incompatible types
--> $DIR/issue-17728.rs:109:14
--> $DIR/issue-17728.rs:113:14
|
LL | / match to_parse {
LL | | "w" | "west" => RoomDirection::West,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-17728.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: `match` arms have incompatible types
--> $DIR/issue-17728.rs:109:14
--> $DIR/issue-17728.rs:113:14
|
LL | / match to_parse {
LL | | "w" | "west" => RoomDirection::West,
Expand Down
6 changes: 5 additions & 1 deletion src/test/ui/issues/issue-17728.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

use std::fmt::{Debug, Formatter, Error};
use std::collections::HashMap;

Expand All @@ -13,7 +17,7 @@ trait TraversesWorld {
let maybe_room = room.direction_to_room.get(&direction);
match maybe_room {
Some(entry) => Ok(entry),
//~^ ERROR lifetime mismatch [E0623]
//[base]~^ ERROR lifetime mismatch [E0623]
_ => Err("Direction does not exist in room.")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
--> $DIR/issue-17758.rs:7:14
--> $DIR/issue-17758.rs:11:14
|
LL | self.foo();
| ^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime defined here...
--> $DIR/issue-17758.rs:6:12
--> $DIR/issue-17758.rs:10:12
|
LL | fn bar(&self) {
| ^^^^^
note: ...so that reference does not outlive borrowed content
--> $DIR/issue-17758.rs:7:9
--> $DIR/issue-17758.rs:11:9
|
LL | self.foo();
| ^^^^
note: but, the lifetime must be valid for the lifetime `'a` as defined here...
--> $DIR/issue-17758.rs:4:11
--> $DIR/issue-17758.rs:8:11
|
LL | trait Foo<'a> {
| ^^
note: ...so that the types are compatible
--> $DIR/issue-17758.rs:7:14
--> $DIR/issue-17758.rs:11:14
|
LL | self.foo();
| ^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-17758.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-17758.rs:7:9
--> $DIR/issue-17758.rs:11:9
|
LL | trait Foo<'a> {
| -- lifetime `'a` defined here
Expand Down
7 changes: 6 additions & 1 deletion src/test/ui/issues/issue-17758.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

// Test that regionck suggestions in a provided method of a trait
// don't ICE

trait Foo<'a> {
fn foo(&'a self);
fn bar(&self) {
self.foo();
//~^ ERROR cannot infer
//[base]~^ ERROR cannot infer
//[nll]~^^ ERROR lifetime may not live long enough
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0477]: the type `&'a i32` does not fulfill the required lifetime
--> $DIR/issue-26217.rs:4:5
--> $DIR/issue-26217.rs:8:5
|
LL | foo::<&'a i32>();
| ^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-26217.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-26217.rs:4:5
--> $DIR/issue-26217.rs:8:5
|
LL | fn bar<'a>() {
| -- lifetime `'a` defined here
Expand Down
7 changes: 6 additions & 1 deletion src/test/ui/issues/issue-26217.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

fn foo<T>() where for<'a> T: 'a {}

fn bar<'a>() {
foo::<&'a i32>();
//~^ ERROR the type `&'a i32` does not fulfill the required lifetime
//[base]~^ ERROR the type `&'a i32` does not fulfill the required lifetime
//[nll]~^^ ERROR lifetime may not live long enough
}

fn main() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/issue-40000.rs:6:9
--> $DIR/issue-40000.rs:10:9
|
LL | foo(bar);
| ^^^ one type is more general than the other
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-40000.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/issue-40000.rs:6:9
--> $DIR/issue-40000.rs:10:9
|
LL | foo(bar);
| ^^^ one type is more general than the other
Expand All @@ -8,7 +8,7 @@ LL | foo(bar);
found trait object `dyn Fn(&i32)`

error[E0308]: mismatched types
--> $DIR/issue-40000.rs:6:9
--> $DIR/issue-40000.rs:10:9
|
LL | foo(bar);
| ^^^ one type is more general than the other
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/issues/issue-40000.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

fn main() {
let bar: fn(&mut u32) = |_| {};

fn foo(x: Box<dyn Fn(&i32)>) {}
let bar = Box::new(|x: &i32| {}) as Box<dyn Fn(_)>;
foo(bar); //~ ERROR E0308
foo(bar);
//~^ ERROR E0308
//[nll]~^^ ERROR mismatched types
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0759]: `x` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
--> $DIR/issue-46983.rs:2:5
--> $DIR/issue-46983.rs:6:5
|
LL | fn foo(x: &u32) -> &'static u32 {
| ---- this data with an anonymous lifetime `'_`...
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-46983.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-46983.rs:2:5
--> $DIR/issue-46983.rs:6:5
|
LL | fn foo(x: &u32) -> &'static u32 {
| - let's call the lifetime of this reference `'1`
Expand Down
7 changes: 6 additions & 1 deletion src/test/ui/issues/issue-46983.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir

fn foo(x: &u32) -> &'static u32 {
&*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]
//[nll]~^^ ERROR lifetime may not live long enough
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
--> $DIR/issue-52533.rs:5:16
--> $DIR/issue-52533.rs:9:16
|
LL | foo(|a, b| b)
| ^
|
note: ...the reference is valid for the anonymous lifetime #1 defined here...
--> $DIR/issue-52533.rs:5:9
--> $DIR/issue-52533.rs:9:9
|
LL | foo(|a, b| b)
| ^^^^^^^^
note: ...but the borrowed content is only valid for the anonymous lifetime #2 defined here
--> $DIR/issue-52533.rs:5:9
--> $DIR/issue-52533.rs:9:9
|
LL | foo(|a, b| b)
| ^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-52533.nll.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-52533.rs:5:16
--> $DIR/issue-52533.rs:9:16
|
LL | foo(|a, b| b)
| - - ^ closure was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
Expand Down
Loading

0 comments on commit b391b32

Please sign in to comment.