about summary refs log tree commit diff
path: root/tests/ui/consts/enclosing-scope-rule.rs
blob: 7041ad9af34e0886dfa80d55e5653b48c8754e87 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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() {}