Skip to content
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

internal compiler error: region_obligations not empty with CoerceUnsized #53475

Closed
sampersand opened this issue Aug 18, 2018 · 3 comments · Fixed by #99796
Closed

internal compiler error: region_obligations not empty with CoerceUnsized #53475

sampersand opened this issue Aug 18, 2018 · 3 comments · Fixed by #99796
Labels
A-coercions Area: implicit and explicit `expr as Type` coercions C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sampersand
Copy link

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
@estebank estebank added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 8, 2019
@estebank
Copy link
Contributor

estebank commented Jan 8, 2019

Current output:

thread 'rustc' panicked at 'region_obligations not empty: [
    (
        NodeId(32),
        RegionObligation(sub_region=ReStatic, sup_type=T)
    )
]', src/librustc/infer/mod.rs:1110:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   6: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:385
   7: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:340
   8: rustc::infer::InferCtxt::resolve_regions_and_report_errors
   9: rustc::ty::context::tls::with_context::{{closure}}
  10: rustc::ty::context::GlobalCtxt::enter_local
  11: rustc_typeck::coherence::builtin::coerce_unsized_info
  12: rustc::ty::query::__query_compute::coerce_unsized_info
  13: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::coerce_unsized_info<'tcx>>::compute
  14: rustc::dep_graph::graph::DepGraph::with_task_impl
  15: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
  16: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  17: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  18: rustc_typeck::coherence::builtin::check_trait
  19: rustc_typeck::coherence::coherent_trait
  20: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::coherent_trait<'tcx>>::compute
  21: rustc::dep_graph::graph::DepGraph::with_task_impl
  22: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
  23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  24: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  25: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
  26: rustc_typeck::coherence::check_coherence
  27: rustc::session::Session::track_errors
  28: rustc_typeck::check_crate
  29: <std::thread::local::LocalKey<T>>::with
  30: rustc::ty::context::TyCtxt::create_and_enter
  31: rustc_driver::driver::compile_input
  32: rustc_driver::run_compiler_with_pool
  33: <scoped_tls::ScopedKey<T>>::set
  34: rustc_driver::run_compiler
  35: <scoped_tls::ScopedKey<T>>::set
  36: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  37: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:92
  38: <F as alloc::boxed::FnBox<A>>::call_box
  39: std::sys::unix::thread::Thread::new::thread_start
             at /rustc/8e2063d02062ee9f088274690a97826333847e17/src/liballoc/boxed.rs:744
             at src/libstd/sys_common/thread.rs:14
             at src/libstd/sys/unix/thread.rs:81
  40: start_thread
  41: __clone
query stack during panic:
#0 [coerce_unsized_info] processing `<Foo<T> as std::ops::CoerceUnsized<Foo<(dyn std::any::Any + 'static)>>>`
  --> src/lib.rs:10:1
   |
10 | impl<T> CoerceUnsized<Foo<dyn Any>> for Foo<T> {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#1 [coherent_trait] coherence checking all impls of trait `std::ops::CoerceUnsized`
end of query stack

error: internal compiler error: unexpected panic

@jonas-schievink jonas-schievink added A-coercions Area: implicit and explicit `expr as Type` coercions C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way. labels Aug 6, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 15, 2019
@steffahn
Copy link
Member

This is not specific to Any. The following produces the same kind of error.

#![feature(coerce_unsized)]
use core::ops::CoerceUnsized;

trait Trait {}

struct B<T>(Box<T>);

impl<T> CoerceUnsized<B<dyn Trait>> for B<T>
where T: Trait {}

@matthiaskrgr
Copy link
Member

@rustbot modify labels: +regression-from-stable-to-stable

The ICE happens on stable regardless of having the feature gate or not (the ICE does not requires a nightly compiler to reproduce)

@rustbot rustbot added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Dec 20, 2020
@apiraino apiraino removed the requires-nightly This issue requires a nightly compiler in some way. label Feb 3, 2022
@bors bors closed this as completed in 110777b Jul 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coercions Area: implicit and explicit `expr as Type` coercions C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants