Skip to content

Commit 50d0959

Browse files
committed
Remove LocalKind::Var.
1 parent d31386a commit 50d0959

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,16 +1985,18 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
19851985
let (place_desc, note) = if let Some(place_desc) = opt_place_desc {
19861986
let local_kind = if let Some(local) = borrow.borrowed_place.as_local() {
19871987
match self.body.local_kind(local) {
1988-
LocalKind::ReturnPointer | LocalKind::Temp => {
1989-
bug!("temporary or return pointer with a name")
1988+
LocalKind::Temp if self.body.local_decls[local].is_user_variable() => {
1989+
"local variable "
19901990
}
1991-
LocalKind::Var => "local variable ",
19921991
LocalKind::Arg
19931992
if !self.upvars.is_empty() && local == ty::CAPTURE_STRUCT_LOCAL =>
19941993
{
19951994
"variable captured by `move` "
19961995
}
19971996
LocalKind::Arg => "function parameter ",
1997+
LocalKind::ReturnPointer | LocalKind::Temp => {
1998+
bug!("temporary or return pointer with a name")
1999+
}
19982000
}
19992001
} else {
20002002
"local data "
@@ -2008,16 +2010,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
20082010
self.prefixes(borrow.borrowed_place.as_ref(), PrefixSet::All).last().unwrap();
20092011
let local = root_place.local;
20102012
match self.body.local_kind(local) {
2011-
LocalKind::ReturnPointer | LocalKind::Temp => {
2012-
("temporary value".to_string(), "temporary value created here".to_string())
2013-
}
20142013
LocalKind::Arg => (
20152014
"function parameter".to_string(),
20162015
"function parameter borrowed here".to_string(),
20172016
),
2018-
LocalKind::Var => {
2017+
LocalKind::Temp if self.body.local_decls[local].is_user_variable() => {
20192018
("local binding".to_string(), "local binding introduced here".to_string())
20202019
}
2020+
LocalKind::ReturnPointer | LocalKind::Temp => {
2021+
("temporary value".to_string(), "temporary value created here".to_string())
2022+
}
20212023
}
20222024
};
20232025

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
16811681
// - maybe we should make that a warning.
16821682
return;
16831683
}
1684-
LocalKind::Var | LocalKind::Temp => {}
1684+
LocalKind::Temp => {}
16851685
}
16861686

16871687
// When `unsized_fn_params` or `unsized_locals` is enabled, only function calls

compiler/rustc_const_eval/src/transform/check_consts/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ pub mod ty {
704704

705705
fn importance(&self) -> DiagnosticImportance {
706706
match self.0 {
707-
mir::LocalKind::Var | mir::LocalKind::Temp => DiagnosticImportance::Secondary,
707+
mir::LocalKind::Temp => DiagnosticImportance::Secondary,
708708
mir::LocalKind::ReturnPointer | mir::LocalKind::Arg => {
709709
DiagnosticImportance::Primary
710710
}

compiler/rustc_const_eval/src/transform/promote_consts.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
106106
debug!("visit_local: index={:?} context={:?} location={:?}", index, context, location);
107107
// We're only interested in temporaries and the return place
108108
match self.ccx.body.local_kind(index) {
109-
LocalKind::Temp | LocalKind::ReturnPointer => {}
110-
LocalKind::Arg | LocalKind::Var => return,
109+
LocalKind::Arg => return,
110+
LocalKind::Temp if self.ccx.body.local_decls[index].is_user_variable() => return,
111+
LocalKind::ReturnPointer | LocalKind::Temp => {}
111112
}
112113

113114
// Ignore drops, if the temp gets promoted,

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,6 @@ impl<'tcx> Body<'tcx> {
401401
LocalKind::ReturnPointer
402402
} else if index < self.arg_count + 1 {
403403
LocalKind::Arg
404-
} else if self.local_decls[local].is_user_variable() {
405-
LocalKind::Var
406404
} else {
407405
LocalKind::Temp
408406
}
@@ -668,9 +666,7 @@ impl Atom for Local {
668666
/// Classifies locals into categories. See `Body::local_kind`.
669667
#[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable)]
670668
pub enum LocalKind {
671-
/// User-declared variable binding.
672-
Var,
673-
/// Compiler-introduced temporary.
669+
/// User-declared variable binding or compiler-introduced temporary.
674670
Temp,
675671
/// Function argument.
676672
Arg,

compiler/rustc_mir_transform/src/dest_prop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ impl<'tcx> Visitor<'tcx> for FindAssignments<'_, '_, 'tcx> {
788788
fn is_local_required(local: Local, body: &Body<'_>) -> bool {
789789
match body.local_kind(local) {
790790
LocalKind::Arg | LocalKind::ReturnPointer => true,
791-
LocalKind::Var | LocalKind::Temp => false,
791+
LocalKind::Temp => false,
792792
}
793793
}
794794

compiler/rustc_mir_transform/src/nrvo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn local_eligible_for_nrvo(body: &mut mir::Body<'_>) -> Option<Local> {
102102
mir::LocalKind::Arg => return None,
103103

104104
mir::LocalKind::ReturnPointer => bug!("Return place was assigned to itself?"),
105-
mir::LocalKind::Var | mir::LocalKind::Temp => {}
105+
mir::LocalKind::Temp => {}
106106
}
107107

108108
// If multiple different locals are copied to the return place. We can't pick a

0 commit comments

Comments
 (0)