forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't check for alias bounds in liveness when aliases have escaping b…
…ound vars
- Loading branch information
1 parent
46455dc
commit 4d5d763
Showing
4 changed files
with
64 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
trait Trait { | ||
type Gat<'a: 'b, 'b: 'c, 'c>: 'c; | ||
} | ||
|
||
fn get_func<'a, T: Trait>(_: &'a str) -> fn(T::Gat<'a, '_, 'static>) { | ||
loop {} | ||
} | ||
|
||
fn test<T: Trait>() { | ||
let func = get_func::<T>(&String::new()); //~ ERROR temporary value dropped | ||
drop(func); | ||
} | ||
|
||
fn main() {} |
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,19 @@ | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/escaping-bounds-2.rs:10:31 | ||
| | ||
LL | let func = get_func::<T>(&String::new()); | ||
| ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement | ||
| | | ||
| creates a temporary value which is freed while still in use | ||
LL | drop(func); | ||
| ---- borrow later used here | ||
| | ||
help: consider using a `let` binding to create a longer lived value | ||
| | ||
LL ~ let binding = String::new(); | ||
LL ~ let func = get_func::<T>(&binding); | ||
| | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0716`. |
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,22 @@ | ||
// check-pass | ||
|
||
// Ensure that we don't ICE when an alias that has escaping bound vars is | ||
// required to be live. This is because the code that allows us to deduce an | ||
// appropriate outlives bound for a given alias type (in this test, a | ||
// projection) does not handle aliases with escaping bound vars. | ||
// See <https://github.com/rust-lang/rust/issues/117455>. | ||
|
||
trait Foo { | ||
type Assoc<'a, 'b>: 'static; | ||
} | ||
|
||
struct MentionsLifetimeAndType<'a, T>(&'a (), T); | ||
|
||
fn foo<'a, 'b, T: Foo>(_: <T as Foo>::Assoc<'a, 'b>) {} | ||
|
||
fn test<'b, T: Foo>() { | ||
let y: MentionsLifetimeAndType<'_, for<'a> fn(<T as Foo>::Assoc<'a, 'b>)> = | ||
MentionsLifetimeAndType(&(), foo); | ||
} | ||
|
||
fn main() {} |