add #[rustc_pass_by_value]
to more types
This commit is contained in:
parent
67b3e81838
commit
b8135fd5c8
27 changed files with 165 additions and 152 deletions
|
@ -220,8 +220,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
PlaceRef {
|
||||
local,
|
||||
projection:
|
||||
[
|
||||
proj_base @ ..,
|
||||
&[
|
||||
ref proj_base @ ..,
|
||||
ProjectionElem::Deref,
|
||||
ProjectionElem::Field(field, _),
|
||||
ProjectionElem::Deref,
|
||||
|
@ -342,7 +342,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
Applicability::MachineApplicable,
|
||||
);
|
||||
let tcx = self.infcx.tcx;
|
||||
if let ty::Closure(id, _) = the_place_err.ty(self.body, tcx).ty.kind() {
|
||||
if let ty::Closure(id, _) = *the_place_err.ty(self.body, tcx).ty.kind() {
|
||||
self.show_mutating_upvar(tcx, id, the_place_err, &mut err);
|
||||
}
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
let tcx = self.infcx.tcx;
|
||||
if let ty::Ref(_, ty, Mutability::Mut) = the_place_err.ty(self.body, tcx).ty.kind()
|
||||
{
|
||||
if let ty::Closure(id, _) = ty.kind() {
|
||||
if let ty::Closure(id, _) = *ty.kind() {
|
||||
self.show_mutating_upvar(tcx, id, the_place_err, &mut err);
|
||||
}
|
||||
}
|
||||
|
@ -687,7 +687,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
fn show_mutating_upvar(
|
||||
&self,
|
||||
tcx: TyCtxt<'_>,
|
||||
id: &hir::def_id::DefId,
|
||||
id: hir::def_id::DefId,
|
||||
the_place_err: PlaceRef<'tcx>,
|
||||
err: &mut Diagnostic,
|
||||
) {
|
||||
|
@ -701,7 +701,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
let upvar = ty::place_to_string_for_capture(tcx, closure_kind_origin);
|
||||
let root_hir_id = upvar_id.var_path.hir_id;
|
||||
// we have an origin for this closure kind starting at this root variable so it's safe to unwrap here
|
||||
let captured_places = tables.closure_min_captures[id].get(&root_hir_id).unwrap();
|
||||
let captured_places = tables.closure_min_captures[&id].get(&root_hir_id).unwrap();
|
||||
|
||||
let origin_projection = closure_kind_origin
|
||||
.projections
|
||||
|
@ -1083,7 +1083,7 @@ fn is_closure_or_generator(ty: Ty<'_>) -> bool {
|
|||
fn get_mut_span_in_struct_field<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
field: &mir::Field,
|
||||
field: mir::Field,
|
||||
) -> Option<Span> {
|
||||
// Expect our local to be a reference to a struct of some kind.
|
||||
if let ty::Ref(_, ty, _) = ty.kind()
|
||||
|
|
|
@ -100,7 +100,7 @@ impl LocationTable {
|
|||
}
|
||||
|
||||
impl LocationIndex {
|
||||
fn is_start(&self) -> bool {
|
||||
fn is_start(self) -> bool {
|
||||
// even indices are start points; odd indices are mid points
|
||||
(self.index() % 2) == 0
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ fn populate_polonius_move_facts(
|
|||
) {
|
||||
all_facts
|
||||
.path_is_var
|
||||
.extend(move_data.rev_lookup.iter_locals_enumerated().map(|(v, &m)| (m, v)));
|
||||
.extend(move_data.rev_lookup.iter_locals_enumerated().map(|(l, r)| (r, l)));
|
||||
|
||||
for (child, move_path) in move_data.move_paths.iter_enumerated() {
|
||||
if let Some(parent) = move_path.parent {
|
||||
|
@ -135,7 +135,7 @@ fn populate_polonius_move_facts(
|
|||
}
|
||||
}
|
||||
|
||||
for (local, &path) in move_data.rev_lookup.iter_locals_enumerated() {
|
||||
for (local, path) in move_data.rev_lookup.iter_locals_enumerated() {
|
||||
if body.local_kind(local) != LocalKind::Arg {
|
||||
// Non-arguments start out deinitialised; we simulate this with an
|
||||
// initial move:
|
||||
|
@ -226,7 +226,7 @@ pub(crate) fn compute_regions<'cx, 'tcx>(
|
|||
fr1={:?}, fr2={:?}",
|
||||
fr1, fr2
|
||||
);
|
||||
all_facts.known_placeholder_subset.push((*fr1, *fr2));
|
||||
all_facts.known_placeholder_subset.push((fr1, fr2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -942,14 +942,14 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
|
||||
debug!("try_promote_type_test: ur={:?}", ur);
|
||||
|
||||
let non_local_ub = self.universal_region_relations.non_local_upper_bounds(&ur);
|
||||
let non_local_ub = self.universal_region_relations.non_local_upper_bounds(ur);
|
||||
debug!("try_promote_type_test: non_local_ub={:?}", non_local_ub);
|
||||
|
||||
// This is slightly too conservative. To show T: '1, given `'2: '1`
|
||||
// and `'3: '1` we only need to prove that T: '2 *or* T: '3, but to
|
||||
// avoid potential non-determinism we approximate this by requiring
|
||||
// T: '1 and T: '2.
|
||||
for &upper_bound in non_local_ub {
|
||||
for upper_bound in non_local_ub {
|
||||
debug_assert!(self.universal_regions.is_universal_region(upper_bound));
|
||||
debug_assert!(!self.universal_regions.is_local_free_region(upper_bound));
|
||||
|
||||
|
@ -1588,12 +1588,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||
// always will.) We'll call them `shorter_fr+` -- they're ever
|
||||
// so slightly larger than `shorter_fr`.
|
||||
let shorter_fr_plus =
|
||||
self.universal_region_relations.non_local_upper_bounds(&shorter_fr);
|
||||
self.universal_region_relations.non_local_upper_bounds(shorter_fr);
|
||||
debug!(
|
||||
"try_propagate_universal_region_error: shorter_fr_plus={:?}",
|
||||
shorter_fr_plus
|
||||
);
|
||||
for &&fr in &shorter_fr_plus {
|
||||
for fr in shorter_fr_plus {
|
||||
// Push the constraint `fr-: shorter_fr+`
|
||||
propagated_outlives_requirements.push(ClosureOutlivesRequirement {
|
||||
subject: ClosureOutlivesSubject::Region(fr_minus),
|
||||
|
|
|
@ -99,10 +99,9 @@ impl UniversalRegionRelations<'_> {
|
|||
crate fn postdom_upper_bound(&self, fr1: RegionVid, fr2: RegionVid) -> RegionVid {
|
||||
assert!(self.universal_regions.is_universal_region(fr1));
|
||||
assert!(self.universal_regions.is_universal_region(fr2));
|
||||
*self
|
||||
.inverse_outlives
|
||||
.postdom_upper_bound(&fr1, &fr2)
|
||||
.unwrap_or(&self.universal_regions.fr_static)
|
||||
self.inverse_outlives
|
||||
.postdom_upper_bound(fr1, fr2)
|
||||
.unwrap_or(self.universal_regions.fr_static)
|
||||
}
|
||||
|
||||
/// Finds an "upper bound" for `fr` that is not local. In other
|
||||
|
@ -110,7 +109,7 @@ impl UniversalRegionRelations<'_> {
|
|||
/// outlives `fr` and (b) is not local.
|
||||
///
|
||||
/// (*) If there are multiple competing choices, we return all of them.
|
||||
crate fn non_local_upper_bounds<'a>(&'a self, fr: &'a RegionVid) -> Vec<&'a RegionVid> {
|
||||
crate fn non_local_upper_bounds<'a>(&'a self, fr: RegionVid) -> Vec<RegionVid> {
|
||||
debug!("non_local_upper_bound(fr={:?})", fr);
|
||||
let res = self.non_local_bounds(&self.inverse_outlives, fr);
|
||||
assert!(!res.is_empty(), "can't find an upper bound!?");
|
||||
|
@ -120,7 +119,7 @@ impl UniversalRegionRelations<'_> {
|
|||
/// Returns the "postdominating" bound of the set of
|
||||
/// `non_local_upper_bounds` for the given region.
|
||||
crate fn non_local_upper_bound(&self, fr: RegionVid) -> RegionVid {
|
||||
let upper_bounds = self.non_local_upper_bounds(&fr);
|
||||
let upper_bounds = self.non_local_upper_bounds(fr);
|
||||
|
||||
// In case we find more than one, reduce to one for
|
||||
// convenience. This is to prevent us from generating more
|
||||
|
@ -130,7 +129,7 @@ impl UniversalRegionRelations<'_> {
|
|||
debug!("non_local_bound: post_dom={:?}", post_dom);
|
||||
|
||||
post_dom
|
||||
.and_then(|&post_dom| {
|
||||
.and_then(|post_dom| {
|
||||
// If the mutual immediate postdom is not local, then
|
||||
// there is no non-local result we can return.
|
||||
if !self.universal_regions.is_local_free_region(post_dom) {
|
||||
|
@ -150,7 +149,7 @@ impl UniversalRegionRelations<'_> {
|
|||
/// one. See `TransitiveRelation::postdom_upper_bound` for details.
|
||||
crate fn non_local_lower_bound(&self, fr: RegionVid) -> Option<RegionVid> {
|
||||
debug!("non_local_lower_bound(fr={:?})", fr);
|
||||
let lower_bounds = self.non_local_bounds(&self.outlives, &fr);
|
||||
let lower_bounds = self.non_local_bounds(&self.outlives, fr);
|
||||
|
||||
// In case we find more than one, reduce to one for
|
||||
// convenience. This is to prevent us from generating more
|
||||
|
@ -159,7 +158,7 @@ impl UniversalRegionRelations<'_> {
|
|||
|
||||
debug!("non_local_bound: post_dom={:?}", post_dom);
|
||||
|
||||
post_dom.and_then(|&post_dom| {
|
||||
post_dom.and_then(|post_dom| {
|
||||
// If the mutual immediate postdom is not local, then
|
||||
// there is no non-local result we can return.
|
||||
if !self.universal_regions.is_local_free_region(post_dom) {
|
||||
|
@ -176,11 +175,11 @@ impl UniversalRegionRelations<'_> {
|
|||
fn non_local_bounds<'a>(
|
||||
&self,
|
||||
relation: &'a TransitiveRelation<RegionVid>,
|
||||
fr0: &'a RegionVid,
|
||||
) -> Vec<&'a RegionVid> {
|
||||
fr0: RegionVid,
|
||||
) -> Vec<RegionVid> {
|
||||
// This method assumes that `fr0` is one of the universally
|
||||
// quantified region variables.
|
||||
assert!(self.universal_regions.is_universal_region(*fr0));
|
||||
assert!(self.universal_regions.is_universal_region(fr0));
|
||||
|
||||
let mut external_parents = vec![];
|
||||
let mut queue = vec![fr0];
|
||||
|
@ -188,7 +187,7 @@ impl UniversalRegionRelations<'_> {
|
|||
// Keep expanding `fr` into its parents until we reach
|
||||
// non-local regions.
|
||||
while let Some(fr) = queue.pop() {
|
||||
if !self.universal_regions.is_local_free_region(*fr) {
|
||||
if !self.universal_regions.is_local_free_region(fr) {
|
||||
external_parents.push(fr);
|
||||
continue;
|
||||
}
|
||||
|
@ -205,17 +204,17 @@ impl UniversalRegionRelations<'_> {
|
|||
///
|
||||
/// This will only ever be true for universally quantified regions.
|
||||
crate fn outlives(&self, fr1: RegionVid, fr2: RegionVid) -> bool {
|
||||
self.outlives.contains(&fr1, &fr2)
|
||||
self.outlives.contains(fr1, fr2)
|
||||
}
|
||||
|
||||
/// Returns a vector of free regions `x` such that `fr1: x` is
|
||||
/// known to hold.
|
||||
crate fn regions_outlived_by(&self, fr1: RegionVid) -> Vec<&RegionVid> {
|
||||
self.outlives.reachable_from(&fr1)
|
||||
crate fn regions_outlived_by(&self, fr1: RegionVid) -> Vec<RegionVid> {
|
||||
self.outlives.reachable_from(fr1)
|
||||
}
|
||||
|
||||
/// Returns the _non-transitive_ set of known `outlives` constraints between free regions.
|
||||
crate fn known_outlives(&self) -> impl Iterator<Item = (&RegionVid, &RegionVid)> {
|
||||
crate fn known_outlives(&self) -> impl Iterator<Item = (RegionVid, RegionVid)> + '_ {
|
||||
self.outlives.base_edges()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1198,7 +1198,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||
tcx,
|
||||
self.param_env,
|
||||
proj,
|
||||
|this, field, &()| {
|
||||
|this, field, ()| {
|
||||
let ty = this.field_ty(tcx, field);
|
||||
self.normalize(ty, locations)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue