I hit this problem while trying to make a task joining function. The problem occured when I started messing around with Arc
The nightly compiler crashes on this too.
Problematic code:
Clone the smtpbis repo on the rustice branch.
https://github.com/zerospam/smtpbis.git
https://github.com/zerospam/smtpbis/commits/rustice
https://github.com/zerospam/smtpbis/commit/607ec56a08b7bd934464f2df077e63cb522bc314
rustc --version --verbose:
rustc 1.39.0 (4560ea788 2019-11-04)
binary: rustc
commit-hash: 4560ea788cb760f0a34127156c78e2552949f734
commit-date: 2019-11-04
host: x86_64-unknown-linux-gnu
release: 1.39.0
LLVM version: 9.0
Backtrace:
RUST_BACKTRACE=1 cargo build --release
Compiling smtpbis v0.1.4 (/home/joe/smtpbis)
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:378:21
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:76
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:60
4: core::fmt::write
at src/libcore/fmt/mod.rs:1030
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1412
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:64
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:196
9: std::panicking::default_hook
at src/libstd/panicking.rs:210
10: rustc_driver::report_ice
11: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:477
12: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:380
13: rust_begin_unwind
at src/libstd/panicking.rs:307
14: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
15: core::panicking::panic
at src/libcore/panicking.rs:49
16: rustc_typeck::check::typeck_tables_of
17: rustc::ty::query::__query_compute::typeck_tables_of
18: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
19: rustc::dep_graph::graph::DepGraph::with_task_impl
20: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
21: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
22: rustc::dep_graph::graph::DepGraph::with_task_impl
23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
24: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt>::note_obligation_cause
25: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt>::report_selection_error
26: rustc::traits::error_reporting::<impl rustc::infer::InferCtxt>::report_fulfillment_errors
27: rustc_typeck::check::FnCtxt::check_argument_types
28: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::confirm_builtin_call
29: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
30: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
31: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
32: rustc_typeck::check::FnCtxt::check_decl_initializer
33: rustc_typeck::check::FnCtxt::check_decl_local
34: rustc_typeck::check::FnCtxt::check_stmt
35: rustc_typeck::check::FnCtxt::check_block_with_expected
36: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
37: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
38: rustc_typeck::check::FnCtxt::check_block_with_expected
39: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
40: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
41: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
42: rustc_typeck::check::check_fn
43: rustc_typeck::check::closure::<impl rustc_typeck::check::FnCtxt>::check_expr_closure
44: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
45: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
46: rustc_typeck::check::FnCtxt::check_argument_types
47: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::confirm_builtin_call
48: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call
49: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
50: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
51: rustc_typeck::check::FnCtxt::check_argument_types
52: rustc_typeck::check::FnCtxt::check_method_argument_types
53: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
54: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
55: rustc_typeck::check::FnCtxt::check_block_with_expected
56: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
57: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs
58: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
59: rustc_typeck::check::check_fn
60: rustc::ty::context::GlobalCtxt::enter_local
61: rustc_typeck::check::typeck_tables_of
62: rustc::ty::query::__query_compute::typeck_tables_of
63: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
64: rustc::dep_graph::graph::DepGraph::with_task_impl
65: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
66: rustc::ty::query::__query_compute::typeck_tables_of
67: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
68: rustc::dep_graph::graph::DepGraph::with_task_impl
69: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
70: rustc_typeck::collect::checked_type_of
71: rustc_typeck::collect::type_of
72: rustc::ty::query::__query_compute::type_of
73: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::compute
74: rustc::dep_graph::graph::DepGraph::with_task_impl
75: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
76: rustc::hir::intravisit::walk_expr
77: rustc::hir::intravisit::walk_expr
78: rustc::hir::intravisit::Visitor::visit_fn
79: rustc::hir::intravisit::walk_item
80: <rustc_typeck::collect::CollectItemTypesVisitor as rustc::hir::intravisit::Visitor>::visit_item
81: rustc::hir::map::Map::visit_item_likes_in_module
82: rustc_typeck::collect::collect_mod_item_types
83: rustc::ty::query::__query_compute::collect_mod_item_types
84: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute
85: rustc::dep_graph::graph::DepGraph::with_task_impl
86: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
87: rustc_typeck::check_crate::{{closure}}::{{closure}}
88: rustc::util::common::time
89: rustc_typeck::check_crate
90: rustc_interface::passes::analysis
91: rustc::ty::query::__query_compute::analysis
92: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
93: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
94: rustc_interface::passes::create_global_ctxt::{{closure}}
95: rustc_interface::interface::run_compiler_in_existing_thread_pool
96: std::thread::local::LocalKey<T>::with
97: scoped_tls::ScopedKey<T>::set
98: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.39.0 (4560ea788 2019-11-04) running on x86_64-unknown-linux-gnu
note: compiler flags: -C opt-level=3 --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [typeck_tables_of] processing `smtpbis::taskjoin::join_tasks`
#1 [typeck_tables_of] processing `smtpbis::taskjoin::join_tasks::{{closure}}#0`
#2 [typeck_tables_of] processing `main`
#3 [typeck_tables_of] processing `main::{{closure}}#0`
#4 [type_of] processing `main::{{closure}}#0`
#5 [collect_mod_item_types] collecting item types in top-level module
#6 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `smtpbis`.
To learn more, run the command again with --verbose.
Cargo.lock for exact reproduction:
Cargo.lock.txt
Does this reproduce on nightly?
@Centril yes, I get the error using rustc 1.41.0-nightly (bbb664a99 2019-11-28)
This line seems to be the culprit. It only exhibits when going over crate bound (at least I couldn't minify it further).
lib.rs:
use std::{
future::Future,
pin::Pin,
sync::RwLock,
task::{Context, Poll},
};
struct S {}
impl Future for S {
type Output = ();
fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<Self::Output> {
Poll::Pending
}
}
pub async fn f() {
let fo = RwLock::new(S {});
(&mut *fo.write().unwrap()).await;
}
main.rs in the binaries folder:
pub fn g<T>(task: T)
where
T: Send,
{
}
fn main() {
g(foo::f());
}
cc @davidtwco @nikomatsakis
triage: P-high, at least to identify whether this is a long-standing bug or a stable-to-stable regression. Removing nomination.
This won't build on 1.30:
~/workspace/proc-macro-workshop (proc-macro-workshop:HEAD 0)$ RUSTC_BOOTSTRAP=1 RUST_BACKTRACE=1 cargo +1.30.0 build
Compiling proc-macro2 v1.0.6
Compiling syn v1.0.11
Compiling bitfield-impl v0.0.0 (/Users/ekuber/workspace/proc-macro-workshop/bitfield/impl)
Compiling sorted v0.0.0 (/Users/ekuber/workspace/proc-macro-workshop/sorted)
error[E0432]: unresolved import `proc_macro`
error[E0432]: unresolved import `proc_macro`
--> bitfield/impl/src/lib.rs:3:5
|
3 | use proc_macro::TokenStream;
| ^^^^^^^^^^ Did you mean `self::proc_macro`?
--> sorted/src/lib.rs:3:5
|
3 | use proc_macro::TokenStream;
| ^^^^^^^^^^ Did you mean `self::proc_macro`?
error: aborting due to previous error
error: aborting due to previous error
For more information about this error, try `rustc --explain E0432`.
For more information about this error, try `rustc --explain E0432`.
error: Could not compile `sorted`.
warning: build failed, waiting for other jobs to finish...
error: Could not compile `bitfield-impl`.
warning: build failed, waiting for other jobs to finish...
error: build failed
Removing I-ICE and P-high as the bug's been fixed in #67071, but leaving open to add a regression test.
@JohnTitor I'm confused. Did you add a testcase for this or not?
@hellow554 As discussed in #67543, we didn't add the test case there due to diffs of diagnostics on some environment.
Most helpful comment
This line seems to be the culprit. It only exhibits when going over crate bound (at least I couldn't minify it further).
lib.rs:
main.rs in the binaries folder: