From ec033e5bf1914094257932de0e7351a998cf40c1 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 30 Oct 2024 17:27:12 +0000 Subject: [PATCH] Do not enforce ~const constness effects in typeck if rustc_do_mot_const_check --- compiler/rustc_hir_typeck/src/callee.rs | 5 +++++ tests/ui/traits/const-traits/do-not-const-check.rs | 3 ++- .../ui/traits/const-traits/do-not-const-check.stderr | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/ui/traits/const-traits/do-not-const-check.stderr diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 9cf1ea3fcb881..6fc53f66feb21 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::HostPolarity::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 443b638573576..d227a9a9c094b 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 0000000000000..0d81ef74e8d31 --- /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 for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted +