Skip to content

Commit fe91cfd

Browse files
committed
Use revisions for NLL in suggestions
1 parent b391b32 commit fe91cfd

23 files changed

+330
-93
lines changed

src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.stderr renamed to src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.base.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error[E0515]: cannot return reference to function parameter `val`
2-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9
2+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:25:9
33
|
44
LL | val.use_self()
55
| ^^^^^^^^^^^^^^ returns a reference to data owned by the current function
66

77
error[E0515]: cannot return reference to function parameter `val`
8-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9
8+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:47:9
99
|
1010
LL | val.use_self()
1111
| ^^^^^^^^^^^^^^ returns a reference to data owned by the current function
1212

1313
error[E0515]: cannot return reference to function parameter `val`
14-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9
14+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:113:9
1515
|
1616
LL | val.use_self()
1717
| ^^^^^^^^^^^^^^ returns a reference to data owned by the current function
1818

1919
error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
20-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:66:13
20+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:70:13
2121
|
2222
LL | fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32> + 'a>) -> &'a () {
2323
| -------------------------------------- this data with lifetime `'a`...
2424
LL | val.use_self()
2525
| ^^^^^^^^ ...is used and required to live as long as `'static` here
2626
|
2727
note: the used `impl` has a `'static` requirement
28-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:60:30
28+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:64:30
2929
|
3030
LL | impl MyTrait for Box<dyn ObjectTrait<Assoc = i32>> {
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement

src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.nll.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0515]: cannot return reference to function parameter `val`
2-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:21:9
2+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:25:9
33
|
44
LL | val.use_self()
55
| ^^^^^^^^^^^^^^ returns a reference to data owned by the current function
66

77
error[E0515]: cannot return reference to function parameter `val`
8-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:43:9
8+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:47:9
99
|
1010
LL | val.use_self()
1111
| ^^^^^^^^^^^^^^ returns a reference to data owned by the current function
1212

1313
error[E0515]: cannot return reference to function parameter `val`
14-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:109:9
14+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs:113:9
1515
|
1616
LL | val.use_self()
1717
| ^^^^^^^^^^^^^^ returns a reference to data owned by the current function

src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-needing-more-suggestions.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// revisions: base nll
2+
// ignore-compare-mode-nll
3+
//[nll] compile-flags: -Z borrowck=mir
4+
15
// FIXME: the following cases need to suggest more things to make users reach a working end state.
26

37
mod bav {
@@ -63,7 +67,7 @@ mod bay {
6367
impl Bar for i32 {}
6468

6569
fn use_it<'a>(val: Box<dyn ObjectTrait<Assoc = i32> + 'a>) -> &'a () {
66-
val.use_self() //~ ERROR E0772
70+
val.use_self() //[base]~ ERROR E0772
6771
}
6872
}
6973

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
// FIXME(nll): On NLL stabilization, this should replace
2+
// `impl-on-dyn-trait-with-implicit-static-bound.rs`. Compiletest has
3+
// problems with rustfix and revisions.
4+
// ignore-compare-mode-nll
5+
// compile-flags: -Zborrowck=mir
6+
7+
#![allow(dead_code)]
8+
9+
mod foo {
10+
trait OtherTrait<'a> {}
11+
impl<'a> OtherTrait<'a> for &'a () {}
12+
13+
trait ObjectTrait<T> {}
14+
trait MyTrait<T> {
15+
fn use_self<K>(&self) -> &();
16+
}
17+
trait Irrelevant {}
18+
19+
impl<T> MyTrait<T> for dyn ObjectTrait<T> {
20+
fn use_self<K>(&self) -> &() { panic!() }
21+
}
22+
impl<T> Irrelevant for dyn ObjectTrait<T> {}
23+
24+
fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a {
25+
val.use_self::<T>() //~ ERROR borrowed data escapes
26+
}
27+
}
28+
29+
mod bar {
30+
trait ObjectTrait {}
31+
trait MyTrait {
32+
fn use_self(&self) -> &();
33+
}
34+
trait Irrelevant {}
35+
36+
impl MyTrait for dyn ObjectTrait {
37+
fn use_self(&self) -> &() { panic!() }
38+
}
39+
impl Irrelevant for dyn ObjectTrait {}
40+
41+
fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () {
42+
val.use_self()
43+
}
44+
}
45+
46+
mod baz {
47+
trait ObjectTrait {}
48+
trait MyTrait {
49+
fn use_self(&self) -> &();
50+
}
51+
trait Irrelevant {}
52+
53+
impl MyTrait for Box<dyn ObjectTrait> {
54+
fn use_self(&self) -> &() { panic!() }
55+
}
56+
impl Irrelevant for Box<dyn ObjectTrait> {}
57+
58+
fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () {
59+
val.use_self()
60+
}
61+
}
62+
63+
mod bat {
64+
trait OtherTrait<'a> {}
65+
impl<'a> OtherTrait<'a> for &'a () {}
66+
67+
trait ObjectTrait {}
68+
69+
impl dyn ObjectTrait {
70+
fn use_self(&self) -> &() { panic!() }
71+
}
72+
73+
fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
74+
val.use_self()
75+
//~^ ERROR borrowed data escapes
76+
}
77+
}
78+
79+
mod ban {
80+
trait OtherTrait<'a> {}
81+
impl<'a> OtherTrait<'a> for &'a () {}
82+
83+
trait ObjectTrait {}
84+
trait MyTrait {
85+
fn use_self(&self) -> &() { panic!() }
86+
}
87+
trait Irrelevant {
88+
fn use_self(&self) -> &() { panic!() }
89+
}
90+
91+
impl MyTrait for dyn ObjectTrait {}
92+
93+
fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> {
94+
val.use_self() //~ ERROR borrowed data escapes
95+
}
96+
}
97+
98+
mod bal {
99+
trait OtherTrait<'a> {}
100+
impl<'a> OtherTrait<'a> for &'a () {}
101+
102+
trait ObjectTrait {}
103+
trait MyTrait {
104+
fn use_self(&self) -> &() { panic!() }
105+
}
106+
trait Irrelevant {
107+
fn use_self(&self) -> &() { panic!() }
108+
}
109+
110+
impl MyTrait for dyn ObjectTrait {}
111+
impl Irrelevant for dyn ObjectTrait {}
112+
113+
fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
114+
MyTrait::use_self(val) //~ ERROR borrowed data escapes
115+
}
116+
}
117+
118+
fn main() {}

