-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #100940 - TaKO8Ki:do-not-suggest-adding-bound-to-opaq…
…ue-type, r=fee1-dead Do not suggest adding a bound to a opaque type fixes #100442
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/regions/do-not-suggest-adding-bound-to-opaque-type.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |