-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Don't add redundant help for object safety violations #117200
Conversation
Could not assign reviewer from: |
r? @spastorino (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
e0e3503
to
76e0c85
Compare
@@ -62,7 +62,6 @@ LL | trait NonObjectSafe4 { | |||
| -------------- this trait cannot be made into an object... | |||
LL | fn foo(&self, s: &Self); | |||
| ^^^^^ ...because method `foo` references the `Self` type in this parameter | |||
= help: consider moving `foo` to another trait |
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.
I don't think this is a change we want. Note that this mentions a different foo
than the previous messages.
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.
Ah okay, sorry about that, I pushed a different solution that doesn't change the other tests
76e0c85
to
a29fb71
Compare
@WaffleLapkin are you taking care of this review? can you assign it to yourselve?. |
@spastorino I can take the review. The cause is that there can be multiple problems with the same item, we want to highlight all of them, but the proposed solution is the same for all problems — move the item to another trait. |
Makes sense, I guess I'd hide from consumers the existence of that vector that tracks already suggested "solutions". |
☔ The latest upstream changes (presumably #117405) made this pull request unmergeable. Please resolve the merge conflicts. |
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 looks fine.
Please add a comment, fix conflicts and use @rustbot review
to ask me for review again =)
@@ -103,9 +103,11 @@ pub fn report_object_safety_error<'tcx>( | |||
if trait_span.is_some() { | |||
let mut reported_violations: Vec<_> = reported_violations.into_iter().collect(); | |||
reported_violations.sort(); | |||
|
|||
let mut reported_names = vec![]; |
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.
Could you add a little comment explaining why this is needed like "allows us to skip suggesting moving the same item to another trait multiple times" or something?
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.
Done! Do you think there is a better way of doing this to hide the vector, maybe by taking in the list of violations up front for example or is it okay as is?
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.
We could create an ObjectSafetyViolationSolution
enum, which would be returned from solution
, then deduplicated, then added to the error. Something like
let mut potential_solutions: Vec<_> = reported_violations.into_iter().map(...::solution).collect();
potential_solutions.sort();
potential_solutions.dedup();
potential_solutions.for_each(|solution| solution.add_to(&mut err));
Do you want to try doing 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.
Ah I see, that sounds better, I'll give it a try!
a29fb71
to
e7b873b
Compare
@rustbot review |
@rustbot author (#117200 (comment)) |
e7b873b
to
e726058
Compare
e726058
to
af6b84a
Compare
// Only provide the help if its a local trait, otherwise it's not actionable. | ||
violation.solution(&mut err); | ||
|
||
// Only provide the help if its a local trait, otherwise it's not actionable. |
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.
Please move this to the if
@rustbot review |
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.
Thanks, I like this fix :)
@bors r+ |
Thanks for the help, I like this one much more too! 😄 |
☀️ Test successful - checks-actions |
Finished benchmarking commit (6eb9524): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 674.379s -> 675.422s (0.15%) |
Fixes #117186
r? WaffleLapkin