Rollup merge of #132366 - compiler-errors:do-not-const-check, r=fee1-dead

Do not enforce `~const` constness effects in typeck if `rustc_do_not_const_check`

Fixes a slight inconsistency between HIR and MIR enforcement of `~const` :D

r? `@rust-lang/project-const-traits`
This commit is contained in:
Matthias Krüger 2024-10-31 06:11:58 +01:00 committed by GitHub
commit 39086e4290
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View File

@ -851,6 +851,11 @@ pub(super) fn enforce_context_effects(
return;
}
// If we have `rustc_do_not_const_check`, do not check `~const` bounds.
if self.tcx.has_attr(self.body_id, sym::rustc_do_not_const_check) {
return;
}
let host = match self.tcx.hir().body_const_context(self.body_id) {
Some(hir::ConstContext::Const { .. } | hir::ConstContext::Static(_)) => {
ty::BoundConstness::Const

View File

@ -1,5 +1,6 @@
//@ check-pass
#![feature(const_trait_impl, rustc_attrs)]
#![feature(const_trait_impl, rustc_attrs, effects)]
//~^ WARN the feature `effects` is incomplete
#[const_trait]
trait IntoIter {

View File

@ -0,0 +1,11 @@
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/do-not-const-check.rs:2:43
|
LL | #![feature(const_trait_impl, rustc_attrs, effects)]
| ^^^^^^^
|
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: 1 warning emitted