src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr renamed to src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound-nll.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0521]: borrowed data escapes outside of function
2-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:9
2+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:25:9
33
|
44
LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a {
55
| -- --- `val` is a reference that is only valid in the function body
@@ -12,7 +12,7 @@ LL | val.use_self::<T>()
1212
| argument requires that `'a` must outlive `'static`
1313

1414
error[E0521]: borrowed data escapes outside of function
15-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:9
15+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:74:9
1616
|
1717
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
1818
| -- --- `val` is a reference that is only valid in the function body
@@ -25,7 +25,7 @@ LL | val.use_self()
2525
| argument requires that `'a` must outlive `'static`
2626

2727
error[E0521]: borrowed data escapes outside of function
28-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:9
28+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:94:9
2929
|
3030
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> {
3131
| -- --- `val` is a reference that is only valid in the function body
@@ -38,7 +38,7 @@ LL | val.use_self()
3838
| argument requires that `'a` must outlive `'static`
3939

4040
error[E0521]: borrowed data escapes outside of function
41-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9
41+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound-nll.rs:114:9
4242
|
4343
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
4444
| -- --- `val` is a reference that is only valid in the function body

src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.fixed

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// FIXME(nll): On NLL stabilization, this should be replaced by
2+
// `impl-on-dyn-trait-with-implicit-static-bound-nll.rs`. Compiletest has
3+
// problems with rustfix and revisions.
4+
// ignore-compare-mode-nll
5+
16
// run-rustfix
27
#![allow(dead_code)]
38

src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// FIXME(nll): On NLL stabilization, this should be replaced by
2+
// `impl-on-dyn-trait-with-implicit-static-bound-nll.rs`. Compiletest has
3+
// problems with rustfix and revisions.
4+
// ignore-compare-mode-nll
5+
16
// run-rustfix
27
#![allow(dead_code)]
38

src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.stderr

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
2-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:20:13
2+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:25:13
33
|
44
LL | fn use_it<'a, T>(val: &'a dyn ObjectTrait<T>) -> impl OtherTrait<'a> + 'a {
55
| ---------------------- this data with lifetime `'a`...
66
LL | val.use_self::<T>()
77
| ^^^^^^^^ ...is used and required to live as long as `'static` here
88
|
99
note: the used `impl` has a `'static` requirement
10-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:14:32
10+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:19:32
1111
|
1212
LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> {
1313
| ^^^^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
@@ -19,15 +19,15 @@ LL | impl<T> MyTrait<T> for dyn ObjectTrait<T> + '_ {
1919
| ++++
2020

2121
error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
22-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:13
22+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:74:13
2323
|
2424
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
2525
| ------------------- this data with lifetime `'a`...
2626
LL | val.use_self()
2727
| ^^^^^^^^ ...is used and required to live as long as `'static` here because of an implicit lifetime bound on the inherent `impl`
2828
|
2929
note: the used `impl` has a `'static` requirement
30-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:64:14
30+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:69:14
3131
|
3232
LL | impl dyn ObjectTrait {
3333
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
@@ -39,15 +39,15 @@ LL | impl dyn ObjectTrait + '_ {
3939
| ++++
4040

4141
error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
42-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:88:13
42+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:93:13
4343
|
4444
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> {
4545
| ------------------- this data with lifetime `'a`...
4646
LL | val.use_self()
4747
| ^^^^^^^^ ...is used and required to live as long as `'static` here
4848
|
4949
note: the used `impl` has a `'static` requirement
50-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:85:26
50+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:90:26
5151
|
5252
LL | fn use_self(&self) -> &() { panic!() }
5353
| -------- calling this method introduces the `impl`'s 'static` requirement
@@ -64,20 +64,20 @@ LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
6464
| ++++
6565

6666
error[E0759]: `val` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
67-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:27
67+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:113:27
6868
|
6969
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> impl OtherTrait<'a> + 'a {
7070
| ------------------- this data with lifetime `'a`...
7171
LL | MyTrait::use_self(val)
7272
| ^^^ ...is used here...
7373
|
7474
note: ...and is required to live as long as `'static` here
75-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:108:9
75+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:113:9
7676
|
7777
LL | MyTrait::use_self(val)
7878
| ^^^^^^^^^^^^^^^^^
7979
note: the used `impl` has a `'static` requirement
80-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:104:26
80+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:109:26
8181
|
8282
LL | fn use_self(&self) -> &() { panic!() }
8383
| -------- calling this method introduces the `impl`'s 'static` requirement
@@ -90,15 +90,15 @@ LL | impl MyTrait for dyn ObjectTrait + '_ {}
9090
| ++++
9191

9292
error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
93-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:37:13
93+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:42:13
9494
|
9595
LL | fn use_it<'a>(val: &'a dyn ObjectTrait) -> &'a () {
9696
| ------------------- this data with lifetime `'a`...
9797
LL | val.use_self()
9898
| ^^^^^^^^ ...is used and required to live as long as `'static` here
9999
|
100100
note: the used `impl` has a `'static` requirement
101-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:31:26
101+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:36:26
102102
|
103103
LL | impl MyTrait for dyn ObjectTrait {
104104
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement
@@ -110,15 +110,15 @@ LL | impl MyTrait for dyn ObjectTrait + '_ {
110110
| ++++
111111

112112
error[E0772]: `val` has lifetime `'a` but calling `use_self` introduces an implicit `'static` lifetime requirement
113-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:54:13
113+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:59:13
114114
|
115115
LL | fn use_it<'a>(val: &'a Box<dyn ObjectTrait + 'a>) -> &'a () {
116116
| ----------------------------- this data with lifetime `'a`...
117117
LL | val.use_self()
118118
| ^^^^^^^^ ...is used and required to live as long as `'static` here
119119
|
120120
note: the used `impl` has a `'static` requirement
121-
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:48:30
121+
--> $DIR/impl-on-dyn-trait-with-implicit-static-bound.rs:53:30
122122
|
123123
LL | impl MyTrait for Box<dyn ObjectTrait> {
124124
| ^^^^^^^^^^^ this has an implicit `'static` lifetime requirement

src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr renamed to src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.base.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
error[E0311]: the parameter type `T` may not live long enough
2-
--> $DIR/missing-lifetimes-in-signature-2.rs:20:9
2+
--> $DIR/missing-lifetimes-in-signature-2.rs:24:9
33
|
44
LL | foo.bar(move |_| {
55
| ^^^
66
|
77
note: the parameter type `T` must be valid for the anonymous lifetime defined here...
8-
--> $DIR/missing-lifetimes-in-signature-2.rs:19:24
8+
--> $DIR/missing-lifetimes-in-signature-2.rs:23:24
99
|
1010
LL | fn func<T: Test>(foo: &Foo, t: T) {
1111
| ^^^
12-
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds...
13-
--> $DIR/missing-lifetimes-in-signature-2.rs:20:9
12+
note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:24:13: 27:6]` will meet its required lifetime bounds...
13+
--> $DIR/missing-lifetimes-in-signature-2.rs:24:9
1414
|
1515
LL | foo.bar(move |_| {
1616
| ^^^
1717
note: ...that is required by this bound
18-
--> $DIR/missing-lifetimes-in-signature-2.rs:11:12
18+
--> $DIR/missing-lifetimes-in-signature-2.rs:15:12
1919
|
2020
LL | F: 'a,
2121
| ^^

0 commit comments

Comments
 (0)