Skip to content

Commit

Permalink
Avoid &Rc<T> arguments.
Browse files Browse the repository at this point in the history
Either `&T` or `Rc<T>` is preferable.
  • Loading branch information
nnethercote committed Oct 4, 2024
1 parent d9975ce commit 56e849c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 25 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } =
Expand All @@ -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,
);

Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_borrowck/src/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ 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 {
infcx,
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(),
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_borrowck/src/type_check/liveness/mod.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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>,
) {
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_borrowck/src/type_check/liveness/trace.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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>,
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -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();
Expand Down

0 comments on commit 56e849c

Please sign in to comment.