1 // Issue #26656: Verify that trait objects cannot bypass dropck.
3 // Using this instead of Fn etc. to take HRTB out of the equation.
4 trait Trigger<B> { fn fire(&self, b: &mut B); }
5 impl<B: Button> Trigger<B> for () {
6 fn fire(&self, b: &mut B) {
12 trait Button { fn push(&self); }
13 struct Zook<B> { button: B, trigger: Box<dyn Trigger<B>+'static> }
15 impl<B> Drop for Zook<B> {
17 self.trigger.fire(&mut self.button);
22 struct Bomb { usable: bool }
23 impl Drop for Bomb { fn drop(&mut self) { self.usable = false; } }
24 impl Bomb { fn activate(&self) { assert!(self.usable) } }
26 enum B<'a> { HarmlessButton, BigRedButton(&'a Bomb) }
27 impl<'a> Button for B<'a> {
29 if let B::BigRedButton(borrowed) = *self {
36 let (mut zook, ticking);
37 zook = Zook { button: B::HarmlessButton,
38 trigger: Box::new(()) };
39 ticking = Bomb { usable: true };
40 zook.button = B::BigRedButton(&ticking);
42 //~^^ ERROR `ticking` does not live long enough