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

Wrong message from object safety checker #40670

Closed
qnighy opened this issue Mar 20, 2017 · 4 comments
Closed

Wrong message from object safety checker #40670

qnighy opened this issue Mar 20, 2017 · 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. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@qnighy
Copy link
Contributor

qnighy commented Mar 20, 2017

UPDATE: There are mentoring instructions to be found in a comment below.


Object safety checker produces messages with "supertrait something" even when the cause is in where-clause.

trait Bar<X:?Sized> {}
trait Foo where Box<Self>: Bar<Self> {}
fn f(x: Box<Foo>) {}
fn main () {
}
rustc 1.17.0-nightly (b1e31766d 2017-03-03)
error[E0038]: the trait `Foo` cannot be made into an object
 --> <anon>:3:1
  |
3 | fn f(x: Box<Foo>) {}
  | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
  |
  = note: the trait cannot use `Self` as a type parameter in the supertrait listing

error: aborting due to previous error

Rust Playground: https://is.gd/mAvVNW

Indeed this seems object-unsafe, but the message should be something about "where-clause", not "supertrait listing".

@steveklabnik steveklabnik added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 20, 2017
@nikomatsakis
Copy link
Contributor

I tend to agree. This message is generated in src/librustc/traits/object_safety.rs, which houses the object safety analysis. The simplest fix would just be to adjust the wording to say "in the supertraits or where-clauses". It would be difficult -- but not impossible -- for us to distinguish the two, since at this phase in the compiler they are effectively unified. Doesn't seem worth the effort.

@nikomatsakis nikomatsakis added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Mar 22, 2017
@mandeep
Copy link
Contributor

mandeep commented Mar 23, 2017

Currently, working on this. Hope to submit a pull request tonight.

frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 23, 2017
…n-message, r=brson

Change object safety violation message

Hello!

This is my first pull request to rust so hopefully all goes well. This PR should fix issue rust-lang#40670. I changed the error message in object_safety.rs and the corresponding compile-fail test in object-safety-supertrait-mentions-Self.rs.

Once the changes were made, I ran ```python x.py test src/tools/tidy``` and ```python x.py test```. Tidy passed and the compile-fail tests passed, however the test suite failed on the tcp tests as my machine has IPv6 disabled. I'm not sure what to do in this case besides letting travis run the suite against my changes. Please let me know if there's anything I can do to help further.

Thanks!
Mandeep
@qnighy
Copy link
Contributor Author

qnighy commented Apr 15, 2017

May I (or should I) close this issue?

@nikomatsakis
Copy link
Contributor

Yep! Thanks. =)

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. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants