Skip to content

Commit 042c9ed

Browse files
Replace .type_of() calls with .bound_type_of()
1 parent 83ce044 commit 042c9ed

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

compiler/rustc_infer/src/infer/outlives/components.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ fn compute_components<'tcx>(
169169
out.push(Component::UnresolvedInferenceVariable(infer_ty));
170170
}
171171

172-
ty::TyAlias(def_id, _) => {
173-
compute_components(tcx, tcx.type_of(def_id), out, visited);
172+
ty::TyAlias(def_id, substs) => {
173+
let binder_ty = tcx.bound_type_of(def_id);
174+
let ty = binder_ty.subst(tcx, substs);
175+
compute_components(tcx, ty, out, visited);
174176
}
175177

176178
// Most types do not introduce any region binders, nor

compiler/rustc_lint/src/types.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use rustc_hir::{is_range_literal, Expr, ExprKind, Node};
88
use rustc_macros::LintDiagnostic;
99
use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton};
1010
use rustc_middle::ty::subst::SubstsRef;
11-
use rustc_middle::ty::{self, AdtKind, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable};
11+
use rustc_middle::ty::{
12+
self, AdtKind, DefIdTree, Subst, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
13+
};
1214
use rustc_span::source_map;
1315
use rustc_span::symbol::sym;
1416
use rustc_span::{Span, Symbol, DUMMY_SP};
@@ -1135,14 +1137,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
11351137
}
11361138

11371139
ty::TyAlias(def_id, substs) => {
1138-
for ty in substs.types() {
1139-
let ty = self.cx.tcx.normalize_erasing_regions(self.cx.param_env, ty);
1140-
match self.check_type_for_ffi(cache, ty) {
1141-
FfiSafe => {}
1142-
r => return r,
1143-
};
1144-
}
1145-
let ty = tcx.type_of(def_id);
1140+
let binder_ty = tcx.bound_type_of(def_id);
1141+
let ty = binder_ty.subst(tcx, substs);
11461142
let ty = self.cx.tcx.normalize_erasing_regions(self.cx.param_env, ty);
11471143
self.check_type_for_ffi(cache, ty)
11481144
}

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,12 @@ impl<'tcx> SizeSkeleton<'tcx> {
365365
}
366366
}
367367

368+
ty::TyAlias(def_id, substs) => {
369+
let generic_ty = tcx.bound_type_of(def_id);
370+
let concrete_ty = generic_ty.subst(tcx, substs);
371+
SizeSkeleton::compute(concrete_ty, tcx, param_env)
372+
}
373+
368374
_ => Err(err),
369375
}
370376
}

compiler/rustc_middle/src/ty/util.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,11 @@ impl<'tcx> Ty<'tcx> {
10501050
| ty::Placeholder(_)
10511051
| ty::Infer(_) => false,
10521052

1053-
ty::TyAlias(def_id, _) => tcx.type_of(def_id).is_structural_eq_shallow(tcx),
1053+
ty::TyAlias(def_id, substs) => {
1054+
let binder_ty = tcx.bound_type_of(*def_id);
1055+
let ty = binder_ty.subst(tcx, substs);
1056+
ty.is_structural_eq_shallow(tcx)
1057+
}
10541058

10551059
ty::Foreign(_) | ty::GeneratorWitness(..) | ty::Error(_) => false,
10561060
}

0 commit comments

Comments
 (0)