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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 4 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)