diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 098e8de9420f..cc5a3e16c963 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1089,7 +1089,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if is_option_or_result && maybe_reinitialized_locations_is_empty { err.span_suggestion_verbose( fn_call_span.shrink_to_lo(), - "consider calling `.as_ref()` to borrow the type's contents", + "consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents", "as_ref().", Applicability::MachineApplicable, ); diff --git a/src/test/ui/borrowck/suggest-as-ref-on-mut-closure.stderr b/src/test/ui/borrowck/suggest-as-ref-on-mut-closure.stderr index af26169c8068..17546f73836c 100644 --- a/src/test/ui/borrowck/suggest-as-ref-on-mut-closure.stderr +++ b/src/test/ui/borrowck/suggest-as-ref-on-mut-closure.stderr @@ -12,7 +12,7 @@ note: this function takes ownership of the receiver `self`, which moves `*cb` | LL | pub const fn map(self, f: F) -> Option | ^^^^ -help: consider calling `.as_ref()` to borrow the type's contents +help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents | LL | cb.as_ref().map(|cb| cb()); | +++++++++ diff --git a/src/test/ui/suggestions/as-ref-2.stderr b/src/test/ui/suggestions/as-ref-2.stderr index 3c9d0f72abe0..08b9fb1abd79 100644 --- a/src/test/ui/suggestions/as-ref-2.stderr +++ b/src/test/ui/suggestions/as-ref-2.stderr @@ -13,7 +13,7 @@ note: this function takes ownership of the receiver `self`, which moves `foo` | LL | pub const fn map(self, f: F) -> Option | ^^^^ -help: consider calling `.as_ref()` to borrow the type's contents +help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents | LL | let _x: Option = foo.as_ref().map(|s| bar(&s)); | +++++++++ diff --git a/src/test/ui/suggestions/option-content-move.stderr b/src/test/ui/suggestions/option-content-move.stderr index fccfbe1d744c..d008971e4384 100644 --- a/src/test/ui/suggestions/option-content-move.stderr +++ b/src/test/ui/suggestions/option-content-move.stderr @@ -11,7 +11,7 @@ note: this function takes ownership of the receiver `self`, which moves `selecti | LL | pub const fn unwrap(self) -> T { | ^^^^ -help: consider calling `.as_ref()` to borrow the type's contents +help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents | LL | if selection.1.as_ref().unwrap().contains(selection.0) { | +++++++++ @@ -29,7 +29,7 @@ note: this function takes ownership of the receiver `self`, which moves `selecti | LL | pub fn unwrap(self) -> T | ^^^^ -help: consider calling `.as_ref()` to borrow the type's contents +help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents | LL | if selection.1.as_ref().unwrap().contains(selection.0) { | +++++++++