-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ICE checking rustc_middle
with debug_assertions enabled
#10253
Comments
This is the relevant part of rustc_middle which causes the panic: https://github.com/rust-lang/rust/blob/a6235a2006edf09e6eb30bac04f33eef0d2744d1/compiler/rustc_middle/src/mir/traversal.rs#L48-L49 Note that 0bb3f5b0a9915f00cbabb11549126ee92296f7ac has some changes to clippy, but I don't think they could cause this ICE: they only affect the sysroot flags and whether clippy runs on build scripts and proc-macros. |
This affects the |
Clippy is fetching the substs of a method in https://github.com/rust-lang/rust/blob/f55b0022db8dccc6aa6bf3f650b562eaec0fdc54/src/tools/clippy/clippy_lints/src/dereference.rs#L858 and then uses those substs as the substs of the trait. In that case it is entirely correct to ask the trait for how many generic parameters it has and only use the first that many entries in the method substs. You can get the number of generic parameters via |
yea, I didn't change behaviour there, but I added the assert that is now being triggered. |
this is still a problem 🙃 |
Maybe a minimization could help here, as it can then be tested in the clippy repo. This issue is not rustc_middle specific, that's just a huge crate with lots of weird shenanigans. The ICEs could happen anywhere in stable code, too |
I think I got a minimized test case, but I'm not sure if this can easily be tested from clippy's side. This ICE happens in a function in rustc_middle in a block that is cfg'd out unless rustc is compiled with debug assertions, so clippy presumably needs a rustc build with debug assertions to even get this to ICE I guess? Afaik clippy relies on the rustc-dev rustup component for calling into the rustc crates, and I don't think there's a way to get that with debug-assertions enabled (someone correct me if im wrong)? Anyway, here's what I think should reproduce the ICE: struct S;
trait X {
fn f<T>(&self);
}
impl X for &S {
fn f<T>(&self) {}
}
fn main() {
(&S).f::<()>();
}
(I tested this by copy-pasting the assertion from the relevant rustc_middle code into the clippy lint, hopefully this didn't miss out on some important detail). |
Oof yea It is essentially what That does explain why we never saw it in the wild. |
Right yeah, I have a rustc build with debug assertions and when I |
Summary
Running
x clippy rustc_middle --stage 1 -Awarnings
when having the tip of rust-lang/rust#106394 checked out (last verified on rust-lang/rust@0bb3f5b) ICEs when checkingrustc_middle
.It only happens when debug assertiaons are enabled.
It is definitely due to clippy.
Here is the error:
cc @jyn514
Version
Error output
Backtrace
The text was updated successfully, but these errors were encountered: