Fix invalid mut T suggestion for &mut T in missing lifetime error#151530
Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom Feb 18, 2026
Merged
Fix invalid mut T suggestion for &mut T in missing lifetime error#151530rust-bors[bot] merged 1 commit intorust-lang:mainfrom
mut T suggestion for &mut T in missing lifetime error#151530rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Collaborator
Member
|
@rustbot reroll |
fee1-dead
requested changes
Feb 17, 2026
Member
There was a problem hiding this comment.
Can you add a test for &mut str?
Member
There was a problem hiding this comment.
Would be nice to use let chains if possible here.
Member
Author
There was a problem hiding this comment.
Can you add a test for &mut str?
Okay! In the existing code, &mut str was suggesting str.
sugg_is_str_to_string was handling only the case for the return type, so I fixed this part.
Would be nice to use let chains if possible here.
cool! I've applied your suggestion
f710f8e to
5fa3703
Compare
This comment has been minimized.
This comment has been minimized.
5fa3703 to
d28a731
Compare
Member
Author
|
@bors squash |
* Find ref prefix span for owned suggestions * Improve missing lifetime suggestions for `&mut str`
Contributor
|
🔨 2 commits were squashed into e0d9d47. |
Member
Author
|
@rustbot ready |
Member
|
LGTM, thanks @bors r+ rollup |
Contributor
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Feb 18, 2026
Fix invalid `mut T` suggestion for `&mut T` in missing lifetime error close: rust-lang#150077 When suggesting to return an owned value instead of a borrowed one, the diagnostic was only removing `&` instead of `&mut `, resulting in invalid syntax like `mut T`. This PR fixes the span calculation to properly cover the entire `&mut ` prefix.
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Feb 18, 2026
Fix invalid `mut T` suggestion for `&mut T` in missing lifetime error close: rust-lang#150077 When suggesting to return an owned value instead of a borrowed one, the diagnostic was only removing `&` instead of `&mut `, resulting in invalid syntax like `mut T`. This PR fixes the span calculation to properly cover the entire `&mut ` prefix.
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Feb 18, 2026
Fix invalid `mut T` suggestion for `&mut T` in missing lifetime error close: rust-lang#150077 When suggesting to return an owned value instead of a borrowed one, the diagnostic was only removing `&` instead of `&mut `, resulting in invalid syntax like `mut T`. This PR fixes the span calculation to properly cover the entire `&mut ` prefix.
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 18, 2026
Rollup of 19 pull requests Successful merges: - #145399 (Unify wording of resolve error) - #150473 (tail calls: fix copying non-scalar arguments to callee) - #152637 (Add a note about elided lifetime) - #152657 (std: move `exit` out of PAL) - #152729 (compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness") - #152753 (remove the explicit error for old `rental` versions) - #152758 (Remove ShallowInitBox.) - #151530 (Fix invalid `mut T` suggestion for `&mut T` in missing lifetime error) - #152179 (Add documentation note about signed overflow direction) - #152474 (Implement opt-bisect-limit for MIR) - #152509 (tests/ui/test-attrs: add annotations for reference rules) - #152672 (std: use libc version of `_NSGetArgc`/`_NSGetArgv`) - #152711 (resolve: Disable an assert that no longer holds) - #152732 (add regression test for 147958) - #152745 (Fix ICE in `suggest_param_env_shadowing` with incompatible args) - #152749 (make `rustc_allow_const_fn_unstable` an actual `rustc_attrs` attribute) - #152756 (Miri: recursive validity: also recurse into Boxes) - #152770 (carryless_mul: mention the base) - #152778 (Update tracking issue number for final_associated_functions)
rust-bors bot
pushed a commit
that referenced
this pull request
Feb 18, 2026
Rollup of 20 pull requests Successful merges: - #145399 (Unify wording of resolve error) - #150473 (tail calls: fix copying non-scalar arguments to callee) - #152637 (Add a note about elided lifetime) - #152729 (compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness") - #152751 (Rename dep node "fingerprints" to distinguish key and value hashes) - #152753 (remove the explicit error for old `rental` versions) - #152758 (Remove ShallowInitBox.) - #151530 (Fix invalid `mut T` suggestion for `&mut T` in missing lifetime error) - #152179 (Add documentation note about signed overflow direction) - #152474 (Implement opt-bisect-limit for MIR) - #152509 (tests/ui/test-attrs: add annotations for reference rules) - #152672 (std: use libc version of `_NSGetArgc`/`_NSGetArgv`) - #152711 (resolve: Disable an assert that no longer holds) - #152725 (Rework explanation of CLI lint level flags) - #152732 (add regression test for 147958) - #152745 (Fix ICE in `suggest_param_env_shadowing` with incompatible args) - #152749 (make `rustc_allow_const_fn_unstable` an actual `rustc_attrs` attribute) - #152756 (Miri: recursive validity: also recurse into Boxes) - #152770 (carryless_mul: mention the base) - #152778 (Update tracking issue number for final_associated_functions)
rust-timer
added a commit
that referenced
this pull request
Feb 18, 2026
Rollup merge of #151530 - reddevilmidzy:e0106, r=fee1-dead Fix invalid `mut T` suggestion for `&mut T` in missing lifetime error close: #150077 When suggesting to return an owned value instead of a borrowed one, the diagnostic was only removing `&` instead of `&mut `, resulting in invalid syntax like `mut T`. This PR fixes the span calculation to properly cover the entire `&mut ` prefix.
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.
close: #150077
When suggesting to return an owned value instead of a borrowed one, the diagnostic was only removing
&instead of&mut, resulting in invalid syntax likemut T. This PR fixes the span calculation to properly cover the entire&mutprefix.