Don't add redundant help for object safety violations#117200
Don't add redundant help for object safety violations#117200bors merged 2 commits intorust-lang:masterfrom rmehri01:repeated_help
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.
| | -------------- 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.
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.
Ah okay, sorry about that, I pushed a different solution that doesn't change the other tests
|
@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.
This looks fine.
Please add a comment, fix conflicts and use @rustbot review to ask me for review again =)
| 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.
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.
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.
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.
Ah I see, that sounds better, I'll give it a try!
|
@rustbot review |
|
@rustbot author (#117200 (comment)) |
| // 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.
Please move this to the if
|
@rustbot review |
WaffleLapkin
left a comment
There was a problem hiding this comment.
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