Rollup merge of #85605 - ptrojahn:closure_struct, r=matthewjasper
Replace Local::new(1) with CAPTURE_STRUCT_LOCAL
This commit is contained in:
commit
ad72247833
6 changed files with 20 additions and 19 deletions
|
@ -4,10 +4,9 @@ use rustc_errors::{Applicability, DiagnosticBuilder};
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{AsyncGeneratorKind, GeneratorKind};
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::mir::{
|
||||
self, AggregateKind, BindingForm, BorrowKind, ClearCrossCrate, ConstraintCategory,
|
||||
FakeReadCause, Local, LocalDecl, LocalInfo, LocalKind, Location, Operand, Place, PlaceRef,
|
||||
FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, Operand, Place, PlaceRef,
|
||||
ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, VarBindingForm,
|
||||
};
|
||||
use rustc_middle::ty::{self, suggest_constraining_type_param, Ty, TypeFoldable};
|
||||
|
@ -1274,7 +1273,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
bug!("temporary or return pointer with a name")
|
||||
}
|
||||
LocalKind::Var => "local variable ",
|
||||
LocalKind::Arg if !self.upvars.is_empty() && local == Local::new(1) => {
|
||||
LocalKind::Arg
|
||||
if !self.upvars.is_empty() && local == ty::CAPTURE_STRUCT_LOCAL =>
|
||||
{
|
||||
"variable captured by `move` "
|
||||
}
|
||||
LocalKind::Arg => "function parameter ",
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::Node;
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::hir::map::Map;
|
||||
use rustc_middle::mir::{Mutability, Place, PlaceRef, ProjectionElem};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
|
@ -115,12 +114,14 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
PlaceRef { local: _, projection: [proj_base @ .., ProjectionElem::Deref] } => {
|
||||
if the_place_err.local == Local::new(1)
|
||||
if the_place_err.local == ty::CAPTURE_STRUCT_LOCAL
|
||||
&& proj_base.is_empty()
|
||||
&& !self.upvars.is_empty()
|
||||
{
|
||||
item_msg = format!("`{}`", access_place_desc.unwrap());
|
||||
debug_assert!(self.body.local_decls[Local::new(1)].ty.is_region_ptr());
|
||||
debug_assert!(
|
||||
self.body.local_decls[ty::CAPTURE_STRUCT_LOCAL].ty.is_region_ptr()
|
||||
);
|
||||
debug_assert!(is_closure_or_generator(
|
||||
Place::ty_from(
|
||||
the_place_err.local,
|
||||
|
@ -478,11 +479,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PlaceRef {
|
||||
local,
|
||||
projection: [ProjectionElem::Deref],
|
||||
// FIXME document what is this 1 magic number about
|
||||
} if local == Local::new(1) && !self.upvars.is_empty() => {
|
||||
PlaceRef { local, projection: [ProjectionElem::Deref] }
|
||||
if local == ty::CAPTURE_STRUCT_LOCAL && !self.upvars.is_empty() =>
|
||||
{
|
||||
self.expected_fn_found_fn_mut_call(&mut err, span, act);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue