Skip to content

ICE: mid > len #138010

Open
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(lazy_type_alias)]

fn needs_copy<T>()  {

type F<T>
where
    #[cfg(a)] T: TraitA,
    #[cfg(b)] T: TraitB,
     
     
     ():,
    
    
     ():, 
= T;
    this(&x);
}

original:

//~ ERROR: cannot find type `Foo`
#![allow(non_upper_case_globals)]


trait TheTrait { fn dummy(&self) { } } // should require *all* lifetimes.

impl TheTrait for &'static isize { }

fn foo<'a, F>(b) where &'a T : TheTrait {
    }

fn needs_copy<T>(_: &'static T) where &'static T : TheTrait {

fn main() {
    static x: isize = 1;
    foo(PhantomData<T>),
}

#[allow(type_alias_bounds)]
type F<T>
where
    #[cfg(a)] T: TraitA,
    #[cfg(b)] T: TraitB,
    #[cfg_attr(a, cfg(a))] T: TraitAA,
    #[cfg_attr(b, cfg(b))] T: TraitBB,
    #[derive(Clone)] ():,
    //~^ ERROR most attributes are not supported in `where` clauses
    //~| ERROR expected non-macro attribute, found attribute macro `derive`
    #[rustfmt::skip] ():, //~ ERROR most attributes are not supported in `where` clauses
= T;
    this(&x);
}

Version information

rustc 1.87.0-nightly (fd17deacc 2025-03-04)
binary: rustc
commit-hash: fd17deacce374a4185c882795be162e17b557050
commit-date: 2025-03-04
host: x86_64-unknown-linux-gnu
release: 1.87.0-nightly
LLVM version: 20.1.0

Possibly related line of code:

) -> Result<(), errors::WhereClauseBeforeTypeAlias> {
if ty_alias.ty.is_none() || !ty_alias.where_clauses.before.has_where_token {
return Ok(());
}
let (before_predicates, after_predicates) =
ty_alias.generics.where_clause.predicates.split_at(ty_alias.where_clauses.split);
let span = ty_alias.where_clauses.before.span;
let sugg = if !before_predicates.is_empty() || !ty_alias.where_clauses.after.has_where_token
{
let mut state = State::new();

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(lazy_type_alias)

Program output


thread 'rustc' panicked at compiler/rustc_ast_passes/src/ast_validation.rs:140:55:
mid > len
stack backtrace:
   0:     0x7550207dad94 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h38d103f25b5fc9da
   1:     0x7550210057e2 - core::fmt::write::h51e5c982d87d838d
   2:     0x7550222d4511 - std::io::Write::write_fmt::h24e7c9ef42bcecab
   3:     0x7550207dabf2 - std::sys::backtrace::BacktraceLock::print::h2f36236a0c89f5ad
   4:     0x7550207dd4d2 - std::panicking::default_hook::{{closure}}::hfa3a01d30bf38a16
   5:     0x7550207dd0c4 - std::panicking::default_hook::h73a43ec84dfb2d2e
   6:     0x75501f92bdd7 - std[5b59e6f68f39e4a3]::panicking::update_hook::<alloc[a5cfa563521ef073]::boxed::Box<rustc_driver_impl[3a7877a37badcc56]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7550207ddd43 - std::panicking::rust_panic_with_hook::h7086c047409dd55a
   8:     0x7550207dda06 - std::panicking::begin_panic_handler::{{closure}}::hbcc7938463cd12bd
   9:     0x7550207db259 - std::sys::backtrace::__rust_end_short_backtrace::hf8fc633b7853f6d2
  10:     0x7550207dd6fd - rust_begin_unwind
  11:     0x75501d45e500 - core::panicking::panic_fmt::h416190ca0b61f92d
  12:     0x7550215a8be3 - <rustc_ast_passes[e09985d241b551c4]::ast_validation::AstValidator>::check_type_alias_where_clause_location
  13:     0x7550215aca53 - <rustc_ast_passes[e09985d241b551c4]::ast_validation::AstValidator as rustc_ast[8d12759f5817a2f9]::visit::Visitor>::visit_item
  14:     0x7550215b2c9f - <rustc_ast_passes[e09985d241b551c4]::ast_validation::AstValidator as rustc_ast[8d12759f5817a2f9]::visit::Visitor>::visit_fn
  15:     0x7550215aa474 - <rustc_ast_passes[e09985d241b551c4]::ast_validation::AstValidator as rustc_ast[8d12759f5817a2f9]::visit::Visitor>::visit_item
  16:     0x7550215a5694 - rustc_interface[2148282fb0834f58]::passes::resolver_for_lowering_raw
  17:     0x7550215a480d - rustc_query_impl[d10ddfe12c3a8e74]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[d10ddfe12c3a8e74]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[20fb34f80dd5af75]::query::erase::Erased<[u8; 16usize]>>
  18:     0x7550215a47eb - <rustc_query_impl[d10ddfe12c3a8e74]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[436ac50667b45076]::ops::function::FnOnce<(rustc_middle[20fb34f80dd5af75]::ty::context::TyCtxt, ())>>::call_once
  19:     0x755022054ed8 - rustc_query_system[3033f91d22641c6f]::query::plumbing::try_execute_query::<rustc_query_impl[d10ddfe12c3a8e74]::DynamicConfig<rustc_query_system[3033f91d22641c6f]::query::caches::SingleCache<rustc_middle[20fb34f80dd5af75]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[d10ddfe12c3a8e74]::plumbing::QueryCtxt, false>
  20:     0x755022054a47 - rustc_query_impl[d10ddfe12c3a8e74]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  21:     0x755022079a2d - rustc_interface[2148282fb0834f58]::passes::create_and_enter_global_ctxt::<core[436ac50667b45076]::option::Option<rustc_interface[2148282fb0834f58]::queries::Linker>, rustc_driver_impl[3a7877a37badcc56]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  22:     0x7550220f19e0 - rustc_interface[2148282fb0834f58]::interface::run_compiler::<(), rustc_driver_impl[3a7877a37badcc56]::run_compiler::{closure#0}>::{closure#1}
  23:     0x755021f20608 - std[5b59e6f68f39e4a3]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[2148282fb0834f58]::util::run_in_thread_with_globals<rustc_interface[2148282fb0834f58]::util::run_in_thread_pool_with_globals<rustc_interface[2148282fb0834f58]::interface::run_compiler<(), rustc_driver_impl[3a7877a37badcc56]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  24:     0x755021f20ef4 - <<std[5b59e6f68f39e4a3]::thread::Builder>::spawn_unchecked_<rustc_interface[2148282fb0834f58]::util::run_in_thread_with_globals<rustc_interface[2148282fb0834f58]::util::run_in_thread_pool_with_globals<rustc_interface[2148282fb0834f58]::interface::run_compiler<(), rustc_driver_impl[3a7877a37badcc56]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[436ac50667b45076]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x755021f222f7 - std::sys::pal::unix::thread::Thread::new::thread_start::hbb5e0f14d5ca8b98
  26:     0x75501c0a370a - <unknown>
  27:     0x75501c127aac - <unknown>
  28:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: rustc 1.87.0-nightly (fd17deacc 2025-03-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(lazy_type_alias) -Z dump-mir-dir=dir

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack

@rustbot label +F-lazy_type_alias

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-lazy_type_alias`#![feature(lazy_type_alias)]`F-where_clause_attrs`#![feature(where_clause_attrs)]`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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions