-
Notifications
You must be signed in to change notification settings - Fork 13k
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
unsafe_op_in_unsafe_fn suggestion overlaps when used in a macro #123304
Comments
Another option I am considering is to have rustfix ignore a top-level diagnostic if all of its suggestions are identical to another top-level diagnostic. That might take a bit of reworking of how rustfix collects suggestions, though. I'm also trying to think of what problems that might introduce, though I think it should be safe. |
Just looked into the given reproduction. It seems that the duplications happens between different diagnostic messages. I am not sure if such a fix should be in rustfix. Rustfix only deal with one diagnostic at a time. Perhaps we need to get it done at a higher level like here in Cargo? Alternatively, we can have |
Is there any situation that we'll get identical machine applicable suggestions, and they are all necessary not duplicated? |
I brought this up in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/overlapping.20suggestions, and I and others couldn't think of any concerns with that. |
It looks like in rust-lang/cargo#13728 that you maybe figured this out? The |
I didn't fully get it. Did you mean rust-lang/cargo#13728 addresses it on Cargo side, not inside |
Oh, indeed, I was thinking of The issue with doing it on the cargo side is that we also need to update Is there some reason cargo doesn't use |
rust-lang/cargo#13728 has been merged. |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, I just caught up on the discussion here. It looks like this can be closed then, now that rust-lang/cargo#13728 is merged? |
I've verified that the reported issue no longer occurs, and the migration behaves correctly with |
The following example triggers the
unsafe_op_in_unsafe_fn
lint twice in the same position:This causes
cargo fix
to apply both suggestions which ends up with:which triggers the
unused_unsafe
lint.Would it be possible to avoid duplicate suggestions when used in a macro?
cc @asquared31415
I suspect this may be encountered frequently with the 2024 edition migration (crater run is pending in #122960). Although it isn't too much of a problem to repair, a frequently used macro could have many unsafe blocks, which could be confusing.
The text was updated successfully, but these errors were encountered: