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

Be more informative with object-unsafe supertraits #19538

Closed
emberian opened this issue Dec 4, 2014 · 4 comments
Closed

Be more informative with object-unsafe supertraits #19538

emberian opened this issue Dec 4, 2014 · 4 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@emberian
Copy link
Member

emberian commented Dec 4, 2014

Currently, we say:

foo.rs:14:22: 14:32 error: cannot convert to a trait object because trait `Foo` is not object-safe [E0038]
foo.rs:14     let test: &Bar = &mut thing;
                               ^~~~~~~~~~
note: cannot call a generic method (`foo`) through a trait object

But we should include the information that it's Bar that is not object-safe, because Foo is not and it inherits from Foo.

@emberian emberian added A-diagnostics Area: Messages for errors, warnings, and lints I-papercut E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Dec 4, 2014
bors added a commit that referenced this issue Dec 7, 2014
Closes #18959

Technically, this causes code that once compiled to no longer compile, but
that code probably never ran.

[breaking-change]

------------

Not quite sure the error message is good enough, I feel like it ought to tell you "because it inherits from non-object-safe trait Foo", so I've opened up a follow-up issue #19538
@emberian
Copy link
Member Author

@steveklabnik this hasn't been fixed, has it been migrated to RFCs?

@steveklabnik
Copy link
Member

Sorry, I saw that #19539 was merged, which says "fixes 19538", and assumed that github incorrectly didn't auto close.

@steveklabnik steveklabnik reopened this Jan 21, 2015
@steveklabnik
Copy link
Member

I now see that the number was wrong, and this is a follow-up, not the original issue. My bad.

@nham
Copy link
Contributor

nham commented May 23, 2015

This looks like it might be resolved. Code:

trait Foo {
    fn foo<T>(&self, val: T);
}

trait Bar: Foo { }

pub struct Thing;

impl Foo for Thing {
    fn foo<T>(&self, val: T) { }
}

impl Bar for Thing { }

fn main() {
    let mut thing = Thing;
    let test: &mut Bar = &mut thing;
}

And the current error:

19538.rs:18:26: 18:36 error: cannot convert to a trait object because trait `Bar` is not object-safe [E0038]
19538.rs:18     let test: &mut Bar = &mut thing;
                                     ^~~~~~~~~~
19538.rs:18:26: 18:36 note: method `foo` has generic type parameters
19538.rs:18     let test: &mut Bar = &mut thing;
                                     ^~~~~~~~~~
error: aborting due to previous error

nham pushed a commit to nham/rust that referenced this issue Jun 24, 2015
bors added a commit that referenced this issue Jun 25, 2015
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 E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants