Turn label into structured suggestion for .as_ref() and .as_mut()#153887
Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom Mar 15, 2026
Merged
Turn label into structured suggestion for .as_ref() and .as_mut()#153887rust-bors[bot] merged 1 commit intorust-lang:mainfrom
.as_ref() and .as_mut()#153887rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
Contributor
estebank
commented
Mar 14, 2026
``` error[E0382]: use of moved value: `foo` --> $DIR/as-ref-2.rs:10:14 | LL | let foo = Some(Struct); | --- move occurs because `foo` has type `Option<Struct>`, which does not implement the `Copy` trait LL | let _x: Option<Struct> = foo.map(|s| bar(&s)); | ---------------- `foo` moved due to this method call LL | let _y = foo; | ^^^ value used here after move | note: `Option::<T>::map` takes ownership of the receiver `self`, which moves `foo` --> $SRC_DIR/core/src/option.rs:LL:COL help: consider calling `.as_ref()` to borrow the value's contents | LL | let _x: Option<Struct> = foo.as_ref().map(|s| bar(&s)); | +++++++++ help: consider calling `.as_mut()` to mutably borrow the value's contents | LL | let _x: Option<Struct> = foo.as_mut().map(|s| bar(&s)); | +++++++++ ```
Collaborator
|
r? @mati865 rustbot has assigned @mati865. Use Why was this reviewer chosen?The reviewer was selected based on:
|
JohnTitor
approved these changes
Mar 15, 2026
Contributor
rust-bors bot
pushed a commit
that referenced
this pull request
Mar 15, 2026
Rollup of 6 pull requests Successful merges: - #153870 (docs: remove stale reference to `check_let_chain`) - #153881 (Provide more context on type errors in const context) - #153887 (Turn label into structured suggestion for `.as_ref()` and `.as_mut()`) - #153897 (Use less `#[macro_use]` in the query system) - #153914 (add test for param-env shadowing) - #153917 (compiletest: show rustdoc logs when `--no-capture`)
github-actions bot
pushed a commit
to rust-lang/miri
that referenced
this pull request
Mar 16, 2026
Rollup of 6 pull requests Successful merges: - rust-lang/rust#153870 (docs: remove stale reference to `check_let_chain`) - rust-lang/rust#153881 (Provide more context on type errors in const context) - rust-lang/rust#153887 (Turn label into structured suggestion for `.as_ref()` and `.as_mut()`) - rust-lang/rust#153897 (Use less `#[macro_use]` in the query system) - rust-lang/rust#153914 (add test for param-env shadowing) - rust-lang/rust#153917 (compiletest: show rustdoc logs when `--no-capture`)
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.