dont suggest changing the mutability of a borrow that comes from a macro - #162638
Open
Albab-Hasan wants to merge 1 commit into
Open
dont suggest changing the mutability of a borrow that comes from a macro#162638Albab-Hasan wants to merge 1 commit into
Albab-Hasan wants to merge 1 commit into
Conversation
the suggestion rewrote the borrow where it was written. for a borrow coming from a macro body that is the macro definition rather than the call site, and for a macro from another crate a file the user cannot edit. it was machine applicable so rustfix would apply it and a macro invoked at more than one call site could stop compiling. gate it on can_be_used_for_suggestions so those cases fall through to the existing note that the trait is implemented for the mutable borrow but not the shared one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
suggest_change_muthas no expansion guard so a borrow written in a macro body gets aMachineApplicablehelp pointing inside the macro or at a file in a dependency. with more than one local call site applying it forces the mutable borrow on every expansion and swapsE0525forE0596. addsspan.can_be_used_for_suggestions()to the guard falling through to the existing note.with a single local call site the suggestion is correct. the span is the defect.
the guard is in the shared helper so it covers all three call sites. full
tests/ui21979 passed 0 failed with zero existing baselines re blessed.r? @chenyukang
cc @davidtwco