change const_param_default query to return EarlyBinder; remove bound_const_param_default query; add EarlyBinder to const_param_default in metadata
This commit is contained in:
parent
bd6c63597b
commit
ef58baf8b8
@ -511,9 +511,7 @@ fn inferred_kind(
|
||||
return tcx.const_error(ty).into();
|
||||
}
|
||||
if !infer_args && has_default {
|
||||
tcx.bound_const_param_default(param.def_id)
|
||||
.subst(tcx, substs.unwrap())
|
||||
.into()
|
||||
tcx.const_param_default(param.def_id).subst(tcx, substs.unwrap()).into()
|
||||
} else {
|
||||
if infer_args {
|
||||
self.astconv.ct_infer(ty, Some(param), self.span).into()
|
||||
|
@ -1350,7 +1350,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
||||
// is incorrect when dealing with unused substs, for example
|
||||
// for `struct Foo<const N: usize, const M: usize = { 1 - 2 }>`
|
||||
// we should eagerly error.
|
||||
let default_ct = tcx.bound_const_param_default(param.def_id).subst_identity();
|
||||
let default_ct = tcx.const_param_default(param.def_id).subst_identity();
|
||||
if !default_ct.needs_subst() {
|
||||
wfcx.register_wf_obligation(
|
||||
tcx.def_span(param.def_id),
|
||||
@ -1396,7 +1396,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
||||
GenericParamDefKind::Const { .. } => {
|
||||
// If the param has a default, ...
|
||||
if is_our_default(param) {
|
||||
let default_ct = tcx.bound_const_param_default(param.def_id).subst_identity();
|
||||
let default_ct = tcx.const_param_default(param.def_id).subst_identity();
|
||||
// ... and it's not a dependent default, ...
|
||||
if !default_ct.needs_subst() {
|
||||
// ... then substitute it with the default.
|
||||
|
@ -1224,9 +1224,7 @@ fn inferred_kind(
|
||||
}
|
||||
GenericParamDefKind::Const { has_default } => {
|
||||
if !infer_args && has_default {
|
||||
tcx.bound_const_param_default(param.def_id)
|
||||
.subst(tcx, substs.unwrap())
|
||||
.into()
|
||||
tcx.const_param_default(param.def_id).subst(tcx, substs.unwrap()).into()
|
||||
} else {
|
||||
self.fcx.var_for_def(self.span, param)
|
||||
}
|
||||
|
@ -2070,7 +2070,7 @@ fn encode_info_for_generics(&mut self, generics: &hir::Generics<'tcx>) {
|
||||
hir::GenericParamKind::Const { ref default, .. } => {
|
||||
let def_id = param.def_id.to_def_id();
|
||||
if default.is_some() {
|
||||
record!(self.tables.const_param_default[def_id] <- self.tcx.bound_const_param_default(def_id).subst_identity())
|
||||
record!(self.tables.const_param_default[def_id] <- self.tcx.const_param_default(def_id))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ fn encode(&self, buf: &mut FileEncoder) -> LazyTables {
|
||||
fn_sig: Table<DefIndex, LazyValue<ty::PolyFnSig<'static>>>,
|
||||
codegen_fn_attrs: Table<DefIndex, LazyValue<CodegenFnAttrs>>,
|
||||
impl_trait_ref: Table<DefIndex, LazyValue<ty::TraitRef<'static>>>,
|
||||
const_param_default: Table<DefIndex, LazyValue<rustc_middle::ty::Const<'static>>>,
|
||||
const_param_default: Table<DefIndex, LazyValue<ty::EarlyBinder<rustc_middle::ty::Const<'static>>>>,
|
||||
object_lifetime_default: Table<DefIndex, LazyValue<ObjectLifetimeDefault>>,
|
||||
optimized_mir: Table<DefIndex, LazyValue<mir::Body<'static>>>,
|
||||
mir_for_ctfe: Table<DefIndex, LazyValue<mir::Body<'static>>>,
|
||||
|
@ -142,7 +142,7 @@
|
||||
|
||||
/// Given the def_id of a const-generic parameter, computes the associated default const
|
||||
/// parameter. e.g. `fn example<const N: usize=3>` called on `N` would return `3`.
|
||||
query const_param_default(param: DefId) -> ty::Const<'tcx> {
|
||||
query const_param_default(param: DefId) -> ty::EarlyBinder<ty::Const<'tcx>> {
|
||||
desc { |tcx| "computing const default for a given parameter `{}`", tcx.def_path_str(param) }
|
||||
cache_on_disk_if { param.is_local() }
|
||||
separate_provide_extern
|
||||
|
@ -239,7 +239,7 @@ pub fn is_ct_infer(self) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn const_param_default(tcx: TyCtxt<'_>, def_id: DefId) -> Const<'_> {
|
||||
pub fn const_param_default(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Const<'_>> {
|
||||
let default_def_id = match tcx.hir().get_by_def_id(def_id.expect_local()) {
|
||||
hir::Node::GenericParam(hir::GenericParam {
|
||||
kind: hir::GenericParamKind::Const { default: Some(ac), .. },
|
||||
@ -250,5 +250,5 @@ pub fn const_param_default(tcx: TyCtxt<'_>, def_id: DefId) -> Const<'_> {
|
||||
"`const_param_default` expected a generic parameter with a constant"
|
||||
),
|
||||
};
|
||||
Const::from_anon_const(tcx, default_def_id)
|
||||
ty::EarlyBinder(Const::from_anon_const(tcx, default_def_id))
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ pub fn default_value<'tcx>(
|
||||
Some(tcx.bound_type_of(self.def_id).map_bound(|t| t.into()))
|
||||
}
|
||||
GenericParamDefKind::Const { has_default } if has_default => {
|
||||
Some(tcx.bound_const_param_default(self.def_id).map_bound(|c| c.into()))
|
||||
Some(tcx.const_param_default(self.def_id).map_bound(|c| c.into()))
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
|
@ -673,10 +673,6 @@ pub fn bound_item_bounds(
|
||||
ty::EarlyBinder(self.item_bounds(def_id))
|
||||
}
|
||||
|
||||
pub fn bound_const_param_default(self, def_id: DefId) -> ty::EarlyBinder<ty::Const<'tcx>> {
|
||||
ty::EarlyBinder(self.const_param_default(def_id))
|
||||
}
|
||||
|
||||
pub fn bound_predicates_of(
|
||||
self,
|
||||
def_id: DefId,
|
||||
|
@ -838,9 +838,7 @@ fn generics(&mut self) -> &mut Self {
|
||||
GenericParamDefKind::Const { has_default } => {
|
||||
self.visit(self.ev.tcx.type_of(param.def_id));
|
||||
if has_default {
|
||||
self.visit(
|
||||
self.ev.tcx.bound_const_param_default(param.def_id).subst_identity(),
|
||||
);
|
||||
self.visit(self.ev.tcx.const_param_default(param.def_id).subst_identity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -507,7 +507,7 @@ fn clean_generic_param_def<'tcx>(
|
||||
)),
|
||||
default: match has_default {
|
||||
true => Some(Box::new(
|
||||
cx.tcx.bound_const_param_default(def.def_id).subst_identity().to_string(),
|
||||
cx.tcx.const_param_default(def.def_id).subst_identity().to_string(),
|
||||
)),
|
||||
false => None,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user