From be4b0261c2d1beb2676bab585556b8893d1cee1a Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sun, 3 Nov 2024 21:47:56 +0000 Subject: [PATCH] ty::KContainer -> ty::AssocItemContainer::K --- .../rustc_codegen_ssa/src/codegen_attrs.rs | 2 +- .../src/check/compare_impl_item.rs | 10 ++++------ .../rustc_hir_analysis/src/check/wfcheck.rs | 8 +++++--- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 4 ++-- .../src/fn_ctxt/suggestions.rs | 2 +- compiler/rustc_hir_typeck/src/lib.rs | 2 +- compiler/rustc_hir_typeck/src/method/probe.rs | 4 ++-- compiler/rustc_lint/src/nonstandard_style.rs | 4 ++-- compiler/rustc_metadata/src/rmeta/encoder.rs | 10 +++++----- compiler/rustc_metadata/src/rmeta/table.rs | 4 ++-- compiler/rustc_middle/src/ty/assoc.rs | 12 +++++------ compiler/rustc_middle/src/ty/instance.rs | 2 +- compiler/rustc_middle/src/ty/mod.rs | 4 +--- compiler/rustc_middle/src/util/call_kind.rs | 4 ++-- .../nice_region_error/static_impl_trait.rs | 4 ++-- compiler/rustc_ty_utils/src/assoc.rs | 8 ++++---- compiler/rustc_ty_utils/src/ty.rs | 2 +- src/librustdoc/clean/mod.rs | 20 +++++++++---------- src/librustdoc/clean/types.rs | 4 ++-- .../clippy/clippy_lints/src/missing_inline.rs | 6 +++--- src/tools/clippy/clippy_utils/src/lib.rs | 4 ++-- 21 files changed, 59 insertions(+), 61 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index a5bd3adbcdd..8f3592090c6 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -710,7 +710,7 @@ pub fn check_tied_features( /// applied to the method prototype. fn should_inherit_track_caller(tcx: TyCtxt<'_>, def_id: DefId) -> bool { if let Some(impl_item) = tcx.opt_associated_item(def_id) - && let ty::AssocItemContainer::ImplContainer = impl_item.container + && let ty::AssocItemContainer::Impl = impl_item.container && let Some(trait_item) = impl_item.trait_item_def_id { return tcx.codegen_fn_attrs(trait_item).flags.intersects(CodegenFnAttrFlags::TRACK_CALLER); diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index dee76c66663..c62028616e1 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -1189,8 +1189,8 @@ fn compare_self_type<'tcx>( let self_string = |method: ty::AssocItem| { let untransformed_self_ty = match method.container { - ty::ImplContainer => impl_trait_ref.self_ty(), - ty::TraitContainer => tcx.types.self_param, + ty::AssocItemContainer::Impl => impl_trait_ref.self_ty(), + ty::AssocItemContainer::Trait => tcx.types.self_param, }; let self_arg_ty = tcx.fn_sig(method.def_id).instantiate_identity().input(0); let param_env = ty::ParamEnv::reveal_all(); @@ -2224,10 +2224,8 @@ fn param_env_with_gat_bounds<'tcx>( for impl_ty in impl_tys_to_install { let trait_ty = match impl_ty.container { - ty::AssocItemContainer::TraitContainer => impl_ty, - ty::AssocItemContainer::ImplContainer => { - tcx.associated_item(impl_ty.trait_item_def_id.unwrap()) - } + ty::AssocItemContainer::Trait => impl_ty, + ty::AssocItemContainer::Impl => tcx.associated_item(impl_ty.trait_item_def_id.unwrap()), }; let mut bound_vars: smallvec::SmallVec<[ty::BoundVariableKind; 8]> = diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index bf7cc713841..3a6ea545741 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1048,8 +1048,10 @@ fn check_associated_item( .coherent_trait(tcx.parent(item.trait_item_def_id.unwrap_or(item_id.into())))?; let self_ty = match item.container { - ty::TraitContainer => tcx.types.self_param, - ty::ImplContainer => tcx.type_of(item.container_id(tcx)).instantiate_identity(), + ty::AssocItemContainer::Trait => tcx.types.self_param, + ty::AssocItemContainer::Impl => { + tcx.type_of(item.container_id(tcx)).instantiate_identity() + } }; match item.kind { @@ -1072,7 +1074,7 @@ fn check_associated_item( check_method_receiver(wfcx, hir_sig, item, self_ty) } ty::AssocKind::Type => { - if let ty::AssocItemContainer::TraitContainer = item.container { + if let ty::AssocItemContainer::Trait = item.container { check_associated_type_bounds(wfcx, item, span) } if item.defaultness(tcx).has_value() { diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 2753bee499b..f026613f4b5 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1025,7 +1025,7 @@ pub(crate) fn instantiate_value_path( let container_id = assoc_item.container_id(tcx); debug!(?def_id, ?container, ?container_id); match container { - ty::TraitContainer => { + ty::AssocItemContainer::Trait => { if let Err(e) = callee::check_legal_trait_for_method_call( tcx, path_span, @@ -1037,7 +1037,7 @@ pub(crate) fn instantiate_value_path( self.set_tainted_by_errors(e); } } - ty::ImplContainer => { + ty::AssocItemContainer::Impl => { if segments.len() == 1 { // `::assoc` will end up here, and so // can `T::assoc`. If this came from an diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 3f703c2fcf6..23842b3014b 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -1796,7 +1796,7 @@ pub(crate) fn note_type_is_not_clone( false, |did| { let assoc_item = self.tcx.associated_item(did); - assoc_item.container == ty::AssocItemContainer::TraitContainer + assoc_item.container == ty::AssocItemContainer::Trait && assoc_item.container_id(self.tcx) == clone_trait_did }, ) diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index d8b63eef577..f5987a11fa5 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -239,7 +239,7 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti let expected_type = if let Some(&hir::Ty { kind: hir::TyKind::Infer, span, .. }) = node.ty() { if let Some(item) = tcx.opt_associated_item(def_id.into()) && let ty::AssocKind::Const = item.kind - && let ty::ImplContainer = item.container + && let ty::AssocItemContainer::Impl = item.container && let Some(trait_item_def_id) = item.trait_item_def_id { let impl_def_id = item.container_id(tcx); diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index eb5581f421b..640729576fc 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -480,7 +480,7 @@ pub(crate) fn probe_op( ProbeScope::Single(def_id) => { let item = self.tcx.associated_item(def_id); // FIXME(fn_delegation): Delegation to inherent methods is not yet supported. - assert_eq!(item.container, AssocItemContainer::TraitContainer); + assert_eq!(item.container, AssocItemContainer::Trait); let trait_def_id = self.tcx.parent(def_id); let trait_span = self.tcx.def_span(trait_def_id); @@ -1406,7 +1406,7 @@ pub(crate) fn maybe_emit_unstable_name_collision_hint( tcx.def_path_str(self.item.def_id), )); } - (ty::AssocKind::Const, ty::AssocItemContainer::TraitContainer) => { + (ty::AssocKind::Const, ty::AssocItemContainer::Trait) => { let def_id = self.item.container_id(tcx); lint.span_suggestion( span, diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index c5f0b94327f..4d8ebf2909e 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -26,8 +26,8 @@ pub(crate) enum MethodLateContext { pub(crate) fn method_context(cx: &LateContext<'_>, id: LocalDefId) -> MethodLateContext { let item = cx.tcx.associated_item(id); match item.container { - ty::TraitContainer => MethodLateContext::TraitAutoImpl, - ty::ImplContainer => match cx.tcx.impl_trait_ref(item.container_id(cx.tcx)) { + ty::AssocItemContainer::Trait => MethodLateContext::TraitAutoImpl, + ty::AssocItemContainer::Impl => match cx.tcx.impl_trait_ref(item.container_id(cx.tcx)) { Some(_) => MethodLateContext::TraitImpl, None => MethodLateContext::PlainImpl, }, diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 7277039bb7d..b5391247cea 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1203,8 +1203,8 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) -> DefKind::AssocTy => { let assoc_item = tcx.associated_item(def_id); match assoc_item.container { - ty::AssocItemContainer::ImplContainer => true, - ty::AssocItemContainer::TraitContainer => assoc_item.defaultness(tcx).has_value(), + ty::AssocItemContainer::Impl => true, + ty::AssocItemContainer::Trait => assoc_item.defaultness(tcx).has_value(), } } DefKind::TyParam => { @@ -1336,7 +1336,7 @@ fn should_encode_const(def_kind: DefKind) -> bool { fn should_encode_fn_impl_trait_in_trait<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool { if let Some(assoc_item) = tcx.opt_associated_item(def_id) - && assoc_item.container == ty::AssocItemContainer::TraitContainer + && assoc_item.container == ty::AssocItemContainer::Trait && assoc_item.kind == ty::AssocKind::Fn { true @@ -1649,7 +1649,7 @@ fn encode_info_for_assoc_item(&mut self, def_id: DefId) { self.tables.assoc_container.set_some(def_id.index, item.container); match item.container { - AssocItemContainer::TraitContainer => { + AssocItemContainer::Trait => { if let ty::AssocKind::Type = item.kind { self.encode_explicit_item_bounds(def_id); self.encode_explicit_item_super_predicates(def_id); @@ -1659,7 +1659,7 @@ fn encode_info_for_assoc_item(&mut self, def_id: DefId) { } } } - AssocItemContainer::ImplContainer => { + AssocItemContainer::Impl => { if let Some(trait_item_def_id) = item.trait_item_def_id { self.tables.trait_item_def_id.set_some(def_id.index, trait_item_def_id.into()); } diff --git a/compiler/rustc_metadata/src/rmeta/table.rs b/compiler/rustc_metadata/src/rmeta/table.rs index 3a6f3543317..63abd2be9a5 100644 --- a/compiler/rustc_metadata/src/rmeta/table.rs +++ b/compiler/rustc_metadata/src/rmeta/table.rs @@ -223,8 +223,8 @@ impl FixedSizeEncoding for Option<$ty> { fixed_size_enum! { ty::AssocItemContainer { - ( TraitContainer ) - ( ImplContainer ) + ( Trait ) + ( Impl ) } } diff --git a/compiler/rustc_middle/src/ty/assoc.rs b/compiler/rustc_middle/src/ty/assoc.rs index 3137fe9bd1d..62157d9bfe2 100644 --- a/compiler/rustc_middle/src/ty/assoc.rs +++ b/compiler/rustc_middle/src/ty/assoc.rs @@ -10,8 +10,8 @@ #[derive(Clone, Copy, PartialEq, Eq, Debug, HashStable, Hash, Encodable, Decodable)] pub enum AssocItemContainer { - TraitContainer, - ImplContainer, + Trait, + Impl, } /// Information about an associated item @@ -63,16 +63,16 @@ pub fn container_id(&self, tcx: TyCtxt<'_>) -> DefId { #[inline] pub fn trait_container(&self, tcx: TyCtxt<'_>) -> Option { match self.container { - AssocItemContainer::ImplContainer => None, - AssocItemContainer::TraitContainer => Some(tcx.parent(self.def_id)), + AssocItemContainer::Impl => None, + AssocItemContainer::Trait => Some(tcx.parent(self.def_id)), } } #[inline] pub fn impl_container(&self, tcx: TyCtxt<'_>) -> Option { match self.container { - AssocItemContainer::ImplContainer => Some(tcx.parent(self.def_id)), - AssocItemContainer::TraitContainer => None, + AssocItemContainer::Impl => Some(tcx.parent(self.def_id)), + AssocItemContainer::Trait => None, } } diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index e237d382900..7ee13bc1725 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -690,7 +690,7 @@ pub fn expect_resolve_for_vtable( && !matches!( tcx.opt_associated_item(def), Some(ty::AssocItem { - container: ty::AssocItemContainer::TraitContainer, + container: ty::AssocItemContainer::Trait, .. }) ) diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 6d7ed56263b..df47ac2099a 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -55,9 +55,7 @@ pub use vtable::*; use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir}; -pub use self::AssocItemContainer::*; pub use self::BorrowKind::*; -pub use self::IntVarValue::*; pub use self::closure::{ BorrowKind, CAPTURE_STRUCT_LOCAL, CaptureInfo, CapturedPlace, ClosureTypeInfo, MinCaptureInformationMap, MinCaptureList, RootVariableMinCaptureList, UpvarCapture, UpvarId, @@ -2074,7 +2072,7 @@ pub fn impl_method_has_trait_impl_trait_tys(self, def_id: DefId) -> bool { let Some(item) = self.opt_associated_item(def_id) else { return false; }; - if item.container != ty::AssocItemContainer::ImplContainer { + if item.container != ty::AssocItemContainer::Impl { return false; } diff --git a/compiler/rustc_middle/src/util/call_kind.rs b/compiler/rustc_middle/src/util/call_kind.rs index fe30cbfae4e..ed27a880562 100644 --- a/compiler/rustc_middle/src/util/call_kind.rs +++ b/compiler/rustc_middle/src/util/call_kind.rs @@ -72,8 +72,8 @@ pub fn call_kind<'tcx>( let parent = tcx.opt_associated_item(method_did).and_then(|assoc| { let container_id = assoc.container_id(tcx); match assoc.container { - AssocItemContainer::ImplContainer => tcx.trait_id_of_impl(container_id), - AssocItemContainer::TraitContainer => Some(container_id), + AssocItemContainer::Impl => tcx.trait_id_of_impl(container_id), + AssocItemContainer::Trait => Some(container_id), } }); diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs index 2b19db2c14e..808e6a50d85 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs @@ -59,11 +59,11 @@ pub(super) fn try_report_static_impl_trait(&self) -> Option { let simple_ident = param.param.pat.simple_ident(); let (has_impl_path, impl_path) = match ctxt.assoc_item.container { - AssocItemContainer::TraitContainer => { + AssocItemContainer::Trait => { let id = ctxt.assoc_item.container_id(tcx); (true, tcx.def_path_str(id)) } - AssocItemContainer::ImplContainer => (false, String::new()), + AssocItemContainer::Impl => (false, String::new()), }; let mut err = self.tcx().dcx().create_err(ButCallingIntroduces { diff --git a/compiler/rustc_ty_utils/src/assoc.rs b/compiler/rustc_ty_utils/src/assoc.rs index 3655fa5ae0e..f97e8d48c8e 100644 --- a/compiler/rustc_ty_utils/src/assoc.rs +++ b/compiler/rustc_ty_utils/src/assoc.rs @@ -140,7 +140,7 @@ fn associated_item_from_trait_item_ref(trait_item_ref: &hir::TraitItemRef) -> ty kind, def_id: owner_id.to_def_id(), trait_item_def_id: Some(owner_id.to_def_id()), - container: ty::TraitContainer, + container: ty::AssocItemContainer::Trait, fn_has_self_parameter: has_self, opt_rpitit_info: None, } @@ -159,7 +159,7 @@ fn associated_item_from_impl_item_ref(impl_item_ref: &hir::ImplItemRef) -> ty::A kind, def_id: def_id.to_def_id(), trait_item_def_id: impl_item_ref.trait_item_def_id, - container: ty::ImplContainer, + container: ty::AssocItemContainer::Impl, fn_has_self_parameter: has_self, opt_rpitit_info: None, } @@ -267,7 +267,7 @@ fn associated_type_for_impl_trait_in_trait( kind: ty::AssocKind::Type, def_id, trait_item_def_id: None, - container: ty::TraitContainer, + container: ty::AssocItemContainer::Trait, fn_has_self_parameter: false, opt_rpitit_info: Some(ImplTraitInTraitData::Trait { fn_def_id: fn_def_id.to_def_id(), @@ -319,7 +319,7 @@ fn associated_type_for_impl_trait_in_impl( kind: ty::AssocKind::Type, def_id, trait_item_def_id: Some(trait_assoc_def_id), - container: ty::ImplContainer, + container: ty::AssocItemContainer::Impl, fn_has_self_parameter: false, opt_rpitit_info: Some(ImplTraitInTraitData::Impl { fn_def_id: impl_fn_def_id.to_def_id() }), }); diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 731d42fc006..2127ba8a423 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -135,7 +135,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { if tcx.def_kind(def_id) == DefKind::AssocFn && let assoc_item = tcx.associated_item(def_id) - && assoc_item.container == ty::AssocItemContainer::TraitContainer + && assoc_item.container == ty::AssocItemContainer::Trait && assoc_item.defaultness(tcx).has_value() { let sig = tcx.fn_sig(def_id).instantiate_identity(); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c367eed53e0..00082b18a04 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1317,8 +1317,8 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo simplify::move_bounds_to_generic_parameters(&mut generics); let provided = match assoc_item.container { - ty::ImplContainer => true, - ty::TraitContainer => tcx.defaultness(assoc_item.def_id).has_value(), + ty::AssocItemContainer::Impl => true, + ty::AssocItemContainer::Trait => tcx.defaultness(assoc_item.def_id).has_value(), }; if provided { AssocConstItem(Box::new(Constant { @@ -1335,10 +1335,10 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo if assoc_item.fn_has_self_parameter { let self_ty = match assoc_item.container { - ty::ImplContainer => { + ty::AssocItemContainer::Impl => { tcx.type_of(assoc_item.container_id(tcx)).instantiate_identity() } - ty::TraitContainer => tcx.types.self_param, + ty::AssocItemContainer::Trait => tcx.types.self_param, }; let self_arg_ty = tcx.fn_sig(assoc_item.def_id).instantiate_identity().input(0).skip_binder(); @@ -1355,13 +1355,13 @@ pub(crate) fn clean_middle_assoc_item(assoc_item: &ty::AssocItem, cx: &mut DocCo } let provided = match assoc_item.container { - ty::ImplContainer => true, - ty::TraitContainer => assoc_item.defaultness(tcx).has_value(), + ty::AssocItemContainer::Impl => true, + ty::AssocItemContainer::Trait => assoc_item.defaultness(tcx).has_value(), }; if provided { let defaultness = match assoc_item.container { - ty::ImplContainer => Some(assoc_item.defaultness(tcx)), - ty::TraitContainer => None, + ty::AssocItemContainer::Impl => Some(assoc_item.defaultness(tcx)), + ty::AssocItemContainer::Trait => None, }; MethodItem(item, defaultness) } else { @@ -1392,7 +1392,7 @@ fn param_eq_arg(param: &GenericParamDef, arg: &GenericArg) -> bool { } let mut predicates = tcx.explicit_predicates_of(assoc_item.def_id).predicates; - if let ty::TraitContainer = assoc_item.container { + if let ty::AssocItemContainer::Trait = assoc_item.container { let bounds = tcx.explicit_item_bounds(assoc_item.def_id).iter_identity_copied(); predicates = tcx.arena.alloc_from_iter(bounds.chain(predicates.iter().copied())); } @@ -1403,7 +1403,7 @@ fn param_eq_arg(param: &GenericParamDef, arg: &GenericArg) -> bool { }); simplify::move_bounds_to_generic_parameters(&mut generics); - if let ty::TraitContainer = assoc_item.container { + if let ty::AssocItemContainer::Trait = assoc_item.container { // Move bounds that are (likely) directly attached to the associated type // from the where-clause to the associated type. // There is no guarantee that this is what the user actually wrote but we have diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index d49b4320db6..e5c9539b5e7 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -703,8 +703,8 @@ pub(crate) fn visibility(&self, tcx: TyCtxt<'_>) -> Option> { | TyMethodItem(..) | MethodItem(..) => { let assoc_item = tcx.associated_item(def_id); let is_trait_item = match assoc_item.container { - ty::TraitContainer => true, - ty::ImplContainer => { + ty::AssocItemContainer::Trait => true, + ty::AssocItemContainer::Impl => { // Trait impl items always inherit the impl's visibility -- // we don't want to show `pub`. tcx.impl_trait_ref(tcx.parent(assoc_item.def_id)).is_some() diff --git a/src/tools/clippy/clippy_lints/src/missing_inline.rs b/src/tools/clippy/clippy_lints/src/missing_inline.rs index f95a0f63fab..e587d695c84 100644 --- a/src/tools/clippy/clippy_lints/src/missing_inline.rs +++ b/src/tools/clippy/clippy_lints/src/missing_inline.rs @@ -2,6 +2,7 @@ use rustc_ast::ast; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_middle::ty::AssocItemContainer; use rustc_session::declare_lint_pass; use rustc_span::{Span, sym}; @@ -138,7 +139,6 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) { } fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::ImplItem<'_>) { - use rustc_middle::ty::{ImplContainer, TraitContainer}; if rustc_middle::lint::in_external_macro(cx.sess(), impl_item.span) || is_executable_or_proc_macro(cx) { return; } @@ -156,8 +156,8 @@ fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::Impl let assoc_item = cx.tcx.associated_item(impl_item.owner_id); let container_id = assoc_item.container_id(cx.tcx); let trait_def_id = match assoc_item.container { - TraitContainer => Some(container_id), - ImplContainer => cx.tcx.impl_trait_ref(container_id).map(|t| t.skip_binder().def_id), + AssocItemContainer::Trait => Some(container_id), + AssocItemContainer::Impl => cx.tcx.impl_trait_ref(container_id).map(|t| t.skip_binder().def_id), }; if let Some(trait_def_id) = trait_def_id { diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index ad85dfa2d1e..2b91f528807 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -3340,8 +3340,8 @@ pub fn get_path_from_caller_to_method_type<'tcx>( let assoc_item = tcx.associated_item(method); let def_id = assoc_item.container_id(tcx); match assoc_item.container { - rustc_ty::TraitContainer => get_path_to_callee(tcx, from, def_id), - rustc_ty::ImplContainer => { + rustc_ty::AssocItemContainer::Trait => get_path_to_callee(tcx, from, def_id), + rustc_ty::AssocItemContainer::Impl => { let ty = tcx.type_of(def_id).instantiate_identity(); get_path_to_ty(tcx, from, ty, args) },