Skip to content

Compiler Error : 'rustc' panicked at 'assertion failed: !self.substitutions.is_empty()', compiler/rustc_errors/src/lib.rs:192:9 #84154

Closed
@diogo464

Description

@diogo464

Code

struct Transform {
    x: f32,
    y: f32,
}

struct SliceWrapper<'a, T>(&'a [T]);
impl<'a, T> SliceWrapper<'a, T> {
    fn slice(&self) -> &[T] {
        self.0
    }
}

fn foo(transforms: SliceWrapper<Transform>) {
    for t in transforms.slice() {
        t.x += 1.0;
    }
}

fn main() {}

Meta

The error doesn't happen on stable 1.51.0 but happens on 1.52.0-beta.3 (2021-04-06 2157381) and nightly.
rustc --version --verbose:

rustc 1.53.0-nightly (d0695c908 2021-04-12)
binary: rustc
commit-hash: d0695c9081b16077d0aed368bccaf437d77ff497
commit-date: 2021-04-12
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

thread 'rustc' panicked at 'assertion failed: !self.substitutions.is_empty()', compiler/rustc_errors/src/lib.rs:192:9
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.53.0-nightly (d0695c908 2021-04-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `foo`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `compiler_bug`

To learn more, run the command again with --verbose.
Expected output, from stable

error[E0594]: cannot assign to `t.x` which is behind a `&` reference
  --> src/main.rs:15:9
   |
14 |     for t in transforms.slice() {
   |              ------------------ this iterator yields `&` references
15 |         t.x += 1.0;
   |         ^^^^^^^^^^ `t` is a `&` reference, so the data it refers to cannot be written

error: aborting due to previous error

For more information about this error, try `rustc --explain E0594`.
error: could not compile `playground`

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

Backtrace

thread 'rustc' panicked at 'assertion failed: !self.substitutions.is_empty()', compiler/rustc_errors/src/lib.rs:192:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d0695c9081b16077d0aed368bccaf437d77ff497/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/d0695c9081b16077d0aed368bccaf437d77ff497/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/d0695c9081b16077d0aed368bccaf437d77ff497/library/core/src/panicking.rs:50:5
   3: rustc_errors::CodeSuggestion::splice_lines
   4: <rustc_errors::emitter::EmitterWriter as rustc_errors::emitter::Emitter>::emit_diagnostic
   5: rustc_errors::json::Diagnostic::from_errors_diagnostic
   6: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
   7: rustc_errors::HandlerInner::emit_diagnostic
   8: rustc_errors::Handler::emit_diagnostic
   9: rustc_mir::borrow_check::do_mir_borrowck
  10: rustc_infer::infer::InferCtxtBuilder::enter
  11: rustc_mir::borrow_check::mir_borrowck
  12: core::ops::function::FnOnce::call_once
  13: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  15: rustc_data_structures::stack::ensure_sufficient_stack
  16: rustc_query_system::query::plumbing::force_query_with_job
  17: rustc_query_system::query::plumbing::get_query_impl
  18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  19: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  20: rustc_interface::passes::analysis
  21: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  22: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  23: rustc_data_structures::stack::ensure_sufficient_stack
  24: rustc_query_system::query::plumbing::force_query_with_job
  25: rustc_query_system::query::plumbing::get_query_impl
  26: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  27: rustc_interface::passes::QueryContext::enter
  28: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  29: rustc_span::with_source_map
  30: rustc_interface::interface::create_compiler_and_run
  31: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.53.0-nightly (d0695c908 2021-04-12) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `foo`
#1 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `compiler_bug`

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions