1
Fork 0

Use ConstArg for const param defaults

Now everything that actually affects the type system (i.e., excluding
const blocks, enum variant discriminants, etc.) *should* be using
`ConstArg`.
This commit is contained in:
Noah Lev 2024-06-07 20:26:50 -07:00
parent 67fccb7045
commit 1c49d406b6
12 changed files with 34 additions and 26 deletions

View file

@ -304,7 +304,10 @@ impl<'tcx> Visitor<'tcx> for CollectItemTypesVisitor<'tcx> {
self.tcx.ensure().type_of(param.def_id);
if let Some(default) = default {
// need to store default and type of default
self.tcx.ensure().type_of(default.def_id);
#[allow(irrefutable_let_patterns)] // FIXME
if let hir::ConstArgKind::Anon(ac) = default.kind {
self.tcx.ensure().type_of(ac.def_id);
}
self.tcx.ensure().const_param_default(param.def_id);
}
}

View file

@ -388,7 +388,7 @@ fn const_evaluatable_predicates_of(
}
}
fn visit_const_param_default(&mut self, _param: HirId, _ct: &'tcx hir::AnonConst) {
fn visit_const_param_default(&mut self, _param: HirId, _ct: &'tcx hir::ConstArg<'tcx>) {
// Do not look into const param defaults,
// these get checked when they are actually instantiated.
//

View file

@ -954,7 +954,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
GenericParamKind::Const { ty, default, .. } => {
self.visit_ty(ty);
if let Some(default) = default {
self.visit_body(self.tcx.hir().body(default.body));
self.visit_const_arg(default);
}
}
}

View file

@ -73,7 +73,7 @@ fn anon_const_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
def_id: param_def_id,
kind: GenericParamKind::Const { default: Some(ct), .. },
..
}) if ct.hir_id == hir_id => {
}) if ct.anon_const_hir_id() == hir_id => {
return tcx
.type_of(param_def_id)
.no_bound_vars()