Skip to content

ICE from const item in lifetime-parametric impl #56445

Closed
@thejpster

Description

@thejpster

Reduced test case (play) from comment below:

struct OnDiskDirEntry<'a> { _s: &'a usize }

impl<'a> OnDiskDirEntry<'a> {
    const LFN_FRAGMENT_LEN: usize = 2;

    fn lfn_contents(&self) -> [char; Self::LFN_FRAGMENT_LEN] { loop { } }
}

Another repro case: #56445 (comment)

Original bug report follows


If I run cargo test on https://github.com/thejpster/embedded-sdmmc-rs/tree/generates_ice, I get an ICE:

user@host:~/Documents/programming/embedded-sdmmc$ cargo test
   Compiling embedded-sdmmc v0.1.0 (/home/jonathan/Documents/programming/embedded-sdmmc)                                                                                                                    
thread 'main' panicked at 'assertion failed: `(left == right)`                                                                                                                                              
  left: `Some(NodeId(1093))`,                                                                                                                                                                               
 right: `None`: free_scope: DefId(0/0:72 ~ embedded_sdmmc[4f8a]::fat[0]::{{impl}}[4]) not recognized by the region scope tree for None / Some(DefId(0/0:79 ~ embedded_sdmmc[4f8a]::fat[0]::{{impl}}[4]::lfn_contents[0]))', librustc/middle/region.rs:673:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.                                                                                                                                                          
                                                                                                                                                                                                            
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 `embedded-sdmmc`.                                                                                                                                                                  
warning: build failed, waiting for other jobs to finish...
thread 'main' panicked at 'assertion failed: `(left == right)`                                                                                                                                              
  left: `Some(NodeId(1090))`,                                                                                                                                                                               
 right: `None`: free_scope: DefId(0/0:71 ~ embedded_sdmmc[be94]::fat[0]::{{impl}}[4]) not recognized by the region scope tree for None / Some(DefId(0/0:78 ~ embedded_sdmmc[be94]::fat[0]::{{impl}}[4]::lfn_contents[0]))', librustc/middle/region.rs:673:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.                                                                                                                                                          
                                                                                                                                                                                                            
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                                                                                                                                                         
                                                                                                                                                                                                            
note: some of the compiler flags provided by cargo are hidden                                                                                                                                               
                                                                                                                                                                                                            
error: Could not compile `embedded-sdmmc`.                                                                                                                                                                  

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

user@host:~/Documents/programming/embedded-sdmmc$ cargo +nightly test
   Compiling embedded-sdmmc v0.1.0 (/home/jonathan/Documents/programming/embedded-sdmmc)
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `Some(NodeId(1093))`,
 right: `None`: free_scope: DefId(0/0:72 ~ embedded_sdmmc[46a7]::fat[0]::{{impl}}[4]) not recognized by the region scope tree for None / Some(DefId(0/0:79 ~ embedded_sdmmc[46a7]::fat[0]::{{impl}}[4]::lfn_contents[0]))', src/librustc/middle/region.rs:673:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.

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.32.0-nightly (400c2bc5e 2018-11-27) 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 `embedded-sdmmc`.
warning: build failed, waiting for other jobs to finish...
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `Some(NodeId(1090))`,
 right: `None`: free_scope: DefId(0/0:71 ~ embedded_sdmmc[93d1]::fat[0]::{{impl}}[4]) not recognized by the region scope tree for None / Some(DefId(0/0:78 ~ embedded_sdmmc[93d1]::fat[0]::{{impl}}[4]::lfn_contents[0]))', src/librustc/middle/region.rs:673:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.

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.32.0-nightly (400c2bc5e 2018-11-27) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental

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

error: Could not compile `embedded-sdmmc`.

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

user@host:~/Documents/programming/embedded-sdmmc$ cargo version
cargo 1.31.0-beta (339d9f9c8 2018-11-16)

user@host:~/Documents/programming/embedded-sdmmc$ cargo +nightly version
cargo 1.32.0-nightly (b3d0b2e54 2018-11-15)

I'm using 2018 edition syntax, so I can only test on beta and nightly.

Metadata

Metadata

Assignees

Labels

A-const-genericsArea: const generics (parameters and arguments)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)A-lifetimesArea: Lifetimes / regionsC-bugCategory: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.F-const_generics`#![feature(const_generics)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.fixed-by-const-genericsEnabling feature `const_generics` fixes the issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions