Remove LocalKind::Var.
This commit is contained in:
parent
d31386a52b
commit
50d0959a2f
7 changed files with 17 additions and 18 deletions
|
@ -1985,16 +1985,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
let (place_desc, note) = if let Some(place_desc) = opt_place_desc {
|
||||
let local_kind = if let Some(local) = borrow.borrowed_place.as_local() {
|
||||
match self.body.local_kind(local) {
|
||||
LocalKind::ReturnPointer | LocalKind::Temp => {
|
||||
bug!("temporary or return pointer with a name")
|
||||
LocalKind::Temp if self.body.local_decls[local].is_user_variable() => {
|
||||
"local variable "
|
||||
}
|
||||
LocalKind::Var => "local variable ",
|
||||
LocalKind::Arg
|
||||
if !self.upvars.is_empty() && local == ty::CAPTURE_STRUCT_LOCAL =>
|
||||
{
|
||||
"variable captured by `move` "
|
||||
}
|
||||
LocalKind::Arg => "function parameter ",
|
||||
LocalKind::ReturnPointer | LocalKind::Temp => {
|
||||
bug!("temporary or return pointer with a name")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
"local data "
|
||||
|
@ -2008,16 +2010,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||
self.prefixes(borrow.borrowed_place.as_ref(), PrefixSet::All).last().unwrap();
|
||||
let local = root_place.local;
|
||||
match self.body.local_kind(local) {
|
||||
LocalKind::ReturnPointer | LocalKind::Temp => {
|
||||
("temporary value".to_string(), "temporary value created here".to_string())
|
||||
}
|
||||
LocalKind::Arg => (
|
||||
"function parameter".to_string(),
|
||||
"function parameter borrowed here".to_string(),
|
||||
),
|
||||
LocalKind::Var => {
|
||||
LocalKind::Temp if self.body.local_decls[local].is_user_variable() => {
|
||||
("local binding".to_string(), "local binding introduced here".to_string())
|
||||
}
|
||||
LocalKind::ReturnPointer | LocalKind::Temp => {
|
||||
("temporary value".to_string(), "temporary value created here".to_string())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1681,7 +1681,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
// - maybe we should make that a warning.
|
||||
return;
|
||||
}
|
||||
LocalKind::Var | LocalKind::Temp => {}
|
||||
LocalKind::Temp => {}
|
||||
}
|
||||
|
||||
// When `unsized_fn_params` or `unsized_locals` is enabled, only function calls
|
||||
|
|
|
@ -704,7 +704,7 @@ pub mod ty {
|
|||
|
||||
fn importance(&self) -> DiagnosticImportance {
|
||||
match self.0 {
|
||||
mir::LocalKind::Var | mir::LocalKind::Temp => DiagnosticImportance::Secondary,
|
||||
mir::LocalKind::Temp => DiagnosticImportance::Secondary,
|
||||
mir::LocalKind::ReturnPointer | mir::LocalKind::Arg => {
|
||||
DiagnosticImportance::Primary
|
||||
}
|
||||
|
|
|
@ -106,8 +106,9 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
|
|||
debug!("visit_local: index={:?} context={:?} location={:?}", index, context, location);
|
||||
// We're only interested in temporaries and the return place
|
||||
match self.ccx.body.local_kind(index) {
|
||||
LocalKind::Temp | LocalKind::ReturnPointer => {}
|
||||
LocalKind::Arg | LocalKind::Var => return,
|
||||
LocalKind::Arg => return,
|
||||
LocalKind::Temp if self.ccx.body.local_decls[index].is_user_variable() => return,
|
||||
LocalKind::ReturnPointer | LocalKind::Temp => {}
|
||||
}
|
||||
|
||||
// Ignore drops, if the temp gets promoted,
|
||||
|
|
|
@ -401,8 +401,6 @@ impl<'tcx> Body<'tcx> {
|
|||
LocalKind::ReturnPointer
|
||||
} else if index < self.arg_count + 1 {
|
||||
LocalKind::Arg
|
||||
} else if self.local_decls[local].is_user_variable() {
|
||||
LocalKind::Var
|
||||
} else {
|
||||
LocalKind::Temp
|
||||
}
|
||||
|
@ -668,9 +666,7 @@ impl Atom for Local {
|
|||
/// Classifies locals into categories. See `Body::local_kind`.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable)]
|
||||
pub enum LocalKind {
|
||||
/// User-declared variable binding.
|
||||
Var,
|
||||
/// Compiler-introduced temporary.
|
||||
/// User-declared variable binding or compiler-introduced temporary.
|
||||
Temp,
|
||||
/// Function argument.
|
||||
Arg,
|
||||
|
|
|
@ -788,7 +788,7 @@ impl<'tcx> Visitor<'tcx> for FindAssignments<'_, '_, 'tcx> {
|
|||
fn is_local_required(local: Local, body: &Body<'_>) -> bool {
|
||||
match body.local_kind(local) {
|
||||
LocalKind::Arg | LocalKind::ReturnPointer => true,
|
||||
LocalKind::Var | LocalKind::Temp => false,
|
||||
LocalKind::Temp => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ fn local_eligible_for_nrvo(body: &mut mir::Body<'_>) -> Option<Local> {
|
|||
mir::LocalKind::Arg => return None,
|
||||
|
||||
mir::LocalKind::ReturnPointer => bug!("Return place was assigned to itself?"),
|
||||
mir::LocalKind::Var | mir::LocalKind::Temp => {}
|
||||
mir::LocalKind::Temp => {}
|
||||
}
|
||||
|
||||
// If multiple different locals are copied to the return place. We can't pick a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue