changes from review

This commit is contained in:
Kyle Matsuda 2023-02-14 14:17:38 -07:00
parent c183110cc2
commit 8e92849cbb
11 changed files with 53 additions and 12 deletions

View File

@ -690,7 +690,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
assert!(self.tcx.is_static(def_id));
assert!(!self.tcx.is_thread_local_static(def_id));
// Use size and align of the type.
let ty = self.tcx.type_of(def_id).subst_identity();
let ty = self
.tcx
.type_of(def_id)
.no_bound_vars()
.expect("statics should not have generic parameters");
let layout = self.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap();
assert!(layout.is_sized());
(layout.size, layout.align.abi, AllocKind::LiveData)

View File

@ -450,7 +450,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
.into()
}
(&GenericParamDefKind::Const { .. }, hir::GenericArg::Infer(inf)) => {
let ty = tcx.at(self.span).type_of(param.def_id).subst_identity();
let ty = tcx
.at(self.span)
.type_of(param.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic");
if self.astconv.allow_ty_infer() {
self.astconv.ct_infer(ty, Some(param), inf.span).into()
} else {
@ -503,7 +507,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
}
}
GenericParamDefKind::Const { has_default } => {
let ty = tcx.at(self.span).type_of(param.def_id).subst_identity();
let ty = tcx
.at(self.span)
.type_of(param.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic");
if ty.references_error() {
return tcx.const_error(ty).into();
}

View File

@ -2037,7 +2037,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
args: &[hir::Expr<'_>],
kind: CallableKind| {
let arg_idx = args.iter().position(|a| a.hir_id == expr.hir_id).unwrap();
let fn_ty = self.tcx.type_of(def_id).0;
let fn_ty = self.tcx.type_of(def_id).skip_binder();
if !fn_ty.is_fn() {
return;
}

View File

@ -1228,7 +1228,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let tcx = self.fcx.tcx();
self.fcx
.ct_infer(
tcx.type_of(param.def_id).subst_identity(),
tcx.type_of(param.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic"),
Some(param),
inf.span,
)

View File

@ -386,7 +386,9 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
let tcx = self.cfcx.tcx();
self.cfcx
.ct_infer(
tcx.type_of(param.def_id).subst_identity(),
tcx.type_of(param.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic"),
Some(param),
inf.span,
)

View File

@ -1958,7 +1958,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
kind: ConstVariableOriginKind::SubstitutionPlaceholder,
span,
};
self.next_const_var(self.tcx.type_of(param.def_id).subst_identity(), origin).into()
self.next_const_var(
self.tcx
.type_of(param.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic"),
origin,
)
.into()
}
})
}

View File

@ -1167,7 +1167,13 @@ impl<'tcx> InferCtxt<'tcx> {
val: ConstVariableValue::Unknown { universe: self.universe() },
});
self.tcx
.mk_const(const_var_id, self.tcx.type_of(param.def_id).subst_identity())
.mk_const(
const_var_id,
self.tcx
.type_of(param.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic"),
)
.into()
}
}

View File

@ -71,7 +71,10 @@ impl<'tcx> Const<'tcx> {
let expr = &tcx.hir().body(body_id).value;
debug!(?expr);
let ty = tcx.type_of(def.def_id_for_type_of()).subst_identity();
let ty = tcx
.type_of(def.def_id_for_type_of())
.no_bound_vars()
.expect("const parameter types cannot be generic");
match Self::try_eval_lit_or_param(tcx, ty, expr) {
Some(v) => v,

View File

@ -2002,7 +2002,9 @@ impl<'tcx> TyCtxt<'tcx> {
GenericParamDefKind::Const { .. } => self
.mk_const(
ParamConst { index: param.index, name: param.name },
self.type_of(param.def_id).subst_identity(),
self.type_of(param.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic"),
)
.into(),
}

View File

@ -557,7 +557,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
ty::INNERMOST,
ty::BoundVar::from_usize(bound_vars.len() - 1),
),
tcx.type_of(param.def_id).subst_identity(),
tcx.type_of(param.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic"),
)
.into()
}

View File

@ -508,7 +508,12 @@ fn clean_generic_param_def<'tcx>(
GenericParamDefKind::Const {
did: def.def_id,
ty: Box::new(clean_middle_ty(
ty::Binder::dummy(cx.tcx.type_of(def.def_id).subst_identity()),
ty::Binder::dummy(
cx.tcx
.type_of(def.def_id)
.no_bound_vars()
.expect("const parameter types cannot be generic"),
),
cx,
Some(def.def_id),
)),