Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: Drop does not check trait bounds #22965

Closed
mahkoh opened this issue Mar 2, 2015 · 3 comments
Closed

ICE: Drop does not check trait bounds #22965

mahkoh opened this issue Mar 2, 2015 · 3 comments
Labels
A-destructors Area: Destructors (`Drop`, …) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@mahkoh
Copy link
Contributor

mahkoh commented Mar 2, 2015

#![feature(optin_builtin_traits, unsafe_destructor)]

trait Print {
    fn print(&self);
}

struct X<T> {
    x: T,
}

#[unsafe_destructor]
impl<T: Print> Drop for X<T> {
    fn drop(&mut self) {
        self.x.print();
    }
}

fn main() {
    X { x: 1 };
}
test4.rs:14:9: 14:23 error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(Print)` during trans
test4.rs:14         self.x.print();
                    ^~~~~~~~~~~~~~
@mahkoh
Copy link
Contributor Author

mahkoh commented Mar 2, 2015

Note that

#[unsafe_destructor]
impl<T: Send> Drop for X<T> {
    fn drop(&mut self) {
    }
}

compiles without an error even if T is not Send.

@kmcallister kmcallister added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-destructors Area: Destructors (`Drop`, …) labels Mar 2, 2015
@oli-obk
Copy link
Contributor

oli-obk commented Mar 13, 2015

trait bounds on impl Drop are forbidden anyway, the compiler just doesn't check them yet. See #8142

@huonw
Copy link
Member

huonw commented Mar 13, 2015

To be clear, only trait bounds more specific than those on the type declaration is forbidden, e.g. this is fine:

struct Foo<T: Trait>;
impl<T: Trait> Drop for Foo { ... }

@mahkoh mahkoh closed this as completed Apr 11, 2015
@rust-lang rust-lang locked and limited conversation to collaborators Apr 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-destructors Area: Destructors (`Drop`, …) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants