Skip to content

Commit

Permalink
Unrolled build for rust-lang#132366
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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`
  • Loading branch information
rust-timer authored Oct 31, 2024
2 parents c8b8378 + ec033e5 commit 0d5d42e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions compiler/rustc_hir_typeck/src/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/traits/const-traits/do-not-const-check.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/traits/const-traits/do-not-const-check.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0d5d42e

Please sign in to comment.