Skip to content

Commit a2c2487

Browse files
committed
Prefer type annotations and returns in free region errors
1 parent 22cc2ae commit a2c2487

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
138138
| ConstraintCategory::Boring
139139
| ConstraintCategory::BoringNoLocation
140140
| ConstraintCategory::Internal => false,
141+
ConstraintCategory::TypeAnnotation
142+
| ConstraintCategory::Return => true,
141143
_ => constraint_sup_scc != target_scc,
142144
}
143145
});

src/test/ui/nll/where_clauses_in_functions.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
66
| |
77
| lifetime `'a` defined here
88
LL | foo(x, y)
9-
| ^^^^^^^^^ argument requires that `'a` must outlive `'b`
9+
| ^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
1010

1111
error: aborting due to previous error
1212

0 commit comments

Comments
 (0)