Skip to content

Commit

Permalink
Do not enforce ~const constness effects in typeck if rustc_do_mot_con…
Browse files Browse the repository at this point in the history
…st_check
  • Loading branch information
compiler-errors committed Oct 30, 2024
1 parent 298c746 commit d706482
Show file tree
Hide file tree
Showing 2 changed files with 7 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::HostPolarity::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

0 comments on commit d706482

Please sign in to comment.