diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-10-31 06:11:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-31 06:11:58 +0100 |
| commit | 39086e42903c2f266df592f0aed155e9ddda1656 (patch) | |
| tree | 9d3a5db45eaee22e1a4ada0f02c4eda35ee3dc5e | |
| parent | 2b93bf60eed03e05b595224b38557f8f170a3ee9 (diff) | |
| parent | ec033e5bf1914094257932de0e7351a998cf40c1 (diff) | |
| download | rust-39086e42903c2f266df592f0aed155e9ddda1656.tar.gz rust-39086e42903c2f266df592f0aed155e9ddda1656.zip | |
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`
| -rw-r--r-- | compiler/rustc_hir_typeck/src/callee.rs | 5 | ||||
| -rw-r--r-- | tests/ui/traits/const-traits/do-not-const-check.rs | 3 | ||||
| -rw-r--r-- | tests/ui/traits/const-traits/do-not-const-check.stderr | 11 |
3 files changed, 18 insertions, 1 deletions
diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 93d50bf3d7b..6eb6792a119 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -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 diff --git a/tests/ui/traits/const-traits/do-not-const-check.rs b/tests/ui/traits/const-traits/do-not-const-check.rs index 443b6385735..d227a9a9c09 100644 --- a/tests/ui/traits/const-traits/do-not-const-check.rs +++ b/tests/ui/traits/const-traits/do-not-const-check.rs @@ -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 { diff --git a/tests/ui/traits/const-traits/do-not-const-check.stderr b/tests/ui/traits/const-traits/do-not-const-check.stderr new file mode 100644 index 00000000000..0d81ef74e8d --- /dev/null +++ b/tests/ui/traits/const-traits/do-not-const-check.stderr @@ -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 + |
