Skip to content

Commit 9554045

Browse files
committed
Auto merge of rust-lang#107753 - kylematsuda:type-of, r=BoxyUwU
Switch to `EarlyBinder` for `type_of` query Part of the work to finish rust-lang#105779 and implement rust-lang/types-team#78. Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `type_of` query and removes `bound_type_of`. r? `@lcnr`
2 parents cc60e21 + 98c4a49 commit 9554045

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+58
-54
lines changed

clippy_lints/src/casts/cast_ptr_alignment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn is_used_as_unaligned(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
6666
if matches!(name.ident.as_str(), "read_unaligned" | "write_unaligned")
6767
&& let Some(def_id) = cx.typeck_results().type_dependent_def_id(parent.hir_id)
6868
&& let Some(def_id) = cx.tcx.impl_of_method(def_id)
69-
&& cx.tcx.type_of(def_id).is_unsafe_ptr()
69+
&& cx.tcx.type_of(def_id).subst_identity().is_unsafe_ptr()
7070
{
7171
true
7272
} else {

clippy_lints/src/copy_iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'tcx> LateLintPass<'tcx> for CopyIterator {
4343
of_trait: Some(ref trait_ref),
4444
..
4545
}) = item.kind;
46-
let ty = cx.tcx.type_of(item.owner_id);
46+
let ty = cx.tcx.type_of(item.owner_id).subst_identity();
4747
if is_copy(cx, ty);
4848
if let Some(trait_id) = trait_ref.trait_def_id();
4949
if cx.tcx.is_diagnostic_item(sym::Iterator, trait_id);

clippy_lints/src/default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
150150
.fields
151151
.iter()
152152
.all(|field| {
153-
is_copy(cx, cx.tcx.type_of(field.did))
153+
is_copy(cx, cx.tcx.type_of(field.did).subst_identity())
154154
});
155155
if !has_drop(cx, binding_type) || all_fields_are_copy;
156156
then {

clippy_lints/src/default_numeric_fallback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NumericFallbackVisitor<'a, 'tcx> {
167167
.iter()
168168
.find_map(|f_def| {
169169
if f_def.ident(self.cx.tcx) == field.ident
170-
{ Some(self.cx.tcx.type_of(f_def.did)) }
170+
{ Some(self.cx.tcx.type_of(f_def.did).subst_identity()) }
171171
else { None }
172172
});
173173
self.ty_bounds.push(bound.into());

clippy_lints/src/dereference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ fn walk_parents<'tcx>(
735735
span,
736736
..
737737
}) if span.ctxt() == ctxt => {
738-
let ty = cx.tcx.type_of(owner_id.def_id);
738+
let ty = cx.tcx.type_of(owner_id.def_id).subst_identity();
739739
Some(ty_auto_deref_stability(cx, ty, precedence).position_for_result(cx))
740740
},
741741

@@ -771,7 +771,7 @@ fn walk_parents<'tcx>(
771771
}) => variant_of_res(cx, cx.qpath_res(path, *hir_id))
772772
.and_then(|variant| variant.fields.iter().find(|f| f.name == field.ident.name))
773773
.map(|field_def| {
774-
ty_auto_deref_stability(cx, cx.tcx.type_of(field_def.did), precedence).position_for_arg()
774+
ty_auto_deref_stability(cx, cx.tcx.type_of(field_def.did).subst_identity(), precedence).position_for_arg()
775775
}),
776776
_ => None,
777777
},

clippy_lints/src/derivable_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
184184
if let Some(Node::ImplItem(impl_item)) = cx.tcx.hir().find(impl_item_hir);
185185
if let ImplItemKind::Fn(_, b) = &impl_item.kind;
186186
if let Body { value: func_expr, .. } = cx.tcx.hir().body(*b);
187-
if let Some(adt_def) = cx.tcx.type_of(item.owner_id).ty_adt_def();
187+
if let Some(adt_def) = cx.tcx.type_of(item.owner_id).subst_identity().ty_adt_def();
188188
if let attrs = cx.tcx.hir().attrs(item.hir_id());
189189
if !attrs.iter().any(|attr| attr.doc_str().is_some());
190190
if let child_attrs = cx.tcx.hir().attrs(impl_item_hir);

