1
Fork 0

Rollup merge of #137977 - nnethercote:less-kw-Empty-1, r=spastorino

Reduce `kw::Empty` usage, part 1

This PR fixes some confusing `kw::Empty` usage, fixing a crash test along the way.

r? ```@spastorino```
This commit is contained in:
Matthias Krüger 2025-03-07 19:15:34 +01:00 committed by GitHub
commit 0defc4f27f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 125 additions and 83 deletions

View file

@ -1890,7 +1890,7 @@ impl<'tcx> TyCtxtAt<'tcx> {
pub fn create_def(
self,
parent: LocalDefId,
name: Symbol,
name: Option<Symbol>,
def_kind: DefKind,
) -> TyCtxtFeed<'tcx, LocalDefId> {
let feed = self.tcx.create_def(parent, name, def_kind);
@ -1905,7 +1905,7 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn create_def(
self,
parent: LocalDefId,
name: Symbol,
name: Option<Symbol>,
def_kind: DefKind,
) -> TyCtxtFeed<'tcx, LocalDefId> {
let data = def_kind.def_path_data(name);

View file

@ -569,7 +569,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
// the children of the visible parent (as was done when computing
// `visible_parent_map`), looking for the specific child we currently have and then
// have access to the re-exported name.
DefPathData::TypeNs(ref mut name) if Some(visible_parent) != actual_parent => {
DefPathData::TypeNs(Some(ref mut name)) if Some(visible_parent) != actual_parent => {
// Item might be re-exported several times, but filter for the one
// that's public and whose identifier isn't `_`.
let reexport = self
@ -590,7 +590,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
}
// Re-exported `extern crate` (#43189).
DefPathData::CrateRoot => {
data = DefPathData::TypeNs(self.tcx().crate_name(def_id.krate));
data = DefPathData::TypeNs(Some(self.tcx().crate_name(def_id.krate)));
}
_ => {}
}

View file

@ -23,9 +23,11 @@ fn true_significant_drop_ty<'tcx>(
match key.disambiguated_data.data {
rustc_hir::definitions::DefPathData::CrateRoot => {
name_rev.push(tcx.crate_name(did.krate))
name_rev.push(tcx.crate_name(did.krate));
}
rustc_hir::definitions::DefPathData::TypeNs(symbol) => {
name_rev.push(symbol.unwrap());
}
rustc_hir::definitions::DefPathData::TypeNs(symbol) => name_rev.push(symbol),
_ => return None,
}
if let Some(parent) = key.parent {