Skip to content

Commit 285064c

Browse files
committed
Probe for CompilerDesugaringKind::Async argument
1 parent 4890ae2 commit 285064c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/librustc_mir/borrow_check/mutability_errors.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc::mir::{
77
use rustc::mir::{Terminator, TerminatorKind};
88
use rustc::ty::{self, Const, DefIdTree, Ty, TyS, TyCtxt};
99
use rustc_data_structures::indexed_vec::Idx;
10-
use syntax_pos::Span;
10+
use syntax_pos::{Span, CompilerDesugaringKind};
1111
use syntax_pos::symbol::kw;
1212

1313
use crate::dataflow::move_paths::InitLocation;
@@ -41,14 +41,16 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
4141
);
4242

4343
let mut err;
44-
let mut item_msg;
4544
let reason;
4645
let access_place_desc = self.describe_place(access_place);
4746
debug!("report_mutability_error: access_place_desc={:?}", access_place_desc);
4847

49-
item_msg = match &access_place_desc {
50-
Some(desc) => format!("`{}`", desc),
51-
None => "temporary place".to_string(),
48+
let mut item_msg = match (&access_place_desc, &the_place_err) {
49+
(Some(desc), _) => format!("`{}`", desc),
50+
(None, Place::Base(PlaceBase::Local(local))) if self.mir.local_decls[*local]
51+
.source_info.span.is_compiler_desugaring(CompilerDesugaringKind::Async)
52+
=> "async `fn` parameter".to_string(),
53+
(None, _) => "temporary place".to_string(),
5254
};
5355
match the_place_err {
5456
Place::Base(PlaceBase::Local(local)) => {

src/test/ui/issues/issue-61187.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0596]: cannot borrow temporary place as mutable, as it is not declared as mutable
1+
error[E0596]: cannot borrow async `fn` parameter as mutable, as it is not declared as mutable
22
--> $DIR/issue-61187.rs:8:5
33
|
44
LL | async fn response(data: Vec<u8>) {

0 commit comments

Comments
 (0)