Skip to content

Commit 709325a

Browse files
authored
Rollup merge of #69782 - matthiaskrgr:redundant_field_name_rep, r=cramertj
Don't redundantly repeat field names (clippy::redundant_field_names)
2 parents ca90c3d + 83980ac commit 709325a

File tree

61 files changed

+88
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+88
-100
lines changed

src/liballoc/collections/linked_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ impl<T> LinkedList<T> {
959959
let it = self.head;
960960
let old_len = self.len;
961961

962-
DrainFilter { list: self, it: it, pred: filter, idx: 0, old_len: old_len }
962+
DrainFilter { list: self, it, pred: filter, idx: 0, old_len }
963963
}
964964
}
965965

src/liballoc/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ struct SetLenOnDrop<'a> {
16591659
impl<'a> SetLenOnDrop<'a> {
16601660
#[inline]
16611661
fn new(len: &'a mut usize) -> Self {
1662-
SetLenOnDrop { local_len: *len, len: len }
1662+
SetLenOnDrop { local_len: *len, len }
16631663
}
16641664

16651665
#[inline]

src/libproc_macro/diagnostic.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ pub struct Diagnostic {
5555
}
5656

5757
macro_rules! diagnostic_child_methods {
58-
($spanned:ident, $regular:ident, $level:expr) => (
58+
($spanned:ident, $regular:ident, $level:expr) => {
5959
/// Adds a new child diagnostic message to `self` with the level
6060
/// identified by this method's name with the given `spans` and
6161
/// `message`.
6262
#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
6363
pub fn $spanned<S, T>(mut self, spans: S, message: T) -> Diagnostic
64-
where S: MultiSpan, T: Into<String>
64+
where
65+
S: MultiSpan,
66+
T: Into<String>,
6567
{
6668
self.children.push(Diagnostic::spanned(spans, $level, message));
6769
self
@@ -74,7 +76,7 @@ macro_rules! diagnostic_child_methods {
7476
self.children.push(Diagnostic::new($level, message));
7577
self
7678
}
77-
)
79+
};
7880
}
7981

8082
/// Iterator over the children diagnostics of a `Diagnostic`.
@@ -96,7 +98,7 @@ impl Diagnostic {
9698
/// Creates a new diagnostic with the given `level` and `message`.
9799
#[unstable(feature = "proc_macro_diagnostic", issue = "54140")]
98100
pub fn new<T: Into<String>>(level: Level, message: T) -> Diagnostic {
99-
Diagnostic { level: level, message: message.into(), spans: vec![], children: vec![] }
101+
Diagnostic { level, message: message.into(), spans: vec![], children: vec![] }
100102
}
101103

102104
/// Creates a new diagnostic with the given `level` and `message` pointing to
@@ -107,12 +109,7 @@ impl Diagnostic {
107109
S: MultiSpan,
108110
T: Into<String>,
109111
{
110-
Diagnostic {
111-
level: level,
112-
message: message.into(),
113-
spans: spans.into_spans(),
114-
children: vec![],
115-
}
112+
Diagnostic { level, message: message.into(), spans: spans.into_spans(), children: vec![] }
116113
}
117114

118115
diagnostic_child_methods!(span_error, error, Level::Error);

src/librustc/hir/map/definitions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl DefPath {
192192
}
193193
}
194194
data.reverse();
195-
DefPath { data: data, krate: krate }
195+
DefPath { data, krate }
196196
}
197197

198198
/// Returns a string representation of the `DefPath` without

src/librustc/mir/mono.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ pub enum Visibility {
258258

259259
impl<'tcx> CodegenUnit<'tcx> {
260260
pub fn new(name: Symbol) -> CodegenUnit<'tcx> {
261-
CodegenUnit { name: name, items: Default::default(), size_estimate: None }
261+
CodegenUnit { name, items: Default::default(), size_estimate: None }
262262
}
263263

264264
pub fn name(&self) -> Symbol {

src/librustc/traits/structural_impls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
532532
nested,
533533
}) => tcx.lift(&substs).map(|substs| {
534534
traits::VtableGenerator(traits::VtableGeneratorData {
535-
generator_def_id: generator_def_id,
536-
substs: substs,
537-
nested: nested,
535+
generator_def_id,
536+
substs,
537+
nested,
538538
})
539539
}),
540540
traits::VtableClosure(traits::VtableClosureData { closure_def_id, substs, nested }) => {

src/librustc/ty/context.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2256,22 +2256,22 @@ impl<'tcx> TyCtxt<'tcx> {
22562256

22572257
#[inline]
22582258
pub fn mk_mut_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
2259-
self.mk_ref(r, TypeAndMut { ty: ty, mutbl: hir::Mutability::Mut })
2259+
self.mk_ref(r, TypeAndMut { ty, mutbl: hir::Mutability::Mut })
22602260
}
22612261

22622262
#[inline]
22632263
pub fn mk_imm_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
2264-
self.mk_ref(r, TypeAndMut { ty: ty, mutbl: hir::Mutability::Not })
2264+
self.mk_ref(r, TypeAndMut { ty, mutbl: hir::Mutability::Not })
22652265
}
22662266

22672267
#[inline]
22682268
pub fn mk_mut_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> {
2269-
self.mk_ptr(TypeAndMut { ty: ty, mutbl: hir::Mutability::Mut })
2269+
self.mk_ptr(TypeAndMut { ty, mutbl: hir::Mutability::Mut })
22702270
}
22712271

22722272
#[inline]
22732273
pub fn mk_imm_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> {
2274-
self.mk_ptr(TypeAndMut { ty: ty, mutbl: hir::Mutability::Not })
2274+
self.mk_ptr(TypeAndMut { ty, mutbl: hir::Mutability::Not })
22752275
}
22762276

22772277
#[inline]
@@ -2393,7 +2393,7 @@ impl<'tcx> TyCtxt<'tcx> {
23932393

23942394
#[inline]
23952395
pub fn mk_ty_param(self, index: u32, name: Symbol) -> Ty<'tcx> {
2396-
self.mk_ty(Param(ParamTy { index, name: name }))
2396+
self.mk_ty(Param(ParamTy { index, name }))
23972397
}
23982398

23992399
#[inline]

src/librustc/ty/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<'tcx> Instance<'tcx> {
241241
def_id,
242242
substs
243243
);
244-
Instance { def: InstanceDef::Item(def_id), substs: substs }
244+
Instance { def: InstanceDef::Item(def_id), substs }
245245
}
246246

247247
pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> {

src/librustc/ty/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ pub trait DefIdTree: Copy {
370370

371371
impl<'tcx> DefIdTree for TyCtxt<'tcx> {
372372
fn parent(self, id: DefId) -> Option<DefId> {
373-
self.def_key(id).parent.map(|index| DefId { index: index, ..id })
373+
self.def_key(id).parent.map(|index| DefId { index, ..id })
374374
}
375375
}
376376

@@ -2227,7 +2227,7 @@ impl ReprOptions {
22272227
if !tcx.consider_optimizing(|| format!("Reorder fields of {:?}", tcx.def_path_str(did))) {
22282228
flags.insert(ReprFlags::IS_LINEAR);
22292229
}
2230-
ReprOptions { int: size, align: max_align, pack: min_pack, flags: flags }
2230+
ReprOptions { int: size, align: max_align, pack: min_pack, flags }
22312231
}
22322232

22332233
#[inline]

src/librustc/ty/normalize_erasing_regions.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ impl<'tcx> TyCtxt<'tcx> {
3434
if !value.has_projections() {
3535
value
3636
} else {
37-
value.fold_with(&mut NormalizeAfterErasingRegionsFolder {
38-
tcx: self,
39-
param_env: param_env,
40-
})
37+
value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, param_env })
4138
}
4239
}
4340

src/librustc/ty/relate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> {
287287
Err(TypeError::Traits(expected_found(relation, &a.def_id, &b.def_id)))
288288
} else {
289289
let substs = relate_substs(relation, None, a.substs, b.substs)?;
290-
Ok(ty::TraitRef { def_id: a.def_id, substs: substs })
290+
Ok(ty::TraitRef { def_id: a.def_id, substs })
291291
}
292292
}
293293
}
@@ -303,7 +303,7 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> {
303303
Err(TypeError::Traits(expected_found(relation, &a.def_id, &b.def_id)))
304304
} else {
305305
let substs = relate_substs(relation, None, a.substs, b.substs)?;
306-
Ok(ty::ExistentialTraitRef { def_id: a.def_id, substs: substs })
306+
Ok(ty::ExistentialTraitRef { def_id: a.def_id, substs })
307307
}
308308
}
309309
}

