Skip to content

ICE: panic when resolving macros #55457

Closed
@davidrusu

Description

@davidrusu

I've managed to reduce the exploding code to:

mod sub_mod {
    use serde_derive::serde;
    use serde::Serialize;

    #[serde(bound(deserialize = ""))]
    #[derive(Serialize)]
    struct Struct {}
}

fn main() {
}

link to proof in rust-playground

I get an ICE on stable, beta and nightly channels.

backtrace running stable 1.30.0

thread 'main' panicked at 'expected `Def::Macro` or `Def::NonMacroAttr`', librustc_resolve/macros.rs:476:18
stack backtrace:                                                                                  
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace                                   
   1: std::sys_common::backtrace::print                                                           
   2: std::panicking::default_hook::{{closure}}                                                   
   3: std::panicking::default_hook                                                                
   4: rustc::util::common::panic_hook                                                             
   5: std::panicking::rust_panic_with_hook                                                        
   6: std::panicking::begin_panic                                                                 
   7: rustc_resolve::macros::<impl rustc_resolve::Resolver<'a, 'cl>>::resolve_macro_to_def        
   8: rustc_resolve::macros::<impl rustc_resolve::Resolver<'a, 'cl>>::resolve_lexical_macro_path_segment
   9: rustc_resolve::macros::<impl rustc_resolve::Resolver<'a, 'cl>>::finalize_current_module_macro_resolutions
  10: rustc_resolve::Resolver::resolve_item                                                       
  11: rustc_resolve::Resolver::resolve_crate                                                      
  12: rustc::util::common::time                                                                   
  13: rustc_driver::driver::phase_2_configure_and_expand                                          
  14: rustc_driver::driver::compile_input                                                         
  15: rustc_driver::run_compiler_with_pool                                                        
  16: rustc_driver::driver::spawn_thread_pool                                                     
  17: rustc_driver::run_compiler                                                                  
  18: <scoped_tls::ScopedKey<T>>::set                                                             
  19: syntax::with_globals                                                                        
  20: __rust_maybe_catch_panic                                                                    
  21: rustc_driver::run                                                                           
  22: rustc_driver::main                                                                          
  23: std::rt::lang_start::{{closure}}                                                            
  24: std::panicking::try::do_call                                                                
  25: __rust_maybe_catch_panic                                                                    
  26: std::rt::lang_start_internal                                                                
  27: main                                                                                        
query stack during panic:                                                                         
end of query stack                             
error: aborting due to 3 previous errors                                                    
For more information about this error, try `rustc --explain E0432`.                            
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 (da5f414c2 2018-10-24) 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 

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions