Closed
Description
Code
use std::cell::Cell;
fn main() {
let xs: Cell<Option<()>> = Cell::new(None);
// ditto get_mut, et. al.
// NB. `if Some` rather than `if let Some`
if Some(xs) = xs.take() { }
}
Meta
Hi! 👋 First issue; sorry if anything is missing/off.
By the minimal example, it looks like the missing let
in the if let
seems to cause a syntax error, but the usual diagnostic isn't reported and an ICE occurs, instead.
This does not happen on stable, but I can reproduce on the following versions:
; rustc --version --verbose
rustc 1.48.0-nightly (bbc677480 2020-09-18)
binary: rustc
commit-hash: bbc677480db8da85ea302e1e89d3df1f00e435bf
commit-date: 2020-09-18
host: x86_64-apple-darwin
release: 1.48.0-nightly
LLVM version: 11.0
; cargo +beta rustc -- --version --verbose
Compiling rustc-ice-2020-10-23 v0.1.0 (/Users/rjs/tmp/rustc-ice-2020-10-23)
rustc 1.48.0-beta.5 (4c78178b1 2020-10-21)
binary: rustc
commit-hash: 4c78178b1c6ee26e493edb58cefaa77ca44e3991
commit-date: 2020-10-21
host: x86_64-apple-darwin
release: 1.48.0-beta.5
LLVM version: 11.0
; cargo +nightly rustc -- --version --verbose
Compiling rustc-ice-2020-10-23 v0.1.0 (/Users/rjs/tmp/rustc-ice-2020-10-23)
rustc 1.49.0-nightly (1eaadebb3 2020-10-21)
binary: rustc
commit-hash: 1eaadebb3dee31669c7649b32747381d11614fae
commit-date: 2020-10-21
host: x86_64-apple-darwin
release: 1.49.0-nightly
LLVM version: 11.0
Error output
; cargo check
Checking rustc-ice-2020-10-23 v0.1.0 (/Users/rjs/tmp/rustc-ice-2020-10-23)
error: internal compiler error: compiler/rustc_typeck/src/check/mod.rs:3396:25: while adjusting Expr { hir_id: HirId { owner: DefId(0:4 ~ rustc_ice_2020_10_23[ee17]::main[0])
, local_id: 29 }, kind: Path(Resolved(None, Path { span: src/main.rs:5:19: 5:21 (#0), res: Local(HirId { owner: DefId(0:4 ~ rustc_ice_2020_10_23[ee17]::main[0]), local_id: 1
}), segments: [PathSegment { ident: xs#0, hir_id: Some(HirId { owner: DefId(0:4 ~ rustc_ice_2020_10_23[ee17]::main[0]), local_id: 28 }), res: Some(Local(HirId { owner: DefId(
0:4 ~ rustc_ice_2020_10_23[ee17]::main[0]), local_id: 1 })), args: None, infer_args: true }] })), attrs: ThinVec(None), span: src/main.rs:5:19: 5:21 (#0) }, can't compose [Bo
rrow(Ref('_#0r, Not)) -> &Cell<Option<()>>] and [Borrow(Ref('_#2r, Not)) -> &Cell<Option<()>>]
thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
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.48.0-nightly (bbc677480 2020-09-18) running on x86_64-apple-darwin
note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental -C target-cpu=native --crate-type bin
note: some of the compiler flags provided by cargo are hidden
error: aborting due to previous error
error: could not compile `rustc-ice-2020-10-23`
To learn more, run the command again with --verbose.
Backtrace
thread 'rustc' panicked at 'Box<Any>', compiler/rustc_errors/src/lib.rs:945:9
stack backtrace:
0: std::panicking::begin_panic
1: rustc_errors::HandlerInner::bug
2: rustc_errors::Handler::bug
3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
4: rustc_middle::ty::context::tls::with_opt::{{closure}}
5: rustc_middle::ty::context::tls::with_opt
6: rustc_middle::util::bug::opt_span_bug_fmt
7: rustc_middle::util::bug::bug_fmt
8: rustc_typeck::check::FnCtxt::apply_adjustments
9: rustc_typeck::check::method::confirm::ConfirmContext::confirm
10: rustc_typeck::check::method::<impl rustc_typeck::check::FnCtxt>::lookup_method
11: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
12: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
13: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_coercable_to_type
14: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
15: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
16: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
17: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
18: rustc_typeck::check::_match::<impl rustc_typeck::check::FnCtxt>::check_match
19: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
20: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
21: rustc_typeck::check::FnCtxt::check_block_with_expected
22: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind
23: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation
24: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr
25: rustc_typeck::check::check_fn
26: rustc_infer::infer::InferCtxtBuilder::enter
27: rustc_typeck::check::typeck
28: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compu
te
29: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
30: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
31: rustc_data_structures::stack::ensure_sufficient_stack
32: rustc_query_system::query::plumbing::get_query_impl
33: rustc_query_system::query::plumbing::ensure_query_impl
34: rustc_typeck::check::typeck_item_bodies
35: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bo
dies>::compute
36: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
37: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
38: rustc_data_structures::stack::ensure_sufficient_stack
39: rustc_query_system::query::plumbing::get_query_impl
40: rustc_typeck::check_crate
41: rustc_interface::passes::analysis
42: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::com
pute
43: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
44: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
45: rustc_data_structures::stack::ensure_sufficient_stack
46: rustc_query_system::query::plumbing::get_query_impl
47: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
48: rustc_span::with_source_map
49: rustc_interface::interface::create_compiler_and_run
50: rustc_span::with_session_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.