mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 18:27:37 +00:00

The SCCs of the region graph are not a reliable heuristic to use for blaming an interesting constraint for diagnostics. For region errors, if the outlived region is `'static`, or the involved types are invariant in their lifetiems, there will be cycles in the constraint graph containing both the target region and the most interesting constraints to blame. To get better diagnostics in these cases, this commit removes that heuristic.
14 lines
490 B
Rust
14 lines
490 B
Rust
//! diagnostic test for #132749: ensure we pick a decent span and reason to blame for region errors
|
|
//! when failing to prove a region outlives 'static
|
|
|
|
struct Bytes(&'static [u8]);
|
|
|
|
fn deserialize_simple_string(buf: &[u8]) -> (Bytes, &[u8]) {
|
|
//~^ NOTE let's call the lifetime of this reference `'1`
|
|
let (s, rest) = buf.split_at(2);
|
|
(Bytes(s), rest) //~ ERROR lifetime may not live long enough
|
|
//~| NOTE this usage requires that `'1` must outlive `'static`
|
|
}
|
|
|
|
fn main() {}
|