Skip to content

ICE: ` unexpected region encountered in variance inference: ReLateParam(DefId´ #119867

Closed

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Archive {}

trait Deserialize<T> {
    fn deserialize(&self);
}

struct ArchivedVec<T>();

#[inline]

impl<T: Archive> Deserialize<T> for ArchivedVec {
    fn deserialize(s: _) {}
}
original code

original:

trait Archive {
    type Archived;
}

trait Deserialize<T> {
    fn deserialize(&self);
}

trait ArchivePointee {
    type ArchivedMetadata;
}

struct RelPtr<T: ArchivePointee + ?Sized> {
    metadata: T::ArchivedMetadata,
}

struct ArchivedVec<T>(RelPtr<[T]>);

#[inline]
fn as_slice<T>(v: &RelPtr<[usize; T::DIM]>) {
    unsafe {
        // CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 0, i32 0)
        prefetch_write_instruction(data.as_ptr(), 0);
        // CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 1, i32 0)
        prefetch_write_instruction(data.as_ptr(), 1);
        // CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 2, i32 0)
        prefetch_write_instruction(data.as_ptr(), 2);
        // CHECK: call void @llvm.prefetch{{.*}}({{.*}}, i32 1, i32 3, i32 0)
        prefetch_write_instruction(data.as_ptr(), 3);
    } _a: <[T] as ArchivePointee>::ArchivedMetadata = v.metadata;
}

impl<T: Archive> Deserialize<T> for ArchivedVec<T::Archived>
where
    [T::Archived]: ArchivePointee,
{
    fn deserialize( s: _) {
        as_slice(x, |y| f(y));
    }
}

impl<Key> ArchivePointee for [T] {
    type ArchivedMetadata = u32;
}

Version information

rustc 1.77.0-nightly (3a6bf351a 2024-01-11)
binary: rustc
commit-hash: 3a6bf351a39b35a662022c151621b932b4ae0bc8
commit-date: 2024-01-11
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2

Program output

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.4Z3vnrH2aVhg/rustc_testrunner_tmpdir_reporting.modI4Lk2Ou1P/mvce.rs:13:2
   |
13 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.4Z3vnrH2aVhg/rustc_testrunner_tmpdir_reporting.modI4Lk2Ou1P/mvce.rs`

error[E0518]: attribute should be applied to function or closure
  --> /tmp/icemaker_global_tempdir.4Z3vnrH2aVhg/rustc_testrunner_tmpdir_reporting.modI4Lk2Ou1P/mvce.rs:9:1
   |
9  |   #[inline]
   |   ^^^^^^^^^
10 |
11 | / impl<T: Archive> Deserialize<T> for ArchivedVec {
12 | |     fn deserialize(s: _) {}
13 | | }
   | |_- not a function or closure

error[E0107]: missing generics for struct `ArchivedVec`
  --> /tmp/icemaker_global_tempdir.4Z3vnrH2aVhg/rustc_testrunner_tmpdir_reporting.modI4Lk2Ou1P/mvce.rs:11:37
   |
