Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Failed to normalize <std::borrow::Cow<str> as rkyv::Archive>::Resolver #94651

Open
carloabelli opened this issue Mar 5, 2022 · 1 comment
Open
Assignees
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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.

Comments

@carloabelli
Copy link

Code

[package]
name = "minimal"
version = "0.1.0"
edition = "2021"

[dependencies]
rkyv = "0.7"
use rkyv::Archive;
use std::borrow::Cow;

#[derive(Archive)]
pub struct Wrapper<'a>(Cow<'a, str>);

Meta

rustc --version --verbose:

rustc 1.59.0 (9d1b2106e 2022-02-23)
binary: rustc
commit-hash: 9d1b2106e23b1abd32fce1f17267604a5102f57a
commit-date: 2022-02-23
host: x86_64-unknown-linux-gnu
release: 1.59.0
LLVM version: 13.0.0

Error output

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:179:90: Failed to normalize <std::borrow::Cow<str> as rkyv::Archive>::Resolver, maybe try to call `try_normalize_erasing_regions` instead
Backtrace

error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:179:90: Failed to normalize <std::borrow::Cow<str> as rkyv::Archive>::Resolver, maybe try to call `try_normalize_erasing_regions` instead

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1169:9
stack backtrace:
   0:     0x623f31a96b9c - std::backtrace_rs::backtrace::libunwind::trace::h91c465e73bf6c785
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x623f31a96b9c - std::backtrace_rs::backtrace::trace_unsynchronized::hae9da36f5d58b5f3
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x623f31a96b9c - std::sys_common::backtrace::_print_fmt::h7f499fa126a7effb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x623f31a96b9c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3e2b509ce2ce6007
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x623f31af7a2c - core::fmt::write::h753c7571fa063ecb
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/fmt/mod.rs:1168:17
   5:     0x623f31a85ea3 - std::io::Write::write_fmt::h2815c0519c99ba09
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/io/mod.rs:1660:15
   6:     0x623f31a9aca2 - std::sys_common::backtrace::_print::h64941a6fc8b0ed9b
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x623f31a9aca2 - std::sys_common::backtrace::print::hcf25e43e1a9b0766
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x623f31a9aca2 - std::panicking::default_hook::{{closure}}::h78d3e6cf97fc623d
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:211:50
   9:     0x623f31a9a885 - std::panicking::default_hook::hda898f8d3ad1a5ae
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:228:9
  10:     0x623f3231a761 - rustc_driver[68791c760b496cb9]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x623f235f0a53 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h22d6801061b803af
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/boxed.rs:1868:9
  12:     0x623f235ee89d - proc_macro::bridge::client::<impl proc_macro::bridge::Bridge>::enter::{{closure}}::{{closure}}::h7644afeedd980844
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/proc_macro/src/bridge/client.rs:320:21
  13:     0x623f31a9b455 - std::panicking::rust_panic_with_hook::h1a5ea2d6c23051aa
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:610:17
  14:     0x623f3354319b - std[c2a6a440a415d498]::panicking::begin_panic::<rustc_errors[a7f9c61e2940d55a]::ExplicitBug>::{closure#0}
  15:     0x623f33543116 - std[c2a6a440a415d498]::sys_common::backtrace::__rust_end_short_backtrace::<std[c2a6a440a415d498]::panicking::begin_panic<rustc_errors[a7f9c61e2940d55a]::ExplicitBug>::{closure#0}, !>
  16:     0x623f33546f7f - std[c2a6a440a415d498]::panicking::begin_panic::<rustc_errors[a7f9c61e2940d55a]::ExplicitBug>
  17:     0x623f33551d0d - std[c2a6a440a415d498]::panic::panic_any::<rustc_errors[a7f9c61e2940d55a]::ExplicitBug>
  18:     0x623f33550f97 - <rustc_errors[a7f9c61e2940d55a]::HandlerInner>::bug
  19:     0x623f335509a0 - <rustc_errors[a7f9c61e2940d55a]::Handler>::bug
  20:     0x623f333d0579 - rustc_middle[918e6c9f11b9cfc2]::ty::context::tls::with_opt::<rustc_middle[918e6c9f11b9cfc2]::util::bug::opt_span_bug_fmt<rustc_span[eb9d2b35b06e162f]::span_encoding::Span>::{closure#0}, ()>
  21:     0x623f333d09e0 - rustc_middle[918e6c9f11b9cfc2]::util::bug::opt_span_bug_fmt::<rustc_span[eb9d2b35b06e162f]::span_encoding::Span>
  22:     0x623f333d0956 - rustc_middle[918e6c9f11b9cfc2]::util::bug::bug_fmt
  23:     0x623f340fcde6 - <rustc_middle[918e6c9f11b9cfc2]::ty::normalize_erasing_regions::NormalizeAfterErasingRegionsFolder as rustc_middle[918e6c9f11b9cfc2]::ty::fold::TypeFolder>::fold_ty
  24:     0x623f3376d4b6 - <core[4b8c045e35bf0313]::iter::adapters::map::Map<core[4b8c045e35bf0313]::iter::adapters::enumerate::Enumerate<core[4b8c045e35bf0313]::slice::iter::Iter<rustc_middle[918e6c9f11b9cfc2]::ty::FieldDef>>, <rustc_mir_dataflow[4254a4158613446]::elaborate_drops::DropCtxt<rustc_mir_transform[6b60019107120a72]::elaborate_drops::Elaborator>>::move_paths_for_fields::{closure#0}> as core[4b8c045e35bf0313]::iter::traits::iterator::Iterator>::fold::<(), core[4b8c045e35bf0313]::iter::traits::iterator::Iterator::for_each::call<(rustc_middle[918e6c9f11b9cfc2]::mir::Place, core[4b8c045e35bf0313]::option::Option<rustc_mir_dataflow[4254a4158613446]::move_paths::MovePathIndex>), <alloc[4d2bf5a5aefb7035]::vec::Vec<(rustc_middle[918e6c9f11b9cfc2]::mir::Place, core[4b8c045e35bf0313]::option::Option<rustc_mir_dataflow[4254a4158613446]::move_paths::MovePathIndex>)> as alloc[4d2bf5a5aefb7035]::vec::spec_extend::SpecExtend<(rustc_middle[918e6c9f11b9cfc2]::mir::Place, core[4b8c045e35bf0313]::option::Option<rustc_mir_dataflow[4254a4158613446]::move_paths::MovePathIndex>), core[4b8c045e35bf0313]::iter::adapters::map::Map<core[4b8c045e35bf0313]::iter::adapters::enumerate::Enumerate<core[4b8c045e35bf0313]::slice::iter::Iter<rustc_middle[918e6c9f11b9cfc2]::ty::FieldDef>>, <rustc_mir_dataflow[4254a4158613446]::elaborate_drops::DropCtxt<rustc_mir_transform[6b60019107120a72]::elaborate_drops::Elaborator>>::move_paths_for_fields::{closure#0}>>>::spec_extend::{closure#0}>::{closure#0}>
  25:     0x623f3377b8ff - <rustc_mir_dataflow[4254a4158613446]::elaborate_drops::DropCtxt<rustc_mir_transform[6b60019107120a72]::elaborate_drops::Elaborator>>::elaborate_drop
  26:     0x623f33755678 - <rustc_mir_transform[6b60019107120a72]::elaborate_drops::ElaborateDrops as rustc_middle[918e6c9f11b9cfc2]::mir::MirPass>::run_pass
  27:     0x623f337a47ff - rustc_mir_transform[6b60019107120a72]::pass_manager::run_passes
  28:     0x623f33788cd7 - rustc_mir_transform[6b60019107120a72]::run_post_borrowck_cleanup_passes
  29:     0x623f33787de9 - rustc_mir_transform[6b60019107120a72]::mir_drops_elaborated_and_const_checked
  30:     0x623f33c86d4c - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::<rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt, rustc_query_system[f23fa726dd903306]::query::caches::DefaultCache<rustc_middle[918e6c9f11b9cfc2]::ty::WithOptConstParam<rustc_span[eb9d2b35b06e162f]::def_id::LocalDefId>, &rustc_data_structures[496dc1ea3fa24648]::steal::Steal<rustc_middle[918e6c9f11b9cfc2]::mir::Body>>>
  31:     0x623f33cec007 - <rustc_query_impl[7556885dd75c8dd5]::Queries as rustc_middle[918e6c9f11b9cfc2]::ty::query::QueryEngine>::mir_drops_elaborated_and_const_checked
  32:     0x623f34336fe0 - rustc_mir_transform[6b60019107120a72]::optimized_mir
  33:     0x623f33c9e477 - rustc_query_system[f23fa726dd903306]::query::plumbing::try_execute_query::<rustc_query_impl[7556885dd75c8dd5]::plumbing::QueryCtxt, rustc_query_system[f23fa726dd903306]::query::caches::DefaultCache<rustc_span[eb9d2b35b06e162f]::def_id::DefId, &rustc_middle[918e6c9f11b9cfc2]::mir::Body>>
  34:     0x623f33cec2d3 - <rustc_query_impl[7556885dd75c8dd5]::Queries as rustc_middle[918e6c9f11b9cfc2]::ty::query::QueryEngine>::optimized_mir
  35:     0x623f33d2f167 - <rustc_metadata[e45939a80f641886]::rmeta::encoder::EncodeContext>::encode_crate_root
  36:     0x623f346f0891 - rustc_metadata[e45939a80f641886]::rmeta::encoder::encode_metadata_impl
  37:     0x623f34706051 - rustc_data_structures[496dc1ea3fa24648]::sync::join::<rustc_metadata[e45939a80f641886]::rmeta::encoder::encode_metadata::{closure#0}, rustc_metadata[e45939a80f641886]::rmeta::encoder::encode_metadata::{closure#1}, rustc_metadata[e45939a80f641886]::rmeta::encoder::EncodedMetadata, ()>
  38:     0x623f346f0076 - rustc_metadata[e45939a80f641886]::rmeta::encoder::encode_metadata
  39:     0x623f3418df19 - <rustc_interface[f4c999472ca453d]::queries::Queries>::ongoing_codegen
  40:     0x623f34168974 - <rustc_interface[f4c999472ca453d]::interface::Compiler>::enter::<rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}::{closure#2}, core[4b8c045e35bf0313]::result::Result<core[4b8c045e35bf0313]::option::Option<rustc_interface[f4c999472ca453d]::queries::Linker>, rustc_errors[a7f9c61e2940d55a]::ErrorReported>>
  41:     0x623f3414b97c - rustc_span[eb9d2b35b06e162f]::with_source_map::<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_interface[f4c999472ca453d]::interface::create_compiler_and_run<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>::{closure#1}>
  42:     0x623f34167cfe - rustc_interface[f4c999472ca453d]::interface::create_compiler_and_run::<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>
  43:     0x623f3414cedb - <scoped_tls[7dc407bead1f97c0]::ScopedKey<rustc_span[eb9d2b35b06e162f]::SessionGlobals>>::set::<rustc_interface[f4c999472ca453d]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[f4c999472ca453d]::interface::run_compiler<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>::{closure#0}::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>
  44:     0x623f3414ccd5 - std[c2a6a440a415d498]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[f4c999472ca453d]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[f4c999472ca453d]::interface::run_compiler<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>
  45:     0x623f34178499 - <<std[c2a6a440a415d498]::thread::Builder>::spawn_unchecked<rustc_interface[f4c999472ca453d]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[f4c999472ca453d]::interface::run_compiler<core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>, rustc_driver[68791c760b496cb9]::run_compiler::{closure#1}>::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>::{closure#0}, core[4b8c045e35bf0313]::result::Result<(), rustc_errors[a7f9c61e2940d55a]::ErrorReported>>::{closure#1} as core[4b8c045e35bf0313]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x623f31aa7073 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h49b6c7c5155a2296
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/boxed.rs:1854:9
  47:     0x623f31aa7073 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha8b5234bfeb15105
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/alloc/src/boxed.rs:1854:9
  48:     0x623f31aa7073 - std::sys::unix::thread::Thread::new::thread_start::h6f207dd842d64859
                               at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/sys/unix/thread.rs:108:17
  49:     0x623f318835c2 - start_thread
  50:     0x623f31908584 - __clone
  51:                0x0 - <unknown>

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.59.0 (9d1b2106e 2022-02-23) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [mir_drops_elaborated_and_const_checked] elaborating drops for `_::<impl at src/lib.rs:4:10: 4:17>::resolve`
#1 [optimized_mir] optimizing MIR for `_::<impl at src/lib.rs:4:10: 4:17>::resolve`
end of query stack
error: could not compile `minimal`

@carloabelli carloabelli 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 5, 2022
@compiler-errors
Copy link
Member

This is due to an (almost, but not currently detected) trivially falsifiable bound. Cow<'_, str> does not satisfy Archive for any lifetime, but we don't raise a type error because there's a where Cow<'a, str>: Archive in the macro expansion. We don't see that this is satisfied for no lifetimes until we erase the region during MIR lowering.

Then since the type is global once we remove the early-bound lifetime, I think we throw away the param-env (i.e. we call ParamEnv::without_caller_bounds), and this type fails to normalize since we no longer have the Cow<ReErased, str>: Archive in our param-env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example 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.
Projects
None yet
Development

No branches or pull requests

3 participants