change usages of const_param_default query to bound_const_param_default

This commit is contained in:
Kyle Matsuda 2023-01-10 12:20:15 -07:00
parent c84917ad2e
commit bd6c63597b
4 changed files with 9 additions and 5 deletions

View File

@ -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 // is incorrect when dealing with unused substs, for example
// for `struct Foo<const N: usize, const M: usize = { 1 - 2 }>` // for `struct Foo<const N: usize, const M: usize = { 1 - 2 }>`
// we should eagerly error. // we should eagerly error.
let default_ct = tcx.const_param_default(param.def_id); let default_ct = tcx.bound_const_param_default(param.def_id).subst_identity();
if !default_ct.needs_subst() { if !default_ct.needs_subst() {
wfcx.register_wf_obligation( wfcx.register_wf_obligation(
tcx.def_span(param.def_id), tcx.def_span(param.def_id),
@ -1396,7 +1396,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
GenericParamDefKind::Const { .. } => { GenericParamDefKind::Const { .. } => {
// If the param has a default, ... // If the param has a default, ...
if is_our_default(param) { if is_our_default(param) {
let default_ct = tcx.const_param_default(param.def_id); let default_ct = tcx.bound_const_param_default(param.def_id).subst_identity();
// ... and it's not a dependent default, ... // ... and it's not a dependent default, ...
if !default_ct.needs_subst() { if !default_ct.needs_subst() {
// ... then substitute it with the default. // ... then substitute it with the default.

View File

@ -2070,7 +2070,7 @@ fn encode_info_for_generics(&mut self, generics: &hir::Generics<'tcx>) {
hir::GenericParamKind::Const { ref default, .. } => { hir::GenericParamKind::Const { ref default, .. } => {
let def_id = param.def_id.to_def_id(); let def_id = param.def_id.to_def_id();
if default.is_some() { if default.is_some() {
record!(self.tables.const_param_default[def_id] <- self.tcx.const_param_default(def_id)) record!(self.tables.const_param_default[def_id] <- self.tcx.bound_const_param_default(def_id).subst_identity())
} }
} }
} }

View File

@ -838,7 +838,9 @@ fn generics(&mut self) -> &mut Self {
GenericParamDefKind::Const { has_default } => { GenericParamDefKind::Const { has_default } => {
self.visit(self.ev.tcx.type_of(param.def_id)); self.visit(self.ev.tcx.type_of(param.def_id));
if has_default { if has_default {
self.visit(self.ev.tcx.const_param_default(param.def_id)); self.visit(
self.ev.tcx.bound_const_param_default(param.def_id).subst_identity(),
);
} }
} }
} }

View File

@ -506,7 +506,9 @@ fn clean_generic_param_def<'tcx>(
Some(def.def_id), Some(def.def_id),
)), )),
default: match has_default { default: match has_default {
true => Some(Box::new(cx.tcx.const_param_default(def.def_id).to_string())), true => Some(Box::new(
cx.tcx.bound_const_param_default(def.def_id).subst_identity().to_string(),
)),
false => None, false => None,
}, },
}, },