Skip to content

Commit 10cf626

Browse files
committed
Bless nll tests.
1 parent c6a3f5d commit 10cf626

File tree

6 files changed

+37
-27
lines changed

6 files changed

+37
-27
lines changed

compiler/rustc_borrowck/src/region_infer/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -2156,6 +2156,24 @@ impl<'tcx> RegionInferenceContext<'tcx> {
21562156
}
21572157
}
21582158

2159+
// When in async fn, prefer errors that come from inside the closure.
2160+
if !categorized_path[i].from_closure {
2161+
let span = categorized_path.iter().find_map(|p| {
2162+
if p.from_closure
2163+
&& p.category == categorized_path[i].category
2164+
&& categorized_path[i].cause.span.contains(p.cause.span)
2165+
{
2166+
Some(p.cause.span)
2167+
} else {
2168+
None
2169+
}
2170+
});
2171+
2172+
if let Some(span) = span {
2173+
categorized_path[i].cause.span = span;
2174+
}
2175+
}
2176+
21592177
return categorized_path[i].clone();
21602178
}
21612179

src/test/ui/async-await/multiple-lifetimes/ret-impl-trait-one.nll.stderr

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
error: lifetime may not live long enough
2-
--> $DIR/ret-impl-trait-one.rs:10:85
2+
--> $DIR/ret-impl-trait-one.rs:12:5
33
|
4-
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
5-
| ________________________________--__--_______________________________________________^
6-
| | | |
7-
| | | lifetime `'b` defined here
8-
| | lifetime `'a` defined here
9-
LL | |
10-
LL | | (a, b)
11-
LL | | }
12-
| |_^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
4+
LL | async fn async_ret_impl_trait3<'a, 'b>(a: &'a u8, b: &'b u8) -> impl Trait<'a> + 'b {
5+
| -- -- lifetime `'b` defined here
6+
| |
7+
| lifetime `'a` defined here
8+
LL |
9+
LL | (a, b)
10+
| ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
1311
|
1412
= help: consider adding the following bound: `'a: 'b`
1513

src/test/ui/dropck/drop-with-active-borrows-2.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
error[E0515]: cannot return value referencing local variable `raw_lines`
2-
--> $DIR/drop-with-active-borrows-2.rs:3:5
2+
--> $DIR/drop-with-active-borrows-2.rs:3:30
33
|
44
LL | raw_lines.iter().map(|l| l.trim()).collect()
5-
| ----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ---------------- ^^^^^^^^ returns a value referencing data owned by the current function
66
| |
7-
| returns a value referencing data owned by the current function
87
| `raw_lines` is borrowed here
98

109
error: aborting due to previous error

src/test/ui/issues/issue-13497-2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fn read_lines_borrowed<'a>() -> Vec<&'a str> {
22
let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()];
3-
rawLines //~ ERROR cannot return value referencing local variable `rawLines`
4-
.iter().map(|l| l.trim()).collect()
3+
rawLines.iter().map(|l| l.trim()).collect()
4+
//~^ ERROR cannot return value referencing local variable `rawLines`
55
}
66

77
fn main() {}

src/test/ui/issues/issue-13497-2.stderr

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
error[E0515]: cannot return value referencing local variable `rawLines`
2-
--> $DIR/issue-13497-2.rs:3:5
2+
--> $DIR/issue-13497-2.rs:3:29
33
|
4-
LL | rawLines
5-
| _____^
6-
| |_____|
7-
| ||
8-
LL | || .iter().map(|l| l.trim()).collect()
9-
| ||_______________-___________________________^ returns a value referencing data owned by the current function
10-
| |________________|
11-
| `rawLines` is borrowed here
4+
LL | rawLines.iter().map(|l| l.trim()).collect()
5+
| --------------- ^^^^^^^^ returns a value referencing data owned by the current function
6+
| |
7+
| `rawLines` is borrowed here
128

139
error: aborting due to previous error
1410

src/test/ui/self/arbitrary_self_types_pin_lifetime_mismatch-async.nll.stderr

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ error: lifetime may not live long enough
2020
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch-async.rs:17:64
2121
|
2222
LL | async fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
23-
| -- - ^^^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
24-
| | |
25-
| | let's call the lifetime of this reference `'1`
23+
| -- ---- has type `Pin<&'1 Foo>` ^^^ associated function was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
24+
| |
2625
| lifetime `'a` defined here
2726

2827
error: aborting due to 3 previous errors

0 commit comments

Comments
 (0)