Skip to content

ICE: assertion failed: !ty.has_vars_bound_at_or_above() , glacier fixed/76826.rs with --emit=mir -Zpolymorphize=on #87219

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

code from glacier fixed/76826.rs

#![feature(generic_associated_types)]

pub trait Iter {
    type Item<'a> where Self: 'a;

    fn next<'a>(&'a mut self) -> Option<Self::Item<'a>>;

    fn for_each<F>(mut self, mut f: F)
        where Self: Sized, F: for<'a> FnMut(Self::Item<'a>)
    {
        while let Some(item) = self.next() {
            f(item);
        }
    }
}

pub struct Windows<T> {
    items: Vec<T>,
    start: usize,
    len: usize,
}

impl<T> Windows<T> {
    pub fn new(items: Vec<T>, len: usize) -> Self {
        Self { items, start: 0, len }
    }
}

impl<T> Iter for Windows<T> {
    type Item<'a> where T: 'a = &'a mut [T];

    fn next<'a>(&'a mut self) -> Option<Self::Item<'a>> {
        let slice = self.items.get_mut(self.start..self.start + self.len)?;
        self.start += 1;
        Some(slice)
    }
}

fn main() {
    Windows::new(vec![1, 2, 3, 4, 5], 3)
        .for_each(|slice| println!("{:?}", slice));
}

Meta

rustc --version --verbose:

rustc 1.55.0-nightly (74ef0c3e4 2021-07-16)
binary: rustc
commit-hash: 74ef0c3e404cc72c08b2d1e14506f90d9e877269
commit-date: 2021-07-16
host: x86_64-unknown-linux-gnu
release: 1.55.0-nightly
LLVM version: 12.0.1

Error output

rustc glacier/fixed/76826.rs --emit=mir -Zpolymorphize=on

thread 'rustc' panicked at 'assertion failed: !ty.has_vars_bound_at_or_above(ty::DebruijnIndex::from_usize(self.universes.len()))', compiler/rustc_trait_selection/src/traits/query/normalize.rs:232:17
note: run with `RUST_BACKTRACE=1` environment variable to display 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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (74ef0c3e4 2021-07-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z polymorphize=on

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `std::option::Option<<Windows<T> as Iter>::Item<'_>>`
end of query stack
Backtrace

thread 'rustc' panicked at 'assertion failed: !ty.has_vars_bound_at_or_above(ty::DebruijnIndex::from_usize(self.universes.len()))', compiler/rustc_trait_selection/src/traits/query/normalize.rs:232:17
stack backtrace:
   0:     0x7f22a1f2af00 - std::backtrace_rs::backtrace::libunwind::trace::h0f5cd2ee8b0d7274
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f22a1f2af00 - std::backtrace_rs::backtrace::trace_unsynchronized::h06905b5aeda069a1
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f22a1f2af00 - std::sys_common::backtrace::_print_fmt::h4fe4c7c875072f30
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f22a1f2af00 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hcc0746f004a9b7ef
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f22a1f98cec - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/core/src/fmt/mod.rs:1115:17
   5:     0x7f22a1f1c655 - std::io::Write::write_fmt::h23dab4cc9ce72ee2
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/io/mod.rs:1663:15
   6:     0x7f22a1f2ec1b - std::sys_common::backtrace::_print::h173dc702502d65d2
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f22a1f2ec1b - std::sys_common::backtrace::print::h61bd27c4742ba817
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f22a1f2ec1b - std::panicking::default_hook::{{closure}}::hcaae87f0495ae613
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/panicking.rs:208:50
   9:     0x7f22a1f2e6f1 - std::panicking::default_hook::h0538e728ee080db0
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/panicking.rs:225:9
  10:     0x7f22a27051c1 - rustc_driver::DEFAULT_HOOK::{{closure}}::{{closure}}::h432ae30fc20e6372
  11:     0x7f22a1f2f449 - std::panicking::rust_panic_with_hook::h3039e236b6ca482c
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/panicking.rs:626:17
  12:     0x7f22a1f2eed7 - std::panicking::begin_panic_handler::{{closure}}::h884fbab544ffd91c
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/panicking.rs:517:13
  13:     0x7f22a1f2b3fc - std::sys_common::backtrace::__rust_end_short_backtrace::hdaf2e18ba3d91210
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7f22a1f2ee69 - rust_begin_unwind
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/panicking.rs:515:5
  15:     0x7f22a1ef9e71 - core::panicking::panic_fmt::hcf5f6d96e1dd7099
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/core/src/panicking.rs:92:14
  16:     0x7f22a1ef9dbd - core::panicking::panic::hd695e3b1d0dd4ef4
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/core/src/panicking.rs:50:5
  17:     0x7f22a409d4b5 - <rustc_trait_selection::traits::query::normalize::QueryNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_ty::hc95a20e7cdd22597
  18:     0x7f22a403fa30 - rustc_middle::ty::fold::TypeFoldable::fold_with::h954fc24bdeb2e96e
  19:     0x7f22a408d66a - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with::h8ceca8e018b93ffa
  20:     0x7f22a409c4f6 - <rustc_trait_selection::traits::query::normalize::QueryNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_ty::hc95a20e7cdd22597
  21:     0x7f22a3899970 - <rustc_infer::infer::at::At as rustc_trait_selection::traits::query::normalize::AtExt>::normalize::hb71d72f0ba35c667
  22:     0x7f22a388c99d - rustc_infer::infer::InferCtxtBuilder::enter::hab199ae1631b39e8
  23:     0x7f22a389af68 - core::ops::function::FnOnce::call_once::h24f16da279ed7bd7
  24:     0x7f22a3b1154d - rustc_query_system::query::plumbing::get_query_impl::hd825fc255c29519f
  25:     0x7f22a3b5c53f - <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::normalize_generic_arg_after_erasing_regions::h062c0c4d5027d100
  26:     0x7f22a41841d0 - rustc_middle::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder::normalize_generic_arg_after_erasing_regions::hcd821ce068baf57a
  27:     0x7f22a36095cb - rustc_middle::ty::util::fold_list::h128f20764f893854
  28:     0x7f22a3660f3b - rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for rustc_middle::ty::sty::Binder<T>>::super_fold_with::hb4b89ad0eb294be5
  29:     0x7f22a36216a4 - rustc_middle::ty::fold::TypeFolder::fold_binder::h3d44401b2d50c4c0
  30:     0x7f22a359dbb5 - rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::normalize_erasing_regions::hb7a1178a524e7b35
  31:     0x7f22a41777ec - rustc_middle::ty::layout::<impl rustc_middle::ty::instance::Instance>::fn_sig_for_fn_abi::hd97e417fc8900b14
  32:     0x7f22a3863487 - <rustc_target::abi::call::FnAbi<&rustc_middle::ty::TyS> as rustc_middle::ty::layout::FnAbiExt<C>>::of_instance::h01bf068a1677b1a2
  33:     0x7f22a38571ba - rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_fn::h9ffd9900040301bc
  34:     0x7f22a3869af3 - rustc_codegen_llvm::base::compile_codegen_unit::module_codegen::hefd9993fd5d8f6af
  35:     0x7f22a42abc07 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task::h109c11c2d2b2fe9e
  36:     0x7f22a42c31f7 - rustc_codegen_llvm::base::compile_codegen_unit::hd128bb1380560c35
  37:     0x7f22a42b03c6 - <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate::hc25561f12c31c9af
  38:     0x7f22a423246c - rustc_interface::passes::QueryContext::enter::h21fac079e595ecfb
  39:     0x7f22a422a3a6 - rustc_interface::queries::Queries::ongoing_codegen::h26b62c4c2f9af25f
  40:     0x7f22a42091bf - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hd3df2f2fd8ee2f9c
  41:     0x7f22a41f7ecc - rustc_span::with_source_map::h4320e6c7562b1c81
  42:     0x7f22a420a32a - rustc_interface::interface::create_compiler_and_run::h8b004a10f044574a
  43:     0x7f22a41fd219 - scoped_tls::ScopedKey<T>::set::hc495f050953f2646
  44:     0x7f22a41f9fdb - std::sys_common::backtrace::__rust_begin_short_backtrace::hf6d64874d4b63366
  45:     0x7f22a41f8865 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h44f63dc93d63fbac
  46:     0x7f22a1f3b9f7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd5b860c6542b008a
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/alloc/src/boxed.rs:1572:9
  47:     0x7f22a1f3b9f7 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc87b98c8a3a585ed
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/alloc/src/boxed.rs:1572:9
  48:     0x7f22a1f3b9f7 - std::sys::unix::thread::Thread::new::thread_start::ha990175c8f3779cc
                               at /rustc/74ef0c3e404cc72c08b2d1e14506f90d9e877269/library/std/src/sys/unix/thread.rs:74:17
  49:     0x7f22a1e47259 - start_thread
  50:     0x7f22a1d5c5e3 - __GI___clone
  51:                0x0 - <unknown>

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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.55.0-nightly (74ef0c3e4 2021-07-16) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z polymorphize=on

query stack during panic:
#0 [normalize_generic_arg_after_erasing_regions] normalizing `std::option::Option<<Windows<T> as Iter>::Item<'_>>`
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    -ZpolymorphizeUnstable option: Polymorphization.C-bugCategory: This is a bug.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.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