Avoid &Rc<T> arguments.

Either `&T` or `Rc<T>` is preferable.
This commit is contained in:
Nicholas Nethercote 2024-10-04 14:18:17 +10:00
parent d9975ce2b4
commit 56e849ca21
7 changed files with 22 additions and 25 deletions

View File

@ -98,7 +98,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
let universal_regions = Rc::new(universal_regions);
let elements = &Rc::new(DenseLocationMap::new(body));
let elements = Rc::new(DenseLocationMap::new(body));
// Run the MIR type-checker.
let MirTypeckResults { constraints, universal_region_relations, opaque_type_values } =
@ -107,13 +107,13 @@ pub(crate) fn compute_regions<'a, 'tcx>(
param_env,
body,
promoted,
&universal_regions,
universal_regions.clone(),
location_table,
borrow_set,
&mut all_facts,
flow_inits,
move_data,
elements,
elements.clone(),
upvars,
);
@ -165,7 +165,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
universe_causes,
type_tests,
liveness_constraints,
elements,
elements.clone(),
);
// If requested: dump NLL facts, and run legacy polonius analysis.

View File

@ -407,7 +407,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
universe_causes: FxIndexMap<ty::UniverseIndex, UniverseInfo<'tcx>>,
type_tests: Vec<TypeTest<'tcx>>,
liveness_constraints: LivenessValues,
elements: &Rc<DenseLocationMap>,
elements: Rc<DenseLocationMap>,
) -> Self {
debug!("universal_regions: {:#?}", universal_regions);
debug!("outlives constraints: {:#?}", outlives_constraints);
@ -430,7 +430,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}
let mut scc_values =
RegionValues::new(elements, universal_regions.len(), &placeholder_indices);
RegionValues::new(elements, universal_regions.len(), placeholder_indices);
for region in liveness_constraints.regions() {
let scc = constraint_sccs.scc(region);

View File

@ -275,15 +275,16 @@ impl<N: Idx> RegionValues<N> {
/// Each of the regions in num_region_variables will be initialized with an
/// empty set of points and no causal information.
pub(crate) fn new(
elements: &Rc<DenseLocationMap>,
elements: Rc<DenseLocationMap>,
num_universal_regions: usize,
placeholder_indices: &Rc<PlaceholderIndices>,
placeholder_indices: Rc<PlaceholderIndices>,
) -> Self {
let num_points = elements.num_points();
let num_placeholders = placeholder_indices.len();
Self {
elements: elements.clone(),
points: SparseIntervalMatrix::new(elements.num_points()),
placeholder_indices: placeholder_indices.clone(),
elements,
points: SparseIntervalMatrix::new(num_points),
placeholder_indices,
free_regions: SparseBitMatrix::new(num_universal_regions),
placeholders: SparseBitMatrix::new(num_placeholders),
}

View File

@ -54,7 +54,7 @@ pub(crate) fn create<'tcx>(
infcx: &InferCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>,
implicit_region_bound: ty::Region<'tcx>,
universal_regions: &Rc<UniversalRegions<'tcx>>,
universal_regions: Rc<UniversalRegions<'tcx>>,
constraints: &mut MirTypeckRegionConstraints<'tcx>,
) -> CreateResult<'tcx> {
UniversalRegionRelationsBuilder {
@ -62,7 +62,7 @@ pub(crate) fn create<'tcx>(
param_env,
implicit_region_bound,
constraints,
universal_regions: universal_regions.clone(),
universal_regions,
region_bound_pairs: Default::default(),
outlives: Default::default(),
inverse_outlives: Default::default(),

View File

@ -1,5 +1,3 @@
use std::rc::Rc;
use itertools::{Either, Itertools};
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::mir::visit::{TyContext, Visitor};
@ -33,7 +31,7 @@ mod trace;
pub(super) fn generate<'a, 'tcx>(
typeck: &mut TypeChecker<'_, 'tcx>,
body: &Body<'tcx>,
elements: &Rc<DenseLocationMap>,
elements: &DenseLocationMap,
flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
move_data: &MoveData<'tcx>,
) {

View File

@ -1,5 +1,3 @@
use std::rc::Rc;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_index::bit_set::BitSet;
use rustc_index::interval::IntervalSet;
@ -40,7 +38,7 @@ use crate::type_check::{NormalizeLocation, TypeChecker};
pub(super) fn trace<'a, 'tcx>(
typeck: &mut TypeChecker<'_, 'tcx>,
body: &Body<'tcx>,
elements: &Rc<DenseLocationMap>,
elements: &DenseLocationMap,
flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
move_data: &MoveData<'tcx>,
relevant_live_locals: Vec<Local>,

View File

@ -121,13 +121,13 @@ pub(crate) fn type_check<'a, 'tcx>(
param_env: ty::ParamEnv<'tcx>,
body: &Body<'tcx>,
promoted: &IndexSlice<Promoted, Body<'tcx>>,
universal_regions: &Rc<UniversalRegions<'tcx>>,
universal_regions: Rc<UniversalRegions<'tcx>>,
location_table: &LocationTable,
borrow_set: &BorrowSet<'tcx>,
all_facts: &mut Option<AllFacts>,
flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
move_data: &MoveData<'tcx>,
elements: &Rc<DenseLocationMap>,
elements: Rc<DenseLocationMap>,
upvars: &[&ty::CapturedPlace<'tcx>],
) -> MirTypeckResults<'tcx> {
let implicit_region_bound = ty::Region::new_var(infcx.tcx, universal_regions.fr_fn_body);
@ -150,14 +150,14 @@ pub(crate) fn type_check<'a, 'tcx>(
infcx,
param_env,
implicit_region_bound,
universal_regions,
universal_regions.clone(),
&mut constraints,
);
debug!(?normalized_inputs_and_output);
let mut borrowck_context = BorrowCheckContext {
universal_regions,
universal_regions: &universal_regions,
location_table,
borrow_set,
all_facts,
@ -181,10 +181,10 @@ pub(crate) fn type_check<'a, 'tcx>(
verifier.visit_body(body);
checker.typeck_mir(body);
checker.equate_inputs_and_outputs(body, universal_regions, &normalized_inputs_and_output);
checker.equate_inputs_and_outputs(body, &universal_regions, &normalized_inputs_and_output);
checker.check_signature_annotation(body);
liveness::generate(&mut checker, body, elements, flow_inits, move_data);
liveness::generate(&mut checker, body, &elements, flow_inits, move_data);
translate_outlives_facts(&mut checker);
let opaque_type_values = infcx.take_opaque_types();