Auto merge of #126023 - amandasystems:you-dropped-this-again, r=nikom… · rust-lang/rust@d49994b

13 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -126,7 +126,7 @@ impl<'tcx> BorrowSet<'tcx> {

126126

) -> Self {

127127

let mut visitor = GatherBorrows {

128128

tcx,

129-

body: body,

129+

body,

130130

location_map: Default::default(),

131131

activation_map: Default::default(),

132132

local_map: Default::default(),

Original file line numberDiff line numberDiff line change

@@ -213,7 +213,7 @@ impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {

213213

via(msg_old),

214214

);

215215
216-

if msg_new == "" {

216+

if msg_new.is_empty() {

217217

// If `msg_new` is empty, then this isn't a borrow of a union field.

218218

err.span_label(span, format!("{kind_new} borrow occurs here"));

219219

err.span_label(old_span, format!("{kind_old} borrow occurs here"));

Original file line numberDiff line numberDiff line change

@@ -43,9 +43,9 @@ impl<'mir, 'tcx> ResultsVisitable<'tcx> for BorrowckResults<'mir, 'tcx> {

4343

}

4444
4545

fn reset_to_block_entry(&self, state: &mut Self::FlowState, block: BasicBlock) {

46-

state.borrows.clone_from(&self.borrows.entry_set_for_block(block));

47-

state.uninits.clone_from(&self.uninits.entry_set_for_block(block));

48-

state.ever_inits.clone_from(&self.ever_inits.entry_set_for_block(block));

46+

state.borrows.clone_from(self.borrows.entry_set_for_block(block));

47+

state.uninits.clone_from(self.uninits.entry_set_for_block(block));

48+

state.ever_inits.clone_from(self.ever_inits.entry_set_for_block(block));

4949

}

5050
5151

fn reconstruct_before_statement_effect(

Original file line numberDiff line numberDiff line change

@@ -895,7 +895,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {

895895

for alias_ty in alias_tys {

896896

if alias_ty.span.desugaring_kind().is_some() {

897897

// Skip `async` desugaring `impl Future`.

898-

()

899898

}

900899

if let TyKind::TraitObject(_, lt, _) = alias_ty.kind {

901900

if lt.ident.name == kw::Empty {

Original file line numberDiff line numberDiff line change

@@ -519,7 +519,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {

519519

}

520520
521521

// Otherwise, let's descend into the referent types.

522-

search_stack.push((*referent_ty, &referent_hir_ty.ty));

522+

search_stack.push((*referent_ty, referent_hir_ty.ty));

523523

}

524524
525525

// Match up something like `Foo<'1>`

@@ -558,7 +558,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {

558558

}

559559
560560

(ty::RawPtr(mut_ty, _), hir::TyKind::Ptr(mut_hir_ty)) => {

561-

search_stack.push((*mut_ty, &mut_hir_ty.ty));

561+

search_stack.push((*mut_ty, mut_hir_ty.ty));

562562

}

563563
564564

_ => {

@@ -652,7 +652,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {

652652

let upvar_index = self.regioncx.get_upvar_index_for_region(self.infcx.tcx, fr)?;

653653

let (upvar_name, upvar_span) = self.regioncx.get_upvar_name_and_span_for_region(

654654

self.infcx.tcx,

655-

&self.upvars,

655+

self.upvars,

656656

upvar_index,

657657

);

658658

let region_name = self.synthesize_region_name();

@@ -717,7 +717,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {

717717

.output;

718718

span = output.span();

719719

if let hir::FnRetTy::Return(ret) = output {

720-

hir_ty = Some(self.get_future_inner_return_ty(*ret));

720+

hir_ty = Some(self.get_future_inner_return_ty(ret));

721721

}

722722

" of async function"

723723

}

@@ -958,7 +958,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {

958958

{

959959

let (upvar_name, upvar_span) = self.regioncx.get_upvar_name_and_span_for_region(

960960

self.infcx.tcx,

961-

&self.upvars,

961+

self.upvars,

962962

upvar_index,

963963

);

964964

let region_name = self.synthesize_region_name();

Original file line numberDiff line numberDiff line change

@@ -114,7 +114,6 @@ pub(crate) fn compute_regions<'cx, 'tcx>(

114114

move_data,

115115

elements,

116116

upvars,

117-

polonius_input,

118117

);

119118
120119

// Create the region inference context, taking ownership of the

Original file line numberDiff line numberDiff line change

@@ -43,8 +43,8 @@ pub(crate) fn emit_facts<'tcx>(

4343

emit_universal_region_facts(

4444

all_facts,

4545

borrow_set,

46-

&universal_regions,

47-

&universal_region_relations,

46+

universal_regions,

47+

universal_region_relations,

4848

);

4949

emit_cfg_and_loan_kills_facts(all_facts, tcx, location_table, body, borrow_set);

5050

emit_loan_invalidations_facts(all_facts, tcx, location_table, body, borrow_set);

Original file line numberDiff line numberDiff line change

@@ -344,7 +344,7 @@ fn sccs_info<'tcx>(infcx: &BorrowckInferCtxt<'tcx>, sccs: &ConstraintSccs) {

344344
345345

for (reg_var_idx, scc_idx) in sccs.scc_indices().iter().enumerate() {

346346

let reg_var = ty::RegionVid::from_usize(reg_var_idx);

347-

let origin = var_to_origin.get(&reg_var).unwrap_or_else(|| &RegionCtxt::Unknown);

347+

let origin = var_to_origin.get(&reg_var).unwrap_or(&RegionCtxt::Unknown);

348348

components[scc_idx.as_usize()].insert((reg_var, *origin));

349349

}

350350

@@ -2216,7 +2216,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {

22162216

// #114907 where this happens via liveness and dropck outlives results.

22172217

// Therefore, we return a default value in case that happens, which should at worst emit a

22182218

// suboptimal error, instead of the ICE.

2219-

self.universe_causes.get(&universe).cloned().unwrap_or_else(|| UniverseInfo::other())

2219+

self.universe_causes.get(&universe).cloned().unwrap_or_else(UniverseInfo::other)

22202220

}

22212221
22222222

/// Tries to find the terminator of the loop in which the region 'r' resides.

Original file line numberDiff line numberDiff line change

@@ -418,9 +418,7 @@ fn check_opaque_type_parameter_valid<'tcx>(

418418

let opaque_param = opaque_generics.param_at(i, tcx);

419419

let kind = opaque_param.kind.descr();

420420
421-

if let Err(guar) = opaque_env.param_is_error(i) {

422-

return Err(guar);

423-

}

421+

opaque_env.param_is_error(i)?;

424422
425423

return Err(tcx.dcx().emit_err(NonGenericOpaqueTypeParam {

426424

ty: arg,

Original file line numberDiff line numberDiff line change

@@ -12,9 +12,7 @@ use rustc_mir_dataflow::ResultsCursor;

1212

use std::rc::Rc;

1313
1414

use crate::{

15-

constraints::OutlivesConstraintSet,

16-

facts::{AllFacts, AllFactsExt},

17-

region_infer::values::LivenessValues,

15+

constraints::OutlivesConstraintSet, region_infer::values::LivenessValues,

1816

universal_regions::UniversalRegions,

1917

};

2018

@@ -38,7 +36,6 @@ pub(super) fn generate<'mir, 'tcx>(

3836

elements: &Rc<DenseLocationMap>,

3937

flow_inits: &mut ResultsCursor<'mir, 'tcx, MaybeInitializedPlaces<'mir, 'tcx>>,

4038

move_data: &MoveData<'tcx>,

41-

use_polonius: bool,

4239

) {

4340

debug!("liveness::generate");

4441

@@ -49,11 +46,8 @@ pub(super) fn generate<'mir, 'tcx>(

4946

);

5047

let (relevant_live_locals, boring_locals) =

5148

compute_relevant_live_locals(typeck.tcx(), &free_regions, body);

52-

let facts_enabled = use_polonius || AllFacts::enabled(typeck.tcx());

5349
54-

if facts_enabled {

55-

polonius::populate_access_facts(typeck, body, move_data);

56-

};

50+

polonius::populate_access_facts(typeck, body, move_data);

5751
5852

trace::trace(

5953

typeck,