Skip to content

ICE: assertion failed: !ty.needs_infer() #112832

Closed

Description

I tried this code: (minimized)

pub trait QueryDb {
    type Db;
}

pub struct QueryTable<Q, DB> {
    db: DB,
    storage: Q,
}

impl<Q> QueryTable<Q, <Q as QueryDb>::Db> where Q: for<'d> AsyncQueryFunction<'d> {}

pub trait AsyncQueryFunction<'d>: QueryDb<Db = <Self as AsyncQueryFunction<'d>>::SendDb> {
    type SendDb: 'd;
}

pub trait QueryStorageOpsAsync<Q>
where
    Q: for<'d> AsyncQueryFunction<'d>,
{
}

fn main() {}

I expected to see this happen: It should compile as it does on rust 1.69 and earlier (or at least not ICE).

Instead, this happened: The program fails to compile with an ICE (see backtrace).

Meta

rustc --version --verbose:

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-apple-darwin
release: 1.70.0
LLVM version: 16.0.2

cc gluon issue that reported this gluon-lang/gluon#951 (the error is coming from https://crates.io/crates/gluon-salsa, a fork of https://crates.io/crates/salsa)

Backtrace

[Running 'cargo check']
    Checking ice v0.1.0 (/Users/markus.westerlind/Code/ice)
thread 'rustc' panicked at 'assertion failed: !ty.needs_infer()', compiler/rustc_trait_selection/src/traits/outlives_bounds.rs:58:9
stack backtrace:
   0:        0x1065bcc66 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hae51cb91d407e2ef
   1:        0x10661c18b - core::fmt::write::h746bc0969202388b
   2:        0x1065b170c - std::io::Write::write_fmt::h4098c2c7437a0bd7
   3:        0x1065bca3a - std::sys_common::backtrace::print::h8360bf0158e89b36
   4:        0x1065bfc20 - std::panicking::default_hook::{{closure}}::hedf04c568eb6e0bc
   5:        0x1065bf9d0 - std::panicking::default_hook::h62889b2c29e2347d
   6:        0x1103b661a - rustc_driver_impl[eafeac5e4366564e]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x1065c038a - std::panicking::rust_panic_with_hook::h22edd02828aff274
   8:        0x1065c00e3 - std::panicking::begin_panic_handler::{{closure}}::h6895f44a9b7e2caa
   9:        0x1065bd0a9 - std::sys_common::backtrace::__rust_end_short_backtrace::h013519e9b77978c5
  10:        0x1065bfe6d - _rust_begin_unwind
  11:        0x1066480d3 - core::panicking::panic_fmt::h2a51b60c12d11322
  12:        0x106648167 - core::panicking::panic::h00b4c20719c0abc2
  13:        0x111eb22a1 - <rustc_infer[8bdc2f06ca9271f6]::infer::InferCtxt as rustc_trait_selection[dd8d47d7dbab2993]::traits::outlives_bounds::InferCtxtExt>::implied_outlives_bounds
  14:        0x110661856 - <rustc_infer[8bdc2f06ca9271f6]::infer::outlives::env::OutlivesEnvironment>::with_bounds::<core[a404433b1679a212]::iter::adapters::flatten::FlatMap<indexmap[12aa5908c2e7a321]::set::IntoIter<rustc_middle[7fc0a978862eb49c]::ty::Ty>, alloc[c6d93a74176871ad]::vec::Vec<rustc_middle[7fc0a978862eb49c]::traits::query::OutlivesBound>, <rustc_infer[8bdc2f06ca9271f6]::infer::InferCtxt as rustc_trait_selection[dd8d47d7dbab2993]::traits::outlives_bounds::InferCtxtExt>::implied_bounds_tys::{closure#0}>>
  15:        0x11079a2dd - rustc_hir_analysis[24cefc37f6c5f787]::check::wfcheck::check_well_formed
  16:        0x1117e39b5 - <std[a8778ef3a639084b]::thread::local::LocalKey<core[a404433b1679a212]::cell::Cell<*const ()>>>::with::<rustc_middle[7fc0a978862eb49c]::ty::context::tls::enter_context<rustc_query_system[a65e9af7c6ae3d01]::query::plumbing::execute_job_incr<rustc_query_impl[598269a19ba1f561]::queries::check_well_formed, rustc_query_impl[598269a19ba1f561]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[7fc0a978862eb49c]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[a65e9af7c6ae3d01]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[7fc0a978862eb49c]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[a65e9af7c6ae3d01]::dep_graph::graph::DepNodeIndex)>
  17:        0x1116c58fd - rustc_query_system[a65e9af7c6ae3d01]::query::plumbing::try_execute_query::<rustc_query_impl[598269a19ba1f561]::queries::check_well_formed, rustc_query_impl[598269a19ba1f561]::plumbing::QueryCtxt>
  18:        0x1119a08be - <rustc_query_impl[598269a19ba1f561]::Queries as rustc_middle[7fc0a978862eb49c]::ty::query::QueryEngine>::check_well_formed
  19:        0x11078796b - rustc_data_structures[958e631f1985e39c]::sync::par_for_each_in::<&[rustc_hir[edfcb1a3e9db0f3e]::hir::ItemId], <rustc_middle[7fc0a978862eb49c]::hir::ModuleItems>::par_items<rustc_hir_analysis[24cefc37f6c5f787]::check::wfcheck::check_mod_type_wf::{closure#0}>::{closure#0}>
  20:        0x1107a0903 - rustc_hir_analysis[24cefc37f6c5f787]::check::wfcheck::check_mod_type_wf
  21:        0x1117e3045 - <std[a8778ef3a639084b]::thread::local::LocalKey<core[a404433b1679a212]::cell::Cell<*const ()>>>::with::<rustc_middle[7fc0a978862eb49c]::ty::context::tls::enter_context<rustc_query_system[a65e9af7c6ae3d01]::query::plumbing::execute_job_incr<rustc_query_impl[598269a19ba1f561]::queries::check_mod_type_wf, rustc_query_impl[598269a19ba1f561]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[7fc0a978862eb49c]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[a65e9af7c6ae3d01]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[7fc0a978862eb49c]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[a65e9af7c6ae3d01]::dep_graph::graph::DepNodeIndex)>
  22:        0x1116c509e - rustc_query_system[a65e9af7c6ae3d01]::query::plumbing::try_execute_query::<rustc_query_impl[598269a19ba1f561]::queries::check_mod_type_wf, rustc_query_impl[598269a19ba1f561]::plumbing::QueryCtxt>
  23:        0x1119935ce - <rustc_query_impl[598269a19ba1f561]::Queries as rustc_middle[7fc0a978862eb49c]::ty::query::QueryEngine>::check_mod_type_wf
  24:        0x110787a5b - rustc_data_structures[958e631f1985e39c]::sync::par_for_each_in::<&[rustc_hir[edfcb1a3e9db0f3e]::hir_id::OwnerId], <rustc_middle[7fc0a978862eb49c]::hir::map::Map>::par_for_each_module<rustc_hir_analysis[24cefc37f6c5f787]::check_crate::{closure#5}::{closure#0}::{closure#0}>::{closure#0}>
  25:        0x1106e7cad - <rustc_session[5be010f910a4943c]::session::Session>::track_errors::<rustc_hir_analysis[24cefc37f6c5f787]::check_crate::{closure#5}, ()>
  26:        0x110690b29 - rustc_hir_analysis[24cefc37f6c5f787]::check_crate
  27:        0x110c2a02d - rustc_interface[47617fbd5781a430]::passes::analysis
  28:        0x111865fdf - <std[a8778ef3a639084b]::thread::local::LocalKey<core[a404433b1679a212]::cell::Cell<*const ()>>>::with::<rustc_middle[7fc0a978862eb49c]::ty::context::tls::enter_context<rustc_query_system[a65e9af7c6ae3d01]::query::plumbing::execute_job_incr<rustc_query_impl[598269a19ba1f561]::queries::analysis, rustc_query_impl[598269a19ba1f561]::plumbing::QueryCtxt>::{closure#2}, (rustc_middle[7fc0a978862eb49c]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[a65e9af7c6ae3d01]::dep_graph::graph::DepNodeIndex)>::{closure#0}, (rustc_middle[7fc0a978862eb49c]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[a65e9af7c6ae3d01]::dep_graph::graph::DepNodeIndex)>
  29:        0x11172c33f - rustc_query_system[a65e9af7c6ae3d01]::query::plumbing::try_execute_query::<rustc_query_impl[598269a19ba1f561]::queries::analysis, rustc_query_impl[598269a19ba1f561]::plumbing::QueryCtxt>
  30:        0x111987046 - <rustc_query_impl[598269a19ba1f561]::Queries as rustc_middle[7fc0a978862eb49c]::ty::query::QueryEngine>::analysis
  31:        0x110406413 - <std[a8778ef3a639084b]::thread::local::LocalKey<core[a404433b1679a212]::cell::Cell<*const ()>>>::with::<rustc_middle[7fc0a978862eb49c]::ty::context::tls::enter_context<<rustc_middle[7fc0a978862eb49c]::ty::context::GlobalCtxt>::enter<rustc_driver_impl[eafeac5e4366564e]::run_compiler::{closure#1}::{closure#2}::{closure#4}, core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>>::{closure#0}, core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>>::{closure#0}, core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>>
  32:        0x1103cc42c - <rustc_interface[47617fbd5781a430]::queries::QueryResult<&rustc_middle[7fc0a978862eb49c]::ty::context::GlobalCtxt>>::enter::<core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>, rustc_driver_impl[eafeac5e4366564e]::run_compiler::{closure#1}::{closure#2}::{closure#4}>
  33:        0x11040d7b0 - <rustc_interface[47617fbd5781a430]::interface::Compiler>::enter::<rustc_driver_impl[eafeac5e4366564e]::run_compiler::{closure#1}::{closure#2}, core[a404433b1679a212]::result::Result<core[a404433b1679a212]::option::Option<rustc_interface[47617fbd5781a430]::queries::Linker>, rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>>
  34:        0x1103bd499 - rustc_span[8ca261ac2dfd0c4e]::set_source_map::<core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>, rustc_interface[47617fbd5781a430]::interface::run_compiler<core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>, rustc_driver_impl[eafeac5e4366564e]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  35:        0x1103cd11d - <scoped_tls[74fa14b5599a25d8]::ScopedKey<rustc_span[8ca261ac2dfd0c4e]::SessionGlobals>>::set::<rustc_interface[47617fbd5781a430]::interface::run_compiler<core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>, rustc_driver_impl[eafeac5e4366564e]::run_compiler::{closure#1}>::{closure#0}, core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>>
  36:        0x1103c2930 - std[a8778ef3a639084b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[47617fbd5781a430]::util::run_in_thread_pool_with_globals<rustc_interface[47617fbd5781a430]::interface::run_compiler<core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>, rustc_driver_impl[eafeac5e4366564e]::run_compiler::{closure#1}>::{closure#0}, core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>>
  37:        0x1103c2f75 - <<std[a8778ef3a639084b]::thread::Builder>::spawn_unchecked_<rustc_interface[47617fbd5781a430]::util::run_in_thread_pool_with_globals<rustc_interface[47617fbd5781a430]::interface::run_compiler<core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>, rustc_driver_impl[eafeac5e4366564e]::run_compiler::{closure#1}>::{closure#0}, core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a404433b1679a212]::result::Result<(), rustc_span[8ca261ac2dfd0c4e]::ErrorGuaranteed>>::{closure#1} as core[a404433b1679a212]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:        0x1065c9ad9 - std::sys::unix::thread::Thread::new::thread_start::ha9b8d2206382b425
  39:     0x7ff803699259 - __pthread_start

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: rustc 1.70.0 (90c541806 2023-05-31) running on x86_64-apple-darwin

note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
#0 [check_well_formed] checking that `<impl at src/main.rs:10:1: 10:42>` is well-formed
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `ice` (bin "ice")
[Finished running. Exit status: 101]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

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.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