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

ICE: assertion failed: self.is_free_or_static(r_a) && self.is_free_or_static(r_b), glacier fixed/74761.rs with --emit=mir -Zsave-analysis #87218

Closed
matthiaskrgr opened this issue Jul 17, 2021 · 2 comments · Fixed by #87287
Assignees
Labels
C-bug Category: This is a bug. 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.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jul 17, 2021

Code

code from glacier fixed/74761.rs

#![feature(member_constraints)]
#![feature(type_alias_impl_trait)]

pub trait A {
    type B;
    fn f(&self) -> Self::B;
}
impl<'a, 'b> A for () {
    type B = impl core::fmt::Debug;

    fn f(&self) -> Self::B {}
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.55.0-nightly (74ef0c3e4 2021-07-16)
binary: rustc
commit-hash: 74ef0c3e404cc72c08b2d1e14506f90d9e877269
commit-date: 2021-07-16
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1

Error output

rustc /home/matthias/vcs/github/glacier/fixed/74761.rs --emit=mir -Zsave-analysis

error[E0658]: `impl Trait` in type aliases is unstable
 --> /home/matthias/vcs/github/glacier/fixed/74761.rs:9:14
  |
9 |     type B = impl core::fmt::Debug;
  |              ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
  = help: add `#![feature(min_type_alias_impl_trait)]` to the crate attributes to enable

warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /home/matthias/vcs/github/glacier/fixed/74761.rs:2:12
  |
2 | #![feature(type_alias_impl_trait)]
  |            ^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information

error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
 --> /home/matthias/vcs/github/glacier/fixed/74761.rs:8:6
  |
8 | impl<'a, 'b> A for () {
  |      ^^ unconstrained lifetime parameter

error[E0207]: the lifetime parameter `'b` is not constrained by the impl trait, self type, or predicates
 --> /home/matthias/vcs/github/glacier/fixed/74761.rs:8:10
  |
8 | impl<'a, 'b> A for () {
  |          ^^ unconstrained lifetime parameter

thread 'rustc' panicked at 'assertion failed: self.is_free_or_static(r_a) && self.is_free_or_static(r_b)', compiler/rustc_infer/src/infer/free_regions.rs:77:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (74ef0c3e4 2021-07-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z save-analysis

query stack during panic:
#0 [typeck] type-checking `<impl at /home/matthias/vcs/github/glacier/fixed/74761.rs:8:1: 12:2>::f`
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0207, E0658.
For more information about an error, try `rustc --explain E0207`.
Backtrace

thread 'rustc' panicked at 'assertion failed: self.is_free_or_static(r_a) && self.is_free_or_static(r_b)', compiler/rustc_infer/src/infer/free_regions.rs:77:9
stack backtrace:
   0:     0x7fafad903f00 - std::backtrace_rs::backtrace::libunwind::trace::h0f5cd2ee8b0d7274
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fafad903f00 - std::backtrace_rs::backtrace::trace_unsynchronized::h06905b5aeda069a1
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fafad903f00 - std::sys_common::backtrace::_print_fmt::h4fe4c7c875072f30
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fafad903f00 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hcc0746f004a9b7ef
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fafad971cec - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/core/src/fmt/mod.rs:1115:17
   5:     0x7fafad8f5655 - std::io::Write::write_fmt::h23dab4cc9ce72ee2
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/io/mod.rs:1663:15
   6:     0x7fafad907c1b - std::sys_common::backtrace::_print::h173dc702502d65d2
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fafad907c1b - std::sys_common::backtrace::print::h61bd27c4742ba817
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fafad907c1b - std::panicking::default_hook::{{closure}}::hcaae87f0495ae613
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/panicking.rs:208:50
   9:     0x7fafad9076f1 - std::panicking::default_hook::h0538e728ee080db0
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/panicking.rs:225:9
  10:     0x7fafae0de1c1 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h432ae30fc20e6372
  11:     0x7fafad908449 - std::panicking::rust_panic_with_hook::h3039e236b6ca482c
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/panicking.rs:626:17
  12:     0x7fafad907ed7 - std::panicking::begin_panic_handler::{{closure}}::h884fbab544ffd91c
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/panicking.rs:517:13
  13:     0x7fafad9043fc - std::sys_common::backtrace::__rust_end_short_backtrace::hdaf2e18ba3d91210
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7fafad907e69 - rust_begin_unwind
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/panicking.rs:515:5
  15:     0x7fafad8d2e71 - core::panicking::panic_fmt::hcf5f6d96e1dd7099
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/core/src/panicking.rs:92:14
  16:     0x7fafad8d2dbd - core::panicking::panic::hd695e3b1d0dd4ef4
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/core/src/panicking.rs:50:5
  17:     0x7fafaef09abd - <rustc_infer::infer::free_regions::FreeRegionMap as rustc_infer::infer::free_regions::FreeRegionRelations>::sub_free_regions::hdfae93b7960847d5
  18:     0x7fafaf37719f - <rustc_infer::infer::InferCtxt as rustc_trait_selection::opaque_types::InferCtxtExt>::constrain_opaque_types::h1b8e03fe94050281
  19:     0x7fafaf3362fd - rustc_typeck::check::regionck::RegionCtxt::visit_fn_body::h2d0701b7799ad1f8
  20:     0x7fafaf2ea77f - rustc_typeck::check::regionck::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::regionck_fn::he03fdfa01ae16140
  21:     0x7fafaf36a9a0 - rustc_infer::infer::InferCtxtBuilder::enter::h5b0049019ece2d91
  22:     0x7fafaf3c3499 - rustc_typeck::check::typeck::h45b639d5069c89f7
  23:     0x7fafaf4c5a0c - rustc_query_system::query::plumbing::get_query_impl::h292344179c2f1a96
  24:     0x7fafaf5332db - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::typeck::h9b8dd6db5e7e34f0
  25:     0x7fafae12ee19 - rustc_save_analysis::dump_visitor::DumpVisitor::process_method::hc8aa5dbea4311631
  26:     0x7fafae131806 - rustc_save_analysis::dump_visitor::DumpVisitor::process_impl_item::h59b684c892943cde
  27:     0x7fafae12d2f3 - rustc_save_analysis::dump_visitor::DumpVisitor::nest_typeck_results::h253be14039dac37b
  28:     0x7fafae1344ac - <rustc_save_analysis::dump_visitor::DumpVisitor as rustc_hir::intravisit::Visitor>::visit_item::h9b52cebc0df4f7b9
  29:     0x7fafae12c2b6 - rustc_hir::intravisit::Visitor::visit_nested_item::h9e975cc0f2a00c21
  30:     0x7fafae119c51 - rustc_hir::intravisit::walk_crate::he7f189f23867b6fd
  31:     0x7fafae131c10 - rustc_save_analysis::dump_visitor::DumpVisitor::process_crate::h8b9b619ce8c21fa3
  32:     0x7fafae105b75 - rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps::hd0ffb7bb05686286
  33:     0x7fafae11046b - std::thread::local::LocalKey<T>::with::h614f74b0ec87e973
  34:     0x7fafae0e00b7 - rustc_save_analysis::process_crate::hc449d2bdb96b795f
  35:     0x7fafae0ea7e7 - rustc_session::utils::<impl rustc_session::session::Session>::time::hd147f92cb70cf437
  36:     0x7fafafbe2869 - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hd3df2f2fd8ee2f9c
  37:     0x7fafafbd0ecc - rustc_span::with_source_map::h4320e6c7562b1c81
  38:     0x7fafafbe332a - rustc_interface::interface::create_compiler_and_run::h8b004a10f044574a
  39:     0x7fafafbd6219 - scoped_tls::ScopedKey<T>::set::hc495f050953f2646
  40:     0x7fafafbd2fdb - std::sys_common::backtrace::__rust_begin_short_backtrace::hf6d64874d4b63366
  41:     0x7fafafbd1865 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h44f63dc93d63fbac
  42:     0x7fafad9149f7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd5b860c6542b008a
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/alloc/src/boxed.rs:1572:9
  43:     0x7fafad9149f7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc87b98c8a3a585ed
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/alloc/src/boxed.rs:1572:9
  44:     0x7fafad9149f7 - std::sys::unix::thread::Thread::new::thread_start::ha990175c8f3779cc
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys/unix/thread.rs:74:17
  45:     0x7fafad820259 - start_thread
  46:     0x7fafad7355e3 - __GI___clone
  47:                0x0 - <unknown>

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (74ef0c3e4 2021-07-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z save-analysis

query stack during panic:
#0 [typeck] type-checking `<impl at /home/matthias/vcs/github/glacier/fixed/74761.rs:8:1: 12:2>::f`
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0207, E0658.
For more information about an error, try `rustc --explain E0207`.

@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. 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 Jul 17, 2021
@matthiaskrgr
Copy link
Member Author

cargo-bisect says Regression in nightly-2021-07-16 but was not able to bisect the PR for some reason. :/

@matthiaskrgr matthiaskrgr changed the title ICE: assertion failed: self.is_free_or_static(r_a) && self.is_free_or_static(r_b), glacier fixed/74761.rs ICE: assertion failed: self.is_free_or_static(r_a) && self.is_free_or_static(r_b), glacier fixed/74761.rs with --emit=mir -Zsave-analysis Jul 17, 2021
@jackh726
Copy link
Member

One option that this could have come from is #86993, which we now we fold through with bound vars (which isn't free or static).

But, could also be #87200.

@oli-obk oli-obk self-assigned this Jul 19, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jul 21, 2021
…pes, r=spastorino

 Make mir borrowck's use of opaque types independent of the typeck query's result

fixes rust-lang#87218
fixes rust-lang#86465

we used to use the typeck results only to generate an obligation for the mir borrowck type to be equal to the typeck result.

When i removed the `fixup_opaque_types` function in rust-lang#87200, I exposed a bug that showed that mir borrowck can't doesn't get enough information from typeck in order to build the correct lifetime mapping from opaque type usage to the actual concrete type. We therefor now fully compute the information within mir borrowck (we already did that, but we only used it to verify the typeck result) and stop using the typeck information.

We will likely be able to remove most opaque type information from the borrowck results in the future and just have all current callers use the mir borrowck result instead.

r? `@spastorino`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Jul 21, 2021
…pes, r=spastorino

 Make mir borrowck's use of opaque types independent of the typeck query's result

fixes rust-lang#87218
fixes rust-lang#86465

we used to use the typeck results only to generate an obligation for the mir borrowck type to be equal to the typeck result.

When i removed the `fixup_opaque_types` function in rust-lang#87200, I exposed a bug that showed that mir borrowck can't doesn't get enough information from typeck in order to build the correct lifetime mapping from opaque type usage to the actual concrete type. We therefor now fully compute the information within mir borrowck (we already did that, but we only used it to verify the typeck result) and stop using the typeck information.

We will likely be able to remove most opaque type information from the borrowck results in the future and just have all current callers use the mir borrowck result instead.

r? ``@spastorino``
@bors bors closed this as completed in b2b7c85 Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants