1
Fork 0

Use the constness from the param env instead of having a separate dimension for it

This breaks a ~const test that will be fixed in a follow up commit of this PR
This commit is contained in:
Oli Scherer 2021-10-21 16:07:37 +00:00 committed by Deadbeef
parent 19f2101272
commit d51068ca28
No known key found for this signature in database
GPG key ID: 6D017A96D8E6C2F9
12 changed files with 25 additions and 142 deletions

View file

@ -69,6 +69,16 @@ impl PredicateObligation<'tcx> {
}
}
impl TraitObligation<'tcx> {
/// Returns `true` if the trait predicate is considered `const` in its ParamEnv.
pub fn is_const(&self) -> bool {
match (self.predicate.skip_binder().constness, self.param_env.constness()) {
(ty::BoundConstness::ConstIfConst, hir::Constness::Const) => true,
_ => false,
}
}
}
// `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
static_assert_size!(PredicateObligation<'_>, 32);