src/librustc/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ pub struct ParamTy {
11931193

11941194
impl<'tcx> ParamTy {
11951195
pub fn new(index: u32, name: Symbol) -> ParamTy {
1196-
ParamTy { index, name: name }
1196+
ParamTy { index, name }
11971197
}
11981198

11991199
pub fn for_self() -> ParamTy {

src/librustc_builtin_macros/deriving/generic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ impl<'a> TraitDef<'a> {
482482
})
483483
.cloned(),
484484
);
485-
push(Annotatable::Item(P(ast::Item { attrs: attrs, ..(*newitem).clone() })))
485+
push(Annotatable::Item(P(ast::Item { attrs, ..(*newitem).clone() })))
486486
}
487487
_ => {
488488
// Non-Item derive is an error, but it should have been

src/librustc_codegen_llvm/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl LlvmType for CastTarget {
148148
.prefix
149149
.iter()
150150
.flat_map(|option_kind| {
151-
option_kind.map(|kind| Reg { kind: kind, size: self.prefix_chunk }.llvm_type(cx))
151+
option_kind.map(|kind| Reg { kind, size: self.prefix_chunk }.llvm_type(cx))
152152
})
153153
.chain((0..rest_count).map(|_| rest_ll_unit))
154154
.collect();

src/librustc_infer/infer/at.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
179179
T: ToTrace<'tcx>,
180180
{
181181
let trace = ToTrace::to_trace(self.cause, a_is_expected, a, b);
182-
Trace { at: self, trace: trace, a_is_expected }
182+
Trace { at: self, trace, a_is_expected }
183183
}
184184
}
185185

src/librustc_infer/infer/equate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl<'combine, 'infcx, 'tcx> Equate<'combine, 'infcx, 'tcx> {
1919
fields: &'combine mut CombineFields<'infcx, 'tcx>,
2020
a_is_expected: bool,
2121
) -> Equate<'combine, 'infcx, 'tcx> {
22-
Equate { fields: fields, a_is_expected: a_is_expected }
22+
Equate { fields, a_is_expected }
2323
}
2424
}
2525

