make the eval() functions on our const types return the resulting value

This commit is contained in:
Ralf Jung
2023-09-12 23:28:25 +02:00
parent e5fedceabf
commit 6e4779ab17
16 changed files with 167 additions and 245 deletions

View File

@@ -129,19 +129,16 @@ mod rustc {
c: Const<'tcx>,
) -> Option<Self> {
use rustc_middle::ty::ScalarInt;
use rustc_middle::ty::TypeVisitableExt;
use rustc_span::symbol::sym;
let c = c.eval(tcx, param_env);
if let Err(err) = c.error_reported() {
let Ok(cv) = c.eval(tcx, param_env, None) else {
return Some(Self {
alignment: true,
lifetimes: true,
safety: true,
validity: true,
});
}
};
let adt_def = c.ty().ty_adt_def()?;
@@ -153,8 +150,8 @@ mod rustc {
);
let variant = adt_def.non_enum_variant();
let fields = match c.try_to_valtree() {
Some(ValTree::Branch(branch)) => branch,
let fields = match cv {
ValTree::Branch(branch) => branch,
_ => {
return Some(Self {
alignment: true,