Skip to content

ICE on beta in macro expansion: "byte index out of bounds" in resolve_imports #56411

Closed
@Shadlock0133

Description

@Shadlock0133
lib.rs:

macro_rules! import {
    ( $($name:ident),* ) => {
        $(
            mod $name;
            pub use self::$name;
        )*
    }
}

import!(day1);

day1.rs is empty
error

ice git:(master)  RUST_BACKTRACE=1 cargo +beta build
   Compiling ice v0.1.0 (/home/shadlock0133/projects/rust/ice)                                           
thread 'main' panicked at 'byte index 45 is out of bounds of `self::$name`', libcore/str/mod.rs:2094: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                                                        
             at libstd/sys_common/backtrace.rs:59                                                        
   2: std::panicking::default_hook::{{closure}}                                                          
             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::continue_panic_fmt                                                                 
             at libstd/panicking.rs:390                                                                  
   7: rust_begin_unwind                                                                                  
             at libstd/panicking.rs:325                                                                  
   8: core::panicking::panic_fmt                                                                         
             at libcore/panicking.rs:77                                                                  
   9: core::str::slice_error_fail                                                                        
             at libcore/str/mod.rs:0                                                                     
  10: core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::RangeTo<usize>>::index::{{closure}}
  11: rustc_resolve::Resolver::report_conflict                                                           
  12: rustc_resolve::resolve_imports::ImportResolver::resolve_imports                                    
  13: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a, 'crateloader>>::resolve_imports
  14: syntax::ext::expand::MacroExpander::expand_fragment                                                
  15: syntax::ext::expand::MacroExpander::expand_crate                                                   
  16: rustc_driver::driver::phase_2_configure_and_expand_inner::{{closure}}                              
  17: rustc::util::common::time                                                                          
  18: rustc_driver::driver::phase_2_configure_and_expand                                                 
  19: rustc_driver::driver::compile_input                                                                
  20: rustc_driver::run_compiler_with_pool                                                               
  21: rustc_driver::driver::spawn_thread_pool                                                            
  22: rustc_driver::run_compiler                                                                         
  23: <scoped_tls::ScopedKey<T>>::set                                                                    
  24: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once                    
  25: __rust_maybe_catch_panic                                                                           
             at libpanic_unwind/lib.rs:102                                                               
  26: rustc_driver::run                                                                                  
  27: rustc_driver::main                                                                                 
  28: std::rt::lang_start::{{closure}}                                                                   
  29: std::panicking::try::do_call                                                                       
             at libstd/rt.rs:59                                                                          
             at libstd/panicking.rs:310                                                                  
  30: __rust_maybe_catch_panic                                                                           
             at libpanic_unwind/lib.rs:102                                                               
  31: std::rt::lang_start_internal                                                                       
             at libstd/panicking.rs:289                                                                  
             at libstd/panic.rs:392                                                                      
             at libstd/rt.rs:58                                                                          
  32: main                                                                                               
  33: __libc_start_main                                                                                  
  34: <unknown>                                                                                          
query stack during panic:                                                                                
end of query stack                                                                                       

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.31.0-beta.19 (42053f9f0 2018-11-26) 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 ice.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)I-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