Git Product home page Git Product logo

Comments (3)

tmiasko avatar tmiasko commented on July 19, 2024 1

Nightly reproducer:

#![feature(core_intrinsics)]
#![feature(const_eval_select)]
use std::intrinsics::const_eval_select;
#[inline(always)]
pub const fn f() {
    const_eval_select((), g, g)
}
#[inline(always)]
pub const fn g() {
    const_eval_select((), f, f)
}
error[E0391]: cycle detected when optimizing MIR for `f`
 --> a.rs:5:1
  |
5 | pub const fn f() {
  | ^^^^^^^^^^^^^^^^
  |
note: ...which requires optimizing MIR for `g`...
 --> a.rs:9:1
  |
9 | pub const fn g() {
  | ^^^^^^^^^^^^^^^^
  = note: ...which again requires optimizing MIR for `f`, completing the cycle

from rust.

tmiasko avatar tmiasko commented on July 19, 2024

The cycle detection probably doesn't understand const_eval_select intrinsic. The intrinsic is lowered in optimized_mir query, while cycle detection operates on promoted_mir.

from rust.

saethlin avatar saethlin commented on July 19, 2024

That was my instinct as well. What's tripping me up mentally is that with this patch, I can x build library without a cycle error:

diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index 4943bbc45d0..bf5539fd1ec 100644
--- a/library/core/src/str/mod.rs
+++ b/library/core/src/str/mod.rs
@@ -80,8 +80,7 @@
 use iter::SplitInternal;
 use iter::{MatchesInternal, SplitNInternal};
 
-#[inline(never)]
-#[cold]
+#[cfg_attr(bootstrap, inline(never))]
 #[track_caller]
 #[rustc_allow_const_fn_unstable(const_eval_select)]
 #[cfg(not(feature = "panic_immediate_abort"))]

There's no remap_mir_for_const_eval_select inside of the cycle detection logic. I think there should be. But I also think that since the latest beta, we accidentally fixed this somehow?

from rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.