Skip to content

Commit 729cd55

Browse files
Associated type bounds in some places in the compiler
1 parent 8f55d60 commit 729cd55

File tree

15 files changed

+22
-41
lines changed

15 files changed

+22
-41
lines changed

compiler/rustc_borrowck/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! This query borrow-checks the MIR to (further) ensure it is not broken.
22
33
#![allow(rustc::potential_query_instability)]
4+
#![feature(associated_type_bounds)]
45
#![feature(box_patterns)]
56
#![feature(let_chains)]
67
#![feature(min_specialization)]

compiler/rustc_borrowck/src/type_check/canonical.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
117117

118118
pub(super) fn prove_predicates(
119119
&mut self,
120-
predicates: impl IntoIterator<Item = impl ToPredicate<'tcx> + std::fmt::Debug>,
120+
predicates: impl IntoIterator<Item: ToPredicate<'tcx> + std::fmt::Debug>,
121121
locations: Locations,
122122
category: ConstraintCategory<'tcx>,
123123
) {

compiler/rustc_infer/src/infer/combine.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
478478
self.obligations.extend(obligations.into_iter());
479479
}
480480

481-
pub fn register_predicates(
482-
&mut self,
483-
obligations: impl IntoIterator<Item = impl ToPredicate<'tcx>>,
484-
) {
481+
pub fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ToPredicate<'tcx>>) {
485482
self.obligations.extend(obligations.into_iter().map(|to_pred| {
486483
Obligation::new(self.infcx.tcx, self.trace.cause.clone(), self.param_env, to_pred)
487484
}))
@@ -814,10 +811,7 @@ pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> {
814811
/// Register predicates that must hold in order for this relation to hold. Uses
815812
/// a default obligation cause, [`ObligationEmittingRelation::register_obligations`] should
816813
/// be used if control over the obligaton causes is required.
817-
fn register_predicates(
818-
&mut self,
819-
obligations: impl IntoIterator<Item = impl ToPredicate<'tcx>>,
820-
);
814+
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ToPredicate<'tcx>>);
821815

822816
/// Register an obligation that both constants must be equal to each other.
823817
///

compiler/rustc_infer/src/infer/equate.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,7 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
201201
}
202202

203203
impl<'tcx> ObligationEmittingRelation<'tcx> for Equate<'_, '_, 'tcx> {
204-
fn register_predicates(
205-
&mut self,
206-
obligations: impl IntoIterator<Item = impl ty::ToPredicate<'tcx>>,
207-
) {
204+
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
208205
self.fields.register_predicates(obligations);
209206
}
210207

compiler/rustc_infer/src/infer/glb.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Glb<'combine, 'infcx,
148148
}
149149

150150
impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
151-
fn register_predicates(
152-
&mut self,
153-
obligations: impl IntoIterator<Item = impl ty::ToPredicate<'tcx>>,
154-
) {
151+
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
155152
self.fields.register_predicates(obligations);
156153
}
157154

compiler/rustc_infer/src/infer/lub.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ impl<'combine, 'infcx, 'tcx> LatticeDir<'infcx, 'tcx> for Lub<'combine, 'infcx,
148148
}
149149

150150
impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
151-
fn register_predicates(
152-
&mut self,
153-
obligations: impl IntoIterator<Item = impl ty::ToPredicate<'tcx>>,
154-
) {
151+
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
155152
self.fields.register_predicates(obligations);
156153
}
157154

compiler/rustc_infer/src/infer/nll_relate/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,7 @@ impl<'tcx, D> ObligationEmittingRelation<'tcx> for TypeRelating<'_, 'tcx, D>
759759
where
760760
D: TypeRelatingDelegate<'tcx>,
761761
{
762-
fn register_predicates(
763-
&mut self,
764-
obligations: impl IntoIterator<Item = impl ty::ToPredicate<'tcx>>,
765-
) {
762+
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
766763
self.delegate.register_obligations(
767764
obligations
768765
.into_iter()

compiler/rustc_infer/src/infer/sub.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,7 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
228228
}
229229

230230
impl<'tcx> ObligationEmittingRelation<'tcx> for Sub<'_, '_, 'tcx> {
231-
fn register_predicates(
232-
&mut self,
233-
obligations: impl IntoIterator<Item = impl ty::ToPredicate<'tcx>>,
234-
) {
231+
fn register_predicates(&mut self, obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>) {
235232
self.fields.register_predicates(obligations);
236233
}
237234

compiler/rustc_infer/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//! This API is completely unstable and subject to change.
1414
1515
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
16+
#![feature(associated_type_bounds)]
1617
#![feature(box_patterns)]
1718
#![feature(control_flow_enum)]
1819
#![feature(extend_one)]

compiler/rustc_middle/src/ty/context.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1857,7 +1857,7 @@ impl<'tcx> TyCtxt<'tcx> {
18571857
pub fn mk_fn_def(
18581858
self,
18591859
def_id: DefId,
1860-
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
1860+
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
18611861
) -> Ty<'tcx> {
18621862
let substs = self.check_substs(def_id, substs);
18631863
self.mk_ty(FnDef(def_id, substs))
@@ -1867,7 +1867,7 @@ impl<'tcx> TyCtxt<'tcx> {
18671867
fn check_substs(
18681868
self,
18691869
_def_id: DefId,
1870-
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
1870+
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
18711871
) -> SubstsRef<'tcx> {
18721872
let substs = substs.into_iter().map(Into::into);
18731873
#[cfg(debug_assertions)]
@@ -1902,7 +1902,7 @@ impl<'tcx> TyCtxt<'tcx> {
19021902
pub fn mk_projection(
19031903
self,
19041904
item_def_id: DefId,
1905-
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
1905+
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
19061906
) -> Ty<'tcx> {
19071907
self.mk_alias(ty::Projection, self.mk_alias_ty(item_def_id, substs))
19081908
}
@@ -2294,7 +2294,7 @@ impl<'tcx> TyCtxt<'tcx> {
22942294
pub fn mk_trait_ref(
22952295
self,
22962296
trait_def_id: DefId,
2297-
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
2297+
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
22982298
) -> ty::TraitRef<'tcx> {
22992299
let substs = self.check_substs(trait_def_id, substs);
23002300
ty::TraitRef { def_id: trait_def_id, substs, _use_mk_trait_ref_instead: () }
@@ -2303,7 +2303,7 @@ impl<'tcx> TyCtxt<'tcx> {
23032303
pub fn mk_alias_ty(
23042304
self,
23052305
def_id: DefId,
2306-
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
2306+
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
23072307
) -> ty::AliasTy<'tcx> {
23082308
let substs = self.check_substs(def_id, substs);
23092309
ty::AliasTy { def_id, substs, _use_mk_alias_ty_instead: () }
@@ -2469,7 +2469,7 @@ impl<'tcx> TyCtxtAt<'tcx> {
24692469
pub fn mk_trait_ref(
24702470
self,
24712471
trait_lang_item: LangItem,
2472-
substs: impl IntoIterator<Item = impl Into<ty::GenericArg<'tcx>>>,
2472+
substs: impl IntoIterator<Item: Into<ty::GenericArg<'tcx>>>,
24732473
) -> ty::TraitRef<'tcx> {
24742474
let trait_def_id = self.require_lang_item(trait_lang_item, Some(self.span));
24752475
self.tcx.mk_trait_ref(trait_def_id, substs)

compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
570570
self,
571571
def_id: DefId,
572572
tcx: TyCtxt<'tcx>,
573-
) -> impl Iterator<Item = impl Iterator<Item = Ty<'tcx>> + Captures<'tcx>> {
573+
) -> impl Iterator<Item: Iterator<Item = Ty<'tcx>> + Captures<'tcx>> {
574574
let layout = tcx.generator_layout(def_id).unwrap();
575575
layout.variant_fields.iter().map(move |variant| {
576576
variant.iter().map(move |field| {

compiler/rustc_mir_build/src/build/matches/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ fn trait_method<'tcx>(
832832
tcx: TyCtxt<'tcx>,
833833
trait_def_id: DefId,
834834
method_name: Symbol,
835-
substs: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
835+
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
836836
) -> ConstantKind<'tcx> {
837837
// The unhygienic comparison here is acceptable because this is only
838838
// used on known traits.

compiler/rustc_trait_selection/src/infer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub trait InferCtxtExt<'tcx> {
4242
fn type_implements_trait(
4343
&self,
4444
trait_def_id: DefId,
45-
params: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
45+
params: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
4646
param_env: ty::ParamEnv<'tcx>,
4747
) -> traits::EvaluationResult;
4848
}
@@ -82,7 +82,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
8282
fn type_implements_trait(
8383
&self,
8484
trait_def_id: DefId,
85-
params: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
85+
params: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
8686
param_env: ty::ParamEnv<'tcx>,
8787
) -> traits::EvaluationResult {
8888
let trait_ref = self.tcx.mk_trait_ref(trait_def_id, params);

compiler/rustc_trait_selection/src/traits/error_reporting/method_chain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for CollectAllMismatches<'_, 'tcx> {
9898

9999
fn register_predicates(
100100
&mut self,
101-
_obligations: impl IntoIterator<Item = impl ty::ToPredicate<'tcx>>,
101+
_obligations: impl IntoIterator<Item: ty::ToPredicate<'tcx>>,
102102
) {
103103
// FIXME(deferred_projection_equality)
104104
}

compiler/rustc_trait_selection/src/traits/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ pub fn predicate_for_trait_def<'tcx>(
239239
cause: ObligationCause<'tcx>,
240240
trait_def_id: DefId,
241241
recursion_depth: usize,
242-
params: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
242+
params: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
243243
) -> PredicateObligation<'tcx> {
244244
let trait_ref = tcx.mk_trait_ref(trait_def_id, params);
245245
predicate_for_trait_ref(tcx, cause, param_env, trait_ref, recursion_depth)

0 commit comments

Comments
 (0)