Closed
Description
Code
code from ./src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs
// check-pass
// edition:2018
type BoxFuture<T> = std::pin::Pin<Box<dyn std::future::Future<Output=T>>>;
fn main() {
f();
}
async fn f() {
run("dependency").await;
}
struct InMemoryStorage;
struct User<'dep> {
dep: &'dep str,
}
impl<'a> StorageRequest<InMemoryStorage> for SaveUser<'a> {
fn execute(&self) -> BoxFuture<Result<(), String>> {
todo!()
}
}
trait Storage {
type Error;
}
impl Storage for InMemoryStorage {
type Error = String;
}
trait StorageRequestReturnType {
type Output;
}
trait StorageRequest<S: Storage>: StorageRequestReturnType {
fn execute(
&self,
) -> BoxFuture<Result<<Self as StorageRequestReturnType>::Output, <S as Storage>::Error>>;
}
struct SaveUser<'a> {
name: &'a str,
}
impl<'a> StorageRequestReturnType for SaveUser<'a> {
type Output = ();
}
impl<'dep> User<'dep> {
async fn save<S>(self)
where
S: Storage,
for<'a> SaveUser<'a>: StorageRequest<S>,
{
SaveUser { name: "Joe" }
.execute()
.await;
}
}
async fn run<S>(dep: &str)
where
S: Storage,
for<'a> SaveUser<'a>: StorageRequest<S>,
{
User { dep }.save().await;
}
Meta
rustc --version --verbose
:
This crashes nightly, beta and stable
rustc 1.61.0-nightly (f103b2969 2022-03-12)
binary: rustc
commit-hash: f103b2969b0088953873dc1ac92eb3387c753596
commit-date: 2022-03-12
host: x86_64-unknown-linux-gnu
release: 1.61.0-nightly
LLVM version: 14.0.0
Error output
rustc ./src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs --edition=2018
warning: field is never read: `dep`
--> ./src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs:17:5
|
17 | dep: &'dep str,
| ^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: field is never read: `name`
--> ./src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs:45:5
|
45 | name: &'a str,
| ^^^^^^^^^^^^^
warning: unused implementer of `Future` that must be used
--> ./src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs:7:5
|
7 | f();
| ^^^^
|
= note: `#[warn(unused_must_use)]` on by default
= note: futures do nothing unless you `.await` or poll them
warning: unused `Result` that must be used
--> ./src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs:58:9
|
58 | / SaveUser { name: "Joe" }
59 | | .execute()
60 | | .await;
| |___________________^
|
= note: this `Result` may be an `Err` variant, which should be handled
error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:949:13: failed to get layout for `Result<<SaveUser as StorageRequestReturnType>::Output, String>`: the type `<SaveUser as StorageRequestReturnType>::Output` has an unknown layout
--> ./src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs:58:9
|
58 | / SaveUser { name: "Joe" }
59 | | .execute()
60 | | .await;
| |__________________^
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/f103b2969b0088953873dc1ac92eb3387c753596/compiler/rustc_errors/src/lib.rs:1180:9
Backtrace
error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:949:13: failed to get layout for `Result<<SaveUser as StorageRequestReturnType>::Output, String>`: the type `<SaveUser as StorageRequestReturnType>::Output` has an unknown layout
--> ./src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-80706.rs:58:9
|
58 | / SaveUser { name: "Joe" }
59 | | .execute()
60 | | .await;
| |__________________^
thread 'rustc' panicked at 'Box<dyn Any>', /rustc/f103b2969b0088953873dc1ac92eb3387c753596/compiler/rustc_errors/src/lib.rs:1180:9
stack backtrace:
0: 0x7f1ca2a9d9dd - std::backtrace_rs::backtrace::libunwind::trace::h7c06355936cefbfa
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7f1ca2a9d9dd - std::backtrace_rs::backtrace::trace_unsynchronized::h0d29350836df727e
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f1ca2a9d9dd - std::sys_common::backtrace::_print_fmt::h7cc76caea8ef80df
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/sys_common/backtrace.rs:66:5
3: 0x7f1ca2a9d9dd - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h41dad21719ef8ab8
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/sys_common/backtrace.rs:45:22
4: 0x7f1ca2af74bc - core::fmt::write::h6c4cfebe9aad777b
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/core/src/fmt/mod.rs:1190:17
5: 0x7f1ca2a8ef61 - std::io::Write::write_fmt::h01de082d65b0a1fb
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/io/mod.rs:1655:15
6: 0x7f1ca2aa0a55 - std::sys_common::backtrace::_print::hcd7176b4e129c3a4
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/sys_common/backtrace.rs:48:5
7: 0x7f1ca2aa0a55 - std::sys_common::backtrace::print::h710200ae52dbc495
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/sys_common/backtrace.rs:35:9
8: 0x7f1ca2aa0a55 - std::panicking::default_hook::{{closure}}::ha61678fe9bc854f8
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/panicking.rs:295:22
9: 0x7f1ca2aa0709 - std::panicking::default_hook::h583260a485b0ad61
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/panicking.rs:314:9
10: 0x7f1ca32c9481 - rustc_driver[3f779205835928cf]::DEFAULT_HOOK::{closure#0}::{closure#0}
11: 0x7f1ca2aa11a0 - std::panicking::rust_panic_with_hook::h1d1648214bd2ee6f
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/panicking.rs:702:17
12: 0x7f1ca33e6521 - std[e601d6bf1b4d13f5]::panicking::begin_panic::<rustc_errors[3e8a3ffb3213487a]::ExplicitBug>::{closure#0}
13: 0x7f1ca33e63e6 - std[e601d6bf1b4d13f5]::sys_common::backtrace::__rust_end_short_backtrace::<std[e601d6bf1b4d13f5]::panicking::begin_panic<rustc_errors[3e8a3ffb3213487a]::ExplicitBug>::{closure#0}, !>
14: 0x7f1ca33f56bf - std[e601d6bf1b4d13f5]::panicking::begin_panic::<rustc_errors[3e8a3ffb3213487a]::ExplicitBug>
15: 0x7f1ca341958d - std[e601d6bf1b4d13f5]::panic::panic_any::<rustc_errors[3e8a3ffb3213487a]::ExplicitBug>
16: 0x7f1ca3414b99 - <rustc_errors[3e8a3ffb3213487a]::HandlerInner>::span_bug::<rustc_span[90a733eefa3cc57d]::span_encoding::Span>
17: 0x7f1ca3414a80 - <rustc_errors[3e8a3ffb3213487a]::Handler>::span_bug::<rustc_span[90a733eefa3cc57d]::span_encoding::Span>
18: 0x7f1ca340bfe2 - rustc_middle[89dca5d1ec46bdf7]::ty::context::tls::with_opt::<rustc_middle[89dca5d1ec46bdf7]::util::bug::opt_span_bug_fmt<rustc_span[90a733eefa3cc57d]::span_encoding::Span>::{closure#0}, ()>
19: 0x7f1ca340bda6 - rustc_middle[89dca5d1ec46bdf7]::util::bug::opt_span_bug_fmt::<rustc_span[90a733eefa3cc57d]::span_encoding::Span>
20: 0x7f1ca340bd67 - rustc_middle[89dca5d1ec46bdf7]::util::bug::span_bug_fmt::<rustc_span[90a733eefa3cc57d]::span_encoding::Span>
21: 0x7f1ca33f1911 - <rustc_codegen_llvm[7683ad14eccadf02]::context::CodegenCx as rustc_middle[89dca5d1ec46bdf7]::ty::layout::LayoutOfHelpers>::handle_layout_err
22: 0x7f1ca33eea81 - <rustc_codegen_llvm[7683ad14eccadf02]::context::CodegenCx as rustc_middle[89dca5d1ec46bdf7]::ty::layout::LayoutOf>::spanned_layout_of::{closure#0}
23: 0x7f1ca4506b4d - <core[f6020851bfb369c]::iter::adapters::map::Map<core[f6020851bfb369c]::slice::iter::Iter<rustc_middle[89dca5d1ec46bdf7]::mir::LocalDecl>, rustc_codegen_ssa[7f80e99a1bc21553]::mir::analyze::non_ssa_locals<rustc_codegen_llvm[7683ad14eccadf02]::builder::Builder>::{closure#0}> as core[f6020851bfb369c]::iter::traits::iterator::Iterator>::fold::<(), core[f6020851bfb369c]::iter::traits::iterator::Iterator::for_each::call<rustc_codegen_ssa[7f80e99a1bc21553]::mir::analyze::LocalKind, <alloc[3231bf856793ad12]::vec::Vec<rustc_codegen_ssa[7f80e99a1bc21553]::mir::analyze::LocalKind> as alloc[3231bf856793ad12]::vec::spec_extend::SpecExtend<rustc_codegen_ssa[7f80e99a1bc21553]::mir::analyze::LocalKind, core[f6020851bfb369c]::iter::adapters::map::Map<core[f6020851bfb369c]::slice::iter::Iter<rustc_middle[89dca5d1ec46bdf7]::mir::LocalDecl>, rustc_codegen_ssa[7f80e99a1bc21553]::mir::analyze::non_ssa_locals<rustc_codegen_llvm[7683ad14eccadf02]::builder::Builder>::{closure#0}>>>::spec_extend::{closure#0}>::{closure#0}>
24: 0x7f1ca45582ec - rustc_codegen_ssa[7f80e99a1bc21553]::mir::analyze::non_ssa_locals::<rustc_codegen_llvm[7683ad14eccadf02]::builder::Builder>
25: 0x7f1ca4520903 - rustc_codegen_ssa[7f80e99a1bc21553]::mir::codegen_mir::<rustc_codegen_llvm[7683ad14eccadf02]::builder::Builder>
26: 0x7f1ca44e9c44 - rustc_codegen_llvm[7683ad14eccadf02]::base::compile_codegen_unit::module_codegen
27: 0x7f1ca51924c3 - <rustc_query_system[ba893fc069cb4510]::dep_graph::graph::DepGraph<rustc_middle[89dca5d1ec46bdf7]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[89dca5d1ec46bdf7]::ty::context::TyCtxt, rustc_span[90a733eefa3cc57d]::symbol::Symbol, rustc_codegen_ssa[7f80e99a1bc21553]::ModuleCodegen<rustc_codegen_llvm[7683ad14eccadf02]::ModuleLlvm>>
28: 0x7f1ca5183109 - rustc_codegen_llvm[7683ad14eccadf02]::base::compile_codegen_unit
29: 0x7f1ca51b4045 - <rustc_codegen_llvm[7683ad14eccadf02]::LlvmCodegenBackend as rustc_codegen_ssa[7f80e99a1bc21553]::traits::backend::CodegenBackend>::codegen_crate
30: 0x7f1ca515c527 - <rustc_session[4bd2d30755fd7d42]::session::Session>::time::<alloc[3231bf856793ad12]::boxed::Box<dyn core[f6020851bfb369c]::any::Any>, rustc_interface[99b5955ea177eda3]::passes::start_codegen::{closure#0}>
31: 0x7f1ca5149d28 - <rustc_interface[99b5955ea177eda3]::passes::QueryContext>::enter::<<rustc_interface[99b5955ea177eda3]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[f6020851bfb369c]::result::Result<alloc[3231bf856793ad12]::boxed::Box<dyn core[f6020851bfb369c]::any::Any>, rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>>
32: 0x7f1ca514260f - <rustc_interface[99b5955ea177eda3]::queries::Queries>::ongoing_codegen
33: 0x7f1ca510624b - <rustc_interface[99b5955ea177eda3]::interface::Compiler>::enter::<rustc_driver[3f779205835928cf]::run_compiler::{closure#1}::{closure#2}, core[f6020851bfb369c]::result::Result<core[f6020851bfb369c]::option::Option<rustc_interface[99b5955ea177eda3]::queries::Linker>, rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>>
34: 0x7f1ca511923f - rustc_span[90a733eefa3cc57d]::with_source_map::<core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>, rustc_interface[99b5955ea177eda3]::interface::create_compiler_and_run<core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>, rustc_driver[3f779205835928cf]::run_compiler::{closure#1}>::{closure#1}>
35: 0x7f1ca5118a44 - rustc_interface[99b5955ea177eda3]::interface::create_compiler_and_run::<core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>, rustc_driver[3f779205835928cf]::run_compiler::{closure#1}>
36: 0x7f1ca5103c42 - <scoped_tls[8d179c61f4b3d0c1]::ScopedKey<rustc_span[90a733eefa3cc57d]::SessionGlobals>>::set::<rustc_interface[99b5955ea177eda3]::interface::run_compiler<core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>, rustc_driver[3f779205835928cf]::run_compiler::{closure#1}>::{closure#0}, core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>>
37: 0x7f1ca510210f - std[e601d6bf1b4d13f5]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[99b5955ea177eda3]::util::run_in_thread_pool_with_globals<rustc_interface[99b5955ea177eda3]::interface::run_compiler<core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>, rustc_driver[3f779205835928cf]::run_compiler::{closure#1}>::{closure#0}, core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>>::{closure#0}, core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>>
38: 0x7f1ca511a1c2 - <<std[e601d6bf1b4d13f5]::thread::Builder>::spawn_unchecked_<rustc_interface[99b5955ea177eda3]::util::run_in_thread_pool_with_globals<rustc_interface[99b5955ea177eda3]::interface::run_compiler<core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>, rustc_driver[3f779205835928cf]::run_compiler::{closure#1}>::{closure#0}, core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>>::{closure#0}, core[f6020851bfb369c]::result::Result<(), rustc_errors[3e8a3ffb3213487a]::ErrorGuaranteed>>::{closure#1} as core[f6020851bfb369c]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
39: 0x7f1ca2aab333 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hab8e95631d63cb7b
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/alloc/src/boxed.rs:1853:9
40: 0x7f1ca2aab333 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4804fab16a5dbf8e
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/alloc/src/boxed.rs:1853:9
41: 0x7f1ca2aab333 - std::sys::unix::thread::Thread::new::thread_start::h9d17249987cabc4d
at /rustc/f103b2969b0088953873dc1ac92eb3387c753596/library/std/src/sys/unix/thread.rs:108:17
42: 0x7f1ca28835c2 - start_thread
43: 0x7f1ca2908584 - __clone
44: 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.61.0-nightly (f103b2969 2022-03-12) running on x86_64-unknown-linux-gnu
query stack during panic:
end of query stack
error: aborting due to previous error; 4 warnings emitted