2022-11-06 10:26:25 -06:00
|
|
|
// The method `assert_static` should be callable only for static values,
|
|
|
|
// because the impl has an implied bound `where T: 'static`.
|
|
|
|
|
2024-02-16 14:02:50 -06:00
|
|
|
//@ check-fail
|
2022-11-06 10:26:25 -06:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|