Skip to content

ICE: librustc/mir/tcx.rs:68: extracting field of non-tuple non-adt: Ty { ty: _ }  #55552

Closed
@vitiral

Description

@vitiral

An underscore (aka wildcard aka _) nested within a type declaration is causing problems for some new code that tries to project out the inner types after normalization is finished. Here is an example (play):

struct X;
struct Y;
struct Z;

pub fn join<A, B, RA, RB>(_oper_a: A, _oper_b: B) -> (RA, RB)
    where A: FnOnce() -> RA + Send,
          B: FnOnce() -> RB + Send,
          RA: Send,
          RB: Send
{
    loop { }
}

fn main() {
    let ((_x, _y), _z): (_, Z) = join(|| (X, Y),
                                      || Z);
}

Original bug report follows


Running cargo test here

error: internal compiler error: librustc/mir/tcx.rs:68: extracting field of non-tuple non-adt: Ty { ty: _ }                             
                                                                                                                                 
thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:600:9 
stack backtrace:                                                
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace                                          
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49                                         
   1: std::sys_common::backtrace::_print                                           
             at libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59        
             at libstd/panicking.rs:211                                                                                              
   3: std::panicking::default_hook                      
             at libstd/panicking.rs:227                
   4: rustc::util::common::panic_hook              
   5: std::panicking::rust_panic_with_hook                                                               
             at libstd/panicking.rs:480                                                       
   6: std::panicking::begin_panic                                                   
   7: rustc_errors::Handler::bug                                       
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}                                                            
   9: rustc::ty::context::tls::with_opt::{{closure}}                                                                                     
  10: rustc::ty::context::tls::with_context_opt                                      
  11: rustc::ty::context::tls::with_opt                
  12: rustc::util::bug::opt_span_bug_fmt                            
  13: rustc::util::bug::bug_fmt                                                                          
  14: rustc::mir::tcx::PlaceTy::field_ty                                                      
  15: rustc::mir::tcx::PlaceTy::projection_ty_core                                               
  16: rustc_mir::borrow_check::nll::type_check::TypeChecker::relate_type_and_user_type
  17: <rustc_mir::borrow_check::nll::type_check::TypeVerifier<'a, 'b, 'gcx, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_local_decl
  18: <rustc_mir::borrow_check::nll::type_check::TypeVerifier<'a, 'b, 'gcx, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_mir
  19: rustc_mir::borrow_check::nll::type_check::type_check_internal
  20: rustc::ty::context::tls::with_related_context             
  21: rustc::infer::InferCtxtBuilder::enter                                                              
  22: <rustc_mir::borrow_check::nll::type_check::TypeckMir as rustc_mir::transform::MirPass>::run_pass
  23: rustc_mir::transform::run_passes::{{closure}}                                
  24: rustc_mir::transform::run_passes           
  25: rustc_mir::transform::mir_const          
  26: rustc::ty::query::__query_compute::mir_const       
  27: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_const<'tcx>>::compute
  28: rustc::ty::context::tls::with_context             
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::context::tls::with_related_context
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  32: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  33: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const
  34: rustc_mir::transform::mir_validated                              
  35: rustc::ty::query::__query_compute::mir_validated                                                           
  36: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_validated<'tcx>>::compute
  37: rustc::ty::context::tls::with_context                                          
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc::ty::context::tls::with_related_context                 
  40: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
  43: rustc_borrowck::borrowck::borrowck                                              
  44: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::borrowck<'tcx>>::compute    
  45: rustc::ty::context::tls::with_context                                                                                      
  46: rustc::dep_graph::graph::DepGraph::with_task_impl            
  47: rustc::ty::context::tls::with_related_context                                                                                                                                                       [22/3644]
  48: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  49: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query        
  50: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::par_body_owners
  51: rustc_borrowck::borrowck::check_crate      
  52: rustc::util::common::time                                 
  53: rustc::ty::context::tls::enter_context             
  54: <std::thread::local::LocalKey<T>>::with                                                                                        
  55: rustc::ty::context::TyCtxt::create_and_enter                                    
  56: rustc_driver::driver::compile_input              
  57: rustc_driver::run_compiler_with_pool         
  58: rustc_driver::driver::spawn_thread_pool                                                            
  59: rustc_driver::run_compiler                                                              
  60: <scoped_tls::ScopedKey<T>>::set                                               
  61: syntax::with_globals               
  62: __rust_maybe_catch_panic                                                                                   
             at libpanic_unwind/lib.rs:102                                                                                               
  63: rustc_driver::run                                                              
  64: rustc_driver::main                               
  65: std::rt::lang_start::{{closure}}                              
  66: std::panicking::try::do_call                                                                       
             at libstd/rt.rs:59                                                               
             at libstd/panicking.rs:310                                                          
  67: __rust_maybe_catch_panic                                                        
             at libpanic_unwind/lib.rs:102                                                                                              
  68: std::rt::lang_start_internal                                                                                               
             at libstd/panicking.rs:289                            
             at libstd/panic.rs:392                             
             at libstd/rt.rs:58                                                                          
  69: main                                                                                            
  70: __libc_start_main                                                            
  71: <unknown>                                  
query stack during panic:                      
#0 [mir_const] processing `artifact::determine_artifacts`
#1 [mir_validated] processing `artifact::determine_artifacts`                                                                        
#2 [borrowck] processing `artifact::determine_artifacts`
end of query stack                                     
error: aborting due to previous error              
                                                                                                         
                                                                                              
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.31.0-nightly (1cf82fd9c 2018-10-30) running on x86_64-unknown-linux-gnu
                                                       
note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib
                                                                                                         
note: some of the compiler flags provided by cargo are hidden                                 
                                                                                                 
error: Could not compile `artifact_data`.                                         
```

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️NLL-completeWorking towards the "valid code works" goalP-highHigh priorityregression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions