Skip to content

Commit b8f9cb3

Browse files
committed
Auto merge of #106696 - kylematsuda:early-binder, r=lcnr
Switch to `EarlyBinder` for `const_param_default` and `impl_trait_ref` queries Part of the work to close #105779 and implement rust-lang/types-team#78. Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This PR adds `EarlyBinder` to the return type of `const_param_default` and `impl_trait_ref`, and removes their `bound_X` variants. r? `@lcnr`
2 parents 4b51adf + 6e969ea commit b8f9cb3

File tree

55 files changed

+145
-112
lines changed

Some content is hidden

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

55 files changed

+145
-112
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
511511
return tcx.const_error(ty).into();
512512
}
513513
if !infer_args && has_default {
514-
tcx.bound_const_param_default(param.def_id)
515-
.subst(tcx, substs.unwrap())
516-
.into()
514+
tcx.const_param_default(param.def_id).subst(tcx, substs.unwrap()).into()
517515
} else {
518516
if infer_args {
519517
self.astconv.ct_infer(ty, Some(param), self.span).into()
@@ -2068,7 +2066,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
20682066
};
20692067

20702068
self.one_bound_for_assoc_type(
2071-
|| traits::supertraits(tcx, ty::Binder::dummy(trait_ref)),
2069+
|| traits::supertraits(tcx, ty::Binder::dummy(trait_ref.subst_identity())),
20722070
|| "Self".to_string(),
20732071
assoc_ident,
20742072
span,
@@ -2157,7 +2155,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
21572155
.is_accessible_from(self.item_def_id(), tcx)
21582156
&& tcx.all_impls(*trait_def_id)
21592157
.any(|impl_def_id| {
2160-
let trait_ref = tcx.bound_impl_trait_ref(impl_def_id);
2158+
let trait_ref = tcx.impl_trait_ref(impl_def_id);
21612159
trait_ref.map_or(false, |trait_ref| {
21622160
let impl_ = trait_ref.subst(
21632161
tcx,
@@ -2310,7 +2308,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
23102308
&& tcx.impl_polarity(impl_def_id) != ty::ImplPolarity::Negative
23112309
})
23122310
.filter_map(|impl_def_id| tcx.impl_trait_ref(impl_def_id))
2313-
.map(|impl_| impl_.self_ty())
2311+
.map(|impl_| impl_.subst_identity().self_ty())
23142312
// We don't care about blanket impls.
23152313
.filter(|self_ty| !self_ty.has_non_region_param())
23162314
.map(|self_ty| tcx.erase_regions(self_ty).to_string())

compiler/rustc_hir_analysis/src/check/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
540540
tcx,
541541
it.span,
542542
it.owner_id.def_id,
543-
impl_trait_ref,
543+
impl_trait_ref.subst_identity(),
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.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.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-4
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
182182
hir::ItemKind::Impl(ref impl_) => {
183183
let is_auto = tcx
184184
.impl_trait_ref(def_id)
185-
.map_or(false, |trait_ref| tcx.trait_is_auto(trait_ref.def_id));
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,7 @@ 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 = tcx.impl_trait_ref(item.owner_id).unwrap().subst_identity();
12571257
let trait_ref = wfcx.normalize(
12581258
ast_trait_ref.path.span,
12591259
Some(WellFormedLoc::Ty(item.hir_id().expect_owner().def_id)),
@@ -1350,7 +1350,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
13501350
// is incorrect when dealing with unused substs, for example
13511351
// for `struct Foo<const N: usize, const M: usize = { 1 - 2 }>`
13521352
// we should eagerly error.
1353-
let default_ct = tcx.const_param_default(param.def_id);
1353+
let default_ct = tcx.const_param_default(param.def_id).subst_identity();
13541354
if !default_ct.needs_subst() {
13551355
wfcx.register_wf_obligation(
13561356
tcx.def_span(param.def_id),
@@ -1396,7 +1396,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
13961396
GenericParamDefKind::Const { .. } => {
13971397
// If the param has a default, ...
13981398
if is_our_default(param) {
1399-
let default_ct = tcx.const_param_default(param.def_id);
1399+
let default_ct = tcx.const_param_default(param.def_id).subst_identity();
14001400
// ... and it's not a dependent default, ...
14011401
if !default_ct.needs_subst() {
14021402
// ... then substitute it with the default.

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.impl_trait_ref(impl_did).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.impl_trait_ref(impl_did).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.impl_trait_ref(impl_def_id).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.impl_trait_ref(impl_def_id).unwrap().subst_identity();
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

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

1616
if let Some(trait_ref) = tcx.impl_trait_ref(item.owner_id) {
17+
let trait_ref = trait_ref.subst_identity();
1718
let trait_def = tcx.trait_def(trait_ref.def_id);
1819
let unsafe_attr =
1920
impl_.generics.params.iter().find(|p| p.pure_wrt_drop).map(|_| "may_dangle");

compiler/rustc_hir_analysis/src/collect.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -1339,18 +1339,22 @@ fn suggest_impl_trait<'tcx>(
13391339
None
13401340
}
13411341

1342-
fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::TraitRef<'_>> {
1342+
fn impl_trait_ref(tcx: TyCtxt<'_>, def_id: DefId) -> Option<ty::EarlyBinder<ty::TraitRef<'_>>> {
13431343
let icx = ItemCtxt::new(tcx, def_id);
13441344
let item = tcx.hir().expect_item(def_id.expect_local());
13451345
match item.kind {
1346-
hir::ItemKind::Impl(ref impl_) => impl_.of_trait.as_ref().map(|ast_trait_ref| {
1347-
let selfty = tcx.type_of(def_id);
1348-
icx.astconv().instantiate_mono_trait_ref(
1349-
ast_trait_ref,
1350-
selfty,
1351-
check_impl_constness(tcx, impl_.constness, ast_trait_ref),
1352-
)
1353-
}),
1346+
hir::ItemKind::Impl(ref impl_) => impl_
1347+
.of_trait
1348+
.as_ref()
1349+
.map(|ast_trait_ref| {
1350+
let selfty = tcx.type_of(def_id);
1351+
icx.astconv().instantiate_mono_trait_ref(
1352+
ast_trait_ref,
1353+
selfty,
1354+
check_impl_constness(tcx, impl_.constness, ast_trait_ref),
1355+
)
1356+
})
1357+
.map(ty::EarlyBinder),
13541358
_ => bug!(),
13551359
}
13561360
}

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ 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 =
91+
tcx.impl_trait_ref(def_id).map(|t| ty::Binder::dummy(t.subst_identity()));
9192
}
9293
&impl_.generics
9394
}
@@ -251,7 +252,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
251252
// for details.
252253
if let Node::Item(&Item { kind: ItemKind::Impl { .. }, .. }) = node {
253254
let self_ty = tcx.type_of(def_id);
254-
let trait_ref = tcx.impl_trait_ref(def_id);
255+
let trait_ref = tcx.impl_trait_ref(def_id).map(ty::EarlyBinder::subst_identity);
255256
cgp::setup_constraining_predicates(
256257
tcx,
257258
&mut predicates,

compiler/rustc_hir_analysis/src/impl_wf_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ 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 = tcx.impl_trait_ref(impl_def_id).map(ty::EarlyBinder::subst_identity);
8989

9090
let mut input_parameters = cgp::parameters_for_impl(impl_self_ty, impl_trait_ref);
9191
cgp::identify_constrained_generic_params(

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub(super) fn check_min_specialization(tcx: TyCtxt<'_>, impl_def_id: LocalDefId)
9090

9191
fn parent_specialization_node(tcx: TyCtxt<'_>, impl1_def_id: LocalDefId) -> Option<Node> {
9292
let trait_ref = tcx.impl_trait_ref(impl1_def_id)?;
93-
let trait_def = tcx.trait_def(trait_ref.def_id);
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.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.impl_trait_ref(impl1_def_id).unwrap().subst_identity().substs {
374374
let infcx = &tcx.infer_ctxt().build();
375375
let obligations = wf::obligations(
376376
infcx,

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1224,9 +1224,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12241224
}
12251225
GenericParamDefKind::Const { has_default } => {
12261226
if !infer_args && has_default {
1227-
tcx.bound_const_param_default(param.def_id)
1228-
.subst(tcx, substs.unwrap())
1229-
.into()
1227+
tcx.const_param_default(param.def_id).subst(tcx, substs.unwrap()).into()
12301228
} else {
12311229
self.fcx.var_for_def(self.span, param)
12321230
}

compiler/rustc_hir_typeck/src/method/suggest.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10721072
// the impl, if local to crate (item may be defaulted), else nothing.
10731073
let Some(item) = self.associated_value(impl_did, item_name).or_else(|| {
10741074
let impl_trait_ref = self.tcx.impl_trait_ref(impl_did)?;
1075-
self.associated_value(impl_trait_ref.def_id, item_name)
1075+
self.associated_value(impl_trait_ref.skip_binder().def_id, item_name)
10761076
}) else {
10771077
continue;
10781078
};
@@ -1090,7 +1090,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10901090
let insertion = match self.tcx.impl_trait_ref(impl_did) {
10911091
None => String::new(),
10921092
Some(trait_ref) => {
1093-
format!(" of the trait `{}`", self.tcx.def_path_str(trait_ref.def_id))
1093+
format!(
1094+
" of the trait `{}`",
1095+
self.tcx.def_path_str(trait_ref.skip_binder().def_id)
1096+
)
10941097
}
10951098
};
10961099

@@ -1121,7 +1124,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11211124
}
11221125
if let Some(sugg_span) = sugg_span
11231126
&& let Some(trait_ref) = self.tcx.impl_trait_ref(impl_did) {
1124-
let path = self.tcx.def_path_str(trait_ref.def_id);
1127+
let path = self.tcx.def_path_str(trait_ref.skip_binder().def_id);
11251128

11261129
let ty = match item.kind {
11271130
ty::AssocKind::Const | ty::AssocKind::Type => rcvr_ty,
@@ -2616,7 +2619,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26162619
self.tcx.impl_polarity(*imp_did) == ty::ImplPolarity::Negative
26172620
})
26182621
.any(|imp_did| {
2619-
let imp = self.tcx.impl_trait_ref(imp_did).unwrap();
2622+
let imp = self.tcx.impl_trait_ref(imp_did).unwrap().subst_identity();
26202623
let imp_simp =
26212624
simplify_type(self.tcx, imp.self_ty(), TreatParams::AsPlaceholder);
26222625
imp_simp.map_or(false, |s| s == simp_rcvr_ty)

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

+1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
320320
.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_metadata/src/rmeta/encoder.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ 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 = self.tcx.impl_trait_ref(def_id).map(ty::EarlyBinder::skip_binder);
15591559
if let Some(trait_ref) = trait_ref {
15601560
let trait_def = self.tcx.trait_def(trait_ref.def_id);
15611561
if let Ok(mut an) = trait_def.ancestors(self.tcx, def_id) {
@@ -1899,6 +1899,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
18991899
for id in tcx.hir().items() {
19001900
if matches!(tcx.def_kind(id.owner_id), DefKind::Impl) {
19011901
if let Some(trait_ref) = tcx.impl_trait_ref(id.owner_id) {
1902+
let trait_ref = trait_ref.subst_identity();
1903+
19021904
let simplified_self_ty = fast_reject::simplify_type(
19031905
self.tcx,
19041906
trait_ref.self_ty(),

compiler/rustc_metadata/src/rmeta/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ define_tables! {
359359
variances_of: Table<DefIndex, LazyArray<ty::Variance>>,
360360
fn_sig: Table<DefIndex, LazyValue<ty::PolyFnSig<'static>>>,
361361
codegen_fn_attrs: Table<DefIndex, LazyValue<CodegenFnAttrs>>,
362-
impl_trait_ref: Table<DefIndex, LazyValue<ty::TraitRef<'static>>>,
363-
const_param_default: Table<DefIndex, LazyValue<rustc_middle::ty::Const<'static>>>,
362+
impl_trait_ref: Table<DefIndex, LazyValue<ty::EarlyBinder<ty::TraitRef<'static>>>>,
363+
const_param_default: Table<DefIndex, LazyValue<ty::EarlyBinder<rustc_middle::ty::Const<'static>>>>,
364364
object_lifetime_default: Table<DefIndex, LazyValue<ObjectLifetimeDefault>>,
365365
optimized_mir: Table<DefIndex, LazyValue<mir::Body<'static>>>,
366366
mir_for_ctfe: Table<DefIndex, LazyValue<mir::Body<'static>>>,

compiler/rustc_middle/src/hir/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ impl<'tcx> TyCtxt<'tcx> {
102102

103103
pub fn impl_subject(self, def_id: DefId) -> ImplSubject<'tcx> {
104104
self.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/query/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ rustc_queries! {
142142

143143
/// Given the def_id of a const-generic parameter, computes the associated default const
144144
/// parameter. e.g. `fn example<const N: usize=3>` called on `N` would return `3`.
145-
query const_param_default(param: DefId) -> ty::Const<'tcx> {
145+
query const_param_default(param: DefId) -> ty::EarlyBinder<ty::Const<'tcx>> {
146146
desc { |tcx| "computing const default for a given parameter `{}`", tcx.def_path_str(param) }
147147
cache_on_disk_if { param.is_local() }
148148
separate_provide_extern
@@ -737,7 +737,7 @@ rustc_queries! {
737737

738738
/// Given an `impl_id`, return the trait it implements.
739739
/// Return `None` if this is an inherent impl.
740-
query impl_trait_ref(impl_id: DefId) -> Option<ty::TraitRef<'tcx>> {
740+
query impl_trait_ref(impl_id: DefId) -> Option<ty::EarlyBinder<ty::TraitRef<'tcx>>> {
741741
desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) }
742742
cache_on_disk_if { impl_id.is_local() }
743743
separate_provide_extern

compiler/rustc_middle/src/ty/consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl<'tcx> Const<'tcx> {
239239
}
240240
}
241241

242-
pub fn const_param_default(tcx: TyCtxt<'_>, def_id: DefId) -> Const<'_> {
242+
pub fn const_param_default(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Const<'_>> {
243243
let default_def_id = match tcx.hir().get_by_def_id(def_id.expect_local()) {
244244
hir::Node::GenericParam(hir::GenericParam {
245245
kind: hir::GenericParamKind::Const { default: Some(ac), .. },
@@ -250,5 +250,5 @@ pub fn const_param_default(tcx: TyCtxt<'_>, def_id: DefId) -> Const<'_> {
250250
"`const_param_default` expected a generic parameter with a constant"
251251
),
252252
};
253-
Const::from_anon_const(tcx, default_def_id)
253+
ty::EarlyBinder(Const::from_anon_const(tcx, default_def_id))
254254
}

compiler/rustc_middle/src/ty/generics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl GenericParamDef {
8888
Some(tcx.bound_type_of(self.def_id).map_bound(|t| t.into()))
8989
}
9090
GenericParamDefKind::Const { has_default } if has_default => {
91-
Some(tcx.bound_const_param_default(self.def_id).map_bound(|c| c.into()))
91+
Some(tcx.const_param_default(self.def_id).map_bound(|c| c.into()))
9292
}
9393
_ => None,
9494
}

0 commit comments

Comments
 (0)