Rollup merge of #138926 - nnethercote:less-kw-Empty-rustc_middle, r=lcnr
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. r? `@lcnr`
This commit is contained in:
commit
10debec01a
5 changed files with 11 additions and 20 deletions
|
@ -73,9 +73,7 @@ impl GenericParamDef {
|
||||||
|
|
||||||
pub fn is_anonymous_lifetime(&self) -> bool {
|
pub fn is_anonymous_lifetime(&self) -> bool {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
GenericParamDefKind::Lifetime => {
|
GenericParamDefKind::Lifetime => self.name == kw::UnderscoreLifetime,
|
||||||
self.name == kw::UnderscoreLifetime || self.name == kw::Empty
|
|
||||||
}
|
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -457,7 +457,7 @@ impl EarlyParamRegion {
|
||||||
/// Does this early bound region have a name? Early bound regions normally
|
/// Does this early bound region have a name? Early bound regions normally
|
||||||
/// always have names except when using anonymous lifetimes (`'_`).
|
/// always have names except when using anonymous lifetimes (`'_`).
|
||||||
pub fn has_name(&self) -> bool {
|
pub fn has_name(&self) -> bool {
|
||||||
self.name != kw::UnderscoreLifetime && self.name != kw::Empty
|
self.name != kw::UnderscoreLifetime
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2591,11 +2591,9 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||||
// to fit that into a short string. Hence the recommendation to use
|
// to fit that into a short string. Hence the recommendation to use
|
||||||
// `explain_region()` or `note_and_explain_region()`.
|
// `explain_region()` or `note_and_explain_region()`.
|
||||||
match *region {
|
match *region {
|
||||||
ty::ReEarlyParam(ref data) => {
|
ty::ReEarlyParam(data) => {
|
||||||
if data.name != kw::Empty {
|
p!(write("{}", data.name));
|
||||||
p!(write("{}", data.name));
|
return Ok(());
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ty::ReLateParam(ty::LateParamRegion { kind, .. }) => {
|
ty::ReLateParam(ty::LateParamRegion { kind, .. }) => {
|
||||||
if let Some(name) = kind.get_name() {
|
if let Some(name) = kind.get_name() {
|
||||||
|
@ -2834,7 +2832,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||||
|
|
||||||
(name, ty::BoundRegionKind::Named(CRATE_DEF_ID.to_def_id(), name))
|
(name, ty::BoundRegionKind::Named(CRATE_DEF_ID.to_def_id(), name))
|
||||||
}
|
}
|
||||||
ty::BoundRegionKind::Named(def_id, kw::UnderscoreLifetime | kw::Empty) => {
|
ty::BoundRegionKind::Named(def_id, kw::UnderscoreLifetime) => {
|
||||||
let name = next_name(self);
|
let name = next_name(self);
|
||||||
|
|
||||||
if let Some(lt_idx) = lifetime_idx {
|
if let Some(lt_idx) = lifetime_idx {
|
||||||
|
|
|
@ -400,9 +400,7 @@ impl LateParamRegionKind {
|
||||||
|
|
||||||
pub fn is_named(&self) -> bool {
|
pub fn is_named(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
LateParamRegionKind::Named(_, name) => {
|
LateParamRegionKind::Named(_, name) => name != kw::UnderscoreLifetime,
|
||||||
name != kw::UnderscoreLifetime && name != kw::Empty
|
|
||||||
}
|
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,7 +473,7 @@ impl core::fmt::Debug for BoundRegion {
|
||||||
impl BoundRegionKind {
|
impl BoundRegionKind {
|
||||||
pub fn is_named(&self) -> bool {
|
pub fn is_named(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
BoundRegionKind::Named(_, name) => name != kw::UnderscoreLifetime && name != kw::Empty,
|
BoundRegionKind::Named(_, name) => name != kw::UnderscoreLifetime,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1943,14 +1943,11 @@ fn clean_trait_object_lifetime_bound<'tcx>(
|
||||||
// latter contrary to `clean_middle_region`.
|
// latter contrary to `clean_middle_region`.
|
||||||
match *region {
|
match *region {
|
||||||
ty::ReStatic => Some(Lifetime::statik()),
|
ty::ReStatic => Some(Lifetime::statik()),
|
||||||
ty::ReEarlyParam(region) if region.name != kw::Empty => Some(Lifetime(region.name)),
|
ty::ReEarlyParam(region) => Some(Lifetime(region.name)),
|
||||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. })
|
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. }) => {
|
||||||
if name != kw::Empty =>
|
|
||||||
{
|
|
||||||
Some(Lifetime(name))
|
Some(Lifetime(name))
|
||||||
}
|
}
|
||||||
ty::ReEarlyParam(_)
|
ty::ReBound(..)
|
||||||
| ty::ReBound(..)
|
|
||||||
| ty::ReLateParam(_)
|
| ty::ReLateParam(_)
|
||||||
| ty::ReVar(_)
|
| ty::ReVar(_)
|
||||||
| ty::RePlaceholder(_)
|
| ty::RePlaceholder(_)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue