Add query for const_param_default
This commit is contained in:
parent
0e56a086f7
commit
9fe793ae5d
17 changed files with 108 additions and 27 deletions
|
@ -505,10 +505,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
}
|
||||
}
|
||||
GenericParamDefKind::Const { has_default } => {
|
||||
let ty = tcx.at(self.span).type_of(param.def_id);
|
||||
if !infer_args && has_default {
|
||||
ty::Const::from_anon_const(tcx, param.def_id.expect_local()).into()
|
||||
tcx.const_param_default(param.def_id).into()
|
||||
} else {
|
||||
let ty = tcx.at(self.span).type_of(param.def_id);
|
||||
if infer_args {
|
||||
self.astconv.ct_infer(ty, Some(param), self.span).into()
|
||||
} else {
|
||||
|
|
|
@ -1445,7 +1445,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
GenericParamDefKind::Const { has_default, .. } => {
|
||||
if !infer_args && has_default {
|
||||
ty::Const::from_anon_const(tcx, param.def_id.expect_local()).into()
|
||||
tcx.const_param_default(param.def_id).into()
|
||||
} else {
|
||||
self.fcx.var_for_def(self.span, param)
|
||||
}
|
||||
|
|
|
@ -774,7 +774,7 @@ fn check_where_clauses<'tcx, 'fcx>(
|
|||
}
|
||||
GenericParamDefKind::Const { .. } => {
|
||||
if is_our_default(param) {
|
||||
let default_ct = ty::Const::from_anon_const(tcx, param.def_id.expect_local());
|
||||
let default_ct = tcx.const_param_default(param.def_id);
|
||||
// Const params have to currently be concrete.
|
||||
assert!(!default_ct.needs_subst());
|
||||
default_ct.into()
|
||||
|
|
|
@ -257,10 +257,11 @@ impl Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
|
|||
hir::GenericParamKind::Const { default, .. } => {
|
||||
let def_id = self.tcx.hir().local_def_id(param.hir_id);
|
||||
self.tcx.ensure().type_of(def_id);
|
||||
// FIXME(const_generics_defaults)
|
||||
if let Some(default) = default {
|
||||
let def_id = self.tcx.hir().local_def_id(default.hir_id);
|
||||
// need to store default and type of default
|
||||
self.tcx.ensure().type_of(def_id);
|
||||
self.tcx.ensure().const_param_default(def_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue