summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_borrowck/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_borrowck/src/lib.rs')
-rw-r--r--compiler/rustc_borrowck/src/lib.rs35
1 files changed, 18 insertions, 17 deletions
diff --git a/compiler/rustc_borrowck/src/lib.rs b/compiler/rustc_borrowck/src/lib.rs
index 97d15cb53..efe525c22 100644
--- a/compiler/rustc_borrowck/src/lib.rs
+++ b/compiler/rustc_borrowck/src/lib.rs
@@ -11,6 +11,7 @@
#![feature(trusted_step)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
+#![cfg_attr(not(bootstrap), allow(internal_features))]
#[macro_use]
extern crate rustc_middle;
@@ -23,7 +24,7 @@ use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticMessage, Subdiagnost
use rustc_fluent_macro::fluent_messages;
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
-use rustc_index::bit_set::ChunkedBitSet;
+use rustc_index::bit_set::{BitSet, ChunkedBitSet};
use rustc_index::{IndexSlice, IndexVec};
use rustc_infer::infer::{
InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin, TyCtxtInferExt,
@@ -42,7 +43,6 @@ use rustc_session::lint::builtin::UNUSED_MUT;
use rustc_span::{Span, Symbol};
use rustc_target::abi::FieldIdx;
-use either::Either;
use smallvec::SmallVec;
use std::cell::RefCell;
use std::collections::BTreeMap;
@@ -301,7 +301,7 @@ fn do_mir_borrowck<'tcx>(
let movable_generator =
// The first argument is the generator type passed by value
if let Some(local) = body.local_decls.raw.get(1)
- // Get the interior types and substs which typeck computed
+ // Get the interior types and args which typeck computed
&& let ty::Generator(_, _, hir::Movability::Static) = local.ty.kind()
{
false
@@ -1035,12 +1035,16 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let borrow_set = self.borrow_set.clone();
// Use polonius output if it has been enabled.
- let polonius_output = self.polonius_output.clone();
- let borrows_in_scope = if let Some(polonius) = &polonius_output {
+ let mut polonius_output;
+ let borrows_in_scope = if let Some(polonius) = &self.polonius_output {
let location = self.location_table.start_index(location);
- Either::Left(polonius.errors_at(location).iter().copied())
+ polonius_output = BitSet::new_empty(borrow_set.len());
+ for &idx in polonius.errors_at(location) {
+ polonius_output.insert(idx);
+ }
+ &polonius_output
} else {
- Either::Right(flow_state.borrows.iter())
+ &flow_state.borrows
};
each_borrow_involving_path(
@@ -1050,7 +1054,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
location,
(sd, place_span.0),
&borrow_set,
- borrows_in_scope,
+ |borrow_index| borrows_in_scope.contains(borrow_index),
|this, borrow_index, borrow| match (rw, borrow.kind) {
// Obviously an activation is compatible with its own
// reservation (or even prior activating uses of same
@@ -1817,8 +1821,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
}
ProjectionElem::Subslice { .. } => {
- panic!("we don't allow assignments to subslices, location: {:?}",
- location);
+ panic!("we don't allow assignments to subslices, location: {location:?}");
}
ProjectionElem::Field(..) => {
@@ -2017,8 +2020,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
self.infcx.tcx.sess.delay_span_bug(
span,
format!(
- "Accessing `{:?}` with the kind `{:?}` shouldn't be possible",
- place, kind,
+ "Accessing `{place:?}` with the kind `{kind:?}` shouldn't be possible",
),
);
}
@@ -2306,11 +2308,10 @@ mod error {
pub fn buffer_error(&mut self, t: DiagnosticBuilder<'_, ErrorGuaranteed>) {
if let None = self.tainted_by_errors {
- self.tainted_by_errors = Some(
- self.tcx
- .sess
- .delay_span_bug(t.span.clone(), "diagnostic buffered but not emitted"),
- )
+ self.tainted_by_errors = Some(self.tcx.sess.delay_span_bug(
+ t.span.clone_ignoring_labels(),
+ "diagnostic buffered but not emitted",
+ ))
}
t.buffer(&mut self.buffered);
}