Skip to content

Commit

Permalink
Probe for CompilerDesugaringKind::Async argument
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed May 26, 2019
1 parent 4890ae2 commit 285064c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/librustc_mir/borrow_check/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustc::mir::{
use rustc::mir::{Terminator, TerminatorKind};
use rustc::ty::{self, Const, DefIdTree, Ty, TyS, TyCtxt};
use rustc_data_structures::indexed_vec::Idx;
use syntax_pos::Span;
use syntax_pos::{Span, CompilerDesugaringKind};
use syntax_pos::symbol::kw;

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

let mut err;
let mut item_msg;
let reason;
let access_place_desc = self.describe_place(access_place);
debug!("report_mutability_error: access_place_desc={:?}", access_place_desc);

item_msg = match &access_place_desc {
Some(desc) => format!("`{}`", desc),
None => "temporary place".to_string(),
let mut item_msg = match (&access_place_desc, &the_place_err) {
(Some(desc), _) => format!("`{}`", desc),
(None, Place::Base(PlaceBase::Local(local))) if self.mir.local_decls[*local]
.source_info.span.is_compiler_desugaring(CompilerDesugaringKind::Async)
=> "async `fn` parameter".to_string(),
(None, _) => "temporary place".to_string(),
};
match the_place_err {
Place::Base(PlaceBase::Local(local)) => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-61187.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0596]: cannot borrow temporary place as mutable, as it is not declared as mutable
error[E0596]: cannot borrow async `fn` parameter as mutable, as it is not declared as mutable
--> $DIR/issue-61187.rs:8:5
|
LL | async fn response(data: Vec<u8>) {
Expand Down

0 comments on commit 285064c

Please sign in to comment.