Suggest as_ref or as_mut

This commit is contained in:
Michael Goulet 2022-08-06 00:17:16 +00:00
parent 801821d156
commit 84ba2289fd
4 changed files with 5 additions and 5 deletions

View File

@ -1089,7 +1089,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
if is_option_or_result && maybe_reinitialized_locations_is_empty { if is_option_or_result && maybe_reinitialized_locations_is_empty {
err.span_suggestion_verbose( err.span_suggestion_verbose(
fn_call_span.shrink_to_lo(), 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().", "as_ref().",
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );

View File

@ -12,7 +12,7 @@ note: this function takes ownership of the receiver `self`, which moves `*cb`
| |
LL | pub const fn map<U, F>(self, f: F) -> Option<U> LL | pub const fn map<U, F>(self, f: F) -> Option<U>
| ^^^^ | ^^^^
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()); LL | cb.as_ref().map(|cb| cb());
| +++++++++ | +++++++++

View File

@ -13,7 +13,7 @@ note: this function takes ownership of the receiver `self`, which moves `foo`
| |
LL | pub const fn map<U, F>(self, f: F) -> Option<U> LL | pub const fn map<U, F>(self, f: F) -> Option<U>
| ^^^^ | ^^^^
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<Struct> = foo.as_ref().map(|s| bar(&s)); LL | let _x: Option<Struct> = foo.as_ref().map(|s| bar(&s));
| +++++++++ | +++++++++

View File

@ -11,7 +11,7 @@ note: this function takes ownership of the receiver `self`, which moves `selecti
| |
LL | pub const fn unwrap(self) -> T { 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) { 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 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) { LL | if selection.1.as_ref().unwrap().contains(selection.0) {
| +++++++++ | +++++++++