Auto merge of #113955 - cjgillot:name-apit, r=WaffleLapkin
Pretty-print argument-position impl trait to name it. This removes a corner case. RPIT and TAIT keep having no name, and it would be wrong to use the one in HIR (Ident::empty), so I make this case ICE.
This commit is contained in:
commit
bdb0fa3ee5
4 changed files with 9 additions and 12 deletions
|
@ -1431,12 +1431,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
),
|
),
|
||||||
ImplTraitContext::Universal => {
|
ImplTraitContext::Universal => {
|
||||||
let span = t.span;
|
let span = t.span;
|
||||||
self.create_def(
|
|
||||||
self.current_hir_id_owner.def_id,
|
|
||||||
*def_node_id,
|
|
||||||
DefPathData::ImplTrait,
|
|
||||||
span,
|
|
||||||
);
|
|
||||||
|
|
||||||
// HACK: pprust breaks strings with newlines when the type
|
// HACK: pprust breaks strings with newlines when the type
|
||||||
// gets too long. We don't want these to show up in compiler
|
// gets too long. We don't want these to show up in compiler
|
||||||
|
@ -1447,6 +1441,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
span,
|
span,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self.create_def(
|
||||||
|
self.current_hir_id_owner.def_id,
|
||||||
|
*def_node_id,
|
||||||
|
DefPathData::TypeNs(ident.name),
|
||||||
|
span,
|
||||||
|
);
|
||||||
let (param, bounds, path) = self.lower_universal_param_and_bounds(
|
let (param, bounds, path) = self.lower_universal_param_and_bounds(
|
||||||
*def_node_id,
|
*def_node_id,
|
||||||
span,
|
span,
|
||||||
|
|
|
@ -278,7 +278,8 @@ pub enum DefPathData {
|
||||||
Ctor,
|
Ctor,
|
||||||
/// A constant expression (see `{ast,hir}::AnonConst`).
|
/// A constant expression (see `{ast,hir}::AnonConst`).
|
||||||
AnonConst,
|
AnonConst,
|
||||||
/// An `impl Trait` type node.
|
/// An existential `impl Trait` type node.
|
||||||
|
/// Argument position `impl Trait` have a `TypeNs` with their pretty-printed name.
|
||||||
ImplTrait,
|
ImplTrait,
|
||||||
/// `impl Trait` generated associated type node.
|
/// `impl Trait` generated associated type node.
|
||||||
ImplTraitAssocTy,
|
ImplTraitAssocTy,
|
||||||
|
|
|
@ -2214,10 +2214,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
// The name of a constructor is that of its parent.
|
// The name of a constructor is that of its parent.
|
||||||
rustc_hir::definitions::DefPathData::Ctor => self
|
rustc_hir::definitions::DefPathData::Ctor => self
|
||||||
.opt_item_name(DefId { krate: def_id.krate, index: def_key.parent.unwrap() }),
|
.opt_item_name(DefId { krate: def_id.krate, index: def_key.parent.unwrap() }),
|
||||||
// The name of opaque types only exists in HIR.
|
|
||||||
rustc_hir::definitions::DefPathData::ImplTrait
|
|
||||||
if let Some(def_id) = def_id.as_local() =>
|
|
||||||
self.hir().opt_name(self.hir().local_def_id_to_hir_id(def_id)),
|
|
||||||
_ => def_key.get_opt_name(),
|
_ => def_key.get_opt_name(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ pub(super) fn external_path<'tcx>(
|
||||||
args: ty::Binder<'tcx, GenericArgsRef<'tcx>>,
|
args: ty::Binder<'tcx, GenericArgsRef<'tcx>>,
|
||||||
) -> Path {
|
) -> Path {
|
||||||
let def_kind = cx.tcx.def_kind(did);
|
let def_kind = cx.tcx.def_kind(did);
|
||||||
let name = cx.tcx.item_name(did);
|
let name = cx.tcx.opt_item_name(did).unwrap_or(kw::Empty);
|
||||||
Path {
|
Path {
|
||||||
res: Res::Def(def_kind, did),
|
res: Res::Def(def_kind, did),
|
||||||
segments: thin_vec![PathSegment {
|
segments: thin_vec![PathSegment {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue