Skip to content

Commit be130b5

Browse files
committed
change usages of impl_trait_ref to bound_impl_trait_ref
1 parent ef58baf commit be130b5

File tree

47 files changed

+134
-100
lines changed

Some content is hidden

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

47 files changed

+134
-100
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2059,14 +2059,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
20592059
(_, Res::SelfTyAlias { alias_to: impl_def_id, is_trait_impl: true, .. }) => {
20602060
// `Self` in an impl of a trait -- we have a concrete self type and a
20612061
// trait reference.
2062-
let Some(trait_ref) = tcx.impl_trait_ref(impl_def_id) else {
2062+
let Some(trait_ref) = tcx.bound_impl_trait_ref(impl_def_id) else {
20632063
// A cycle error occurred, most likely.
20642064
let guar = tcx.sess.delay_span_bug(span, "expected cycle error");
20652065
return Err(guar);
20662066
};
20672067

20682068
self.one_bound_for_assoc_type(
2069-
|| traits::supertraits(tcx, ty::Binder::dummy(trait_ref)),
2069+
|| traits::supertraits(tcx, ty::Binder::dummy(trait_ref.skip_binder())),
20702070
|| "Self".to_string(),
20712071
assoc_ident,
20722072
span,

compiler/rustc_hir_analysis/src/check/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,12 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
535535
return;
536536
};
537537
debug!("ItemKind::Impl {} with id {:?}", it.ident, it.owner_id);
538-
if let Some(impl_trait_ref) = tcx.impl_trait_ref(it.owner_id) {
538+
if let Some(impl_trait_ref) = tcx.bound_impl_trait_ref(it.owner_id.to_def_id()) {
539539
check_impl_items_against_trait(
540540
tcx,
541541
it.span,
542542
it.owner_id.def_id,
543-
impl_trait_ref,
543+
impl_trait_ref.skip_binder(),
544544
&impl_.items,
545545
);
546546
check_on_unimplemented(tcx, it);

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,8 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
616616
) -> Result<&'tcx FxHashMap<DefId, Ty<'tcx>>, ErrorGuaranteed> {
617617
let impl_m = tcx.opt_associated_item(def_id).unwrap();
618618
let trait_m = tcx.opt_associated_item(impl_m.trait_item_def_id.unwrap()).unwrap();
619-
let impl_trait_ref = tcx.impl_trait_ref(impl_m.impl_container(tcx).unwrap()).unwrap();
619+
let impl_trait_ref =
620+
tcx.bound_impl_trait_ref(impl_m.impl_container(tcx).unwrap()).unwrap().subst_identity();
620621
let param_env = tcx.param_env(def_id);
621622

622623
// First, check a few of the same things as `compare_impl_method`,
@@ -1684,7 +1685,8 @@ pub(super) fn compare_impl_const_raw(
16841685
) -> Result<(), ErrorGuaranteed> {
16851686
let impl_const_item = tcx.associated_item(impl_const_item_def);
16861687
let trait_const_item = tcx.associated_item(trait_const_item_def);
1687-
let impl_trait_ref = tcx.impl_trait_ref(impl_const_item.container_id(tcx)).unwrap();
1688+
let impl_trait_ref =
1689+
tcx.bound_impl_trait_ref(impl_const_item.container_id(tcx)).unwrap().subst_identity();
16881690
debug!("compare_const_impl(impl_trait_ref={:?})", impl_trait_ref);
16891691

16901692
let impl_c_span = tcx.def_span(impl_const_item_def.to_def_id());

compiler/rustc_hir_analysis/src/check/wfcheck.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
181181
// for `T`
182182
hir::ItemKind::Impl(ref impl_) => {
183183
let is_auto = tcx
184-
.impl_trait_ref(def_id)
185-
.map_or(false, |trait_ref| tcx.trait_is_auto(trait_ref.def_id));
184+
.bound_impl_trait_ref(def_id.into())
185+
.map_or(false, |trait_ref| tcx.trait_is_auto(trait_ref.skip_binder().def_id));
186186
if let (hir::Defaultness::Default { .. }, true) = (impl_.defaultness, is_auto) {
187187
let sp = impl_.of_trait.as_ref().map_or(item.span, |t| t.path.span);
188188
let mut err =
@@ -1253,7 +1253,8 @@ fn check_impl<'tcx>(
12531253
// `#[rustc_reservation_impl]` impls are not real impls and
12541254
// therefore don't need to be WF (the trait's `Self: Trait` predicate
12551255
// won't hold).
1256-
let trait_ref = tcx.impl_trait_ref(item.owner_id).unwrap();
1256+
let trait_ref =
1257+
tcx.bound_impl_trait_ref(item.owner_id.to_def_id()).unwrap().subst_identity();
12571258
let trait_ref = wfcx.normalize(
12581259
ast_trait_ref.path.span,
12591260
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),

compiler/rustc_hir_analysis/src/coherence/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
192192
let source = tcx.type_of(impl_did);
193193
assert!(!source.has_escaping_bound_vars());
194194
let target = {
195-
let trait_ref = tcx.impl_trait_ref(impl_did).unwrap();
195+
let trait_ref = tcx.bound_impl_trait_ref(impl_did.into()).unwrap().subst_identity();
196196
assert_eq!(trait_ref.def_id, dispatch_from_dyn_trait);
197197

198198
trait_ref.substs.type_at(1)
@@ -354,7 +354,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
354354
});
355355

356356
let source = tcx.type_of(impl_did);
357-
let trait_ref = tcx.impl_trait_ref(impl_did).unwrap();
357+
let trait_ref = tcx.bound_impl_trait_ref(impl_did.into()).unwrap().subst_identity();
358358
assert_eq!(trait_ref.def_id, coerce_unsized_trait);
359359
let target = trait_ref.substs.type_at(1);
360360
debug!("visit_implementation_of_coerce_unsized: {:?} -> {:?} (bound)", source, target);

compiler/rustc_hir_analysis/src/coherence/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn coherent_trait(tcx: TyCtxt<'_>, def_id: DefId) {
128128

129129
let impls = tcx.hir().trait_impls(def_id);
130130
for &impl_def_id in impls {
131-
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
131+
let trait_ref = tcx.bound_impl_trait_ref(impl_def_id.into()).unwrap().subst_identity();
132132

133133
check_impl(tcx, impl_def_id, trait_ref);
134134
check_object_overlap(tcx, impl_def_id, trait_ref);

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub(crate) fn orphan_check_impl(
2121
tcx: TyCtxt<'_>,
2222
impl_def_id: LocalDefId,
2323
) -> Result<(), ErrorGuaranteed> {
24-
let trait_ref = tcx.impl_trait_ref(impl_def_id).unwrap();
24+
let trait_ref = tcx.bound_impl_trait_ref(impl_def_id.into()).unwrap().skip_binder();
2525
trait_ref.error_reported()?;
2626

2727
let ret = do_orphan_check_impl(tcx, trait_ref, impl_def_id);

compiler/rustc_hir_analysis/src/coherence/unsafety.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ pub(super) fn check_item(tcx: TyCtxt<'_>, def_id: LocalDefId) {
1313
let item = tcx.hir().expect_item(def_id);
1414
let hir::ItemKind::Impl(ref impl_) = item.kind else { bug!() };
1515

16-
if let Some(trait_ref) = tcx.impl_trait_ref(item.owner_id) {
16+
if let Some(trait_ref) =
17+
tcx.bound_impl_trait_ref(item.owner_id.to_def_id()).map(|t| t.subst_identity())
18+
{
1719
let trait_def = tcx.trait_def(trait_ref.def_id);
1820
let unsafe_attr =
1921
impl_.generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle");

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
8787
Node::Item(item) => match item.kind {
8888
ItemKind::Impl(ref impl_) => {
8989
if impl_.defaultness.is_default() {
90-
is_default_impl_trait = tcx.impl_trait_ref(def_id).map(ty::Binder::dummy);
90+
is_default_impl_trait = tcx
91+
.bound_impl_trait_ref(def_id)
92+
.map(|t| ty::Binder::dummy(t.subst_identity()));
9193
}
9294
&impl_.generics
9395
}
@@ -251,7 +253,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
251253
// for details.
252254
if let Node::Item(&Item { kind: ItemKind::Impl { .. }, .. }) = node {
253255
let self_ty = tcx.type_of(def_id);
254-
let trait_ref = tcx.impl_trait_ref(def_id);
256+
let trait_ref = tcx.bound_impl_trait_ref(def_id).map(ty::EarlyBinder::subst_identity);
255257
cgp::setup_constraining_predicates(
256258
tcx,
257259
&mut predicates,

compiler/rustc_hir_analysis/src/collect/type_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
286286
}
287287
}
288288
ImplItemKind::Type(ty) => {
289-
if tcx.impl_trait_ref(tcx.hir().get_parent_item(hir_id)).is_none() {
289+
if tcx.bound_impl_trait_ref(tcx.hir().get_parent_item(hir_id).to_def_id()).is_none() {
290290
check_feature_inherent_assoc_ty(tcx, item.span);
291291
}
292292

compiler/rustc_hir_analysis/src/impl_wf_check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ fn enforce_impl_params_are_constrained(tcx: TyCtxt<'_>, impl_def_id: LocalDefId)
8585
}
8686
let impl_generics = tcx.generics_of(impl_def_id);
8787
let impl_predicates = tcx.predicates_of(impl_def_id);
88-
let impl_trait_ref = tcx.impl_trait_ref(impl_def_id);
88+
let impl_trait_ref =
89+
tcx.bound_impl_trait_ref(impl_def_id.into()).map(ty::EarlyBinder::subst_identity);
8990

9091
let mut input_parameters = cgp::parameters_for_impl(impl_self_ty, impl_trait_ref);
9192
cgp::identify_constrained_generic_params(

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ pub(super) fn check_min_specialization(tcx: TyCtxt<'_>, impl_def_id: LocalDefId)
8989
}
9090

9191
fn parent_specialization_node(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId) -> Option<Node> {
92-
let trait_ref = tcx.impl_trait_ref(impl1_def_id)?;
93-
let trait_def = tcx.trait_def(trait_ref.def_id);
92+
let trait_ref = tcx.bound_impl_trait_ref(impl1_def_id.into())?;
93+
let trait_def = tcx.trait_def(trait_ref.skip_binder().def_id);
9494

9595
let impl2_node = trait_def.ancestors(tcx, impl1_def_id.to_def_id()).ok()?.nth(1)?;
9696

@@ -207,7 +207,7 @@ fn unconstrained_parent_impl_substs<'tcx>(
207207
let impl_generic_predicates = tcx.predicates_of(impl_def_id);
208208
let mut unconstrained_parameters = FxHashSet::default();
209209
let mut constrained_params = FxHashSet::default();
210-
let impl_trait_ref = tcx.impl_trait_ref(impl_def_id);
210+
let impl_trait_ref = tcx.bound_impl_trait_ref(impl_def_id).map(ty::EarlyBinder::subst_identity);
211211

212212
// Unfortunately the functions in `constrained_generic_parameters` don't do
213213
// what we want here. We want only a list of constrained parameters while
@@ -370,7 +370,7 @@ fn check_predicates<'tcx>(
370370
});
371371

372372
// Include the well-formed predicates of the type parameters of the impl.
373-
for arg in tcx.impl_trait_ref(impl1_def_id).unwrap().substs {
373+
for arg in tcx.bound_impl_trait_ref(impl1_def_id.into()).unwrap().subst_identity().substs {
374374
let infcx = &tcx.infer_ctxt().build();
375375
let obligations = wf::obligations(
376376
infcx,

compiler/rustc_hir_typeck/src/method/confirm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
240240
probe::InherentImplPick => {
241241
let impl_def_id = pick.item.container_id(self.tcx);
242242
assert!(
243-
self.tcx.impl_trait_ref(impl_def_id).is_none(),
243+
self.tcx.bound_impl_trait_ref(impl_def_id).is_none(),
244244
"impl {:?} is not an inherent impl",
245245
impl_def_id
246246
);

compiler/rustc_hir_typeck/src/method/suggest.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10361036
// Provide the best span we can. Use the item, if local to crate, else
10371037
// the impl, if local to crate (item may be defaulted), else nothing.
10381038
let Some(item) = self.associated_value(impl_did, item_name).or_else(|| {
1039-
let impl_trait_ref = self.tcx.impl_trait_ref(impl_did)?;
1040-
self.associated_value(impl_trait_ref.def_id, item_name)
1039+
let impl_trait_ref = self.tcx.bound_impl_trait_ref(impl_did)?;
1040+
self.associated_value(impl_trait_ref.skip_binder().def_id, item_name)
10411041
}) else {
10421042
continue;
10431043
};
@@ -1052,10 +1052,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10521052

10531053
let impl_ty = self.tcx.at(span).type_of(impl_did);
10541054

1055-
let insertion = match self.tcx.impl_trait_ref(impl_did) {
1055+
let insertion = match self.tcx.bound_impl_trait_ref(impl_did) {
10561056
None => String::new(),
10571057
Some(trait_ref) => {
1058-
format!(" of the trait `{}`", self.tcx.def_path_str(trait_ref.def_id))
1058+
format!(
1059+
" of the trait `{}`",
1060+
self.tcx.def_path_str(trait_ref.skip_binder().def_id)
1061+
)
10591062
}
10601063
};
10611064

@@ -1085,8 +1088,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10851088
err.note(&note_str);
10861089
}
10871090
if let Some(sugg_span) = sugg_span
1088-
&& let Some(trait_ref) = self.tcx.impl_trait_ref(impl_did) {
1089-
let path = self.tcx.def_path_str(trait_ref.def_id);
1091+
&& let Some(trait_ref) = self.tcx.bound_impl_trait_ref(impl_did) {
1092+
let path = self.tcx.def_path_str(trait_ref.skip_binder().def_id);
10901093

10911094
let ty = match item.kind {
10921095
ty::AssocKind::Const | ty::AssocKind::Type => rcvr_ty,
@@ -2581,7 +2584,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25812584
self.tcx.impl_polarity(*imp_did) == ty::ImplPolarity::Negative
25822585
})
25832586
.any(|imp_did| {
2584-
let imp = self.tcx.impl_trait_ref(imp_did).unwrap();
2587+
let imp =
2588+
self.tcx.bound_impl_trait_ref(imp_did).unwrap().subst_identity();
25852589
let imp_simp =
25862590
simplify_type(self.tcx, imp.self_ty(), TreatParams::AsPlaceholder);
25872591
imp_simp.map_or(false, |s| s == simp_rcvr_ty)

compiler/rustc_infer/src/infer/error_reporting/note.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,10 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
317317
self.tcx.associated_item(impl_item_def_id).impl_container(self.tcx) else { return; };
318318
let Some(trait_ref) = self
319319
.tcx
320-
.impl_trait_ref(impl_def_id)
320+
.bound_impl_trait_ref(impl_def_id)
321321
else { return; };
322322
let trait_substs = trait_ref
323+
.subst_identity()
323324
// Replace the explicit self type with `Self` for better suggestion rendering
324325
.with_self_ty(self.tcx, self.tcx.mk_ty_param(0, kw::SelfUpper))
325326
.substs;

compiler/rustc_lint/src/nonstandard_style.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn method_context(cx: &LateContext<'_>, id: hir::HirId) -> MethodLateContext
2626
let item = cx.tcx.associated_item(def_id);
2727
match item.container {
2828
ty::TraitContainer => MethodLateContext::TraitAutoImpl,
29-
ty::ImplContainer => match cx.tcx.impl_trait_ref(item.container_id(cx.tcx)) {
29+
ty::ImplContainer => match cx.tcx.bound_impl_trait_ref(item.container_id(cx.tcx)) {
3030
Some(_) => MethodLateContext::TraitImpl,
3131
None => MethodLateContext::PlainImpl,
3232
},

compiler/rustc_lint/src/pass_by_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByValue {
2424
match &ty.kind {
2525
TyKind::Ref(_, hir::MutTy { ty: inner_ty, mutbl: hir::Mutability::Not }) => {
2626
if let Some(impl_did) = cx.tcx.impl_of_method(ty.hir_id.owner.to_def_id()) {
27-
if cx.tcx.impl_trait_ref(impl_did).is_some() {
27+
if cx.tcx.bound_impl_trait_ref(impl_did).is_some() {
2828
return;
2929
}
3030
}

compiler/rustc_metadata/src/rmeta/encoder.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
15551555
self.tables.impl_defaultness.set(def_id.index, *defaultness);
15561556
self.tables.constness.set(def_id.index, *constness);
15571557

1558-
let trait_ref = self.tcx.impl_trait_ref(def_id);
1558+
let trait_ref =
1559+
self.tcx.bound_impl_trait_ref(def_id).map(ty::EarlyBinder::skip_binder);
15591560
if let Some(trait_ref) = trait_ref {
15601561
let trait_def = self.tcx.trait_def(trait_ref.def_id);
15611562
if let Ok(mut an) = trait_def.ancestors(self.tcx, def_id) {
@@ -1632,7 +1633,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
16321633
}
16331634
}
16341635
if let hir::ItemKind::Impl { .. } = item.kind {
1635-
if let Some(trait_ref) = self.tcx.impl_trait_ref(def_id) {
1636+
if let Some(trait_ref) =
1637+
self.tcx.bound_impl_trait_ref(def_id).map(ty::EarlyBinder::subst_identity)
1638+
{
16361639
record!(self.tables.impl_trait_ref[def_id] <- trait_ref);
16371640
}
16381641
}
@@ -1898,7 +1901,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
18981901

18991902
for id in tcx.hir().items() {
19001903
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl) {
1901-
if let Some(trait_ref) = tcx.impl_trait_ref(id.owner_id) {
1904+
if let Some(trait_ref) = tcx
1905+
.bound_impl_trait_ref(id.owner_id.to_def_id())
1906+
.map(ty::EarlyBinder::subst_identity)
1907+
{
19021908
let simplified_self_ty = fast_reject::simplify_type(
19031909
self.tcx,
19041910
trait_ref.self_ty(),

compiler/rustc_middle/src/hir/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ impl<'tcx> TyCtxt<'tcx> {
101101
}
102102

103103
pub fn impl_subject(self, def_id: DefId) -> ImplSubject<'tcx> {
104-
self.impl_trait_ref(def_id)
104+
self.bound_impl_trait_ref(def_id)
105+
.map(|t| t.subst_identity())
105106
.map(ImplSubject::Trait)
106107
.unwrap_or_else(|| ImplSubject::Inherent(self.type_of(def_id)))
107108
}

compiler/rustc_middle/src/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ impl<'tcx> TyCtxt<'tcx> {
10271027
/// Checks if the bound region is in Impl Item.
10281028
pub fn is_bound_region_in_impl_item(self, suitable_region_binding_scope: LocalDefId) -> bool {
10291029
let container_id = self.parent(suitable_region_binding_scope.to_def_id());
1030-
if self.impl_trait_ref(container_id).is_some() {
1030+
if self.bound_impl_trait_ref(container_id).is_some() {
10311031
// For now, we do not try to target impls of traits. This is
10321032
// because this message is going to suggest that the user
10331033
// change the fn signature, but they may not be free to do so,

compiler/rustc_middle/src/ty/mod.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -2187,8 +2187,12 @@ impl<'tcx> TyCtxt<'tcx> {
21872187
) -> Option<ImplOverlapKind> {
21882188
// If either trait impl references an error, they're allowed to overlap,
21892189
// as one of them essentially doesn't exist.
2190-
if self.impl_trait_ref(def_id1).map_or(false, |tr| tr.references_error())
2191-
|| self.impl_trait_ref(def_id2).map_or(false, |tr| tr.references_error())
2190+
if self
2191+
.bound_impl_trait_ref(def_id1)
2192+
.map_or(false, |tr| tr.skip_binder().references_error())
2193+
|| self
2194+
.bound_impl_trait_ref(def_id2)
2195+
.map_or(false, |tr| tr.skip_binder().references_error())
21922196
{
21932197
return Some(ImplOverlapKind::Permitted { marker: false });
21942198
}
@@ -2217,8 +2221,8 @@ impl<'tcx> TyCtxt<'tcx> {
22172221

22182222
let is_marker_overlap = {
22192223
let is_marker_impl = |def_id: DefId| -> bool {
2220-
let trait_ref = self.impl_trait_ref(def_id);
2221-
trait_ref.map_or(false, |tr| self.trait_def(tr.def_id).is_marker)
2224+
let trait_ref = self.bound_impl_trait_ref(def_id);
2225+
trait_ref.map_or(false, |tr| self.trait_def(tr.skip_binder().def_id).is_marker)
22222226
};
22232227
is_marker_impl(def_id1) && is_marker_impl(def_id2)
22242228
};
@@ -2364,7 +2368,7 @@ impl<'tcx> TyCtxt<'tcx> {
23642368
/// Given the `DefId` of an impl, returns the `DefId` of the trait it implements.
23652369
/// If it implements no trait, returns `None`.
23662370
pub fn trait_id_of_impl(self, def_id: DefId) -> Option<DefId> {
2367-
self.impl_trait_ref(def_id).map(|tr| tr.def_id)
2371+
self.bound_impl_trait_ref(def_id).map(|tr| tr.skip_binder().def_id)
23682372
}
23692373

23702374
/// If the given `DefId` describes an item belonging to a trait,

compiler/rustc_monomorphize/src/collector.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,10 @@ fn create_mono_items_for_default_impls<'tcx>(
13511351
tcx.def_path_str(item.owner_id.to_def_id())
13521352
);
13531353

1354-
if let Some(trait_ref) = tcx.impl_trait_ref(item.owner_id) {
1354+
if let Some(trait_ref) = tcx
1355+
.bound_impl_trait_ref(item.owner_id.to_def_id())
1356+
.map(ty::EarlyBinder::subst_identity)
1357+
{
13551358
let param_env = ty::ParamEnv::reveal_all();
13561359
let trait_ref = tcx.normalize_erasing_regions(param_env, trait_ref);
13571360
let overridden_methods = tcx.impl_item_implementor_ids(item.owner_id);

0 commit comments

Comments
 (0)