Skip to content

Commit

Permalink
Bless nll tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Feb 12, 2022
1 parent c6a3f5d commit 10cf626
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 27 deletions.
18 changes: 18 additions & 0 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2156,6 +2156,24 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}
}

// When in async fn, prefer errors that come from inside the closure.
if !categorized_path[i].from_closure {
let span = categorized_path.iter().find_map(|p| {
if p.from_closure
&& p.category == categorized_path[i].category
&& categorized_path[i].cause.span.contains(p.cause.span)
{
Some(p.cause.span)
} else {
None
}
});

if let Some(span) = span {
categorized_path[i].cause.span = span;
}
}

return categorized_path[i].clone();
}

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

Expand Down
5 changes: 2 additions & 3 deletions src/test/ui/dropck/drop-with-active-borrows-2.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
error[E0515]: cannot return value referencing local variable `raw_lines`
--> $DIR/drop-with-active-borrows-2.rs:3:5
--> $DIR/drop-with-active-borrows-2.rs:3:30
|
LL | raw_lines.iter().map(|l| l.trim()).collect()
| ----------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ---------------- ^^^^^^^^ returns a value referencing data owned by the current function
| |
| returns a value referencing data owned by the current function
| `raw_lines` is borrowed here

error: aborting due to previous error
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-13497-2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fn read_lines_borrowed<'a>() -> Vec<&'a str> {
let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()];
rawLines //~ ERROR cannot return value referencing local variable `rawLines`
.iter().map(|l| l.trim()).collect()
rawLines.iter().map(|l| l.trim()).collect()
//~^ ERROR cannot return value referencing local variable `rawLines`
}

fn main() {}
14 changes: 5 additions & 9 deletions src/test/ui/issues/issue-13497-2.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
error[E0515]: cannot return value referencing local variable `rawLines`
--> $DIR/issue-13497-2.rs:3:5
--> $DIR/issue-13497-2.rs:3:29
|
LL | rawLines
| _____^
| |_____|
| ||
LL | || .iter().map(|l| l.trim()).collect()
| ||_______________-___________________________^ returns a value referencing data owned by the current function
| |________________|
| `rawLines` is borrowed here
LL | rawLines.iter().map(|l| l.trim()).collect()
| --------------- ^^^^^^^^ returns a value referencing data owned by the current function
| |
| `rawLines` is borrowed here

error: aborting due to previous error

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

error: aborting due to 3 previous errors
Expand Down

0 comments on commit 10cf626

Please sign in to comment.