Skip to content

Commit 84ba228

Browse files
Suggest as_ref or as_mut
1 parent 801821d commit 84ba228

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10891089
if is_option_or_result && maybe_reinitialized_locations_is_empty {
10901090
err.span_suggestion_verbose(
10911091
fn_call_span.shrink_to_lo(),
1092-
"consider calling `.as_ref()` to borrow the type's contents",
1092+
"consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents",
10931093
"as_ref().",
10941094
Applicability::MachineApplicable,
10951095
);

src/test/ui/borrowck/suggest-as-ref-on-mut-closure.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ note: this function takes ownership of the receiver `self`, which moves `*cb`
1212
|
1313
LL | pub const fn map<U, F>(self, f: F) -> Option<U>
1414
| ^^^^
15-
help: consider calling `.as_ref()` to borrow the type's contents
15+
help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
1616
|
1717
LL | cb.as_ref().map(|cb| cb());
1818
| +++++++++

src/test/ui/suggestions/as-ref-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ note: this function takes ownership of the receiver `self`, which moves `foo`
1313
|
1414
LL | pub const fn map<U, F>(self, f: F) -> Option<U>
1515
| ^^^^
16-
help: consider calling `.as_ref()` to borrow the type's contents
16+
help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
1717
|
1818
LL | let _x: Option<Struct> = foo.as_ref().map(|s| bar(&s));
1919
| +++++++++

src/test/ui/suggestions/option-content-move.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ note: this function takes ownership of the receiver `self`, which moves `selecti
1111
|
1212
LL | pub const fn unwrap(self) -> T {
1313
| ^^^^
14-
help: consider calling `.as_ref()` to borrow the type's contents
14+
help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
1515
|
1616
LL | if selection.1.as_ref().unwrap().contains(selection.0) {
1717
| +++++++++
@@ -29,7 +29,7 @@ note: this function takes ownership of the receiver `self`, which moves `selecti
2929
|
3030
LL | pub fn unwrap(self) -> T
3131
| ^^^^
32-
help: consider calling `.as_ref()` to borrow the type's contents
32+
help: consider calling `.as_ref()` or `.as_mut()` to borrow the type's contents
3333
|
3434
LL | if selection.1.as_ref().unwrap().contains(selection.0) {
3535
| +++++++++

0 commit comments

Comments
 (0)