Skip to content

Commit 4137f3b

Browse files
authored
Rollup merge of #129345 - compiler-errors:scratch4, r=jieyouxu
Use shorthand field initialization syntax more aggressively in the compiler Caught these when cleaning up #129344 and decided to run clippy to find the rest
2 parents 937a18d + 0b2525c commit 4137f3b

File tree

16 files changed

+19
-30
lines changed

16 files changed

+19
-30
lines changed

compiler/rustc_ast_lowering/src/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14211421
};
14221422
hir::FnHeader {
14231423
safety: self.lower_safety(h.safety, default_safety),
1424-
asyncness: asyncness,
1424+
asyncness,
14251425
constness: self.lower_constness(h.constness),
14261426
abi: self.lower_extern(h.ext),
14271427
}

compiler/rustc_ast_passes/src/ast_validation.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,8 @@ impl<'a> AstValidator<'a> {
562562
FnHeader { safety: _, coroutine_kind, constness, ext }: FnHeader,
563563
) {
564564
let report_err = |span| {
565-
self.dcx().emit_err(errors::FnQualifierInExtern {
566-
span: span,
567-
block: self.current_extern_span(),
568-
});
565+
self.dcx()
566+
.emit_err(errors::FnQualifierInExtern { span, block: self.current_extern_span() });
569567
};
570568
match coroutine_kind {
571569
Some(knd) => report_err(knd.span()),

compiler/rustc_codegen_ssa/src/back/linker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ impl<'a> Linker for L4Bender<'a> {
15001500

15011501
impl<'a> L4Bender<'a> {
15021502
pub fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
1503-
L4Bender { cmd, sess: sess, hinted_static: false }
1503+
L4Bender { cmd, sess, hinted_static: false }
15041504
}
15051505

15061506
fn hint_static(&mut self) {
@@ -1520,7 +1520,7 @@ pub struct AixLinker<'a> {
15201520

15211521
impl<'a> AixLinker<'a> {
15221522
pub fn new(cmd: Command, sess: &'a Session) -> AixLinker<'a> {
1523-
AixLinker { cmd, sess: sess, hinted_static: None }
1523+
AixLinker { cmd, sess, hinted_static: None }
15241524
}
15251525

15261526
fn hint_static(&mut self) {

compiler/rustc_hir_analysis/src/check/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: DefId) {
216216
}
217217
if sig.header.asyncness.is_async() {
218218
let span = tcx.def_span(it.owner_id);
219-
tcx.dcx().emit_err(errors::StartAsync { span: span });
219+
tcx.dcx().emit_err(errors::StartAsync { span });
220220
error = true;
221221
}
222222

compiler/rustc_hir_typeck/src/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
527527
{
528528
if self.check_and_add_sugg_binding(LetStmt {
529529
ty_hir_id_opt: if let Some(ty) = ty { Some(ty.hir_id) } else { None },
530-
binding_id: binding_id,
530+
binding_id,
531531
span: pat.span,
532532
init_hir_id: init.hir_id,
533533
}) {

compiler/rustc_incremental/src/persist/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ fn delete_old(sess: &Session, path: &Path) {
851851
debug!("garbage_collect_session_directories() - deleting `{}`", path.display());
852852

853853
if let Err(err) = safe_remove_dir_all(path) {
854-
sess.dcx().emit_warn(errors::SessionGcFailed { path: path, err });
854+
sess.dcx().emit_warn(errors::SessionGcFailed { path, err });
855855
} else {
856856
delete_session_dir_lock_file(sess, &lock_file_path(path));
857857
}

compiler/rustc_metadata/src/locator.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1002,11 +1002,7 @@ impl CrateError {
10021002
if !locator.crate_rejections.via_filename.is_empty() {
10031003
let mismatches = locator.crate_rejections.via_filename.iter();
10041004
for CrateMismatch { path, .. } in mismatches {
1005-
dcx.emit_err(errors::CrateLocationUnknownType {
1006-
span,
1007-
path: path,
1008-
crate_name,
1009-
});
1005+
dcx.emit_err(errors::CrateLocationUnknownType { span, path, crate_name });
10101006
dcx.emit_err(errors::LibFilenameForm {
10111007
span,
10121008
dll_prefix: &locator.dll_prefix,
@@ -1035,7 +1031,7 @@ impl CrateError {
10351031
}
10361032
dcx.emit_err(errors::NewerCrateVersion {
10371033
span,
1038-
crate_name: crate_name,
1034+
crate_name,
10391035
add_info,
10401036
found_crates,
10411037
});

compiler/rustc_mir_build/src/thir/cx/expr.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,7 @@ impl<'tcx> Cx<'tcx> {
218218
let lhs =
219219
self.thir.exprs.push(Expr { temp_lifetime, ty: discr_ty, span, kind });
220220
let bin = ExprKind::Binary { op: BinOp::Add, lhs, rhs: offset };
221-
self.thir.exprs.push(Expr {
222-
temp_lifetime,
223-
ty: discr_ty,
224-
span: span,
225-
kind: bin,
226-
})
221+
self.thir.exprs.push(Expr { temp_lifetime, ty: discr_ty, span, kind: bin })
227222
}
228223
None => offset,
229224
};

compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'tcx> ConstToPat<'tcx> {
129129
let err = TypeNotPartialEq { span: self.span, non_peq_ty: ty };
130130
let e = self.tcx().dcx().emit_err(err);
131131
let kind = PatKind::Error(e);
132-
return Box::new(Pat { span: self.span, ty: ty, kind });
132+
return Box::new(Pat { span: self.span, ty, kind });
133133
}
134134
}
135135

compiler/rustc_mir_transform/src/coroutine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ fn compute_storage_conflicts<'mir, 'tcx>(
931931
// Compute the storage conflicts for all eligible locals.
932932
let mut visitor = StorageConflictVisitor {
933933
body,
934-
saved_locals: saved_locals,
934+
saved_locals,
935935
local_conflicts: BitMatrix::from_row_n(&ineligible_locals, body.local_decls.len()),
936936
eligible_storage_live: BitSet::new_empty(body.local_decls.len()),
937937
};

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> {
338338
tcx,
339339
local_decls: &body.local_decls,
340340
ecx: InterpCx::new(tcx, DUMMY_SP, param_env, DummyMachine),
341-
param_env: param_env,
341+
param_env,
342342
}
343343
}
344344

compiler/rustc_query_impl/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub fn query_system<'tcx>(
214214
local_providers,
215215
extern_providers,
216216
encode_query_results: encode_all_query_results,
217-
try_mark_green: try_mark_green,
217+
try_mark_green,
218218
},
219219
jobs: AtomicU64::new(1),
220220
}

compiler/rustc_resolve/src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14561456
let label_span = ident.span.shrink_to_hi();
14571457
let mut spans = MultiSpan::from_span(label_span);
14581458
spans.push_span_label(label_span, "put a macro name here");
1459-
err.subdiagnostic(MaybeMissingMacroRulesName { spans: spans });
1459+
err.subdiagnostic(MaybeMissingMacroRulesName { spans });
14601460
return;
14611461
}
14621462

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ pub fn transform_instance<'tcx>(
316316
.drop_trait()
317317
.unwrap_or_else(|| bug!("typeid_for_instance: couldn't get drop_trait lang item"));
318318
let predicate = ty::ExistentialPredicate::Trait(ty::ExistentialTraitRef {
319-
def_id: def_id,
319+
def_id,
320320
args: List::empty(),
321321
});
322322
let predicates = tcx.mk_poly_existential_predicates(&[ty::Binder::dummy(predicate)]);

compiler/rustc_smir/src/rustc_smir/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub(super) fn allocation_filter<'tcx>(
132132
));
133133
}
134134
Allocation {
135-
bytes: bytes,
135+
bytes,
136136
provenance: ProvenanceMap { ptrs },
137137
align: alloc.align.bytes(),
138138
mutability: alloc.mutability.stable(tables),

compiler/rustc_trait_selection/src/traits/auto_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
770770
let reported =
771771
tcx.dcx().emit_err(UnableToConstructConstantValue {
772772
span: tcx.def_span(unevaluated.def),
773-
unevaluated: unevaluated,
773+
unevaluated,
774774
});
775775
Err(ErrorHandled::Reported(reported.into(), tcx.def_span(unevaluated.def)))
776776
}

0 commit comments

Comments
 (0)