-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
'cargo check' passes but 'cargo build' fails when there are errors during monomorphization #99682
Comments
So what would be a way to fix it? The only option I can think of right now is to perform some kind of "fake monomorphization" with |
Tangential question: is there an official guarantee as to what |
I think, almost everyone expect it to catch everything as actual compilation would. This is a whole point of it: check compilation errors without generating code. |
To fix this, we have to at least do something like a "mentioned item" monomorphizing traversal of the collector (also see #122568). Fundamentally there's no way to avoid having to touch the same function multiple times, since it might be instantiated with different types implementing a trait and their associated consts may behave differently. So the regression for check times is likely going to be gigantic. It will be up to the compiler team to decide if they want to take that or not. (RFC 3477 puts this choice into t-compiler jurisdiction. It even mentions not doing any kind of monomorphization during check builds -- for performance reasons -- as a motivation for why we are okay with check builds passing when full builds fail.) I think this issue will likely remain open at least until we decide to have "slow" and "fast" check builds. But it's still useful to have this as a central tracking location. |
experiment: run mono-item collection in check build r? `@ghost` This is just to get an upper bound to the perf overhead associated with fixing rust-lang#99682. We could be a bit more clever and only perform collection, not partitioning, or even more clever and do "mentioned items" collection rather than full collection (when rust-lang#122568 lands) -- but for now let's just get a ballpark number.
I did an implementation experiment in #122744 (to be able to measure the regression). Some work needs to happen before we can even do the experiment:
|
Consider the following code:
When I do a check-build of this (
rustc --emit=metadata
), it works fine. But when I do a full build (rustc --emit=link
), it fails:This is a post-monomorphization error. It is a long-known problem but I could not find an issue tracking it.
It seems worth tracking as it is rather surprising, so if we can find a way to fix it, that would be great. It also leads to issues with Miri such as rust-lang/miri#2423.
All that said, currently this is intended behavior. This RFC gives some relevant background:
This is related to #49292 but not the same -- that issue is about lints that arise pre-monomorphization, during MIR passes that are skipped in check builds. This here is about errors that appear even later during compilation.
The text was updated successfully, but these errors were encountered: