about summary refs log tree commit diff
path: root/tests/ui/borrowck/fn-item-check-trait-ref.rs
blob: 8b193430e9e978bceb386fbd8f179fc38d3f8d16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// The method `assert_static` should be callable only for static values,
// because the impl has an implied bound `where T: 'static`.

//@ check-fail

trait AnyStatic<Witness>: Sized {
    fn assert_static(self) {}
}

impl<T> AnyStatic<&'static T> for T {}

fn main() {
    (&String::new()).assert_static();
    //~^ ERROR temporary value dropped while borrowed
}