Allow features like const_try in d_m_b_i_c

This commit is contained in:
Deadbeef 2021-09-29 12:15:35 +00:00
parent e0c2ff7ccc
commit b2005117bc
No known key found for this signature in database
GPG key ID: 027DF9338862ADDD
2 changed files with 57 additions and 0 deletions

View file

@ -173,6 +173,12 @@ impl<'tcx> CheckConstVisitor<'tcx> {
None => return true,
};
// If the function belongs to a trait, then it must enable the const_trait_impl
// feature to use that trait function (with a const default body).
if tcx.trait_of_item(def_id).is_some() {
return true;
}
// If this crate is not using stability attributes, or this function is not claiming to be a
// stable `const fn`, that is all that is required.
if !tcx.features().staged_api || tcx.has_attr(def_id, sym::rustc_const_unstable) {