|
9 | 9 | //! This pass assumes that every use is dominated by an initialization and can |
10 | 10 | //! otherwise silence errors, if move analysis runs after promotion on broken |
11 | 11 | //! MIR. |
| 12 | +#![allow(unused)] |
12 | 13 |
|
13 | 14 | use std::assert_matches::assert_matches; |
14 | 15 | use std::cell::Cell; |
@@ -662,33 +663,8 @@ impl<'tcx> Validator<'_, 'tcx> { |
662 | 663 | } |
663 | 664 | } |
664 | 665 |
|
665 | | - // Ideally, we'd stop here and reject the rest. |
666 | | - // But for backward compatibility, we have to accept some promotion in const/static |
667 | | - // initializers. Inline consts are explicitly excluded, they are more recent so we have no |
668 | | - // backwards compatibility reason to allow more promotion inside of them. |
669 | | - let promote_all_fn = matches!( |
670 | | - self.const_kind, |
671 | | - Some(hir::ConstContext::Static(_) | hir::ConstContext::Const { inline: false }) |
672 | | - ); |
673 | | - if !promote_all_fn { |
674 | | - return Err(Unpromotable); |
675 | | - } |
676 | | - // Make sure the callee is a `const fn`. |
677 | | - let is_const_fn = match *fn_ty.kind() { |
678 | | - ty::FnDef(def_id, _) => self.tcx.is_const_fn(def_id), |
679 | | - _ => false, |
680 | | - }; |
681 | | - if !is_const_fn { |
682 | | - return Err(Unpromotable); |
683 | | - } |
684 | | - // The problem is, this may promote calls to functions that panic. |
685 | | - // We don't want to introduce compilation errors if there's a panic in a call in dead code. |
686 | | - // So we ensure that this is not dead code. |
687 | | - if !self.is_promotion_safe_block(block) { |
688 | | - return Err(Unpromotable); |
689 | | - } |
690 | | - // This passed all checks, so let's accept. |
691 | | - Ok(()) |
| 666 | + // Ideally, we'd stop here and reject the rest. So let's do that. |
| 667 | + return Err(Unpromotable); |
692 | 668 | } |
693 | 669 | } |
694 | 670 |
|
|
0 commit comments