Skip to content

Commit 172af03

Browse files
committed
Rename trait_of_item -> trait_of_assoc
1 parent 0d7abc8 commit 172af03

File tree

37 files changed

+47
-47
lines changed

37 files changed

+47
-47
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
23842384
if let Some(body_expr) = finder.body_expr
23852385
&& let Some(loop_span) = finder.loop_span
23862386
&& let Some(def_id) = typeck_results.type_dependent_def_id(body_expr.hir_id)
2387-
&& let Some(trait_did) = tcx.trait_of_item(def_id)
2387+
&& let Some(trait_did) = tcx.trait_of_assoc(def_id)
23882388
&& tcx.is_diagnostic_item(sym::Iterator, trait_did)
23892389
{
23902390
if let Some(loop_bind) = finder.loop_bind {

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ impl<'tcx> BorrowedContentSource<'tcx> {
938938
fn from_call(func: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> Option<Self> {
939939
match *func.kind() {
940940
ty::FnDef(def_id, args) => {
941-
let trait_id = tcx.trait_of_item(def_id)?;
941+
let trait_id = tcx.trait_of_assoc(def_id)?;
942942

943943
if tcx.is_lang_item(trait_id, LangItem::Deref)
944944
|| tcx.is_lang_item(trait_id, LangItem::DerefMut)

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
784784
self.revalidate_conditional_constness(callee, fn_args, *fn_span);
785785

786786
// Attempting to call a trait method?
787-
if let Some(trait_did) = tcx.trait_of_item(callee) {
787+
if let Some(trait_did) = tcx.trait_of_assoc(callee) {
788788
// We can't determine the actual callee here, so we have to do different checks
789789
// than usual.
790790

compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ where
369369
assert!(promoted.is_none() || Q::ALLOW_PROMOTED);
370370

371371
// Don't peek inside trait associated constants.
372-
if promoted.is_none() && cx.tcx.trait_of_item(def).is_none() {
372+
if promoted.is_none() && cx.tcx.trait_of_assoc(def).is_none() {
373373
let qualifs = cx.tcx.at(constant.span).mir_const_qualif(def);
374374

375375
if !Q::in_qualifs(&qualifs) {

compiler/rustc_const_eval/src/interpret/call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
725725
) {
726726
let tcx = *self.tcx;
727727

728-
let trait_def_id = tcx.trait_of_item(def_id).unwrap();
728+
let trait_def_id = tcx.trait_of_assoc(def_id).unwrap();
729729
let virtual_trait_ref = ty::TraitRef::from_method(tcx, trait_def_id, virtual_instance.args);
730730
let existential_trait_ref = ty::ExistentialTraitRef::erase_self_ty(tcx, virtual_trait_ref);
731731
let concrete_trait_ref = existential_trait_ref.with_self_ty(tcx, dyn_ty);

compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
759759
&self,
760760
err: &mut Diag<'_, impl EmissionGuarantee>,
761761
) {
762-
let trait_ = match self.tcx.trait_of_item(self.def_id) {
762+
let trait_ = match self.tcx.trait_of_assoc(self.def_id) {
763763
Some(def_id) => def_id,
764764
None => return,
765765
};

compiler/rustc_hir_typeck/src/fallback.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ impl<'tcx> Visitor<'tcx> for AnnotateUnitFallbackVisitor<'_, 'tcx> {
694694
// i.e. changing `Default::default()` to `<() as Default>::default()`.
695695
if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = expr.kind
696696
&& let Res::Def(DefKind::AssocFn, def_id) = path.res
697-
&& self.fcx.tcx.trait_of_item(def_id).is_some()
697+
&& self.fcx.tcx.trait_of_assoc(def_id).is_some()
698698
&& let Some(args) = self.fcx.typeck_results.borrow().node_args_opt(expr.hir_id)
699699
&& let self_ty = args.type_at(0)
700700
&& let Some(vid) = self.fcx.root_vid(self_ty)

compiler/rustc_lint/src/noop_method_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
8484
return;
8585
};
8686

87-
let Some(trait_id) = cx.tcx.trait_of_item(did) else { return };
87+
let Some(trait_id) = cx.tcx.trait_of_assoc(did) else { return };
8888

8989
let Some(trait_) = cx.tcx.get_diagnostic_name(trait_id) else { return };
9090

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,7 @@ impl<'tcx> TyCtxt<'tcx> {
19961996
/// If the given `DefId` describes an item belonging to a trait,
19971997
/// returns the `DefId` of the trait that the trait item belongs to;
19981998
/// otherwise, returns `None`.
1999-
pub fn trait_of_item(self, def_id: DefId) -> Option<DefId> {
1999+
pub fn trait_of_assoc(self, def_id: DefId) -> Option<DefId> {
20002000
self.assoc_parent(def_id).filter(|id| self.def_kind(id) == DefKind::Trait)
20012001
}
20022002

@@ -2174,7 +2174,7 @@ impl<'tcx> TyCtxt<'tcx> {
21742174

21752175
#[inline]
21762176
pub fn is_const_default_method(self, def_id: DefId) -> bool {
2177-
matches!(self.trait_of_item(def_id), Some(trait_id) if self.is_const_trait(trait_id))
2177+
matches!(self.trait_of_assoc(def_id), Some(trait_id) if self.is_const_trait(trait_id))
21782178
}
21792179

21802180
pub fn impl_method_has_trait_impl_trait_tys(self, def_id: DefId) -> bool {

compiler/rustc_mir_transform/src/check_call_recursion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl<'tcx> MirLint<'tcx> for CheckCallRecursion {
2121

2222
if let DefKind::Fn | DefKind::AssocFn = tcx.def_kind(def_id) {
2323
// If this is trait/impl method, extract the trait's args.
24-
let trait_args = match tcx.trait_of_item(def_id.to_def_id()) {
24+
let trait_args = match tcx.trait_of_assoc(def_id.to_def_id()) {
2525
Some(trait_def_id) => {
2626
let trait_args_count = tcx.generics_of(trait_def_id).count();
2727
&GenericArgs::identity_for_item(tcx, def_id)[..trait_args_count]

0 commit comments

Comments
 (0)