rust/tests/ui/nll/issue-67007-escaping-data.rs
dianne ac922245f0 best_blame_constraint: don't filter constraints by sup SCC
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.
2025-01-06 16:08:29 -08:00

25 lines
606 B
Rust

// Regression test for issue #67007
// Ensures that we show information about the specific regions involved
// Covariant over 'a, invariant over 'tcx
struct FnCtxt<'a, 'tcx: 'a>(&'a (), *mut &'tcx ());
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn use_it(&self, _: &'tcx ()) {}
}
struct Consumer<'tcx>(&'tcx ());
impl<'tcx> Consumer<'tcx> {
fn bad_method<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) {
let other = self.use_fcx(fcx);
fcx.use_it(other); //~ ERROR lifetime may not live long enough
}
fn use_fcx<'a>(&self, _: &FnCtxt<'a, 'tcx>) -> &'a () {
&()
}
}
fn main() {}