517d361a1f
Fixes #67765 When reporting errors during MIR region inference, we sometimes use `universal_upper_bound` to obtain a named universal region that we can display to the user. However, this is not always possible - in a case like `fn foo<'a, 'b>() { .. }`, the only upper bound for a region containing `'a` and `'b` is `'static`. When displaying diagnostics, it's usually better to display *some* named region (even if there are multiple involved) rather than fall back to a generic error involving `'static`. This commit adds a new `approx_universal_upper_bound` method, which uses the lowest-numbered universal region if the only alternative is to return `'static`.
12 lines
381 B
Plaintext
12 lines
381 B
Plaintext
error[E0515]: cannot return value referencing function parameter `x`
|
|
--> $DIR/return-disjoint-regions.rs:4:5
|
|
|
|
|
LL | let y = &x;
|
|
| -- `x` is borrowed here
|
|
LL | (y, y)
|
|
| ^^^^^^ returns a value referencing data owned by the current function
|
|
|
|
error: aborting due to previous error
|
|
|
|
For more information about this error, try `rustc --explain E0515`.
|