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: can't type-check body: glacier fixed/78721.rs #79099

Closed
matthiaskrgr opened this issue Nov 16, 2020 · 6 comments · Fixed by #87383
Closed

ICE: can't type-check body: glacier fixed/78721.rs #79099

matthiaskrgr opened this issue Nov 16, 2020 · 6 comments · Fixed by #87383
Labels
C-bug Category: This is a bug. F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Nov 16, 2020

Code

code from glacier fixed/78721.rs

#![feature(impl_trait_in_bindings)]

struct Bug {
    V1: [(); {
        let f: impl core::future::Future<Output = u8> = async { 1 };
        1
    }],
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (f5230fbf7 2020-11-16)
binary: rustc
commit-hash: f5230fbf76bafd86ee4376a0e26e551df8d17fec
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

Error output

rustc fixed/78721.rs

error: expected identifier, found `1`
 --> ./78721.rs:5:65
  |
5 |         let f: impl core::future::Future<Output = u8> = async { 1 };
  |                                                         -----   ^ expected identifier
  |                                                         |
  |                                                         `async` blocks are only allowed in the 2018 edition
  |
  = help: set `edition = "2018"` in `Cargo.toml`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
 --> ./78721.rs:1:12
  |
1 | #![feature(impl_trait_in_bindings)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information

error: internal compiler error: compiler/rustc_typeck/src/check/mod.rs:489:9: can't type-check body of DefId(0:3 ~ 78721[317d]::Bug)
 --> ./78721.rs:3:1
  |
3 | / struct Bug {
4 | |     V1: [(); {
5 | |         let f: impl core::future::Future<Output = u8> = async { 1 };
6 | |         1
7 | |     }],
8 | | }
  | |_^

thread 'rustc' panicked at 'Box<Any>', /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/compiler/rustc_errors/src/lib.rs:904:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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.50.0-nightly (f5230fbf7 2020-11-16) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `Bug`
#1 [type_of] computing type of `Bug::V1::{constant#0}::{opaque#0}`
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted
Backtrace

thread 'rustc' panicked at 'Box<Any>', /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/compiler/rustc_errors/src/lib.rs:904:9
stack backtrace:
   0:     0x7f637d062fa0 - std::backtrace_rs::backtrace::libunwind::trace::h448c56741b6011d3
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/../../backtrace/src/backtrace/libunwind.rs:100:5
   1:     0x7f637d062fa0 - std::backtrace_rs::backtrace::trace_unsynchronized::h2d26397c5720fdbb
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f637d062fa0 - std::sys_common::backtrace::_print_fmt::h720a2f61f75b9f58
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f637d062fa0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8d62bbfda6d5c836
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f637d0d236c - core::fmt::write::h1857a60b204f1b6a
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/core/src/fmt/mod.rs:1078:17
   5:     0x7f637d054c02 - std::io::Write::write_fmt::h16a9fe7680ac245c
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/io/mod.rs:1521:15
   6:     0x7f637d067025 - std::sys_common::backtrace::_print::h9ba51a6db618de7d
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f637d067025 - std::sys_common::backtrace::print::h5f20e41c85e91716
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f637d067025 - std::panicking::default_hook::{{closure}}::h5b7294ca19e8edab
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/panicking.rs:208:50
   9:     0x7f637d066cc8 - std::panicking::default_hook::hb3948d1f74b6ff4c
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/panicking.rs:227:9
  10:     0x7f637d948e38 - rustc_driver::report_ice::h7d9ce14184308134
  11:     0x7f637d067926 - std::panicking::rust_panic_with_hook::h55d23fef0ad751bc
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/panicking.rs:597:17
  12:     0x7f637e5c102d - std::panicking::begin_panic::{{closure}}::h8ed9a3a33c3cff07
  13:     0x7f637e5c0fc6 - std::sys_common::backtrace::__rust_end_short_backtrace::h12877d695ee54607
  14:     0x7f637e58b3b6 - std::panicking::begin_panic::hf80c83cb05d9e96b
  15:     0x7f637e55e4a5 - rustc_errors::HandlerInner::span_bug::h6fac04d253db2775
  16:     0x7f637e55e770 - rustc_errors::Handler::span_bug::h311f1a863fb84a83
  17:     0x7f637e67e514 - rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}::h90c34eb7069c0e0d
  18:     0x7f637e67e10b - rustc_middle::ty::context::tls::with_opt::{{closure}}::h4f5cedf51880f643
  19:     0x7f637e67e0b2 - rustc_middle::ty::context::tls::with_opt::h1abd1ee9103ab829
  20:     0x7f637e67e419 - rustc_middle::util::bug::opt_span_bug_fmt::h988677b387978718
  21:     0x7f637e67e3d3 - rustc_middle::util::bug::span_bug_fmt::h03690d0821b8588f
  22:     0x7f637e69b08a - rustc_typeck::check::typeck_with_fallback::{{closure}}::h2a0fb83340fba4ce
  23:     0x7f637e69ac16 - rustc_typeck::check::typeck::h40a6a2fbf5762437
  24:     0x7f637e67d07e - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute::hbad0f7f90880e308
  25:     0x7f637e573a77 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h1630d8019b850f77
  26:     0x7f637e4e4c11 - rustc_data_structures::stack::ensure_sufficient_stack::h65c269314faf280e
  27:     0x7f637e444369 - rustc_query_system::query::plumbing::get_query_impl::hfe85414a1a5ccee1
  28:     0x7f637e6a536f - rustc_typeck::collect::type_of::type_of::h42fbf74ecd2a48fc
  29:     0x7f637e45eb86 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::type_of>::compute::hae9279cbf2fd8f00
  30:     0x7f637e583c34 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hc6e75e9c8f7caa60
  31:     0x7f637e4e49b1 - rustc_data_structures::stack::ensure_sufficient_stack::h645165e5d5ff3eff
  32:     0x7f637e3db24f - rustc_query_system::query::plumbing::get_query_impl::h2e3741383e4d3139
  33:     0x7f637e48fc4c - rustc_typeck::check::check::check_item_type::h8867dc9155a10775
  34:     0x7f637e564222 - rustc_middle::hir::map::Map::visit_item_likes_in_module::h7168eb874fb9fd0c
  35:     0x7f637e493b1d - rustc_typeck::check::check::check_mod_item_types::h9a48b787176c4c98
  36:     0x7f637e56058e - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_mod_item_types>::compute::h5b43bca885c2b48a
  37:     0x7f637e571717 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h0022a71a2a880b88
  38:     0x7f637e4eabd4 - rustc_data_structures::stack::ensure_sufficient_stack::hbfdcb494e19b13d3
  39:     0x7f637e4125f5 - rustc_query_system::query::plumbing::get_query_impl::h9da7036e49fcf602
  40:     0x7f637e44627e - rustc_query_system::query::plumbing::ensure_query_impl::h310784e0cb080e9e
  41:     0x7f637e566e74 - rustc_session::utils::<impl rustc_session::session::Session>::time::h3ca5e6132e41bfe6
  42:     0x7f637e5d998f - rustc_typeck::check_crate::h603c10bbe6bfd147
  43:     0x7f637db740c2 - rustc_interface::passes::analysis::h0297dc70c5f42ca2
  44:     0x7f637d97eb82 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute::h483a2b5cb9981507
  45:     0x7f637d94c2d7 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h5dab9677a1869822
  46:     0x7f637d95d080 - rustc_data_structures::stack::ensure_sufficient_stack::hef1bfd0aeb694af5
  47:     0x7f637d8f18a0 - rustc_query_system::query::plumbing::get_query_impl::hc8aa257a6f276f4a
  48:     0x7f637d981fff - rustc_interface::passes::QueryContext::enter::hf64e301c55abd329
  49:     0x7f637d95ac7e - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::ha4de22cb0dda795a
  50:     0x7f637d8e6f57 - rustc_span::with_source_map::h29633e90c8bdca16
  51:     0x7f637d955ca1 - scoped_tls::ScopedKey<T>::set::hb520569c8597e8d2
  52:     0x7f637d95de65 - std::sys_common::backtrace::__rust_begin_short_backtrace::hc0d91feb93491fb8
  53:     0x7f637d8c9b28 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h425334629854e612
  54:     0x7f637d0768ba - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9e7afb7a0a438236
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/alloc/src/boxed.rs:1307:9
  55:     0x7f637d0768ba - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h70c646c4271337a1
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/alloc/src/boxed.rs:1307:9
  56:     0x7f637d0768ba - std::sys::unix::thread::Thread::new::thread_start::h35d2b8d36f210d02
                               at /rustc/f5230fbf76bafd86ee4376a0e26e551df8d17fec/library/std/src/sys/unix/thread.rs:71:17
  57:     0x7f637cf6f3e9 - start_thread
  58:     0x7f637ce8c293 - __GI___clone
  59:                0x0 - <unknown>

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.50.0-nightly (f5230fbf7 2020-11-16) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `Bug`
#1 [type_of] computing type of `Bug::V1::{constant#0}::{opaque#0}`
#2 [check_mod_item_types] checking item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

