-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Improve parsing diagnostic for negative supertrait bounds #57364
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the tests are currently broken. Added an alternative way of getting the suggestion span.
Ping from triage @hdhoang Have you been able to make any progress on this? |
thank you, I have a rough outline of the necessary flow inside the loop. I will describe most of it later while working it out locally. |
I have pushed a WIP flow for review. Firstly, I have renamed the supertraits in tests to make talking about them easier. On to the parser, to pass the colon span into the loop, I have added a Next, I have implemented your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output looks superb.
I think that we can iterate on the changes to parse_generic_bounds_common
, as you're using a DUMMY_SP
in some cases. I think that replacing that with None
would be safer, and just avoid giving any suggestion if colon_span
isn't Some(sp)
, just a help
line similar to what we have now.
You can see how I handled a similar suggestion case in 28ea03e, but that one was more self contained.
thanks! I intend to update this weekend, and see how it goes |
hopefully I have addressed your review correctly. I have also downgraded the colon suggestion to a warning, since it's due to rustfix, not the original code |
ping @estebank, have you had a chance chance to look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay. Some suggestions inline. Let me know what you think.
src/libsyntax/parse/parser.rs
Outdated
"".into(), | ||
Applicability::MachineApplicable); | ||
} else { | ||
err.help("remove this trait bound"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the other comment is implemented, this is the branch where you would have to account for the trailing +
span instead, and suggest the removal of it, instead of in the warning.
help: remove the trait bound | ||
| | ||
LL | trait Tr3 + SuperB {} //~ ERROR negative trait bounds are not supported | ||
| -- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These help messages come out nonsensical, but the code suggestions apply correctly. Is this okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a shame, we should try to make the suggestion more readable by showing the final code in a single step, instead of applying multiple changes at the same time. In this case it should be something like
error: negative trait bounds are not supported
--> $DIR/issue-33418.rs:5:10
|
LL | trait Tr3: !SuperA + SuperB {} //~ ERROR negative trait bounds are not supported
| ^^^^^^^^^
help: remove the trait bound
|
LL | trait Tr3: SuperB {} //~ ERROR negative trait bounds are not supported
| --
I have reconstructed a new bound list from the parsed |
hi @estebank, how do you feel about the current approach? |
@hdhoang I've been away for the past week. I'll try to review today. |
☔ The latest upstream changes (presumably #58341) made this pull request unmergeable. Please resolve the merge conflicts. |
I have resolved the conflict locally, but still would like to wait to rebase & make use of #58296 before pushing |
Using |
@bors r+ |
📌 Commit a55f1c3da60797b5c705ef34433a1d3414f99bf6 has been approved by |
Looks to be a network failure, please retry. |
@bors retry |
@ljedrz: 🔑 Insufficient privileges: not in try users |
Oops, it seems that my try privileges haven't been deployed yet. |
@bors retry |
☔ The latest upstream changes (presumably #58644) made this pull request unmergeable. Please resolve the merge conflicts. |
I'll get on this |
hi, this is good to go again. please ask @bors to retry. |
Ok, let's try again ^^. @bors retry |
@ljedrz: 🔑 Insufficient privileges: not in try users |
After push to a PR it can't simply be retried, it must be r+'ed again. @bors r=estebank |
📌 Commit 7cfddfb has been approved by |
…tebank Improve parsing diagnostic for negative supertrait bounds closes rust-lang#33418 r? @estebank
…tebank Improve parsing diagnostic for negative supertrait bounds closes rust-lang#33418 r? @estebank
Rollup of 6 pull requests Successful merges: - #57364 (Improve parsing diagnostic for negative supertrait bounds) - #58183 (Clarify guarantees for `Box` allocation) - #58442 (Simplify the unix `Weak` functionality) - #58454 (Refactor Windows stdio and remove stdin double buffering ) - #58511 (Const to op simplification) - #58642 (rustdoc: support methods on primitives in intra-doc links) Failed merges: r? @ghost
thanks to everyone for guidance! |
closes #33418
r? @estebank