src/librustc_infer/infer/error_reporting/nice_region_error/util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
7777
if found_anon_region {
7878
let is_first = index == 0;
7979
Some(AnonymousParamInfo {
80-
param: param,
80+
param,
8181
param_ty: new_param_ty,
82-
param_ty_span: param_ty_span,
83-
bound_region: bound_region,
84-
is_first: is_first,
82+
param_ty_span,
83+
bound_region,
84+
is_first,
8585
})
8686
} else {
8787
None

src/librustc_infer/infer/glb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl<'combine, 'infcx, 'tcx> Glb<'combine, 'infcx, 'tcx> {
1818
fields: &'combine mut CombineFields<'infcx, 'tcx>,
1919
a_is_expected: bool,
2020
) -> Glb<'combine, 'infcx, 'tcx> {
21-
Glb { fields: fields, a_is_expected: a_is_expected }
21+
Glb { fields, a_is_expected }
2222
}
2323
}
2424

src/librustc_infer/infer/lub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl<'combine, 'infcx, 'tcx> Lub<'combine, 'infcx, 'tcx> {
1818
fields: &'combine mut CombineFields<'infcx, 'tcx>,
1919
a_is_expected: bool,
2020
) -> Lub<'combine, 'infcx, 'tcx> {
21-
Lub { fields: fields, a_is_expected: a_is_expected }
21+
Lub { fields, a_is_expected }
2222
}
2323
}
2424

src/librustc_infer/infer/region_constraints/leak_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'tcx> TaintSet<'tcx> {
8585
fn new(directions: TaintDirections, initial_region: ty::Region<'tcx>) -> Self {
8686
let mut regions = FxHashSet::default();
8787
regions.insert(initial_region);
88-
TaintSet { directions: directions, regions: regions }
88+
TaintSet { directions, regions }
8989
}
9090

9191
fn fixed_point(

src/librustc_infer/infer/region_constraints/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> {
766766
b: Region<'tcx>,
767767
origin: SubregionOrigin<'tcx>,
768768
) -> Region<'tcx> {
769-
let vars = TwoRegions { a: a, b: b };
769+
let vars = TwoRegions { a, b };
770770
if let Some(&c) = self.combine_map(t).get(&vars) {
771771
return tcx.mk_region(ReVar(c));
772772
}

src/librustc_infer/infer/resolve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, value: &T) -> Fix
160160
where
161161
T: TypeFoldable<'tcx>,
162162
{
163-
let mut full_resolver = FullTypeResolver { infcx: infcx, err: None };
163+
let mut full_resolver = FullTypeResolver { infcx, err: None };
164164
let result = value.fold_with(&mut full_resolver);
165165
match full_resolver.err {
166166
None => Ok(result),

src/librustc_infer/infer/sub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl<'combine, 'infcx, 'tcx> Sub<'combine, 'infcx, 'tcx> {
1919
f: &'combine mut CombineFields<'infcx, 'tcx>,
2020
a_is_expected: bool,
2121
) -> Sub<'combine, 'infcx, 'tcx> {
22-
Sub { fields: f, a_is_expected: a_is_expected }
22+
Sub { fields: f, a_is_expected }
2323
}
2424

2525
fn with_expected_switched<R, F: FnOnce(&mut Self) -> R>(&mut self, f: F) -> R {

src/librustc_infer/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ impl<'tcx> FulfillmentError<'tcx> {
619619
obligation: PredicateObligation<'tcx>,
620620
code: FulfillmentErrorCode<'tcx>,
621621
) -> FulfillmentError<'tcx> {
622-
FulfillmentError { obligation: obligation, code: code, points_at_arg_span: false }
622+
FulfillmentError { obligation, code, points_at_arg_span: false }
623623
}
624624
}
625625

src/librustc_infer/traits/project.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ pub type NormalizedTy<'tcx> = Normalized<'tcx, Ty<'tcx>>;
403403

404404
impl<'tcx, T> Normalized<'tcx, T> {
405405
pub fn with<U>(self, value: U) -> Normalized<'tcx, U> {
406-
Normalized { value: value, obligations: self.obligations }
406+
Normalized { value, obligations: self.obligations }
407407
}
408408
}
409409