@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 Nov 16, 2020
@lcnr lcnr added the F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` label Nov 16, 2020
@fanninpm
Copy link

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Dec 20, 2020

lol, this crashes stable rustc compilers all the way down to 1.44, but ONLY WITH the feature gate. 😆
If I remove the feature gate, there is a proper compiler error.

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

@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 20, 2020
@matthiaskrgr
Copy link
Member Author

The ICE happens since 1.42

@fanninpm
Copy link

After further review, I can confirm that this does cause an ICE with rustc 1.50.0-nightly (1f5bc17 2020-12-19) on macOS 10.15. However, both the playground, running 1.50.0-nightly (2020-12-03 5be3f9f) as of this comment, and (for some weird reason) running glacier locally do not cause an ICE. I will note this in an upcoming PR to glacier.

fanninpm added a commit to fanninpm/glacier that referenced this issue Dec 20, 2020
Locally running `cargo run` and running `rustc` directly produced different
results.

Issue: rust-lang/rust#79099
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Dec 21, 2020
@apiraino
Copy link
Contributor

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@apiraino apiraino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 30, 2020
@digama0
Copy link
Contributor

digama0 commented May 15, 2021

Was going to report this but it looks like a duplicate of this bug. In any case, here's a different reproducer:

#![feature(impl_trait_in_bindings)]
const _: impl Fn() = async { 0 };
fn main() {}
Compiler output

   Compiling playground v0.0.1 (/playground)
warning: the feature `impl_trait_in_bindings` is incomplete and may not be safe to use and/or cause compiler crashes
 --> src/main.rs:1:12
  |
1 | #![feature(impl_trait_in_bindings)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information

error[E0277]: expected a `Fn<()>` closure, found `impl Future`
 --> src/main.rs:2:10
  |
2 | const _: impl Fn() = async { 0 };
  |          ^^^^^^^^^ expected an `Fn<()>` closure, found `impl Future`
  |
  = help: the trait `Fn<()>` is not implemented for `impl Future`
  = note: wrap the `impl Future` in a closure with no arguments: `|| { /* code */ }`

error: internal compiler error: compiler/rustc_mir/src/borrow_check/universal_regions.rs:533:26: expected defining type for `DefId(0:5 ~ playground[b426]::_::{closure#0})`: `[type error]`
 --> src/main.rs:2:28
  |
2 | const _: impl Fn() = async { 0 };
  |                            ^^^^^

thread 'rustc' panicked at 'Box<Any>', /rustc/6d395a1c2946c79966490f5b1e6e619d3a713e6b/library/std/src/panic.rs:59:5
stack backtrace:
   0: std::panicking::begin_panic
   1: std::panic::panic_any
   2: rustc_errors::HandlerInner::span_bug
   3: rustc_errors::Handler::span_bug
   4: rustc_middle::ty::context::tls::with_opt
   5: rustc_middle::util::bug::opt_span_bug_fmt
   6: rustc_middle::util::bug::span_bug_fmt
   7: rustc_mir::borrow_check::universal_regions::UniversalRegions::new
   8: rustc_mir::borrow_check::nll::replace_regions_in_mir
   9: rustc_mir::borrow_check::do_mir_borrowck
  10: rustc_infer::infer::InferCtxtBuilder::enter
  11: rustc_mir::borrow_check::mir_borrowck
  12: core::ops::function::FnOnce::call_once
  13: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  14: rustc_data_structures::stack::ensure_sufficient_stack
  15: rustc_query_system::query::plumbing::force_query_with_job
  16: rustc_query_system::query::plumbing::get_query_impl
  17: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  18: rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator::check
  19: <rustc_typeck::collect::type_of::find_opaque_ty_constraints::ConstraintLocator as rustc_hir::intravisit::Visitor>::visit_expr
  20: rustc_hir::intravisit::walk_expr
  21: rustc_hir::intravisit::Visitor::visit_nested_body
  22: rustc_typeck::collect::type_of::type_of
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_query_system::query::plumbing::force_query_with_job
  26: rustc_query_system::query::plumbing::get_query_impl
  27: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
  28: rustc_typeck::check::check::check_item_type
  29: rustc_middle::hir::map::Map::visit_item_likes_in_module
  30: rustc_typeck::check::check::check_mod_item_types
  31: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  32: rustc_query_system::query::plumbing::force_query_with_job
  33: rustc_query_system::query::plumbing::get_query_impl
  34: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
  35: rustc_session::utils::<impl rustc_session::session::Session>::time
  36: rustc_typeck::check_crate
  37: rustc_interface::passes::analysis
  38: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  39: rustc_data_structures::stack::ensure_sufficient_stack
  40: rustc_query_system::query::plumbing::force_query_with_job
  41: rustc_query_system::query::plumbing::get_query_impl
  42: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  43: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  44: rustc_span::with_source_map
  45: rustc_interface::interface::create_compiler_and_run
  46: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.54.0-nightly (6d395a1c2 2021-05-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type bin

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `_::{closure#0}`
#1 [type_of] computing type of `_::{opaque#0}`
#2 [check_mod_item_types] checking item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground`

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

JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 23, 2021
…sts, r=oli-obk

Add regression tests for the impl_trait_in_bindings ICEs

Closes rust-lang#54600, closes rust-lang#54840, closes rust-lang#58504, closes rust-lang#58956, closes rust-lang#70971, closes rust-lang#79099, closes rust-lang#84919, closes rust-lang#86201, closes rust-lang#86642, closes rust-lang#87295

r? `@oli-obk`
@bors bors closed this as completed in 7c0c329 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. F-impl_trait_in_bindings `#![feature(impl_trait_in_bindings)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority 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.

7 participants