Skip to content

Commit 39086e4

Browse files
authored
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`
2 parents 2b93bf6 + ec033e5 commit 39086e4

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Diff for: compiler/rustc_hir_typeck/src/callee.rs

+5
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
851851
return;
852852
}
853853

854+
// If we have `rustc_do_not_const_check`, do not check `~const` bounds.
855+
if self.tcx.has_attr(self.body_id, sym::rustc_do_not_const_check) {
856+
return;
857+
}
858+
854859
let host = match self.tcx.hir().body_const_context(self.body_id) {
855860
Some(hir::ConstContext::Const { .. } | hir::ConstContext::Static(_)) => {
856861
ty::BoundConstness::Const

Diff for: tests/ui/traits/const-traits/do-not-const-check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//@ check-pass
2-
#![feature(const_trait_impl, rustc_attrs)]
2+
#![feature(const_trait_impl, rustc_attrs, effects)]
3+
//~^ WARN the feature `effects` is incomplete
34

45
#[const_trait]
56
trait IntoIter {
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/do-not-const-check.rs:2:43
3+
|
4+
LL | #![feature(const_trait_impl, rustc_attrs, effects)]
5+
| ^^^^^^^
6+
|
7+
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+

0 commit comments

Comments
 (0)