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
|
@ -127,7 +127,10 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
|
|||
&AggregateKind::Closure(def_id, _) | &AggregateKind::Generator(def_id, _, _) => {
|
||||
let UnsafetyCheckResult { violations, used_unsafe_blocks, .. } =
|
||||
self.tcx.unsafety_check_result(def_id.expect_local());
|
||||
self.register_violations(violations, used_unsafe_blocks);
|
||||
self.register_violations(
|
||||
violations,
|
||||
used_unsafe_blocks.iter().map(|(&h, &d)| (h, d)),
|
||||
);
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
|
@ -261,7 +264,7 @@ impl<'tcx> UnsafetyChecker<'_, 'tcx> {
|
|||
fn register_violations<'a>(
|
||||
&mut self,
|
||||
violations: impl IntoIterator<Item = &'a UnsafetyViolation>,
|
||||
new_used_unsafe_blocks: impl IntoIterator<Item = (&'a HirId, &'a UsedUnsafeBlockData)>,
|
||||
new_used_unsafe_blocks: impl IntoIterator<Item = (HirId, UsedUnsafeBlockData)>,
|
||||
) {
|
||||
use UsedUnsafeBlockData::{AllAllowedInUnsafeFn, SomeDisallowedInUnsafeFn};
|
||||
|
||||
|
@ -318,7 +321,7 @@ impl<'tcx> UnsafetyChecker<'_, 'tcx> {
|
|||
|
||||
new_used_unsafe_blocks
|
||||
.into_iter()
|
||||
.for_each(|(&hir_id, &usage_data)| update_entry(self, hir_id, usage_data));
|
||||
.for_each(|(hir_id, usage_data)| update_entry(self, hir_id, usage_data));
|
||||
}
|
||||
fn check_mut_borrowing_layout_constrained_field(
|
||||
&mut self,
|
||||
|
|
|
@ -48,7 +48,7 @@ impl CoverageGraph {
|
|||
let mut bcb_successors = Vec::new();
|
||||
for successor in
|
||||
bcb_filtered_successors(&mir_body, &bcb_data.terminator(mir_body).kind)
|
||||
.filter_map(|&successor_bb| bb_to_bcb[successor_bb])
|
||||
.filter_map(|successor_bb| bb_to_bcb[successor_bb])
|
||||
{
|
||||
if !seen[successor] {
|
||||
seen[successor] = true;
|
||||
|
@ -483,7 +483,7 @@ impl std::fmt::Debug for BcbBranch {
|
|||
fn bcb_filtered_successors<'a, 'tcx>(
|
||||
body: &'tcx &'a mir::Body<'tcx>,
|
||||
term_kind: &'tcx TerminatorKind<'tcx>,
|
||||
) -> Box<dyn Iterator<Item = &'a BasicBlock> + 'a> {
|
||||
) -> Box<dyn Iterator<Item = BasicBlock> + 'a> {
|
||||
let mut successors = term_kind.successors();
|
||||
Box::new(
|
||||
match &term_kind {
|
||||
|
@ -494,9 +494,8 @@ fn bcb_filtered_successors<'a, 'tcx>(
|
|||
// `next().into_iter()`) into the `mir::Successors` aliased type.
|
||||
_ => successors.next().into_iter().chain(&[]),
|
||||
}
|
||||
.filter(move |&&successor| {
|
||||
body[successor].terminator().kind != TerminatorKind::Unreachable
|
||||
}),
|
||||
.copied()
|
||||
.filter(move |&successor| body[successor].terminator().kind != TerminatorKind::Unreachable),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -695,7 +694,7 @@ pub struct ShortCircuitPreorder<
|
|||
F: Fn(
|
||||
&'tcx &'a mir::Body<'tcx>,
|
||||
&'tcx TerminatorKind<'tcx>,
|
||||
) -> Box<dyn Iterator<Item = &'a BasicBlock> + 'a>,
|
||||
) -> Box<dyn Iterator<Item = BasicBlock> + 'a>,
|
||||
> {
|
||||
body: &'tcx &'a mir::Body<'tcx>,
|
||||
visited: BitSet<BasicBlock>,
|
||||
|
@ -709,7 +708,7 @@ impl<
|
|||
F: Fn(
|
||||
&'tcx &'a mir::Body<'tcx>,
|
||||
&'tcx TerminatorKind<'tcx>,
|
||||
) -> Box<dyn Iterator<Item = &'a BasicBlock> + 'a>,
|
||||
) -> Box<dyn Iterator<Item = BasicBlock> + 'a>,
|
||||
> ShortCircuitPreorder<'a, 'tcx, F>
|
||||
{
|
||||
pub fn new(
|
||||
|
@ -733,7 +732,7 @@ impl<
|
|||
F: Fn(
|
||||
&'tcx &'a mir::Body<'tcx>,
|
||||
&'tcx TerminatorKind<'tcx>,
|
||||
) -> Box<dyn Iterator<Item = &'a BasicBlock> + 'a>,
|
||||
) -> Box<dyn Iterator<Item = BasicBlock> + 'a>,
|
||||
> Iterator for ShortCircuitPreorder<'a, 'tcx, F>
|
||||
{
|
||||
type Item = (BasicBlock, &'a BasicBlockData<'tcx>);
|
||||
|
|
|
@ -707,7 +707,7 @@ impl<'tcx> SimplifyBranchSameOptimizationFinder<'_, 'tcx> {
|
|||
) -> StatementEquality {
|
||||
let helper = |rhs: &Rvalue<'tcx>,
|
||||
place: &Place<'tcx>,
|
||||
variant_index: &VariantIdx,
|
||||
variant_index: VariantIdx,
|
||||
switch_value: u128,
|
||||
side_to_choose| {
|
||||
let place_type = place.ty(self.body, self.tcx).ty;
|
||||
|
@ -717,7 +717,7 @@ impl<'tcx> SimplifyBranchSameOptimizationFinder<'_, 'tcx> {
|
|||
};
|
||||
// We need to make sure that the switch value that targets the bb with
|
||||
// SetDiscriminant is the same as the variant discriminant.
|
||||
let variant_discr = adt.discriminant_for_variant(self.tcx, *variant_index).val;
|
||||
let variant_discr = adt.discriminant_for_variant(self.tcx, variant_index).val;
|
||||
if variant_discr != switch_value {
|
||||
trace!(
|
||||
"NO: variant discriminant {} does not equal switch value {}",
|
||||
|
@ -726,7 +726,7 @@ impl<'tcx> SimplifyBranchSameOptimizationFinder<'_, 'tcx> {
|
|||
);
|
||||
return StatementEquality::NotEqual;
|
||||
}
|
||||
let variant_is_fieldless = adt.variants[*variant_index].fields.is_empty();
|
||||
let variant_is_fieldless = adt.variants[variant_index].fields.is_empty();
|
||||
if !variant_is_fieldless {
|
||||
trace!("NO: variant {:?} was not fieldless", variant_index);
|
||||
return StatementEquality::NotEqual;
|
||||
|
@ -753,7 +753,7 @@ impl<'tcx> SimplifyBranchSameOptimizationFinder<'_, 'tcx> {
|
|||
// check for case A
|
||||
(
|
||||
StatementKind::Assign(box (_, rhs)),
|
||||
StatementKind::SetDiscriminant { place, variant_index },
|
||||
&StatementKind::SetDiscriminant { ref place, variant_index },
|
||||
) if y_target_and_value.value.is_some() => {
|
||||
// choose basic block of x, as that has the assign
|
||||
helper(
|
||||
|
@ -765,8 +765,8 @@ impl<'tcx> SimplifyBranchSameOptimizationFinder<'_, 'tcx> {
|
|||
)
|
||||
}
|
||||
(
|
||||
StatementKind::SetDiscriminant { place, variant_index },
|
||||
StatementKind::Assign(box (_, rhs)),
|
||||
&StatementKind::SetDiscriminant { ref place, variant_index },
|
||||
&StatementKind::Assign(box (_, ref rhs)),
|
||||
) if x_target_and_value.value.is_some() => {
|
||||
// choose basic block of y, as that has the assign
|
||||
helper(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue