rust-lang / rust

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

ptr_metadata + useless where clause = ICE in normalize_projection_ty #95823

Closed CAD97 closed 2 years ago

CAD97 commented 2 years ago

Code

#![feature(ptr_metadata)]

pub struct S;

impl S
where
    ():,
{
    fn f<T: ?Sized>(_: <T as core::ptr::Pointee>::Metadata) {}
}

Removing the where (): clause removes the ICE. Replacing core::ptr::Pointee with a non-lang trait with a blanket impl removes teh ICE.

Meta

rustc --version --verbose:

rustc 1.61.0-nightly (76d770ac2 2022-04-02)
binary: rustc
commit-hash: 76d770ac21d9521db6a92a48c7b3d5b2cc535941
commit-date: 2022-04-02
host: x86_64-pc-windows-msvc
release: 1.61.0-nightly
LLVM version: 14.0.0

Error output

error: internal compiler error: compiler\rustc_middle\src\ty\impls_ty.rs:141:17: StableHasher: unexpected region '_#0r

thread 'rustc' panicked at 'Box<dyn Any>', compiler\rustc_errors\src\lib.rs:1279:9

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.61.0-nightly (76d770ac2 2022-04-02) running on x86_64-pc-windows-msvc

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

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

query stack during panic:
#0 [normalize_projection_ty] normalizing `Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder(OutlivesPredicate((), ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrAnon(0) })), [])], reveal: UserFacing, constness: NotConst }, value: ProjectionTy { substs: [T], item_def_id: DefId(2:2092 ~ core[1973]::ptr::metadata::Pointee::Metadata) } } }`
#1 [try_normalize_generic_arg_after_erasing_regions] normalizing `<T as core::ptr::metadata::Pointee>::Metadata`
#2 [mir_built] building MIR for `<impl at src\lib.rs:5:1: 10:2>::f`
#3 [unsafety_check_result] unsafety-checking `<impl at src\lib.rs:5:1: 10:2>::f`
#4 [analysis] running analysis passes on this crate
end of query stack
Backtrace

``` stack backtrace: 0: 0x7ffca1a0988f - ::fmt::h3048494f893b29ff 1: 0x7ffca1a34cba - core::fmt::write::h2686dfebc8d906b9 2: 0x7ffca19fc709 - ::fmt::hdce67e6f391114af 3: 0x7ffca1a0ceab - std::panicking::default_hook::h15a087fa7cb3dd98 4: 0x7ffca1a0ca9e - std::panicking::default_hook::h15a087fa7cb3dd98 5: 0x7ffc94a62176 - rustc_driver[abf927877bd9162]::pretty::print_after_hir_lowering 6: 0x7ffca1a0d78a - std::panicking::rust_panic_with_hook::h6d095d4c57cdf9fd 7: 0x7ffc993b0a25 - ::fmt 8: 0x7ffc993af139 - ::fmt 9: 0x7ffc996d4d71 - rustc_query_system[cbf34d96f6e90a6f]::query::plumbing::incremental_verify_ich_cold 10: 0x7ffc99362a89 - ::fmt 11: 0x7ffc9936b8fa - ::emit_diagnostic 12: 0x7ffc99368e62 - ::bug 13: 0x7ffc991498d3 - ::zst 14: 0x7ffc9914ccfc - ::visit_lifetime 15: 0x7ffc996bfa00 - rustc_middle[543984f644f50821]::util::bug::bug_fmt 16: 0x7ffc991d6581 - >::hash_stable 17: 0x7ffc991d668e - >::hash_stable 18: 0x7ffc991e57ff - ::lift_to_tcx 19: 0x7ffc990ae8a4 - >::hash_stable 20: 0x7ffc98157e8f - <&[rustc_middle[543984f644f50821]::thir::abstract_const::Node] as rustc_serialize[23736f889541b224]::serialize::Decodable>::decode 21: 0x7ffc9836e703 - ::spec_to_self_profile_string 22: 0x7ffc9849ccc7 - ::spec_to_self_profile_string 23: 0x7ffc990a6d77 - ::is_sized 24: 0x7ffc98e329a2 - ::fmt 25: 0x7ffc98e1d013 - ::fmt 26: 0x7ffc98e1a1d7 - ::fmt 27: 0x7ffc98e141d7 - rustc_trait_selection[756657197aff2e3f]::traits::project::normalize_projection_type 28: 0x7ffc97f0548b - >>::lower_into 29: 0x7ffc97de5c69 - ::visit_region 30: 0x7ffc9829a263 - >::describe 31: 0x7ffc98259a93 - >::describe 32: 0x7ffc9837f1a9 - ::spec_to_self_profile_string 33: 0x7ffc984cc0cb - ::spec_to_self_profile_string 34: 0x7ffc98199776 - ::try_mark_green 35: 0x7ffc98dfd37c - ::try_fold_ty 36: 0x7ffc97e72605 - >::adt_variance 37: 0x7ffc97efd47c - >>::lower_into 38: 0x7ffc97e5c921 - ::fold_ty 39: 0x7ffc98298bc1 - >::describe 40: 0x7ffc9824ec63 - >::describe 41: 0x7ffc984e0107 - ::spec_to_self_profile_string 42: 0x7ffc9914e4c4 - ::fmt 43: 0x7ffc991468c8 - ::try_fold_ty 44: 0x7ffc97b99244 - ::to_borrow_kind 45: 0x7ffc97bcb3bf - ::to_borrow_kind 46: 0x7ffc97b9d2e1 - ::to_borrow_kind 47: 0x7ffc97b6b9c2 - ::fmt 48: 0x7ffc97b9b8c9 - ::to_borrow_kind 49: 0x7ffc98299993 - >::describe 50: 0x7ffc982548a4 - >::describe 51: 0x7ffc98373a84 - ::spec_to_self_profile_string 52: 0x7ffc984e4724 - ::spec_to_self_profile_string 53: 0x7ffc98197cc1 - ::try_mark_green 54: 0x7ffc9722fe99 - ::visit_fn 55: 0x7ffc9722c4c1 - ::visit_impl_item 56: 0x7ffc9829b318 - >::describe 57: 0x7ffc98261482 - >::describe 58: 0x7ffc983aa2cc - ::spec_to_self_profile_string 59: 0x7ffc98307383 - ::spec_to_self_profile_string 60: 0x7ffc982b2829 - ::spec_to_self_profile_string 61: 0x7ffc990dba33 - ::try_force_from_dep_node 62: 0x7ffc9824c95f - >::describe 63: 0x7ffc9824c937 - >::describe 64: 0x7ffc9824c937 - >::describe 65: 0x7ffc98318efa - ::spec_to_self_profile_string 66: 0x7ffc9849ed53 - ::spec_to_self_profile_string 67: 0x7ffc94b7ab81 - ::link 68: 0x7ffc94b50dd3 - ::fmt 69: 0x7ffc94bd8658 - rustc_interface[ba8740adefebcae0]::passes::analysis 70: 0x7ffc9829ce9e - >::describe 71: 0x7ffc9827ee9f - >::describe 72: 0x7ffc9842b90b - ::spec_to_self_profile_string 73: 0x7ffc984e1926 - ::spec_to_self_profile_string 74: 0x7ffc94a256ff - ::fmt 75: 0x7ffc94a8c2ed - ::fmt 76: 0x7ffc94a24135 - ::fmt 77: 0x7ffc94aac750 - ::fmt 78: 0x7ffc94a166e7 - 79: 0x7ffc94a73546 - ::fmt 80: 0x7ffc94a22ca8 - ::fmt 81: 0x7ffca1a1cbcc - std::sys::windows::thread::Thread::new::h3b8480cac41d5d84 82: 0x7ffd27757034 - BaseThreadInitThunk 83: 0x7ffd29562651 - RtlUserThreadStart ```

Meta (playground)

Playground Nightly version: 1.62.0-nightly (2022-04-07 e745b4ddbd05026c75aa)

Error output (different)

Backtrace

``` thread 'rustc' panicked at 'index out of bounds: the len is 0 but the index is 0', /cargo/registry/src/github.com-1ecc6299db9ec823/ena-0.14.0/src/snapshot_vec.rs:199:10 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.62.0-nightly (e745b4ddb 2022-04-07) running on x86_64-unknown-linux-gnu note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 note: some of the compiler flags provided by cargo are hidden query stack during panic: #0 [is_sized_raw] computing whether `T` is `Sized` #1 [normalize_projection_ty] normalizing `Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder(OutlivesPredicate((), ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrAnon(0) })), [])], reveal: UserFacing, constness: NotConst }, value: ProjectionTy { substs: [T], item_def_id: DefId(2:2101 ~ core[eae4]::ptr::metadata::Pointee::Metadata) } } }` #2 [try_normalize_generic_arg_after_erasing_regions] normalizing `::Metadata` #3 [mir_built] building MIR for `::f` #4 [unsafety_check_result] unsafety-checking `::f` #5 [mir_const] processing MIR for `::f` #6 [mir_promoted] processing `::f` #7 [mir_borrowck] borrow-checking `::f` #8 [analysis] running analysis passes on this crate end of query stack ``` ``` stack backtrace: 0: 0x7f3d87b9fe0d - std::backtrace_rs::backtrace::libunwind::trace::h87fc9110a03070c9 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7f3d87b9fe0d - std::backtrace_rs::backtrace::trace_unsynchronized::hf8e09efda70fd4c4 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f3d87b9fe0d - std::sys_common::backtrace::_print_fmt::h2bba281e85b7e4cf at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/sys_common/backtrace.rs:66:5 3: 0x7f3d87b9fe0d - ::fmt::h72fd149eebcc176d at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/sys_common/backtrace.rs:45:22 4: 0x7f3d87bf9c6c - core::fmt::write::h16877f69e16283c2 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/core/src/fmt/mod.rs:1194:17 5: 0x7f3d87b91611 - std::io::Write::write_fmt::h505f84b4395e02be at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/io/mod.rs:1655:15 6: 0x7f3d87ba2d35 - std::sys_common::backtrace::_print::hff1b2addc8b3ab2e at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/sys_common/backtrace.rs:48:5 7: 0x7f3d87ba2d35 - std::sys_common::backtrace::print::h5383334ff1a62414 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/sys_common/backtrace.rs:35:9 8: 0x7f3d87ba2d35 - std::panicking::default_hook::{{closure}}::h55bff06032661335 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/panicking.rs:295:22 9: 0x7f3d87ba29a9 - std::panicking::default_hook::hbddb577ba3bd3e3a at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/panicking.rs:314:9 10: 0x7f3d88342d31 - rustc_driver[20943ffe626f84b6]::DEFAULT_HOOK::{closure#0}::{closure#0} 11: 0x7f3d87ba34d0 - std::panicking::rust_panic_with_hook::h8fddd70bf6ad28e0 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/panicking.rs:702:17 12: 0x7f3d87ba3307 - std::panicking::begin_panic_handler::{{closure}}::h9ed2b9c069b0b649 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/panicking.rs:588:13 13: 0x7f3d87ba02c4 - std::sys_common::backtrace::__rust_end_short_backtrace::hc2651b8923246021 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/sys_common/backtrace.rs:138:18 14: 0x7f3d87ba3039 - rust_begin_unwind at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/panicking.rs:584:5 15: 0x7f3d87b676f3 - core::panicking::panic_fmt::h0606840aebfd8c79 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/core/src/panicking.rs:142:14 16: 0x7f3d87b67632 - core::panicking::panic_bounds_check::hda03ddffa0d42b34 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/core/src/panicking.rs:84:5 17: 0x7f3d8a11e1f5 - >, &mut rustc_infer[2bb09421bfed907a]::infer::undo_log::InferCtxtUndoLogs>>>::uninlined_get_root_key 18: 0x7f3d8a0fbef8 - ::fold_region 19: 0x7f3d8a0806d4 - rustc_middle[7f64d339e0b7d513]::ty::util::fold_list:: as rustc_middle[7f64d339e0b7d513]::ty::fold::TypeFoldable>::try_super_fold_with::{closure#0}> 20: 0x7f3d8a00b94f - ::predicate_must_hold_modulo_regions 21: 0x7f3d8a06ac3a - rustc_trait_selection[41f150cee6be8073]::traits::type_known_to_meet_bound_modulo_regions 22: 0x7f3d898e02bb - ::enter:: 23: 0x7f3d8a5edcb0 - rustc_ty_utils[47a113fcd8c9b200]::common_traits::is_item_raw 24: 0x7f3d89cf238c - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::try_execute_query::, bool>> 25: 0x7f3d8a7e542b - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::get_query:: 26: 0x7f3d8a2480d5 - ::is_sized 27: 0x7f3d8a03afe2 - rustc_trait_selection[41f150cee6be8073]::traits::project::opt_normalize_projection_type 28: 0x7f3d8a0313b3 - rustc_trait_selection[41f150cee6be8073]::traits::project::normalize_projection_type 29: 0x7f3d8a70f045 - ::enter_canonical_trait_query::, rustc_middle[7f64d339e0b7d513]::traits::query::NormalizationResult, rustc_traits[8b0618417cc35a4e]::normalize_projection_ty::normalize_projection_ty::{closure#0}> 30: 0x7f3d8a716515 - rustc_traits[8b0618417cc35a4e]::normalize_projection_ty::normalize_projection_ty 31: 0x7f3d8a789068 - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::try_execute_query::>, core[eae4a2c4558b790c]::result::Result<&rustc_middle[7f64d339e0b7d513]::infer::canonical::Canonical>, rustc_middle[7f64d339e0b7d513]::traits::query::NoSolution>>> 32: 0x7f3d8a7f5698 - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::get_query:: 33: 0x7f3d8a8b6088 - ::normalize_projection_ty 34: 0x7f3d8a06d99f - ::try_fold_ty 35: 0x7f3d89bc37d1 - ::normalize:: 36: 0x7f3d89bc7f8a - ::enter::, rustc_traits[8b0618417cc35a4e]::normalize_erasing_regions::try_normalize_after_erasing_regions::{closure#0}> 37: 0x7f3d89bd5fec - )>>::call_once 38: 0x7f3d89cf3ca9 - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::try_execute_query::, core[eae4a2c4558b790c]::result::Result>> 39: 0x7f3d89defff3 - ::try_normalize_generic_arg_after_erasing_regions 40: 0x7f3d8a22e452 - ::try_fold_ty 41: 0x7f3d89a300e8 - rustc_mir_build[862dae384f97135a]::build::construct_fn::, core[eae4a2c4558b790c]::iter::adapters::map::Map>, rustc_mir_build[862dae384f97135a]::build::mir_build::{closure#1}::{closure#1}>>> 42: 0x7f3d89a88f0f - ::enter:: 43: 0x7f3d89a2cf6a - rustc_mir_build[862dae384f97135a]::build::mir_built 44: 0x7f3d89cfc251 - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::try_execute_query::, &rustc_data_structures[fae15044d3ca7ff8]::steal::Steal>> 45: 0x7f3d89debcc5 - ::mir_built 46: 0x7f3d89753ca2 - rustc_mir_transform[e3256c1f1ea9fed0]::check_unsafety::unsafety_check_result 47: 0x7f3d8974ff40 - >::call_once 48: 0x7f3d89d106b7 - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::try_execute_query::> 49: 0x7f3d89ded03e - ::unsafety_check_result 50: 0x7f3d8974b0ef - rustc_mir_transform[e3256c1f1ea9fed0]::mir_const 51: 0x7f3d89cfc251 - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::try_execute_query::, &rustc_data_structures[fae15044d3ca7ff8]::steal::Steal>> 52: 0x7f3d89debdfc - ::mir_const 53: 0x7f3d8974cc0d - rustc_mir_transform[e3256c1f1ea9fed0]::mir_promoted 54: 0x7f3d89cfd759 - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::try_execute_query::, (&rustc_data_structures[fae15044d3ca7ff8]::steal::Steal, &rustc_data_structures[fae15044d3ca7ff8]::steal::Steal>)>> 55: 0x7f3d89dec214 - ::mir_promoted 56: 0x7f3d89b54479 - rustc_borrowck[fe87f904ca1034d]::mir_borrowck 57: 0x7f3d89b514d0 - >::call_once 58: 0x7f3d89d0f6b1 - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::try_execute_query::> 59: 0x7f3d89ded6aa - ::mir_borrowck 60: 0x7f3d895f4828 - ::par_body_owners:: 61: 0x7f3d8a2f7758 - ::time::<(), rustc_interface[6f5777461d223668]::passes::analysis::{closure#2}> 62: 0x7f3d8a2f2f15 - rustc_interface[6f5777461d223668]::passes::analysis 63: 0x7f3d8a7b9aae - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::try_execute_query::>> 64: 0x7f3d8a7fd25e - rustc_query_system[bc809a0ba9a8482d]::query::plumbing::get_query:: 65: 0x7f3d8a2cb9d7 - ::enter::> 66: 0x7f3d8a2b609b - ::enter::, rustc_errors[bbde95346f1428cb]::ErrorGuaranteed>> 67: 0x7f3d8a2df54f - rustc_span[c549c48e758487d2]::with_source_map::, rustc_interface[6f5777461d223668]::interface::create_compiler_and_run, rustc_driver[20943ffe626f84b6]::run_compiler::{closure#1}>::{closure#1}> 68: 0x7f3d8a2b6f27 - >::set::, rustc_driver[20943ffe626f84b6]::run_compiler::{closure#1}>::{closure#0}, core[eae4a2c4558b790c]::result::Result<(), rustc_errors[bbde95346f1428cb]::ErrorGuaranteed>> 69: 0x7f3d8a2cc05f - std[1f52b9863de3167b]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver[20943ffe626f84b6]::run_compiler::{closure#1}>::{closure#0}, core[eae4a2c4558b790c]::result::Result<(), rustc_errors[bbde95346f1428cb]::ErrorGuaranteed>>::{closure#0}, core[eae4a2c4558b790c]::result::Result<(), rustc_errors[bbde95346f1428cb]::ErrorGuaranteed>> 70: 0x7f3d8a2cc199 - <::spawn_unchecked_, rustc_driver[20943ffe626f84b6]::run_compiler::{closure#1}>::{closure#0}, core[eae4a2c4558b790c]::result::Result<(), rustc_errors[bbde95346f1428cb]::ErrorGuaranteed>>::{closure#0}, core[eae4a2c4558b790c]::result::Result<(), rustc_errors[bbde95346f1428cb]::ErrorGuaranteed>>::{closure#1} as core[eae4a2c4558b790c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 71: 0x7f3d87bad5c3 - as core::ops::function::FnOnce>::call_once::h66b0cb04558949f8 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/alloc/src/boxed.rs:1853:9 72: 0x7f3d87bad5c3 - as core::ops::function::FnOnce>::call_once::h2674426c74373260 at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/alloc/src/boxed.rs:1853:9 73: 0x7f3d87bad5c3 - std::sys::unix::thread::Thread::new::thread_start::he975fba2104844cd at /rustc/e745b4ddbd05026c75aae4506aef39fdfe1603c5/library/std/src/sys/unix/thread.rs:108:17 74: 0x7f3d87add609 - start_thread 75: 0x7f3d879f6163 - clone 76: 0x0 - ```

@rustbot modify labels +F-requires-nightly

CAD97 commented 2 years ago

Oops

@rustbot modify labels: +requires-nightly

compiler-errors commented 2 years ago

This is fixed in #95315

compiler-errors commented 2 years ago

Well... probably. Haven't checked, but I can. @rustbot claim

JohnTitor commented 2 years ago

Triage: Indeed fixed by #95315, closing as the PR has a regression test and it should be sufficient.