Rollup merge of #77203 - ecstatic-morse:const-stability-attr-checks, r=oli-obk
Check for missing const-stability attributes in `rustc_passes` Currently, this happens as a side effect of `is_min_const_fn`, which is non-obvious. Also adds a test for this case, since we didn't seem to have one before.
This commit is contained in:
commit
9f086fcb00
5 changed files with 52 additions and 11 deletions
|
@ -50,7 +50,7 @@ pub fn is_min_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
|||
None => {
|
||||
if let Some(stab) = tcx.lookup_stability(def_id) {
|
||||
if stab.level.is_stable() {
|
||||
tcx.sess.span_err(
|
||||
tcx.sess.delay_span_bug(
|
||||
tcx.def_span(def_id),
|
||||
"stable const functions must have either `rustc_const_stable` or \
|
||||
`rustc_const_unstable` attribute",
|
||||
|
|
|
@ -204,9 +204,6 @@ impl Validator<'mir, 'tcx> {
|
|||
pub fn check_body(&mut self) {
|
||||
let ConstCx { tcx, body, def_id, .. } = *self.ccx;
|
||||
|
||||
// HACK: This function has side-effects???? Make sure we call it.
|
||||
let _ = crate::const_eval::is_min_const_fn(tcx, def_id.to_def_id());
|
||||
|
||||
// The local type and predicate checks are not free and only relevant for `const fn`s.
|
||||
if self.const_kind() == hir::ConstContext::ConstFn {
|
||||
// Prevent const trait methods from being annotated as `stable`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue