rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.58k stars 12.48k forks source link

ICE On unknown type on HapMap templated #98620

Closed AurelienFT closed 2 years ago

AurelienFT commented 2 years ago

Code

use std::collections::HashMap;
use std::hash::BuildHasherDefault;

pub type BuildMap<T> = BuildHasherDefault<T>;

pub type Map<K, V> = HashMap<K, V, BuildMap<K>>;

fn main() {
    let length = 3;
    let mut new_operations = Map::with_capacity_and_hasher(length, BuildMap::default());
    if !new_operations.is_empty() {
        return;
    }
}

Meta

rustc --version --verbose:

rustc 1.63.0-nightly (5435ed691 2022-06-07)
binary: rustc
commit-hash: 5435ed6916a59e8d5acba2149316a841c3905cbd
commit-date: 2022-06-07
host: aarch64-apple-darwin
release: 1.63.0-nightly
LLVM version: 14.0.5

Error output

error: internal compiler error: compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:856:33: unexpected path: def=std::collections::HashMap substs=[_, _, _] path=Path { span: src/main.rs:22:30: 22:33 (#0), res: Def(TyAlias, DefId(0:20 ~ tmp[b4a0]::Map)), segments: [PathSegment { ident: Map#0, hir_id: Some(HirId { owner: DefId(0:23 ~ tmp[b4a0]::main), local_id: 6 }), res: Some(Err), args: None, infer_args: true }] }
Backtrace

``` thread 'rustc' panicked at 'Box', /rustc/5435ed6916a59e8d5acba2149316a841c3905cbd/compiler/rustc_errors/src/lib.rs:1334:9 stack backtrace: 0: 0x103a44090 - ::fmt::h289ddc002351b523 1: 0x103a95a6c - core::fmt::write::h799deef4ed1d694b 2: 0x103a3718c - std::io::Write::write_fmt::h3e628554da7ceb9c 3: 0x103a46cd4 - std::panicking::default_hook::{{closure}}::ha83375eb6d56849c 4: 0x103a46a3c - std::panicking::default_hook::h8ca7f4d98f9cfccf 5: 0x10ae703cc - rustc_driver[6012721eacdbdd6d]::DEFAULT_HOOK::{closure#0}::{closure#0} 6: 0x103a472a4 - std::panicking::rust_panic_with_hook::h69563d1f3c0e4475 7: 0x10e958270 - std[3f1a734e0e85718c]::panicking::begin_panic::::{closure#0} 8: 0x10e956548 - std[3f1a734e0e85718c]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 9: 0x10ed8886c - std[3f1a734e0e85718c]::panicking::begin_panic:: 10: 0x10e8d480c - std[3f1a734e0e85718c]::panic::panic_any:: 11: 0x10e8d455c - ::bug::<&alloc[a2584a6b23f7fae9]::string::String> 12: 0x10e8d2ae4 - ::bug::<&alloc[a2584a6b23f7fae9]::string::String> 13: 0x10e961efc - rustc_middle[f73a57d5dc2f596d]::ty::context::tls::with_opt::::{closure#0}, ()> 14: 0x10e961f70 - rustc_middle[f73a57d5dc2f596d]::util::bug::opt_span_bug_fmt:: 15: 0x10ed8d7d4 - rustc_middle[f73a57d5dc2f596d]::util::bug::bug_fmt 16: 0x10e79e97c - ::path_inferred_subst_iter 17: 0x10e79f00c - ::visit_expr 18: 0x10e79edf4 - ::visit_expr 19: 0x10e79e9d8 - ::visit_local 20: 0x10e7bafac - rustc_hir[ff83a92110a313d3]::intravisit::walk_expr:: 21: 0x10e79ef1c - ::visit_expr 22: 0x10e73e80c - ::emit_inference_failure_err 23: 0x10e63eddc - ::maybe_report_ambiguity 24: 0x10e63213c - ::report_fulfillment_errors 25: 0x10d28815c - ::select_all_obligations_or_error 26: 0x10d383c7c - ::enter::<&rustc_middle[f73a57d5dc2f596d]::ty::context::TypeckResults, ::enter::{closure#1}, &rustc_middle[f73a57d5dc2f596d]::ty::context::TypeckResults>::{closure#0}> 27: 0x10d2fd464 - rustc_typeck[4f19e3822f8d5d40]::check::typeck 28: 0x10de61808 - >::with_task:: 29: 0x10dc0a3b8 - rustc_query_system[136bb7c139dddbdd]::query::plumbing::try_execute_query::> 30: 0x10dce218c - rustc_query_system[136bb7c139dddbdd]::query::plumbing::get_query:: 31: 0x10d427ca8 - ::par_body_owners:: 32: 0x10d301508 - rustc_typeck[4f19e3822f8d5d40]::check::typeck_item_bodies 33: 0x10de8a154 - >::with_task:: 34: 0x10dc4c9ac - rustc_query_system[136bb7c139dddbdd]::query::plumbing::try_execute_query::> 35: 0x10dcb142c - rustc_query_system[136bb7c139dddbdd]::query::plumbing::get_query:: 36: 0x10d3b0b14 - ::time::<(), rustc_typeck[4f19e3822f8d5d40]::check_crate::{closure#7}> 37: 0x10d3789b4 - rustc_typeck[4f19e3822f8d5d40]::check_crate 38: 0x10af75574 - rustc_interface[b81c2f735902673e]::passes::analysis 39: 0x10de81ddc - >::with_task::> 40: 0x10dc41654 - rustc_query_system[136bb7c139dddbdd]::query::plumbing::try_execute_query::>> 41: 0x10dce25e0 - rustc_query_system[136bb7c139dddbdd]::query::plumbing::get_query:: 42: 0x10ae33ecc - ::enter::> 43: 0x10ae16fd4 - ::enter::, rustc_errors[5dd2c2aa9e856d8b]::ErrorGuaranteed>> 44: 0x10ae036d8 - rustc_span[3a27d002c0bb3dbf]::with_source_map::, rustc_interface[b81c2f735902673e]::interface::create_compiler_and_run, rustc_driver[6012721eacdbdd6d]::run_compiler::{closure#1}>::{closure#1}> 45: 0x10ae177c0 - >::set::, rustc_driver[6012721eacdbdd6d]::run_compiler::{closure#1}>::{closure#0}, core[aa3fa2e4c8a303d9]::result::Result<(), rustc_errors[5dd2c2aa9e856d8b]::ErrorGuaranteed>> 46: 0x10ae3640c - std[3f1a734e0e85718c]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver[6012721eacdbdd6d]::run_compiler::{closure#1}>::{closure#0}, core[aa3fa2e4c8a303d9]::result::Result<(), rustc_errors[5dd2c2aa9e856d8b]::ErrorGuaranteed>>::{closure#0}, core[aa3fa2e4c8a303d9]::result::Result<(), rustc_errors[5dd2c2aa9e856d8b]::ErrorGuaranteed>> 47: 0x10ae36c84 - <::spawn_unchecked_, rustc_driver[6012721eacdbdd6d]::run_compiler::{closure#1}>::{closure#0}, core[aa3fa2e4c8a303d9]::result::Result<(), rustc_errors[5dd2c2aa9e856d8b]::ErrorGuaranteed>>::{closure#0}, core[aa3fa2e4c8a303d9]::result::Result<(), rustc_errors[5dd2c2aa9e856d8b]::ErrorGuaranteed>>::{closure#1} as core[aa3fa2e4c8a303d9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 48: 0x103a4fb00 - std::sys::unix::thread::Thread::new::thread_start::h65074f5cfbbe5af3 49: 0x18ccd026c - __pthread_deallocate 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.63.0-nightly (5435ed691 2022-06-07) running on aarch64-apple-darwin note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [typeck] type-checking `main` #1 [typeck_item_bodies] type-checking all item bodies #2 [analysis] running analysis passes on this crate end of query stack error: could not compile `tmp` ```

Rageking8 commented 2 years ago

Seems to have already been fixed with the latest Nightly version: 1.64.0-nightly (2022-06-27 2f3ddd9f594adf977354). Could not reproduce ICE using rust playground for latest nightly, beta and stable 1.61.

AurelienFT commented 2 years ago

Yes it has been fixed. Just test it I close it.