Closed
Description
Possible duplicate of: #38868
Problem:
rustc crashes with 'internal compiler error' if a special file (see the 'Input' section) is compiled.
Exact error output (run via cargo run
):
[me@my_machine rustc_bug_1]$ cargo run
Compiling rustc_bug_1 v0.1.0 (file:///home/me/some_folder/rustc_bug_1)
error: internal compiler error: /checkout/src/librustc_typeck/check/dropck.rs:650: substs for an impl must map types to TyParam
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:417
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: Could not compile `rustc_bug_1`.
To learn more, run the command again with --verbose.
How to reproduce the error:
-
Create a new (binary) project with
cargo new rustc_bug_1 --bin
-
Put the attached source inside
main.rs
-
Run the project with
cargo run
-
Witness the error ;-)
The error-causeing source:
struct A<T> {
a: T,
}
fn main() {
struct Z {}
let x: A<Z> = A{ a: Z{} };
struct DropStruct;
impl Drop for A<DropStruct> {
fn drop(&mut self) {
println!("I'm dropping an A<DropStruct>!");
}
}
}
Explanation:
I tried some crazy stuff in Rust in order to better understand the languages' semantics when i encountered the bug. I know....usually you cannot specialize the Drop impl, or so the compiler keeps telling me if i further minimize the provided source.
Used OS and rust toolchain:
Arch x64 (up2date)
Rust Toolchains:
stable-x86_64-unknown-linux-gnu
beta-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu
Tested with all three.