rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.1k stars 12.55k forks source link

ICE: impl trait in bindings can't type-check body of DefId #78721

Closed DutchGhost closed 3 years ago

DutchGhost commented 3 years ago

Code

#![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.49.0-nightly (338f939a8 2020-11-02)

Error output

error: internal compiler error: compiler/rustc_typeck/src/check/mod.rs:489:9: can't type-check body of DefId(0:3 ~ playground[f69e]::Bug)
Backtrace

``` thread 'rustc' panicked at 'Box', /rustc/338f939a8d77061896cd0a1ca87a2c6d1f4ec359/compiler/rustc_errors/src/lib.rs:904:9 stack backtrace: 0: std::panicking::begin_panic 1: rustc_errors::HandlerInner::span_bug 2: rustc_errors::Handler::span_bug 3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}} 4: rustc_middle::ty::context::tls::with_opt::{{closure}} 5: rustc_middle::ty::context::tls::with_opt 6: rustc_middle::util::bug::opt_span_bug_fmt 7: rustc_middle::util::bug::span_bug_fmt 8: rustc_typeck::check::typeck_with_fallback::{{closure}} 9: rustc_typeck::check::typeck 10: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::typeck>::compute 11: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 12: rustc_data_structures::stack::ensure_sufficient_stack 13: rustc_query_system::query::plumbing::get_query_impl 14: rustc_typeck::collect::type_of::type_of 15: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::type_of>::compute 16: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 17: rustc_data_structures::stack::ensure_sufficient_stack 18: rustc_query_system::query::plumbing::get_query_impl 19: ::fold_ty 20: ::normalize 21: rustc_infer::infer::InferCtxtBuilder::enter 22: rustc_traits::normalize_erasing_regions::normalize_generic_arg_after_erasing_regions 23: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 24: rustc_data_structures::stack::ensure_sufficient_stack 25: rustc_query_system::query::plumbing::get_query_impl 26: ::fold_ty 27: rustc_middle::ty::util::::needs_drop 28: rustc_mir::dataflow::drop_flag_effects::on_all_children_bits::on_all_children_bits 29: ::run_pass 30: rustc_mir::transform::run_passes 31: rustc_mir::transform::run_post_borrowck_cleanup_passes 32: rustc_mir::transform::mir_drops_elaborated_and_const_checked 33: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::mir_drops_elaborated_and_const_checked>::compute 34: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 35: rustc_data_structures::stack::ensure_sufficient_stack 36: rustc_query_system::query::plumbing::get_query_impl 37: rustc_mir::transform::optimized_mir 38: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::optimized_mir>::compute 39: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 40: rustc_data_structures::stack::ensure_sufficient_stack 41: rustc_query_system::query::plumbing::get_query_impl 42: rustc_mir::interpret::eval_context::InterpCx::load_mir 43: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider 44: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::eval_to_allocation_raw>::compute 45: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 46: rustc_data_structures::stack::ensure_sufficient_stack 47: rustc_query_system::query::plumbing::get_query_impl 48: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider 49: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::eval_to_const_value_raw>::compute 50: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 51: rustc_data_structures::stack::ensure_sufficient_stack 52: rustc_query_system::query::plumbing::get_query_impl 53: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider 54: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::eval_to_const_value_raw>::compute 55: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 56: rustc_data_structures::stack::ensure_sufficient_stack 57: rustc_query_system::query::plumbing::get_query_impl 58: rustc_middle::mir::interpret::queries::::const_eval_global_id 59: rustc_middle::mir::interpret::queries::::const_eval_resolve 60: rustc_middle::ty::consts::Const::eval 61: rustc_middle::ty::structural_impls::::super_fold_with 62: ::fold_ty 63: rustc_data_structures::stack::ensure_sufficient_stack 64: rustc_trait_selection::traits::project::normalize 65: ::partially_normalize_associated_types_in 66: rustc_typeck::check::inherited::Inherited::normalize_associated_types_in 67: as core::iter::traits::iterator::Iterator>::fold 68: rustc_infer::infer::InferCtxtBuilder::enter 69: rustc_typeck::check::wfcheck::check_item_well_formed 70: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::check_item_well_formed>::compute 71: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 72: rustc_data_structures::stack::ensure_sufficient_stack 73: rustc_query_system::query::plumbing::get_query_impl 74: rustc_query_system::query::plumbing::ensure_query_impl 75: rustc_data_structures::sync::par_for_each_in 76: rustc_hir::hir::Crate::par_visit_all_item_likes 77: rustc_session::session::Session::track_errors 78: rustc_typeck::check_crate 79: rustc_interface::passes::analysis 80: rustc_middle::ty::query:: for rustc_middle::ty::query::queries::analysis>::compute 81: rustc_query_system::dep_graph::graph::DepGraph::with_task_impl 82: rustc_data_structures::stack::ensure_sufficient_stack 83: rustc_query_system::query::plumbing::get_query_impl 84: rustc_interface::passes::QueryContext::enter 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.49.0-nightly (338f939a8 2020-11-02) 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 [typeck] type-checking `Bug` #1 [type_of] computing type of `Bug::V1::{constant#0}::{opaque#0}` #2 [normalize_generic_arg_after_erasing_regions] normalizing `impl std::future::Future` #3 [mir_drops_elaborated_and_const_checked] elaborating drops for `Bug::V1::{constant#0}` #4 [optimized_mir] optimizing MIR for `Bug::V1::{constant#0}` #5 [eval_to_allocation_raw] const-evaluating + checking `Bug::V1::{constant#0}` #6 [eval_to_const_value_raw] simplifying constant for the type system `Bug::V1::{constant#0}` #7 [eval_to_const_value_raw] simplifying constant for the type system `Bug::V1::{constant#0}` #8 [check_item_well_formed] checking that `Bug` is well-formed #9 [analysis] running analysis passes on this crate end of query stack error: aborting due to 3 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0493`. error: could not compile `playground` ```

Alexendoo commented 3 years ago

No longer ICEs since #78809