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

declaration of non-object-safe trait object type should be invalid #21953

Closed
mandel59 opened this issue Feb 5, 2015 · 1 comment
Closed

declaration of non-object-safe trait object type should be invalid #21953

mandel59 opened this issue Feb 5, 2015 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@mandel59
Copy link

mandel59 commented Feb 5, 2015

trait A {
    fn foo(&self, _x: &Self);
}

impl A for () {
    fn foo(&self, _x: &Self) {}
}

fn main() {                                                 
    let _x: &A;
}

This code passes, while the codes like let x = &() as &A; cause compile error because the trait A is not object-safe. 0255-object-safety

Is there any reason for type &A to exist? If not, the declaration of variables of type &A should be invalid.

@jdm jdm added the A-diagnostics Area: Messages for errors, warnings, and lints label Feb 5, 2015
@alexcrichton
Copy link
Member

This is now rejected (presumably fixed in the meantime), so closing, yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants