Skip to content

Commit 9935796

Browse files
committed
Add bound_const_param_default
1 parent f165843 commit 9935796

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

Diff for: compiler/rustc_middle/src/ty/generics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ impl GenericParamDef {
8585
) -> Option<EarlyBinder<ty::GenericArg<'tcx>>> {
8686
match self.kind {
8787
GenericParamDefKind::Type { has_default, .. } if has_default => {
88-
Some(EarlyBinder(tcx.type_of(self.def_id).into()))
88+
Some(tcx.bound_type_of(self.def_id).map_bound(|t| t.into()))
8989
}
9090
GenericParamDefKind::Const { has_default } if has_default => {
91-
Some(EarlyBinder(tcx.const_param_default(self.def_id).into()))
91+
Some(tcx.bound_const_param_default(self.def_id).map_bound(|c| c.into()))
9292
}
9393
_ => None,
9494
}

Diff for: compiler/rustc_middle/src/ty/util.rs

+4
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,10 @@ impl<'tcx> TyCtxt<'tcx> {
676676
) -> ty::EarlyBinder<&'tcx ty::List<ty::Predicate<'tcx>>> {
677677
ty::EarlyBinder(self.item_bounds(def_id))
678678
}
679+
680+
pub fn bound_const_param_default(self, def_id: DefId) -> ty::EarlyBinder<ty::Const<'tcx>> {
681+
ty::EarlyBinder(self.const_param_default(def_id))
682+
}
679683
}
680684

681685
struct OpaqueTypeExpander<'tcx> {

Diff for: compiler/rustc_typeck/src/astconv/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
550550
GenericParamDefKind::Const { has_default } => {
551551
let ty = tcx.at(self.span).type_of(param.def_id);
552552
if !infer_args && has_default {
553-
EarlyBinder(tcx.const_param_default(param.def_id))
553+
tcx.bound_const_param_default(param.def_id)
554554
.subst(tcx, substs.unwrap())
555555
.into()
556556
} else {

Diff for: compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14261426
}
14271427
GenericParamDefKind::Const { has_default } => {
14281428
if !infer_args && has_default {
1429-
EarlyBinder(tcx.const_param_default(param.def_id))
1429+
tcx.bound_const_param_default(param.def_id)
14301430
.subst(tcx, substs.unwrap())
14311431
.into()
14321432
} else {

Diff for: compiler/rustc_typeck/src/check/method/probe.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ use rustc_middle::middle::stability;
2121
use rustc_middle::ty::fast_reject::{simplify_type, TreatParams};
2222
use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
2323
use rustc_middle::ty::GenericParamDefKind;
24-
use rustc_middle::ty::{
25-
self, EarlyBinder, ParamEnvAnd, ToPredicate, Ty, TyCtxt, TypeFoldable, TypeVisitable,
26-
};
24+
use rustc_middle::ty::{self, ParamEnvAnd, ToPredicate, Ty, TyCtxt, TypeFoldable, TypeVisitable};
2725
use rustc_session::lint;
2826
use rustc_span::def_id::LocalDefId;
2927
use rustc_span::lev_distance::{
@@ -713,7 +711,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
713711
}
714712

715713
let (impl_ty, impl_substs) = self.impl_ty_and_substs(impl_def_id);
716-
let impl_ty = EarlyBinder(impl_ty).subst(self.tcx, impl_substs);
714+
let impl_ty = impl_ty.subst(self.tcx, impl_substs);
717715

718716
debug!("impl_ty: {:?}", impl_ty);
719717

@@ -1812,8 +1810,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
18121810
}
18131811

18141812
/// Gets the type of an impl and generate substitutions with placeholders.
1815-
fn impl_ty_and_substs(&self, impl_def_id: DefId) -> (Ty<'tcx>, SubstsRef<'tcx>) {
1816-
(self.tcx.type_of(impl_def_id), self.fresh_item_substs(impl_def_id))
1813+
fn impl_ty_and_substs(
1814+
&self,
1815+
impl_def_id: DefId,
1816+
) -> (ty::EarlyBinder<Ty<'tcx>>, SubstsRef<'tcx>) {
1817+
(self.tcx.bound_type_of(impl_def_id), self.fresh_item_substs(impl_def_id))
18171818
}
18181819

18191820
fn fresh_item_substs(&self, def_id: DefId) -> SubstsRef<'tcx> {

0 commit comments

Comments
 (0)