Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6f97186

Browse files
authoredDec 5, 2024
Unrolled build for rust-lang#133872
Rollup merge of rust-lang#133872 - compiler-errors:simplify-gat-check, r=oli-obk No need to create placeholders for GAT args in confirm_object_candidate We no longer need this logic to add placeholders for GAT args since with the removal of the `gat_extended` feature gate (rust-lang#133768) we no longer allow GATs in dyn trait anyways. r? oli-obk
2 parents 5a0a5e6 + 81291ec commit 6f97186

File tree

1 file changed

+2
-52
lines changed

1 file changed

+2
-52
lines changed
 

‎compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+2-52
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ use rustc_hir::lang_items::LangItem;
1616
use rustc_infer::infer::{DefineOpaqueTypes, HigherRankedType, InferOk};
1717
use rustc_infer::traits::ObligationCauseCode;
1818
use rustc_middle::traits::{BuiltinImplSource, SignatureMismatchData};
19-
use rustc_middle::ty::{
20-
self, GenericArgs, GenericArgsRef, GenericParamDefKind, ToPolyTraitRef, Ty, TyCtxt, Upcast,
21-
};
19+
use rustc_middle::ty::{self, GenericArgsRef, ToPolyTraitRef, Ty, TyCtxt, Upcast};
2220
use rustc_middle::{bug, span_bug};
2321
use rustc_span::def_id::DefId;
2422
use tracing::{debug, instrument};
@@ -638,60 +636,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
638636
// higher-ranked things.
639637
// Prevent, e.g., `dyn Iterator<Item = str>`.
640638
for bound in self.tcx().item_bounds(assoc_type).transpose_iter() {
641-
let arg_bound = if defs.is_empty() {
642-
bound.instantiate(tcx, trait_predicate.trait_ref.args)
643-
} else {
644-
let mut args = smallvec::SmallVec::with_capacity(defs.count());
645-
args.extend(trait_predicate.trait_ref.args.iter());
646-
let mut bound_vars: smallvec::SmallVec<[ty::BoundVariableKind; 8]> =
647-
smallvec::SmallVec::with_capacity(
648-
bound.skip_binder().kind().bound_vars().len() + defs.count(),
649-
);
650-
bound_vars.extend(bound.skip_binder().kind().bound_vars().into_iter());
651-
GenericArgs::fill_single(&mut args, defs, &mut |param, _| match param.kind {
652-
GenericParamDefKind::Type { .. } => {
653-
let kind = ty::BoundTyKind::Param(param.def_id, param.name);
654-
let bound_var = ty::BoundVariableKind::Ty(kind);
655-
bound_vars.push(bound_var);
656-
Ty::new_bound(tcx, ty::INNERMOST, ty::BoundTy {
657-
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
658-
kind,
659-
})
660-
.into()
661-
}
662-
GenericParamDefKind::Lifetime => {
663-
let kind = ty::BoundRegionKind::Named(param.def_id, param.name);
664-
let bound_var = ty::BoundVariableKind::Region(kind);
665-
bound_vars.push(bound_var);
666-
ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion {
667-
var: ty::BoundVar::from_usize(bound_vars.len() - 1),
668-
kind,
669-
})
670-
.into()
671-
}
672-
GenericParamDefKind::Const { .. } => {
673-
let bound_var = ty::BoundVariableKind::Const;
674-
bound_vars.push(bound_var);
675-
ty::Const::new_bound(
676-
tcx,
677-
ty::INNERMOST,
678-
ty::BoundVar::from_usize(bound_vars.len() - 1),
679-
)
680-
.into()
681-
}
682-
});
683-
let bound_vars = tcx.mk_bound_variable_kinds(&bound_vars);
684-
let assoc_ty_args = tcx.mk_args(&args);
685-
let bound =
686-
bound.map_bound(|b| b.kind().skip_binder()).instantiate(tcx, assoc_ty_args);
687-
ty::Binder::bind_with_vars(bound, bound_vars).upcast(tcx)
688-
};
689639
let normalized_bound = normalize_with_depth_to(
690640
self,
691641
obligation.param_env,
692642
obligation.cause.clone(),
693643
obligation.recursion_depth + 1,
694-
arg_bound,
644+
bound.instantiate(tcx, trait_predicate.trait_ref.args),
695645
&mut nested,
696646
);
697647
nested.push(obligation.with(tcx, normalized_bound));

0 commit comments

Comments
 (0)
Failed to load comments.