11 | impl<T: Archive> Deserialize<T> for ArchivedVec {
   |                                     ^^^^^^^^^^^ expected 1 generic argument
   |
note: struct defined here, with 1 generic parameter: `T`
  --> /tmp/icemaker_global_tempdir.4Z3vnrH2aVhg/rustc_testrunner_tmpdir_reporting.modI4Lk2Ou1P/mvce.rs:7:8
   |
7  | struct ArchivedVec<T>();
   |        ^^^^^^^^^^^ -
help: add missing generic argument
   |
11 | impl<T: Archive> Deserialize<T> for ArchivedVec<T> {
   |                                                +++

error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
  --> /tmp/icemaker_global_tempdir.4Z3vnrH2aVhg/rustc_testrunner_tmpdir_reporting.modI4Lk2Ou1P/mvce.rs:12:23
   |
12 |     fn deserialize(s: _) {}
   |                       ^ not allowed in type signatures
   |
help: try replacing `_` with the type in the corresponding trait method signature
   |
12 |     fn deserialize(s: &ArchivedVec<{type error}>) {}
   |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~

error: internal compiler error: compiler/rustc_hir_analysis/src/variance/constraints.rs:434:17: unexpected region encountered in variance inference: ReLateParam(DefId(0:12 ~ mvce[1238]::{impl#0}::deserialize), BrNamed(DefId(0:13 ~ mvce[1238]::Deserialize::deserialize::'_), '_))

thread 'rustc' panicked at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/compiler/rustc_errors/src/lib.rs:935:30:
Box<dyn Any>
stack backtrace:
   0:     0x7f5c2305f7e6 - std::backtrace_rs::backtrace::libunwind::trace::h9689a5b68e9c4345
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f5c2305f7e6 - std::backtrace_rs::backtrace::trace_unsynchronized::h006e31c1f4897e0b
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f5c2305f7e6 - std::sys_common::backtrace::_print_fmt::he6c321772602beda
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f5c2305f7e6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2087d3f3218b8652
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f5c230b1ec0 - core::fmt::rt::Argument::fmt::ha70d28e66610dee4
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/core/src/fmt/rt.rs:142:9
   5:     0x7f5c230b1ec0 - core::fmt::write::h4eaa518815055ff7
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f5c2305314f - std::io::Write::write_fmt::he668edc91169e99a
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/std/src/io/mod.rs:1810:15
   7:     0x7f5c2305f5c4 - std::sys_common::backtrace::_print::h3d27aab23d848cd0
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f5c2305f5c4 - std::sys_common::backtrace::print::hce0d767cb56228ea
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f5c23062357 - std::panicking::default_hook::{{closure}}::hf20f443c51a9b00d
  10:     0x7f5c230620b9 - std::panicking::default_hook::hbe0120c8f36861fc
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/std/src/panicking.rs:292:9
  11:     0x7f5c1fd5f1cc - std[c18c707f701c262]::panicking::update_hook::<alloc[9976f368541258cf]::boxed::Box<rustc_driver_impl[3e420d1aa25f93fd]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f5c23062aa6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4afd436f332a62ec
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/alloc/src/boxed.rs:2030:9
  13:     0x7f5c23062aa6 - std::panicking::rust_panic_with_hook::h1ff237de70ac5559
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/std/src/panicking.rs:785:13
  14:     0x7f5c1fd91664 - std[c18c707f701c262]::panicking::begin_panic::<rustc_errors[92248014b4f514df]::ExplicitBug>::{closure#0}
  15:     0x7f5c1fd8dc26 - std[c18c707f701c262]::sys_common::backtrace::__rust_end_short_backtrace::<std[c18c707f701c262]::panicking::begin_panic<rustc_errors[92248014b4f514df]::ExplicitBug>::{closure#0}, !>
  16:     0x7f5c1fd88cf6 - std[c18c707f701c262]::panicking::begin_panic::<rustc_errors[92248014b4f514df]::ExplicitBug>
  17:     0x7f5c1fd9c591 - <rustc_errors[92248014b4f514df]::diagnostic_builder::BugAbort as rustc_errors[92248014b4f514df]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f5c20165ade - <rustc_errors[92248014b4f514df]::DiagCtxt>::bug::<alloc[9976f368541258cf]::string::String>
  19:     0x7f5c201fe46b - rustc_middle[93dc66790a885dd9]::util::bug::opt_span_bug_fmt::<rustc_span[91821f31c8c8c042]::span_encoding::Span>::{closure#0}
  20:     0x7f5c201e69aa - rustc_middle[93dc66790a885dd9]::ty::context::tls::with_opt::<rustc_middle[93dc66790a885dd9]::util::bug::opt_span_bug_fmt<rustc_span[91821f31c8c8c042]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f5c201e6848 - rustc_middle[93dc66790a885dd9]::ty::context::tls::with_context_opt::<rustc_middle[93dc66790a885dd9]::ty::context::tls::with_opt<rustc_middle[93dc66790a885dd9]::util::bug::opt_span_bug_fmt<rustc_span[91821f31c8c8c042]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f5c1e190bd0 - rustc_middle[93dc66790a885dd9]::util::bug::bug_fmt
  23:     0x7f5c214d4f19 - <rustc_hir_analysis[bda823070f40d417]::variance::constraints::ConstraintContext>::add_constraints_from_ty
  24:     0x7f5c214d3cc3 - <rustc_hir_analysis[bda823070f40d417]::variance::constraints::ConstraintContext>::build_constraints_for_item
  25:     0x7f5c1e405c96 - rustc_hir_analysis[bda823070f40d417]::variance::crate_variances
  26:     0x7f5c21cc86e0 - rustc_query_impl[359904eed6d656af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[359904eed6d656af]::query_impl::crate_variances::dynamic_query::{closure#2}::{closure#0}, rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 8usize]>>
  27:     0x7f5c21cd4b22 - rustc_query_system[1ff1e1688f065fb]::query::plumbing::try_execute_query::<rustc_query_impl[359904eed6d656af]::DynamicConfig<rustc_query_system[1ff1e1688f065fb]::query::caches::SingleCache<rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[359904eed6d656af]::plumbing::QueryCtxt, true>
  28:     0x7f5c220ce60b - rustc_query_impl[359904eed6d656af]::query_impl::crate_variances::get_query_incr::__rust_end_short_backtrace
  29:     0x7f5c214d2818 - rustc_hir_analysis[bda823070f40d417]::variance::variances_of
  30:     0x7f5c214d239a - rustc_query_impl[359904eed6d656af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[359904eed6d656af]::query_impl::variances_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 16usize]>>
  31:     0x7f5c21576c74 - rustc_query_system[1ff1e1688f065fb]::query::plumbing::try_execute_query::<rustc_query_impl[359904eed6d656af]::DynamicConfig<rustc_query_system[1ff1e1688f065fb]::query::caches::DefaultCache<rustc_span[91821f31c8c8c042]::def_id::DefId, rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[359904eed6d656af]::plumbing::QueryCtxt, true>
  32:     0x7f5c2157520c - rustc_query_impl[359904eed6d656af]::query_impl::variances_of::get_query_incr::__rust_end_short_backtrace
  33:     0x7f5c21955a06 - rustc_middle[93dc66790a885dd9]::query::plumbing::query_get_at::<rustc_query_system[1ff1e1688f065fb]::query::caches::DefaultCache<rustc_span[91821f31c8c8c042]::def_id::DefId, rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 16usize]>>>
  34:     0x7f5c21c28bb9 - rustc_hir_analysis[bda823070f40d417]::check::wfcheck::check_variances_for_type_defn
  35:     0x7f5c2172295e - rustc_hir_analysis[bda823070f40d417]::check::wfcheck::check_well_formed
  36:     0x7f5c217215f3 - rustc_query_impl[359904eed6d656af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[359904eed6d656af]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7f5c21492bce - rustc_query_system[1ff1e1688f065fb]::query::plumbing::try_execute_query::<rustc_query_impl[359904eed6d656af]::DynamicConfig<rustc_query_system[1ff1e1688f065fb]::query::caches::VecCache<rustc_hir[56b7f2694a32a58e]::hir_id::OwnerId, rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[359904eed6d656af]::plumbing::QueryCtxt, true>
  38:     0x7f5c214926cf - rustc_query_impl[359904eed6d656af]::query_impl::check_well_formed::get_query_incr::__rust_end_short_backtrace
  39:     0x7f5c2171e3f7 - rustc_hir_analysis[bda823070f40d417]::check::wfcheck::check_mod_type_wf
  40:     0x7f5c2171e33b - rustc_query_impl[359904eed6d656af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[359904eed6d656af]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 1usize]>>
  41:     0x7f5c2171c687 - rustc_query_system[1ff1e1688f065fb]::query::plumbing::try_execute_query::<rustc_query_impl[359904eed6d656af]::DynamicConfig<rustc_query_system[1ff1e1688f065fb]::query::caches::DefaultCache<rustc_span[91821f31c8c8c042]::def_id::LocalModDefId, rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[359904eed6d656af]::plumbing::QueryCtxt, true>
  42:     0x7f5c21ccc408 - rustc_query_impl[359904eed6d656af]::query_impl::check_mod_type_wf::get_query_incr::__rust_end_short_backtrace
  43:     0x7f5c214f69da - <rustc_middle[93dc66790a885dd9]::hir::map::Map>::try_par_for_each_module::<rustc_hir_analysis[bda823070f40d417]::check_crate::{closure#4}::{closure#0}>::{closure#0}
  44:     0x7f5c214f7210 - rustc_hir_analysis[bda823070f40d417]::check_crate
  45:     0x7f5c21978699 - rustc_interface[58d1074f9ef2e73f]::passes::analysis
  46:     0x7f5c219782df - rustc_query_impl[359904eed6d656af]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[359904eed6d656af]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 1usize]>>
  47:     0x7f5c21fc24cb - rustc_query_system[1ff1e1688f065fb]::query::plumbing::try_execute_query::<rustc_query_impl[359904eed6d656af]::DynamicConfig<rustc_query_system[1ff1e1688f065fb]::query::caches::SingleCache<rustc_middle[93dc66790a885dd9]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[359904eed6d656af]::plumbing::QueryCtxt, true>
  48:     0x7f5c21fc2160 - rustc_query_impl[359904eed6d656af]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  49:     0x7f5c21d48788 - rustc_interface[58d1074f9ef2e73f]::interface::run_compiler::<core[acf8665615a4934c]::result::Result<(), rustc_span[91821f31c8c8c042]::ErrorGuaranteed>, rustc_driver_impl[3e420d1aa25f93fd]::run_compiler::{closure#0}>::{closure#0}
  50:     0x7f5c21feadc6 - std[c18c707f701c262]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[58d1074f9ef2e73f]::util::run_in_thread_with_globals<rustc_interface[58d1074f9ef2e73f]::util::run_in_thread_pool_with_globals<rustc_interface[58d1074f9ef2e73f]::interface::run_compiler<core[acf8665615a4934c]::result::Result<(), rustc_span[91821f31c8c8c042]::ErrorGuaranteed>, rustc_driver_impl[3e420d1aa25f93fd]::run_compiler::{closure#0}>::{closure#0}, core[acf8665615a4934c]::result::Result<(), rustc_span[91821f31c8c8c042]::ErrorGuaranteed>>::{closure#0}, core[acf8665615a4934c]::result::Result<(), rustc_span[91821f31c8c8c042]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[acf8665615a4934c]::result::Result<(), rustc_span[91821f31c8c8c042]::ErrorGuaranteed>>
  51:     0x7f5c21feabf3 - <<std[c18c707f701c262]::thread::Builder>::spawn_unchecked_<rustc_interface[58d1074f9ef2e73f]::util::run_in_thread_with_globals<rustc_interface[58d1074f9ef2e73f]::util::run_in_thread_pool_with_globals<rustc_interface[58d1074f9ef2e73f]::interface::run_compiler<core[acf8665615a4934c]::result::Result<(), rustc_span[91821f31c8c8c042]::ErrorGuaranteed>, rustc_driver_impl[3e420d1aa25f93fd]::run_compiler::{closure#0}>::{closure#0}, core[acf8665615a4934c]::result::Result<(), rustc_span[91821f31c8c8c042]::ErrorGuaranteed>>::{closure#0}, core[acf8665615a4934c]::result::Result<(), rustc_span[91821f31c8c8c042]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[acf8665615a4934c]::result::Result<(), rustc_span[91821f31c8c8c042]::ErrorGuaranteed>>::{closure#1} as core[acf8665615a4934c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  52:     0x7f5c2306c9d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcc5bce6395d1fd7d
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/alloc/src/boxed.rs:2016:9
  53:     0x7f5c2306c9d5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8dc8fe0641e39937
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/alloc/src/boxed.rs:2016:9
  54:     0x7f5c2306c9d5 - std::sys::unix::thread::Thread::new::thread_start::he09d15ae9674e03c
                               at /rustc/3a6bf351a39b35a662022c151621b932b4ae0bc8/library/std/src/sys/unix/thread.rs:108:17
  55:     0x7f5c1ceaa9eb - <unknown>
  56:     0x7f5c1cf2e7cc - <unknown>
  57:                0x0 - <unknown>

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.77.0-nightly (3a6bf351a 2024-01-11) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2

query stack during panic:
#0 [crate_variances] computing the variances for items in this crate
#1 [variances_of] computing the variances of `ArchivedVec`
#2 [check_well_formed] checking that `ArchivedVec` is well-formed
#3 [check_mod_type_wf] checking that types are well-formed in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors

Some errors have detailed explanations: E0107, E0121, E0518, E0601.
For more information about an error, try `rustc --explain E0107`.

Activity

  1. added
    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.
    C-bugCategory: This is a bug.
    on Jan 11, 2024
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 11, 2024
  3. matthiaskrgr commented on Jan 11, 2024

    @matthiaskrgr
    MemberAuthor
  4. removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 11, 2024
  5. self-assigned this
    on Jan 11, 2024
  6. oli-obk commented on Jan 12, 2024

    @oli-obk
    Contributor

    Minimized:

    trait Deserialize {
        fn deserialize(&self);
    }
    
    struct ArchivedVec<T>();
    
    impl<T> Deserialize for ArchivedVec<T> {
        fn deserialize(s: _) {}
    }
    
    fn main() {}
  7. added 2 commits that reference this issue on Jan 13, 2024
    dd58f00
    9696ef7
  8. added a commit that references this issue on Jan 13, 2024
    a5f91df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

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.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions