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

Update error message E0120 #35298

Merged
merged 1 commit into from
Aug 5, 2016
Merged

Update error message E0120 #35298

merged 1 commit into from
Aug 5, 2016

Conversation

Keats
Copy link

@Keats Keats commented Aug 4, 2016

Fixes #35253 as part of #35233.

r? @jonathandturner

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jonathandturner (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@Keats
Copy link
Author

Keats commented Aug 4, 2016

Is there a better way to get the type name span? Also I guess I should put something other than unreachable!?

@sophiajt
Copy link
Contributor

sophiajt commented Aug 4, 2016

There may be a better way to get the type name span, but if that works, it's fine with me.

For unreachable!, it looks like people are using panic! instead and passing in a short message.

Actually, in your case, can we do something more like:

let mut err = struct_span_err!(tcx.sess, item.span, E0120,
                                                  "the Drop trait may only be implemented on structures");
match item.node {
    ItemImpl(_, _, _, _, ref ty, _) => {
        err.span = ty.span;
        err.span_label(ty.span, &format!("implementing Drop requires a struct"));
    },
    _ => {
        err.span_label(item.span, &format!("implementing Drop requires a struct"));
    }
};
err.emit();

That way we can fall-back to the larger span if we have a node type we don't expect.

@Keats
Copy link
Author

Keats commented Aug 4, 2016

Updated

@sophiajt
Copy link
Contributor

sophiajt commented Aug 4, 2016

Even better :) Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 4, 2016

📌 Commit 4492838 has been approved by jonathandturner

sophiajt pushed a commit to sophiajt/rust that referenced this pull request Aug 4, 2016
steveklabnik added a commit to steveklabnik/rust that referenced this pull request Aug 4, 2016
@sophiajt
Copy link
Contributor

sophiajt commented Aug 4, 2016

Can you run:

python src/bootstrap/bootstrap.py --stage 1 --step check-tidy

and update this PR after fixing the tidy errors?

@sophiajt
Copy link
Contributor

sophiajt commented Aug 4, 2016

@bors r-

@Keats
Copy link
Author

Keats commented Aug 4, 2016

Sorry, updated

@sophiajt
Copy link
Contributor

sophiajt commented Aug 4, 2016

No worries, thanks for updating.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 4, 2016

📌 Commit 3b2f184 has been approved by jonathandturner

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 5, 2016
bors added a commit that referenced this pull request Aug 5, 2016
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 5, 2016
bors added a commit that referenced this pull request Aug 5, 2016
@bors bors merged commit 3b2f184 into rust-lang:master Aug 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants