Auto merge of #101887 - nnethercote:shrink-Res, r=spastorino

Shrink `hir::def::Res`

r? `@spastorino`
This commit is contained in:
bors
2022-09-29 22:45:24 +00:00
28 changed files with 225 additions and 186 deletions

View File

@@ -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));
}
_ => {}

View File

@@ -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))
}