@@ -1291,7 +1291,7 @@ fn confirm_generator_candidate<'cx, 'tcx>(
12911291
substs: trait_ref.substs,
12921292
item_def_id: obligation.predicate.item_def_id,
12931293
},
1294-
ty: ty,
1294+
ty,
12951295
}
12961296
});
12971297

src/librustc_infer/traits/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2923,7 +2923,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
29232923
ty::Predicate::ClosureKind(closure_def_id, substs, kind),
29242924
));
29252925

2926-
Ok(VtableClosureData { closure_def_id, substs: substs, nested: obligations })
2926+
Ok(VtableClosureData { closure_def_id, substs, nested: obligations })
29272927
}
29282928

29292929
/// In the case of closure types and fn pointers,

src/librustc_infer/traits/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct PredicateSet<'tcx> {
5555

5656
impl PredicateSet<'tcx> {
5757
fn new(tcx: TyCtxt<'tcx>) -> Self {
58-
Self { tcx: tcx, set: Default::default() }
58+
Self { tcx, set: Default::default() }
5959
}
6060

6161
fn insert(&mut self, pred: &ty::Predicate<'tcx>) -> bool {

src/librustc_lint/levels.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,10 @@ impl<'s> LintLevelsBuilder<'s> {
377377
let prev = self.cur;
378378
if !specs.is_empty() {
379379
self.cur = self.sets.list.len() as u32;
380-
self.sets.list.push(LintSet::Node { specs: specs, parent: prev });
380+
self.sets.list.push(LintSet::Node { specs, parent: prev });
381381
}
382382

383-
BuilderPush { prev: prev, changed: prev != self.cur }
383+
BuilderPush { prev, changed: prev != self.cur }
384384
}
385385

386386
/// Called after `push` when the scope of a set of attributes are exited.

src/librustc_metadata/rmeta/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ impl<'tcx> EncodeContext<'tcx> {
493493
edition: tcx.sess.edition(),
494494
has_global_allocator: tcx.has_global_allocator(LOCAL_CRATE),
495495
has_panic_handler: tcx.has_panic_handler(LOCAL_CRATE),
496-
has_default_lib_allocator: has_default_lib_allocator,
496+
has_default_lib_allocator,
497497
plugin_registrar_fn: tcx.plugin_registrar_fn(LOCAL_CRATE).map(|id| id.index),
498498
proc_macro_decls_static: if is_proc_macro {
499499
let id = tcx.proc_macro_decls_static(LOCAL_CRATE).unwrap();

src/librustc_mir/borrow_check/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
175175
if self.body.local_decls[local].is_ref_for_guard() =>
176176
{
177177
self.append_place_to_string(
178-
PlaceRef { local: local, projection: &[] },
178+
PlaceRef { local, projection: &[] },
179179
buf,
180180
autoderef,
181181
&including_downcast,

src/librustc_mir/borrow_check/region_infer/values.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<N: Idx> LivenessValues<N> {
140140
/// Each of the regions in num_region_variables will be initialized with an
141141
/// empty set of points and no causal information.
142142
crate fn new(elements: Rc<RegionValueElements>) -> Self {
143-
Self { points: SparseBitMatrix::new(elements.num_points), elements: elements }
143+
Self { points: SparseBitMatrix::new(elements.num_points), elements }
144144
}
145145

146146
/// Iterate through each region that has a value in this set.

0 commit comments

Comments
 (0)