{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/26656","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/26656/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/26656/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/26656/events","html_url":"https://github.com/rust-lang/rust/issues/26656","id":91849618,"number":26656,"title":"dropck can be bypassed via a trait object method","user":{"login":"arielb1","id":1830974,"avatar_url":"https://avatars.githubusercontent.com/u/1830974?v=3","gravatar_id":"","url":"https://api.github.com/users/arielb1","html_url":"https://github.com/arielb1","followers_url":"https://api.github.com/users/arielb1/followers","following_url":"https://api.github.com/users/arielb1/following{/other_user}","gists_url":"https://api.github.com/users/arielb1/gists{/gist_id}","starred_url":"https://api.github.com/users/arielb1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arielb1/subscriptions","organizations_url":"https://api.github.com/users/arielb1/orgs","repos_url":"https://api.github.com/users/arielb1/repos","events_url":"https://api.github.com/users/arielb1/events{/privacy}","received_events_url":"https://api.github.com/users/arielb1/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-destructors","name":"A-destructors","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/P-high","name":"P-high","color":"eb6420"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/T-compiler","name":"T-compiler","color":"bfd4f2"}],"state":"open","locked":false,"assignee":{"login":"pnkfelix","id":173127,"avatar_url":"https://avatars.githubusercontent.com/u/173127?v=3","gravatar_id":"","url":"https://api.github.com/users/pnkfelix","html_url":"https://github.com/pnkfelix","followers_url":"https://api.github.com/users/pnkfelix/followers","following_url":"https://api.github.com/users/pnkfelix/following{/other_user}","gists_url":"https://api.github.com/users/pnkfelix/gists{/gist_id}","starred_url":"https://api.github.com/users/pnkfelix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnkfelix/subscriptions","organizations_url":"https://api.github.com/users/pnkfelix/orgs","repos_url":"https://api.github.com/users/pnkfelix/repos","events_url":"https://api.github.com/users/pnkfelix/events{/privacy}","received_events_url":"https://api.github.com/users/pnkfelix/received_events","type":"User","site_admin":false},"milestone":null,"comments":11,"created_at":"2015-06-29T16:25:51Z","updated_at":"2015-07-16T09:56:01Z","closed_at":null,"body":"## STR\r\n```Rust\r\n// Using this instead of Fn etc. to take HRTB out of the equation.\r\ntrait Trigger<B> { fn fire(&self, b: &mut B); }\r\nimpl<B: Button> Trigger<B> for () {\r\n    fn fire(&self, b: &mut B) {\r\n        b.push();\r\n    }\r\n}\r\n\r\n// Still unsound Zook\r\ntrait Button { fn push(&self); }\r\nstruct Zook<B> { button: B, trigger: Box<Trigger<B>+'static> }\r\n\r\nimpl<B> Drop for Zook<B> {\r\n    fn drop(&mut self) {\r\n        self.trigger.fire(&mut self.button);\r\n    }\r\n}\r\n\r\n// AND\r\nstruct Bomb { usable: bool }\r\nimpl Drop for Bomb { fn drop(&mut self) { self.usable = false; } }\r\nimpl Bomb { fn activate(&self) { assert!(self.usable) } }\r\n\r\nenum B<'a> { HarmlessButton, BigRedButton(&'a Bomb) }\r\nimpl<'a> Button for B<'a> {\r\n    fn push(&self) {\r\n        if let B::BigRedButton(borrowed) = *self {\r\n            borrowed.activate();\r\n        }\r\n    }\r\n}\r\n\r\nfn main() {\r\n    let (mut zook, ticking);\r\n    zook = Zook { button: B::HarmlessButton,\r\n                  trigger: Box::new(()) };\r\n    ticking = Bomb { usable: true };\r\n    zook.button = B::BigRedButton(&ticking);\r\n}\r\n```\r\n\r\nThis fails the assertion. cc @pnkfelix. I think the problem here is that `Box<Trigger<B>+'static>` does not require that `B: 'static` (cc @nikomatsakis)."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/121912674","html_url":"https://github.com/rust-lang/rust/issues/26656#issuecomment-121912674","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/26656","id":121912674,"user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"created_at":"2015-07-16T09:56:01Z","updated_at":"2015-07-16T09:56:01Z","body":"The more I think about this, the more I would prefer to back away from the current (unsound, as demonstrated here) parametricity-based reasoning and lean on something simpler (e.g., an unsafe annotation), at least for the time being, if not forever."}}