clippy_lints/src/derive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl<'tcx> LateLintPass<'tcx> for Derive {
211211
..
212212
}) = item.kind
213213
{
214-
let ty = cx.tcx.type_of(item.owner_id);
214+
let ty = cx.tcx.type_of(item.owner_id).subst_identity();
215215
let is_automatically_derived = cx.tcx.has_attr(item.owner_id.to_def_id(), sym::automatically_derived);
216216

217217
check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
@@ -347,7 +347,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
347347
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).map_or(false, |impls| {
348348
impls
349349
.iter()
350-
.any(|&id| matches!(cx.tcx.type_of(id).kind(), ty::Adt(adt, _) if ty_adt.did() == adt.did()))
350+
.any(|&id| matches!(cx.tcx.type_of(id).subst_identity().kind(), ty::Adt(adt, _) if ty_adt.did() == adt.did()))
351351
});
352352
if !has_copy_impl {
353353
return;

clippy_lints/src/empty_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for EmptyEnum {
4949
}
5050

5151
if let ItemKind::Enum(..) = item.kind {
52-
let ty = cx.tcx.type_of(item.owner_id);
52+
let ty = cx.tcx.type_of(item.owner_id).subst_identity();
5353
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
5454
if adt.variants().is_empty() {
5555
span_lint_and_help(

clippy_lints/src/enum_clike.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'tcx> LateLintPass<'tcx> for UnportableVariant {
4545
for var in def.variants {
4646
if let Some(anon_const) = &var.disr_expr {
4747
let def_id = cx.tcx.hir().body_owner_def_id(anon_const.body);
48-
let mut ty = cx.tcx.type_of(def_id.to_def_id());
48+
let mut ty = cx.tcx.type_of(def_id.to_def_id()).subst_identity();
4949
let constant = cx
5050
.tcx
5151
.const_eval_poly(def_id.to_def_id())

clippy_lints/src/eta_reduction.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
108108
if check_inputs(cx, body.params, None, args);
109109
let callee_ty = cx.typeck_results().expr_ty_adjusted(callee);
110110
let call_ty = cx.typeck_results().type_dependent_def_id(body.value.hir_id)
111-
.map_or(callee_ty, |id| cx.tcx.type_of(id));
111+
.map_or(callee_ty, |id| cx.tcx.type_of(id).subst_identity());
112112
if check_sig(cx, closure_ty, call_ty);
113113
let substs = cx.typeck_results().node_substs(callee.hir_id);
114114
// This fixes some false positives that I don't entirely understand
@@ -153,7 +153,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
153153
if check_inputs(cx, body.params, Some(receiver), args);
154154
let method_def_id = cx.typeck_results().type_dependent_def_id(body.value.hir_id).unwrap();
155155
let substs = cx.typeck_results().node_substs(body.value.hir_id);
156-
let call_ty = cx.tcx.bound_type_of(method_def_id).subst(cx.tcx, substs);
156+
let call_ty = cx.tcx.type_of(method_def_id).subst(cx.tcx, substs);
157157
if check_sig(cx, closure_ty, call_ty);
158158
then {
159159
span_lint_and_then(cx, REDUNDANT_CLOSURE_FOR_METHOD_CALLS, expr.span, "redundant closure", |diag| {
@@ -233,7 +233,7 @@ fn get_ufcs_type_name<'tcx>(cx: &LateContext<'tcx>, method_def_id: DefId, substs
233233
match assoc_item.container {
234234
ty::TraitContainer => cx.tcx.def_path_str(def_id),
235235
ty::ImplContainer => {
236-
let ty = cx.tcx.type_of(def_id);
236+
let ty = cx.tcx.type_of(def_id).skip_binder();
237237
match ty.kind() {
238238
ty::Adt(adt, _) => cx.tcx.def_path_str(adt.did()),
239239
ty::Array(..)

0 commit comments

Comments
 (0)