diff options
| author | Kyle Matsuda <kyle.yoshio.matsuda@gmail.com> | 2023-02-06 17:48:12 -0700 |
|---|---|---|
| committer | Kyle Matsuda <kyle.yoshio.matsuda@gmail.com> | 2023-02-16 17:01:52 -0700 |
| commit | d822b97a27e50f5a091d2918f6ff0ffd2d2827f5 (patch) | |
| tree | dd0aae1c09476ba8d74e83999cadc77266ae2c20 /compiler/rustc_lint/src | |
| parent | 9a7cc6c32f1a690f86827e4724bcda85e506ef35 (diff) | |
| download | rust-d822b97a27e50f5a091d2918f6ff0ffd2d2827f5.tar.gz rust-d822b97a27e50f5a091d2918f6ff0ffd2d2827f5.zip | |
change usages of type_of to bound_type_of
Diffstat (limited to 'compiler/rustc_lint/src')
| -rw-r--r-- | compiler/rustc_lint/src/builtin.rs | 28 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/deref_into_dyn_supertrait.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/internal.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/pass_by_value.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/types.rs | 8 |
5 files changed, 24 insertions, 18 deletions
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 34cf17d25a9..36c9390793f 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -182,9 +182,11 @@ impl<'tcx> LateLintPass<'tcx> for BoxPointers { | hir::ItemKind::TyAlias(..) | hir::ItemKind::Enum(..) | hir::ItemKind::Struct(..) - | hir::ItemKind::Union(..) => { - self.check_heap_type(cx, it.span, cx.tcx.type_of(it.owner_id)) - } + | hir::ItemKind::Union(..) => self.check_heap_type( + cx, + it.span, + cx.tcx.bound_type_of(it.owner_id).subst_identity(), + ), _ => (), } @@ -192,7 +194,11 @@ impl<'tcx> LateLintPass<'tcx> for BoxPointers { match it.kind { hir::ItemKind::Struct(ref struct_def, _) | hir::ItemKind::Union(ref struct_def, _) => { for field in struct_def.fields() { - self.check_heap_type(cx, field.span, cx.tcx.type_of(field.def_id)); + self.check_heap_type( + cx, + field.span, + cx.tcx.bound_type_of(field.def_id).subst_identity(), + ); } } _ => (), @@ -589,7 +595,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc { // If the method is an impl for an item with docs_hidden, don't doc. MethodLateContext::PlainImpl => { let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()); - let impl_ty = cx.tcx.type_of(parent); + let impl_ty = cx.tcx.bound_type_of(parent).subst_identity(); let outerdef = match impl_ty.kind() { ty::Adt(def, _) => Some(def.did()), ty::Foreign(def_id) => Some(*def_id), @@ -698,7 +704,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingCopyImplementations { // and recommending Copy might be a bad idea. for field in def.all_fields() { let did = field.did; - if cx.tcx.type_of(did).is_unsafe_ptr() { + if cx.tcx.bound_type_of(did).subst_identity().is_unsafe_ptr() { return; } } @@ -798,7 +804,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDebugImplementations { if self.impling_types.is_none() { let mut impls = LocalDefIdSet::default(); cx.tcx.for_each_impl(debug, |d| { - if let Some(ty_def) = cx.tcx.type_of(d).ty_adt_def() { + if let Some(ty_def) = cx.tcx.bound_type_of(d).subst_identity().ty_adt_def() { if let Some(def_id) = ty_def.did().as_local() { impls.insert(def_id); } @@ -2852,8 +2858,8 @@ impl ClashingExternDeclarations { structurally_same_type_impl( seen_types, cx, - tcx.type_of(a_did), - tcx.type_of(b_did), + tcx.bound_type_of(a_did).subst_identity(), + tcx.bound_type_of(b_did).subst_identity(), ckind, ) }, @@ -2953,8 +2959,8 @@ impl<'tcx> LateLintPass<'tcx> for ClashingExternDeclarations { if let ForeignItemKind::Fn(..) = this_fi.kind { let tcx = cx.tcx; if let Some(existing_did) = self.insert(tcx, this_fi) { - let existing_decl_ty = tcx.type_of(existing_did); - let this_decl_ty = tcx.type_of(this_fi.owner_id); + let existing_decl_ty = tcx.bound_type_of(existing_did).skip_binder(); + let this_decl_ty = tcx.bound_type_of(this_fi.owner_id).subst_identity(); debug!( "ClashingExternDeclarations: Comparing existing {:?}: {:?} to this {:?}: {:?}", existing_did, existing_decl_ty, this_fi.owner_id, this_decl_ty diff --git a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs index dff5a645c17..d26d4f4e8c4 100644 --- a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs +++ b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs @@ -59,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait { // `Deref` is being implemented for `t` if let hir::ItemKind::Impl(impl_) = item.kind && let Some(trait_) = &impl_.of_trait - && let t = cx.tcx.type_of(item.owner_id) + && let t = cx.tcx.bound_type_of(item.owner_id).subst_identity() && let opt_did @ Some(did) = trait_.trait_def_id() && opt_did == cx.tcx.lang_items().deref_trait() // `t` is `dyn t_principal` diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 6cefaea2bc7..72519085187 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -216,7 +216,7 @@ fn is_ty_or_ty_ctxt(cx: &LateContext<'_>, path: &Path<'_>) -> Option<String> { } // Only lint on `&Ty` and `&TyCtxt` if it is used outside of a trait. Res::SelfTyAlias { alias_to: did, is_trait_impl: false, .. } => { - if let ty::Adt(adt, substs) = cx.tcx.type_of(did).kind() { + if let ty::Adt(adt, substs) = cx.tcx.bound_type_of(did).subst_identity().kind() { if let Some(name @ (sym::Ty | sym::TyCtxt)) = cx.tcx.get_diagnostic_name(adt.did()) { // NOTE: This path is currently unreachable as `Ty<'tcx>` is diff --git a/compiler/rustc_lint/src/pass_by_value.rs b/compiler/rustc_lint/src/pass_by_value.rs index 392e13f2fa9..a6e99cdbbad 100644 --- a/compiler/rustc_lint/src/pass_by_value.rs +++ b/compiler/rustc_lint/src/pass_by_value.rs @@ -50,7 +50,7 @@ fn path_for_pass_by_value(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> Option<Stri return Some(format!("{}{}", name, gen_args(cx, path_segment))); } Res::SelfTyAlias { alias_to: did, is_trait_impl: false, .. } => { - if let ty::Adt(adt, substs) = cx.tcx.type_of(did).kind() { + if let ty::Adt(adt, substs) = cx.tcx.bound_type_of(did).subst_identity().kind() { if cx.tcx.has_attr(adt.did(), sym::rustc_pass_by_value) { return Some(cx.tcx.def_path_str_with_substs(adt.did(), substs)); } diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 88c6ea7efb2..01470082727 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -651,7 +651,7 @@ pub fn transparent_newtype_field<'a, 'tcx>( ) -> Option<&'a ty::FieldDef> { let param_env = tcx.param_env(variant.def_id); variant.fields.iter().find(|field| { - let field_ty = tcx.type_of(field.did); + let field_ty = tcx.bound_type_of(field.did).subst_identity(); let is_zst = tcx.layout_of(param_env.and(field_ty)).map_or(false, |layout| layout.is_zst()); !is_zst }) @@ -1240,7 +1240,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { } fn check_foreign_static(&mut self, id: hir::OwnerId, span: Span) { - let ty = self.cx.tcx.type_of(id); + let ty = self.cx.tcx.bound_type_of(id).subst_identity(); self.check_type_for_ffi_and_report_errors(span, ty, true, false); } @@ -1301,7 +1301,7 @@ declare_lint_pass!(VariantSizeDifferences => [VARIANT_SIZE_DIFFERENCES]); impl<'tcx> LateLintPass<'tcx> for VariantSizeDifferences { fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) { if let hir::ItemKind::Enum(ref enum_definition, _) = it.kind { - let t = cx.tcx.type_of(it.owner_id); + let t = cx.tcx.bound_type_of(it.owner_id).subst_identity(); let ty = cx.tcx.erase_regions(t); let Ok(layout) = cx.layout_of(ty) else { return }; let Variants::Multiple { @@ -1421,7 +1421,7 @@ impl InvalidAtomicOrdering { && recognized_names.contains(&method_path.ident.name) && let Some(m_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) && let Some(impl_did) = cx.tcx.impl_of_method(m_def_id) - && let Some(adt) = cx.tcx.type_of(impl_did).ty_adt_def() + && let Some(adt) = cx.tcx.bound_type_of(impl_did).subst_identity().ty_adt_def() // skip extension traits, only lint functions from the standard library && cx.tcx.trait_id_of_impl(impl_did).is_none() && let parent = cx.tcx.parent(adt.did()) |
