Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
const-checking: add some corner case tests, and fix some nits
- Loading branch information
Showing
5 changed files
with
46 additions
and
6 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,16 @@ | ||
//@build-pass | ||
// Some code that looks like it might be relying on promotion, but actually this is using the | ||
// enclosing-scope rule, meaning the reference is "extended" to outlive its block and live as long | ||
// as the surrounding block (which in this case is the entire program). There are multiple | ||
// allocations being interned at once. | ||
|
||
struct Gen<T>(T); | ||
impl<'a, T> Gen<&'a T> { | ||
// Can't be promoted because `T` might not be `'static`. | ||
const C: &'a [T] = &[]; | ||
} | ||
|
||
// Can't be promoted because of `Drop`. | ||
const V: &Vec<i32> = &Vec::new(); | ||
|
||
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
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