-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler error doesn't show full query chain when evaluating const cycle #66332
Comments
While it would be easy to dump the entire query stack instead of just the last part, the output can contain very surprising things that may confuse even more and its root will change arbitrarily between runs (especially with a parallel compiler). You could have the situation where rerunning the same program would tell you a different root cause with every rerun. |
As far as I can tell, if the rust/src/librustc/ty/query/plumbing.rs Lines 308 to 313 in a916ac2
I think it would be deisirable to note something that caused the cycle to be evaluated, even if that something isn't perfect. I think this because const cycles can exist in valid rust code as long as that const cycle is never evaluated. So a user doing innocent enough refactoring might trigger evaluation of a const cycle and see this cycle error even if they never touched the part of the program containing the cycle. See a playground example here: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e02eff4470d70269dce44ccb2440a537 In that playground, the use of the function Of course, my opinion may be differ from others and please disregard mine if the majority disagrees! |
Yea that's definitely a good idea.
Oh neat. So I'm guessing rust/src/librustc/ty/query/job.rs Lines 95 to 97 in a916ac2
In rust/src/librustc/ty/query/job.rs Line 395 in a916ac2
rust/src/librustc/ty/query/job.rs Line 386 in a916ac2
So to debug this issue, you can compile your snippet with a nightly rustc and pass If the backtrace is useless due to missing line information, you can build your own rustc and activate |
Awesome! I'll try to find some time to dig further into this over the holidays. |
Consider the following code (both on stable 1.39.0 and nightly)
There's a cycle evaluating the constants
C -> A -> B -> A -> ...
The
dbg!(i32::C)
line is the offending code which causes this cycle to be evaluated.However, the emitted error message doesn't actually reference the usage
dbg!(i32::C)
which caused the evaluation, as below:This error could probably be improved by having an additional
note:
showing that the cycle was used when evaluatingdbg!(i32::C)
.cc @oli-obk
The text was updated successfully, but these errors were encountered: