Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove kw::Empty uses from rustc_middle. #138926

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions compiler/rustc_middle/src/ty/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ impl GenericParamDef {

pub fn is_anonymous_lifetime(&self) -> bool {
match self.kind {
GenericParamDefKind::Lifetime => {
self.name == kw::UnderscoreLifetime || self.name == kw::Empty
}
GenericParamDefKind::Lifetime => self.name == kw::UnderscoreLifetime,
_ => false,
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ impl EarlyParamRegion {
/// Does this early bound region have a name? Early bound regions normally
/// always have names except when using anonymous lifetimes (`'_`).
pub fn has_name(&self) -> bool {
self.name != kw::UnderscoreLifetime && self.name != kw::Empty
self.name != kw::UnderscoreLifetime
}
}

Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2591,11 +2591,9 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
// to fit that into a short string. Hence the recommendation to use
// `explain_region()` or `note_and_explain_region()`.
match *region {
ty::ReEarlyParam(ref data) => {
if data.name != kw::Empty {
p!(write("{}", data.name));
return Ok(());
}
ty::ReEarlyParam(data) => {
p!(write("{}", data.name));
return Ok(());
}
ty::ReLateParam(ty::LateParamRegion { kind, .. }) => {
if let Some(name) = kind.get_name() {
Expand Down Expand Up @@ -2834,7 +2832,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {

(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);

if let Some(lt_idx) = lifetime_idx {
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_middle/src/ty/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,7 @@ impl LateParamRegionKind {

pub fn is_named(&self) -> bool {
match *self {
LateParamRegionKind::Named(_, name) => {
name != kw::UnderscoreLifetime && name != kw::Empty
}
LateParamRegionKind::Named(_, name) => name != kw::UnderscoreLifetime,
_ => false,
}
}
Expand Down Expand Up @@ -475,7 +473,7 @@ impl core::fmt::Debug for BoundRegion {
impl BoundRegionKind {
pub fn is_named(&self) -> bool {
match *self {
BoundRegionKind::Named(_, name) => name != kw::UnderscoreLifetime && name != kw::Empty,
BoundRegionKind::Named(_, name) => name != kw::UnderscoreLifetime,
_ => false,
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1943,14 +1943,11 @@ fn clean_trait_object_lifetime_bound<'tcx>(
// latter contrary to `clean_middle_region`.
match *region {
ty::ReStatic => Some(Lifetime::statik()),
ty::ReEarlyParam(region) if region.name != kw::Empty => Some(Lifetime(region.name)),
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. })
if name != kw::Empty =>
{
ty::ReEarlyParam(region) => Some(Lifetime(region.name)),
ty::ReBound(_, ty::BoundRegion { kind: ty::BoundRegionKind::Named(_, name), .. }) => {
Some(Lifetime(name))
}
ty::ReEarlyParam(_)
| ty::ReBound(..)
ty::ReBound(..)
| ty::ReLateParam(_)
| ty::ReVar(_)
| ty::RePlaceholder(_)
Expand Down
Loading