Skip to content

internal compiler error: region_obligations not empty with CoerceUnsized #53475

Closed
@sampersand

Description

@sampersand

CoerceUnsized into dyn Any causes an internal compiler panic

Minimal Example:

#![feature(coerce_unsized)]

use std::ops::CoerceUnsized;
use std::any::Any;

struct Foo<T> {
	data: Box<T>
}

impl<T> CoerceUnsized<Foo<dyn Any>> for Foo<T> {}

This causes an internal compiler error:

$ cargo run
   Compiling rusting v0.1.0 (file:///tmp/rusting)                                                                                                                                      
error[E0601]: `main` function not found in crate `rusting`
  |
  = note: consider adding a `main` function to `src/main.rs`

thread 'main' panicked at 'region_obligations not empty: [
    (
        NodeId(
            17
        ),
        RegionObligation(sub_region=ReStatic, sup_type=T)
    )
]', librustc/infer/mod.rs:1036:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0601`.

error: internal compiler error: unexpected panic

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

note: rustc 1.30.0-nightly (1fa944914 2018-08-17) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `rusting`.

To learn more, run the command again with --verbose.

This seems related to #51649, except this is using CoerceUnsized

Meta

rustc 1.30.0-nightly (1fa944914 2018-08-17)
binary: rustc
commit-hash: 1fa944914c092d728c8307e976a4b447df25bf16
commit-date: 2018-08-17
host: x86_64-apple-darwin
release: 1.30.0-nightly
LLVM version: 7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coercionsArea: implicit and explicit `expr as Type` coercionsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions