Skip to content

thread 'rustc' panicked at 'assertion failed: !self.substitutions.is_empty()', compiler/rustc_errors/src/lib.rs:189:9 #83309

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
szunami opened this issue Mar 19, 2021 · 5 comments · Fixed by #83401
Assignees
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@szunami
Copy link

szunami commented Mar 19, 2021

thread 'rustc' panicked at 'assertion failed: !self.substitutions.is_empty()', compiler/rustc_errors/src/lib.rs:189:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/e9920ef7749d11fc71cc32ca4ba055bcfeaab945/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/e9920ef7749d11fc71cc32ca4ba055bcfeaab945/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/e9920ef7749d11fc71cc32ca4ba055bcfeaab945/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: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
  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_system::query::plumbing::ensure_query_impl
  19: rustc_interface::passes::analysis
  20: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  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_interface::passes::QueryContext::enter
  27: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  28: rustc_span::with_source_map
  29: rustc_interface::interface::create_compiler_and_run
  30: 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.52.0-nightly (e9920ef77 2021-02-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z share-generics=y -C embed-bitcode=no -C debuginfo=2 -C linker=/usr/bin/clang -C incremental -C link-arg=-fuse-ld=lld --crate-type bin

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `falling`
#1 [analysis] running analysis passes on this crate
end of query stack
warning: 5 warnings emitted

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

Code that generated this error is available here:

szunami/staircases@cc74cec

I am happy to spend some time trying to create a smaller repro but it will take me a few days. This error is reproducible on my machine.

@szunami szunami added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 19, 2021
@szunami
Copy link
Author

szunami commented Mar 20, 2021

FYI, with szunami/staircases@a0dfe83 this code compiled.

@tmiasko
Copy link
Contributor

tmiasko commented Mar 20, 2021

Minimized:

fn main() {
    for v in Query.iter_mut() {
        *v -= 1;
    }
}

pub struct Query;
pub struct QueryIter<'a>(&'a i32);

impl Query {
    pub fn iter_mut<'a>(&'a mut self) -> QueryIter<'a> {
        todo!();
    }
}

impl<'a> Iterator for QueryIter<'a> {
    type Item = &'a i32;

    fn next(&mut self) -> Option<Self::Item> {
        todo!();
    }
}

Similar error was reported in #83292.

The issue is in code that attempts to suggest a different method, that might potentially return &mut items. In that particular case there are no other suggestions to make, but code will attempt to emit diagnostic anyway, eventually failing the assertion:

let opt_suggestions = path_segment
.hir_id
.map(|path_hir_id| self.infcx.tcx.typeck(path_hir_id.owner))
.and_then(|typeck| typeck.type_dependent_def_id(*hir_id))
.and_then(|def_id| self.infcx.tcx.impl_of_method(def_id))
.map(|def_id| self.infcx.tcx.associated_items(def_id))
.map(|assoc_items| {
assoc_items
.in_definition_order()
.map(|assoc_item_def| assoc_item_def.ident)
.filter(|&ident| {
let original_method_ident = path_segment.ident;
original_method_ident != ident
&& ident
.as_str()
.starts_with(&original_method_ident.name.to_string())
})
.map(|ident| format!("{}()", ident))
});
if let Some(suggestions) = opt_suggestions {
err.span_suggestions(
path_segment.ident.span,
&format!("use mutable method"),
suggestions,
Applicability::MaybeIncorrect,
);
}
}
};

@rustbot label: +E-easy

@rustbot rustbot added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Mar 20, 2021
@fee1-dead
Copy link
Member

@rustbot claim

fanninpm added a commit to fanninpm/glacier that referenced this issue Mar 26, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 27, 2021
@tmiasko
Copy link
Contributor

tmiasko commented Mar 31, 2021

@rustbot label +regression-from-stable-to-beta

@rustbot rustbot added regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 31, 2021
@apiraino
Copy link
Contributor

apiraino commented Apr 6, 2021

Assigning priority as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@rustbot label -I-prioritize +P-medium

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants