-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-specializationArea: Trait impl specializationArea: Trait impl specializationI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
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.
Metadata
Metadata
Assignees
Labels
A-specializationArea: Trait impl specializationArea: Trait impl specializationI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
arielb1 commentedon Feb 27, 2017
cc @pnkfelix
TimNN commentedon Feb 27, 2017
Drop implementations cannot be specialised, and an error to that regard is (in theory) reported. The
let
statement however causes the ICE before that error can be reported.Slightly minified / cleaned up code:
Backtrace:
malbarbo commentedon Mar 1, 2017
Another example
Removing derive avoids the ICE
convert AdtDef::destructor to on-demand
Auto merge of #40178 - arielb1:provide-destructors, r=eddyb