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

type aliases cannot be used for traits note is printed wrongly #31686

Closed
nagisa opened this issue Feb 15, 2016 · 7 comments
Closed

type aliases cannot be used for traits note is printed wrongly #31686

nagisa opened this issue Feb 15, 2016 · 7 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.

Comments

@nagisa
Copy link
Member

nagisa commented Feb 15, 2016

src/librustc/session/mod.rs:63:39: 63:67 error: `mir::transform::Passes` is not a trait [E0404]
src/librustc/session/mod.rs:63     pub mir_passes: RefCell<for<'tcx> mir::transform::Passes<'tcx>>,
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/librustc/session/mod.rs:63:39: 63:67 help: run `rustc --explain E0404` to see a detailed explanation
src/librustc/session/mod.rs:63:39: 63:67 note: `type` aliases cannot be used for traits
src/librustc/session/mod.rs:63     pub mir_passes: RefCell<for<'tcx> mir::transform::Passes<'tcx>>,
                                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

The error here is pretty clear, but the note is completely wrong as the relevant snippet appears in the type of the struct field and not type item.

@nagisa nagisa added the A-diagnostics Area: Messages for errors, warnings, and lints label Feb 15, 2016
@nagisa
Copy link
Member Author

nagisa commented Feb 15, 2016

A bit relatedly, the E0404 is explaining something about implementing non-traits. The error explanation should either be expanded to include the current case or a different error code should be used.

cc @GuillaumeGomez on the thing described in this comment, since you originally authored the explanation for the code.

EDIT: err, I’ll just fill another issue (#31687).

@Manishearth Manishearth 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 Feb 29, 2016
@Manishearth
Copy link
Member

The note should use fileline_note instead, and we should have an extra note in case the type alias has a span (which will not be the case if it's from a foreign mod)

@Manishearth
Copy link
Member

Mentoring this.

Relevant code
Change the span_note to fileline_note.

You will also need to use resolver.ast_map.span_if_local(def_id) on the defid contained in the TyAlias to find the span for the alias (to use for outputting the extra note)

Let me know if you have any questions!

@nagisa
Copy link
Member Author

nagisa commented Feb 29, 2016

@Manishearth while I do not disagree with general suggestion to use fileline_note but I think that won’t resolve the issue, because mir::transform::Passes<'tcx> is not a trait in a first place and the failing code snippet not appear in a typedef.


#31687 (comment) has a code sample which reproduces the issue, by the way.

@Manishearth
Copy link
Member

As I see it there are two distinct issues. One is that there should be better diagnostics pointing to the typedef. That's what this bug is about. The other is that sometimes it errors for struct types instead (I find this unlikely?). Could you provide an example which reproduces this? The one you link to doesn't. http://is.gd/VKbcPH

@nagisa
Copy link
Member Author

nagisa commented Feb 29, 2016

Oh, it doesn’t fail on nightly. I guess, then, original issue I reported is not really an issue anymore.

@vegai
Copy link
Contributor

vegai commented Mar 2, 2016

Ongoing work at #32005

bors added a commit that referenced this issue Mar 2, 2016
Fix note for type alias in trait position

Fixes #31686
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.
Projects
None yet
Development

No branches or pull requests

3 participants