diff options
| author | Michael Goulet <michael@errs.io> | 2022-08-16 03:02:04 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-08-16 03:02:04 +0000 |
| commit | e37565d2db8d7cf92a6d1df535343d4b2881fc35 (patch) | |
| tree | 05d532d6e7218bb8c19c1f886e5744da592508ce /compiler/rustc_borrowck/src | |
| parent | 84ba2289fdd3c41ebbef53de3fdb5035f2e73e60 (diff) | |
| download | rust-e37565d2db8d7cf92a6d1df535343d4b2881fc35.tar.gz rust-e37565d2db8d7cf92a6d1df535343d4b2881fc35.zip | |
Make as_ref suggestion a note
Diffstat (limited to 'compiler/rustc_borrowck/src')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/mod.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index cc5a3e16c96..683084cf09d 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -1086,14 +1086,6 @@ 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()` or `.as_mut()` to borrow the type's contents", - "as_ref().", - Applicability::MachineApplicable, - ); - } // Avoid pointing to the same function in multiple different // error messages. if span != DUMMY_SP && self.fn_self_span_reported.insert(self_arg.span) { @@ -1102,6 +1094,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { &format!("this function takes ownership of the receiver `self`, which moves {}", place_name) ); } + if is_option_or_result && maybe_reinitialized_locations_is_empty { + err.span_label( + var_span, + "help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents", + ); + } } // Other desugarings takes &self, which cannot cause a move _ => {} |
