Skip to content

Specialized Drop impl causes 'internal compiler error' #3769

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

Closed
Lazarus535 opened this issue Feb 27, 2017 · 1 comment
Closed

Specialized Drop impl causes 'internal compiler error' #3769

Lazarus535 opened this issue Feb 27, 2017 · 1 comment

Comments

@Lazarus535
Copy link

Lazarus535 commented Feb 27, 2017

------------IMPORTANT----------------

I accedentally posted the issue for Cargo, but it is a rustc bug.
I already opened the correct issue for rustc:
rust-lang/rust#40132
Please just close! :-(


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:

  1. Create a new (binary) project with cargo new rustc_bug_1 --bin

  2. Put the attached source inside main.rs

  3. Run the project with cargo run

  4. 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.

@alexcrichton
Copy link
Member

No worries for the accidental post to cargo :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants