-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
fn foo(x: &mut u32) {
let bar = || { foo(x); };
bar();
}
fn main() {}
Compiled with rustc bug2.rs
gives:
error: internal compiler error: compiler\rustc_mir\src\borrow_check\diagnostics\mutability_errors.rs:525:22: upvar `x` borrowed, but not mutably
thread 'rustc' panicked at 'Box<Any>', compiler\rustc_errors\src\lib.rs:958: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
5: rustc_middle::util::bug::opt_span_bug_fmt
6: rustc_middle::util::bug::bug_fmt
7: rustc_mir::borrow_check::diagnostics::mutability_errors::<impl rustc_mir::borrow_check::MirBorrowckCtxt>::show_mutating_upvar
8: rustc_mir::borrow_check::diagnostics::mutability_errors::<impl rustc_mir::borrow_check::MirBorrowckCtxt>::report_mutability_error
9: rustc_mir::borrow_check::MirBorrowckCtxt::access_place
10: <rustc_mir::borrow_check::MirBorrowckCtxt as rustc_mir::dataflow::framework::visitor::ResultsVisitor>::visit_statement_before_primary_effect
11: <rustc_mir::dataflow::framework::direction::Forward as rustc_mir::dataflow::framework::direction::Direction>::visit_results_in_block
12: rustc_mir::dataflow::framework::visitor::visit_results
13: rustc_mir::borrow_check::do_mir_borrowck
14: rustc_infer::infer::InferCtxtBuilder::enter
15: rustc_mir::borrow_check::mir_borrowck
16: core::ops::function::FnOnce::call_once
17: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
18: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
19: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
20: rustc_query_system::query::plumbing::force_query_with_job
21: rustc_query_system::query::plumbing::get_query_impl
22: rustc_query_system::query::plumbing::ensure_query_impl
23: rustc_session::utils::<impl rustc_session::session::Session>::time
24: rustc_interface::passes::analysis
25: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
26: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
27: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
28: rustc_query_system::query::plumbing::force_query_with_job
29: rustc_query_system::query::plumbing::get_query_impl
30: rustc_interface::passes::QueryContext::enter
31: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
32: rustc_span::with_source_map
33: rustc_interface::interface::create_compiler_and_run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.51.0-nightly (d4e3570db 2021-02-01) running on x86_64-pc-windows-gnu
query stack during panic:
#0 [mir_borrowck] borrow-checking `foo`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
matthiaskrgr commentedon Feb 3, 2021
This was caused by 74500b9
@rustbot prioritize
edit:
in beta, this gives the following error:
apiraino commentedon Feb 3, 2021
Assigning
P-medium
as discussed as part of the Prioritization Working Group procedure and removingI-prioritize
.camelid commentedon Feb 3, 2021
Looks likely that #81158 is the cause. cc @Aaron1011
camelid commentedon Feb 3, 2021
Re-prioritizing as
P-high
and removingI-prioritize
as discussed in the prioritization working group.@rustbot label: +regression-from-stable-to-nightly +P-high -P-medium -I-prioritize
Fix panic when emitting diagnostic for closure mutable binding error
Auto merge of rust-lang#81717 - Aaron1011:fix/closure-diag, r=estebank