Rollup merge of #100940 - TaKO8Ki:do-not-suggest-adding-bound-to-opaque-type, r=fee1-dead
Do not suggest adding a bound to a opaque type fixes #100442
This commit is contained in:
commit
75b1b69171
@ -281,6 +281,9 @@ impl<'tcx> BorrowExplanation<'tcx> {
|
||||
span: Span,
|
||||
region_name: &RegionName,
|
||||
) {
|
||||
if !span.is_desugaring(DesugaringKind::OpaqueTy) {
|
||||
return;
|
||||
}
|
||||
if let ConstraintCategory::OpaqueType = category {
|
||||
let suggestable_name =
|
||||
if region_name.was_named() { region_name.name } else { kw::UnderscoreLifetime };
|
||||
|
@ -0,0 +1,12 @@
|
||||
pub trait T {}
|
||||
|
||||
struct S<'a>(&'a ());
|
||||
|
||||
impl<'a> T for S<'a> {}
|
||||
|
||||
fn foo() -> impl T {
|
||||
let x = ();
|
||||
S(&x) //~ ERROR `x` does not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,14 @@
|
||||
error[E0597]: `x` does not live long enough
|
||||
--> $DIR/do-not-suggest-adding-bound-to-opaque-type.rs:9:7
|
||||
|
|
||||
LL | S(&x)
|
||||
| --^^-
|
||||
| | |
|
||||
| | borrowed value does not live long enough
|
||||
| opaque type requires that `x` is borrowed for `'static`
|
||||
LL | }
|
||||
| - `x` dropped here while still borrowed
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
Loading…
x
Reference in New Issue
Block a user