Auto merge of #101887 - nnethercote:shrink-Res, r=spastorino
Shrink `hir::def::Res` r? `@spastorino`
This commit is contained in:
commit
1bb8d276c9
28 changed files with 225 additions and 186 deletions
|
@ -1902,7 +1902,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
// Find the type of the associated item, and the trait where the associated
|
||||
// item is declared.
|
||||
let bound = match (&qself_ty.kind(), qself_res) {
|
||||
(_, Res::SelfTy { trait_: Some(_), alias_to: Some((impl_def_id, _)) }) => {
|
||||
(_, Res::SelfTyAlias { alias_to: impl_def_id, is_trait_impl: true, .. }) => {
|
||||
// `Self` in an impl of a trait -- we have a concrete self type and a
|
||||
// trait reference.
|
||||
let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else {
|
||||
|
@ -1921,8 +1921,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
}
|
||||
(
|
||||
&ty::Param(_),
|
||||
Res::SelfTy { trait_: Some(param_did), alias_to: None }
|
||||
| Res::Def(DefKind::TyParam, param_did),
|
||||
Res::SelfTyParam { trait_: param_did } | Res::Def(DefKind::TyParam, param_did),
|
||||
) => self.find_bound_for_assoc_item(param_did.expect_local(), assoc_ident, span)?,
|
||||
_ => {
|
||||
let reported = if variant_resolution.is_some() {
|
||||
|
@ -2417,7 +2416,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
|
||||
tcx.mk_ty_param(index, tcx.hir().ty_param_name(def_id))
|
||||
}
|
||||
Res::SelfTy { trait_: Some(_), alias_to: None } => {
|
||||
Res::SelfTyParam { .. } => {
|
||||
// `Self` in trait or type alias.
|
||||
assert_eq!(opt_self_ty, None);
|
||||
self.prohibit_generics(path.segments.iter(), |err| {
|
||||
|
@ -2432,7 +2431,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
});
|
||||
tcx.types.self_param
|
||||
}
|
||||
Res::SelfTy { trait_: _, alias_to: Some((def_id, forbid_generic)) } => {
|
||||
Res::SelfTyAlias { alias_to: def_id, forbid_generic, .. } => {
|
||||
// `Self` in impl (we know the concrete type).
|
||||
assert_eq!(opt_self_ty, None);
|
||||
// Try to evaluate any array length constants.
|
||||
|
|
|
@ -609,9 +609,12 @@ pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
|
|||
fn visit_ty(&mut self, arg: &'tcx hir::Ty<'tcx>) {
|
||||
match arg.kind {
|
||||
hir::TyKind::Path(hir::QPath::Resolved(None, path)) => match &path.segments {
|
||||
[PathSegment { res: Res::SelfTy { trait_: _, alias_to: impl_ref }, .. }] => {
|
||||
let impl_ty_name =
|
||||
impl_ref.map(|(def_id, _)| self.tcx.def_path_str(def_id));
|
||||
[PathSegment { res: Res::SelfTyParam { .. }, .. }] => {
|
||||
let impl_ty_name = None;
|
||||
self.selftys.push((path.span, impl_ty_name));
|
||||
}
|
||||
[PathSegment { res: Res::SelfTyAlias { alias_to: def_id, .. }, .. }] => {
|
||||
let impl_ty_name = Some(self.tcx.def_path_str(*def_id));
|
||||
self.selftys.push((path.span, impl_ty_name));
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -1199,7 +1199,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
_ => bug!("unexpected type: {:?}", ty),
|
||||
},
|
||||
Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
|
||||
| Res::SelfTy { .. } => match ty.kind() {
|
||||
| Res::SelfTyParam { .. }
|
||||
| Res::SelfTyAlias { .. } => match ty.kind() {
|
||||
ty::Adt(adt, substs) if !adt.is_enum() => {
|
||||
Some((adt.non_enum_variant(), adt.did(), substs))
|
||||
}
|
||||
|
|
|
@ -560,7 +560,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
|
|||
Res::Def(DefKind::Ctor(CtorOf::Struct, ..), _)
|
||||
| Res::Def(DefKind::Struct | DefKind::Union | DefKind::TyAlias | DefKind::AssocTy, _)
|
||||
| Res::SelfCtor(..)
|
||||
| Res::SelfTy { .. } => {
|
||||
| Res::SelfTyParam { .. }
|
||||
| Res::SelfTyAlias { .. } => {
|
||||
// Structs and Unions have only have one variant.
|
||||
Ok(VariantIdx::new(0))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue