-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Happens with rustc nightly from 21.6.19 in rust playground.
#![feature(async_await)]
use std::cell::RefCell;
use std::future::Future;
//use futures::future::FutureExt;
struct Connection {
a: RefCell<()>
}
impl Connection {
async fn execute<'a>(&'a mut self, _sql: &'a str) -> Result<(), ()> {
Ok(())
}
async fn transaction<'a, 'b, T, R, FT>(&'a mut self, f: T) -> Result<R, ()>
where T: FnOnce(&mut Connection) -> FT + 'static,
FT: Future<Output = Result<R, ()>> + 'b,
'b: 'a,
{
self.execute("BEGIN").await?;
match f(self).await {
Ok(res) => {
self.execute("COMMIT").await?;
Ok(res)
}
Err(err) => {
self.execute("ROLLBACK ").await?;
Err(err)
}
}
}
}
async fn foo(_conn: &mut Connection) -> Result<(), ()> {
Ok(())
}
async fn bar(_conn: &mut Connection) -> Result<(),()> {
Ok(())
}
async fn do_something(conn: &mut Connection) -> Result<(), ()> {
foo(conn).await?;
bar(conn).await?;
Ok(())
}
fn assert_send<F>(_f: F) where F: Future + Send {}
fn main() {
let res = async {
let mut conn = Connection {
a: RefCell::new(())
};
conn.transaction(async move |conn| {
//do_something(conn).await?;
//foo(conn).await?;
Ok(())
}).await
};
assert_send(res);
println!("Hello, world!");
}Backtrace:
thread 'rustc' panicked at 'assertion failed: target_offset >= offset', src/librustc_codegen_llvm/type_of.rs:130:9
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.29/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:47
3: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:36
4: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:198
5: std::panicking::default_hook
at src/libstd/panicking.rs:212
6: rustc::util::common::panic_hook
7: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:479
8: std::panicking::begin_panic
9: rustc_codegen_llvm::type_of::struct_llfields
10: <rustc_target::abi::TyLayout<&rustc::ty::TyS> as rustc_codegen_llvm::type_of::LayoutLlvmExt>::llvm_type
11: <rustc_target::abi::TyLayout<&rustc::ty::TyS> as rustc_codegen_llvm::type_of::LayoutLlvmExt>::llvm_type
12: <rustc_target::abi::call::FnType<&rustc::ty::TyS> as rustc_codegen_llvm::abi::FnTypeLlvmExt>::llvm_type
13: rustc_codegen_llvm::declare::<impl rustc_codegen_ssa::traits::declare::DeclareMethods for rustc_codegen_llvm::context::CodegenCx>::declare_fn
14: rustc_codegen_llvm::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_llvm::context::CodegenCx>::predefine_fn
15: <rustc::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::predefine
16: rustc_codegen_llvm::base::compile_codegen_unit::module_codegen
17: rustc::dep_graph::graph::DepGraph::with_task
18: rustc_codegen_llvm::base::compile_codegen_unit
19: rustc_codegen_ssa::base::codegen_crate
20: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
21: rustc::util::common::time
22: rustc_interface::passes::start_codegen
23: rustc::ty::context::tls::enter_global
24: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
25: rustc_interface::passes::create_global_ctxt::{{closure}}
26: rustc_interface::passes::BoxedGlobalCtxt::enter
27: rustc_interface::queries::Query<T>::compute
28: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::ongoing_codegen
29: rustc_interface::interface::run_compiler_in_existing_thread_pool
30: std::thread::local::LocalKey<T>::with
31: scoped_tls::ScopedKey<T>::set
32: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stack during panic:
end of query stack
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.