Skip to content

Commit 01ec436

Browse files
committed
Remove kw::Empty uses from rustc_middle.
There are several places in `rustc_middle` that check for an empty lifetime name. These checks appear to be totally unnecessary, because empty lifetime names aren't produced here. (Empty lifetime names *are* possible in `hir::Lifetime`. Perhaps there was some confusion between it and the `rustc_middle` types?) This commit removes the `kw::Empty` checks.
1 parent aa8f0fd commit 01ec436

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

compiler/rustc_middle/src/ty/generics.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ impl GenericParamDef {
7373

7474
pub fn is_anonymous_lifetime(&self) -> bool {
7575
match self.kind {
76-
GenericParamDefKind::Lifetime => {
77-
self.name == kw::UnderscoreLifetime || self.name == kw::Empty
78-
}
76+
GenericParamDefKind::Lifetime => self.name == kw::UnderscoreLifetime,
7977
_ => false,
8078
}
8179
}

compiler/rustc_middle/src/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl EarlyParamRegion {
457457
/// Does this early bound region have a name? Early bound regions normally
458458
/// always have names except when using anonymous lifetimes (`'_`).
459459
pub fn has_name(&self) -> bool {
460-
self.name != kw::UnderscoreLifetime && self.name != kw::Empty
460+
self.name != kw::UnderscoreLifetime
461461
}
462462
}
463463

compiler/rustc_middle/src/ty/print/pretty.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -2591,11 +2591,9 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
25912591
// to fit that into a short string. Hence the recommendation to use
25922592
// `explain_region()` or `note_and_explain_region()`.
25932593
match *region {
2594-
ty::ReEarlyParam(ref data) => {
2595-
if data.name != kw::Empty {
2596-
p!(write("{}", data.name));
2597-
return Ok(());
2598-
}
2594+
ty::ReEarlyParam(data) => {
2595+
p!(write("{}", data.name));
2596+
return Ok(());
25992597
}
26002598
ty::ReLateParam(ty::LateParamRegion { kind, .. }) => {
26012599
if let Some(name) = kind.get_name() {
@@ -2834,7 +2832,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
28342832

28352833
(name, ty::BoundRegionKind::Named(CRATE_DEF_ID.to_def_id(), name))
28362834
}
2837-
ty::BoundRegionKind::Named(def_id, kw::UnderscoreLifetime | kw::Empty) => {
2835+
ty::BoundRegionKind::Named(def_id, kw::UnderscoreLifetime) => {
28382836
let name = next_name(self);
28392837

28402838
if let Some(lt_idx) = lifetime_idx {

compiler/rustc_middle/src/ty/region.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,7 @@ impl LateParamRegionKind {
400400

401401
pub fn is_named(&self) -> bool {
402402
match *self {
403-
LateParamRegionKind::Named(_, name) => {
404-
name != kw::UnderscoreLifetime && name != kw::Empty
405-
}
403+
LateParamRegionKind::Named(_, name) => name != kw::UnderscoreLifetime,
406404
_ => false,
407405
}
408406
}
@@ -475,7 +473,7 @@ impl core::fmt::Debug for BoundRegion {
475473
impl BoundRegionKind {
476474
pub fn is_named(&self) -> bool {
477475
match *self {
478-
BoundRegionKind::Named(_, name) => name != kw::UnderscoreLifetime && name != kw::Empty,
476+
BoundRegionKind::Named(_, name) => name != kw::UnderscoreLifetime,
479477
_ => false,
480478
}
481479
}

0 commit comments

Comments
 (0)