Prefer type annotations and returns in free region errors

This commit is contained in:
Matthew Jasper 2018-10-13 13:21:04 +01:00
parent 22cc2ae805
commit a2c24873b1
2 changed files with 3 additions and 1 deletions

View File

@ -138,6 +138,8 @@ impl<'tcx> RegionInferenceContext<'tcx> {
| ConstraintCategory::Boring
| ConstraintCategory::BoringNoLocation
| ConstraintCategory::Internal => false,
ConstraintCategory::TypeAnnotation
| ConstraintCategory::Return => true,
_ => constraint_sup_scc != target_scc,
}
});

View File

@ -6,7 +6,7 @@ LL | fn bar<'a, 'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
| |
| lifetime `'a` defined here
LL | foo(x, y)
| ^^^^^^^^^ argument requires that `'a` must outlive `'b`
| ^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
error: aborting due to previous error