-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check RPIT and AFIT hidden types are well-formed considering regions
- Loading branch information
1 parent
b03864d
commit fa1e4ba
Showing
4 changed files
with
43 additions
and
17 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
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
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,21 @@ | ||
type Static<'a> = &'static &'a (); | ||
|
||
trait Extend<'a> { | ||
fn extend(self, _: &'a str) -> &'static str; | ||
} | ||
|
||
impl<'a> Extend<'a> for Static<'a> { | ||
fn extend(self, s: &'a str) -> &'static str { | ||
s | ||
} | ||
} | ||
|
||
fn boom<'a>(arg: Static<'_>) -> impl Extend<'a> { | ||
//~^ ERROR in type `&'static &'a ()`, reference has a longer lifetime than the data it references | ||
arg | ||
} | ||
|
||
fn main() { | ||
let y = boom(&&()).extend(&String::from("temporary")); | ||
println!("{}", y); | ||
} |
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,16 @@ | ||
error[E0491]: in type `&'static &'a ()`, reference has a longer lifetime than the data it references | ||
--> $DIR/check-rpit-is-wf-regions.rs:13:33 | ||
| | ||
LL | fn boom<'a>(arg: Static<'_>) -> impl Extend<'a> { | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
= note: the pointer is valid for the static lifetime | ||
note: but the referenced data is only valid for the lifetime `'a` as defined here | ||
--> $DIR/check-rpit-is-wf-regions.rs:13:9 | ||
| | ||
LL | fn boom<'a>(arg: Static<'_>) -> impl Extend<'a> { | ||
| ^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0491`. |