From 83980aca2086e5c4dca5aae9a92a065a9ff4ac56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 6 Mar 2020 19:28:44 +0100 Subject: [PATCH] Don't redundantly repeat field names (clippy::redundant_field_names) --- src/liballoc/collections/linked_list.rs | 2 +- src/liballoc/vec.rs | 2 +- src/libproc_macro/diagnostic.rs | 17 +++++++---------- src/librustc/hir/map/definitions.rs | 2 +- src/librustc/mir/mono.rs | 2 +- src/librustc/traits/structural_impls.rs | 6 +++--- src/librustc/ty/context.rs | 10 +++++----- src/librustc/ty/instance.rs | 2 +- src/librustc/ty/mod.rs | 4 ++-- src/librustc/ty/normalize_erasing_regions.rs | 5 +---- src/librustc/ty/relate.rs | 4 ++-- src/librustc/ty/sty.rs | 2 +- .../deriving/generic/mod.rs | 2 +- src/librustc_codegen_llvm/abi.rs | 2 +- src/librustc_infer/infer/at.rs | 2 +- src/librustc_infer/infer/equate.rs | 2 +- .../error_reporting/nice_region_error/util.rs | 8 ++++---- src/librustc_infer/infer/glb.rs | 2 +- src/librustc_infer/infer/lub.rs | 2 +- .../infer/region_constraints/leak_check.rs | 2 +- .../infer/region_constraints/mod.rs | 2 +- src/librustc_infer/infer/resolve.rs | 2 +- src/librustc_infer/infer/sub.rs | 2 +- src/librustc_infer/traits/mod.rs | 2 +- src/librustc_infer/traits/project.rs | 4 ++-- src/librustc_infer/traits/select.rs | 2 +- src/librustc_infer/traits/util.rs | 2 +- src/librustc_lint/levels.rs | 4 ++-- src/librustc_metadata/rmeta/encoder.rs | 2 +- .../borrow_check/diagnostics/mod.rs | 2 +- .../borrow_check/region_infer/values.rs | 2 +- .../borrow_check/universal_regions.rs | 2 +- src/librustc_mir/dataflow/graphviz.rs | 2 +- src/librustc_mir/dataflow/move_paths/builder.rs | 2 +- src/librustc_mir/interpret/place.rs | 2 +- src/librustc_mir/monomorphize/mod.rs | 2 +- src/librustc_mir/transform/add_retag.rs | 4 ++-- src/librustc_mir/transform/generator.rs | 2 +- src/librustc_mir/transform/rustc_peek.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 4 ++-- src/librustc_mir/util/pretty.rs | 2 +- .../build/matches/simplify.rs | 2 +- src/librustc_mir_build/build/matches/test.rs | 5 +---- src/librustc_mir_build/build/mod.rs | 2 +- src/librustc_mir_build/hair/cx/block.rs | 2 +- src/librustc_resolve/late.rs | 2 +- src/librustc_resolve/late/lifetimes.rs | 8 ++++---- src/librustc_save_analysis/lib.rs | 2 +- src/librustc_save_analysis/sig.rs | 2 +- src/librustc_session/code_stats.rs | 2 +- src/librustc_span/def_id.rs | 2 +- src/librustc_ty/instance.rs | 2 +- src/librustc_typeck/check/expr.rs | 2 +- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/outlives/implicit_infer.rs | 4 ++-- src/librustdoc/doctree.rs | 2 +- src/libstd/collections/hash/map.rs | 2 +- src/libstd/io/cursor.rs | 2 +- src/libstd/io/mod.rs | 4 ++-- src/libstd/sync/mutex.rs | 2 +- src/libstd/sync/rwlock.rs | 7 ++----- 61 files changed, 88 insertions(+), 100 deletions(-) diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index a9b4e3e4706b8..8efacf108fc2f 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -959,7 +959,7 @@ impl LinkedList { let it = self.head; let old_len = self.len; - DrainFilter { list: self, it: it, pred: filter, idx: 0, old_len: old_len } + DrainFilter { list: self, it, pred: filter, idx: 0, old_len } } } diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 3fd7be06fd4fc..7523d9c5ba3b1 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1659,7 +1659,7 @@ struct SetLenOnDrop<'a> { impl<'a> SetLenOnDrop<'a> { #[inline] fn new(len: &'a mut usize) -> Self { - SetLenOnDrop { local_len: *len, len: len } + SetLenOnDrop { local_len: *len, len } } #[inline] diff --git a/src/libproc_macro/diagnostic.rs b/src/libproc_macro/diagnostic.rs index fdf252e53387e..7495468a05b6c 100644 --- a/src/libproc_macro/diagnostic.rs +++ b/src/libproc_macro/diagnostic.rs @@ -55,13 +55,15 @@ pub struct Diagnostic { } macro_rules! diagnostic_child_methods { - ($spanned:ident, $regular:ident, $level:expr) => ( + ($spanned:ident, $regular:ident, $level:expr) => { /// Adds a new child diagnostic message to `self` with the level /// identified by this method's name with the given `spans` and /// `message`. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub fn $spanned(mut self, spans: S, message: T) -> Diagnostic - where S: MultiSpan, T: Into + where + S: MultiSpan, + T: Into, { self.children.push(Diagnostic::spanned(spans, $level, message)); self @@ -74,7 +76,7 @@ macro_rules! diagnostic_child_methods { self.children.push(Diagnostic::new($level, message)); self } - ) + }; } /// Iterator over the children diagnostics of a `Diagnostic`. @@ -96,7 +98,7 @@ impl Diagnostic { /// Creates a new diagnostic with the given `level` and `message`. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub fn new>(level: Level, message: T) -> Diagnostic { - Diagnostic { level: level, message: message.into(), spans: vec![], children: vec![] } + Diagnostic { level, message: message.into(), spans: vec![], children: vec![] } } /// Creates a new diagnostic with the given `level` and `message` pointing to @@ -107,12 +109,7 @@ impl Diagnostic { S: MultiSpan, T: Into, { - Diagnostic { - level: level, - message: message.into(), - spans: spans.into_spans(), - children: vec![], - } + Diagnostic { level, message: message.into(), spans: spans.into_spans(), children: vec![] } } diagnostic_child_methods!(span_error, error, Level::Error); diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index 047ce8b8445fd..e1b5ec041db06 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -192,7 +192,7 @@ impl DefPath { } } data.reverse(); - DefPath { data: data, krate: krate } + DefPath { data, krate } } /// Returns a string representation of the `DefPath` without diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index 9a3ddfb0e82c9..4f8efc1607eaa 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -258,7 +258,7 @@ pub enum Visibility { impl<'tcx> CodegenUnit<'tcx> { pub fn new(name: Symbol) -> CodegenUnit<'tcx> { - CodegenUnit { name: name, items: Default::default(), size_estimate: None } + CodegenUnit { name, items: Default::default(), size_estimate: None } } pub fn name(&self) -> Symbol { diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index 63d7124ee91f9..a5efea9e5fa4d 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -532,9 +532,9 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> { nested, }) => tcx.lift(&substs).map(|substs| { traits::VtableGenerator(traits::VtableGeneratorData { - generator_def_id: generator_def_id, - substs: substs, - nested: nested, + generator_def_id, + substs, + nested, }) }), traits::VtableClosure(traits::VtableClosureData { closure_def_id, substs, nested }) => { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 20736b50831bb..48ef81c1d5bf7 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2256,22 +2256,22 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn mk_mut_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { - self.mk_ref(r, TypeAndMut { ty: ty, mutbl: hir::Mutability::Mut }) + self.mk_ref(r, TypeAndMut { ty, mutbl: hir::Mutability::Mut }) } #[inline] pub fn mk_imm_ref(self, r: Region<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { - self.mk_ref(r, TypeAndMut { ty: ty, mutbl: hir::Mutability::Not }) + self.mk_ref(r, TypeAndMut { ty, mutbl: hir::Mutability::Not }) } #[inline] pub fn mk_mut_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> { - self.mk_ptr(TypeAndMut { ty: ty, mutbl: hir::Mutability::Mut }) + self.mk_ptr(TypeAndMut { ty, mutbl: hir::Mutability::Mut }) } #[inline] pub fn mk_imm_ptr(self, ty: Ty<'tcx>) -> Ty<'tcx> { - self.mk_ptr(TypeAndMut { ty: ty, mutbl: hir::Mutability::Not }) + self.mk_ptr(TypeAndMut { ty, mutbl: hir::Mutability::Not }) } #[inline] @@ -2393,7 +2393,7 @@ impl<'tcx> TyCtxt<'tcx> { #[inline] pub fn mk_ty_param(self, index: u32, name: Symbol) -> Ty<'tcx> { - self.mk_ty(Param(ParamTy { index, name: name })) + self.mk_ty(Param(ParamTy { index, name })) } #[inline] diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index 4014d1d8ae250..445df76cd32be 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -241,7 +241,7 @@ impl<'tcx> Instance<'tcx> { def_id, substs ); - Instance { def: InstanceDef::Item(def_id), substs: substs } + Instance { def: InstanceDef::Item(def_id), substs } } pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index b25fd3c61fd5d..7bcd63b965534 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -370,7 +370,7 @@ pub trait DefIdTree: Copy { impl<'tcx> DefIdTree for TyCtxt<'tcx> { fn parent(self, id: DefId) -> Option { - self.def_key(id).parent.map(|index| DefId { index: index, ..id }) + self.def_key(id).parent.map(|index| DefId { index, ..id }) } } @@ -2227,7 +2227,7 @@ impl ReprOptions { if !tcx.consider_optimizing(|| format!("Reorder fields of {:?}", tcx.def_path_str(did))) { flags.insert(ReprFlags::IS_LINEAR); } - ReprOptions { int: size, align: max_align, pack: min_pack, flags: flags } + ReprOptions { int: size, align: max_align, pack: min_pack, flags } } #[inline] diff --git a/src/librustc/ty/normalize_erasing_regions.rs b/src/librustc/ty/normalize_erasing_regions.rs index dc64482907f75..cbaabd8e1f137 100644 --- a/src/librustc/ty/normalize_erasing_regions.rs +++ b/src/librustc/ty/normalize_erasing_regions.rs @@ -34,10 +34,7 @@ impl<'tcx> TyCtxt<'tcx> { if !value.has_projections() { value } else { - value.fold_with(&mut NormalizeAfterErasingRegionsFolder { - tcx: self, - param_env: param_env, - }) + value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, param_env }) } } diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index 3b9df72266f09..10f27bf66f383 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -287,7 +287,7 @@ impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> { Err(TypeError::Traits(expected_found(relation, &a.def_id, &b.def_id))) } else { let substs = relate_substs(relation, None, a.substs, b.substs)?; - Ok(ty::TraitRef { def_id: a.def_id, substs: substs }) + Ok(ty::TraitRef { def_id: a.def_id, substs }) } } } @@ -303,7 +303,7 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> { Err(TypeError::Traits(expected_found(relation, &a.def_id, &b.def_id))) } else { let substs = relate_substs(relation, None, a.substs, b.substs)?; - Ok(ty::ExistentialTraitRef { def_id: a.def_id, substs: substs }) + Ok(ty::ExistentialTraitRef { def_id: a.def_id, substs }) } } } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index ab2c98c89b4e6..47bf7822b1f55 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1193,7 +1193,7 @@ pub struct ParamTy { impl<'tcx> ParamTy { pub fn new(index: u32, name: Symbol) -> ParamTy { - ParamTy { index, name: name } + ParamTy { index, name } } pub fn for_self() -> ParamTy { diff --git a/src/librustc_builtin_macros/deriving/generic/mod.rs b/src/librustc_builtin_macros/deriving/generic/mod.rs index 311298c0f4083..e0c619fcbd378 100644 --- a/src/librustc_builtin_macros/deriving/generic/mod.rs +++ b/src/librustc_builtin_macros/deriving/generic/mod.rs @@ -482,7 +482,7 @@ impl<'a> TraitDef<'a> { }) .cloned(), ); - push(Annotatable::Item(P(ast::Item { attrs: attrs, ..(*newitem).clone() }))) + push(Annotatable::Item(P(ast::Item { attrs, ..(*newitem).clone() }))) } _ => { // Non-Item derive is an error, but it should have been diff --git a/src/librustc_codegen_llvm/abi.rs b/src/librustc_codegen_llvm/abi.rs index c79d9f77e654e..470a2bb8e1ea5 100644 --- a/src/librustc_codegen_llvm/abi.rs +++ b/src/librustc_codegen_llvm/abi.rs @@ -148,7 +148,7 @@ impl LlvmType for CastTarget { .prefix .iter() .flat_map(|option_kind| { - option_kind.map(|kind| Reg { kind: kind, size: self.prefix_chunk }.llvm_type(cx)) + option_kind.map(|kind| Reg { kind, size: self.prefix_chunk }.llvm_type(cx)) }) .chain((0..rest_count).map(|_| rest_ll_unit)) .collect(); diff --git a/src/librustc_infer/infer/at.rs b/src/librustc_infer/infer/at.rs index 156b5a8b0b50b..04f5b03c0e15c 100644 --- a/src/librustc_infer/infer/at.rs +++ b/src/librustc_infer/infer/at.rs @@ -179,7 +179,7 @@ impl<'a, 'tcx> At<'a, 'tcx> { T: ToTrace<'tcx>, { let trace = ToTrace::to_trace(self.cause, a_is_expected, a, b); - Trace { at: self, trace: trace, a_is_expected } + Trace { at: self, trace, a_is_expected } } } diff --git a/src/librustc_infer/infer/equate.rs b/src/librustc_infer/infer/equate.rs index c1eec6832b826..bb0c124a1892d 100644 --- a/src/librustc_infer/infer/equate.rs +++ b/src/librustc_infer/infer/equate.rs @@ -19,7 +19,7 @@ impl<'combine, 'infcx, 'tcx> Equate<'combine, 'infcx, 'tcx> { fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, ) -> Equate<'combine, 'infcx, 'tcx> { - Equate { fields: fields, a_is_expected: a_is_expected } + Equate { fields, a_is_expected } } } diff --git a/src/librustc_infer/infer/error_reporting/nice_region_error/util.rs b/src/librustc_infer/infer/error_reporting/nice_region_error/util.rs index 4dc9096533b84..cab632935fd8e 100644 --- a/src/librustc_infer/infer/error_reporting/nice_region_error/util.rs +++ b/src/librustc_infer/infer/error_reporting/nice_region_error/util.rs @@ -77,11 +77,11 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { if found_anon_region { let is_first = index == 0; Some(AnonymousParamInfo { - param: param, + param, param_ty: new_param_ty, - param_ty_span: param_ty_span, - bound_region: bound_region, - is_first: is_first, + param_ty_span, + bound_region, + is_first, }) } else { None diff --git a/src/librustc_infer/infer/glb.rs b/src/librustc_infer/infer/glb.rs index 2634d9cac3e99..8b26bcef57304 100644 --- a/src/librustc_infer/infer/glb.rs +++ b/src/librustc_infer/infer/glb.rs @@ -18,7 +18,7 @@ impl<'combine, 'infcx, 'tcx> Glb<'combine, 'infcx, 'tcx> { fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, ) -> Glb<'combine, 'infcx, 'tcx> { - Glb { fields: fields, a_is_expected: a_is_expected } + Glb { fields, a_is_expected } } } diff --git a/src/librustc_infer/infer/lub.rs b/src/librustc_infer/infer/lub.rs index b6d20ba1f3f12..20ddeec68503a 100644 --- a/src/librustc_infer/infer/lub.rs +++ b/src/librustc_infer/infer/lub.rs @@ -18,7 +18,7 @@ impl<'combine, 'infcx, 'tcx> Lub<'combine, 'infcx, 'tcx> { fields: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, ) -> Lub<'combine, 'infcx, 'tcx> { - Lub { fields: fields, a_is_expected: a_is_expected } + Lub { fields, a_is_expected } } } diff --git a/src/librustc_infer/infer/region_constraints/leak_check.rs b/src/librustc_infer/infer/region_constraints/leak_check.rs index bbd4f3b35508e..6ebe3f5759760 100644 --- a/src/librustc_infer/infer/region_constraints/leak_check.rs +++ b/src/librustc_infer/infer/region_constraints/leak_check.rs @@ -85,7 +85,7 @@ impl<'tcx> TaintSet<'tcx> { fn new(directions: TaintDirections, initial_region: ty::Region<'tcx>) -> Self { let mut regions = FxHashSet::default(); regions.insert(initial_region); - TaintSet { directions: directions, regions: regions } + TaintSet { directions, regions } } fn fixed_point( diff --git a/src/librustc_infer/infer/region_constraints/mod.rs b/src/librustc_infer/infer/region_constraints/mod.rs index 3f9fa6459b37f..868b95043796b 100644 --- a/src/librustc_infer/infer/region_constraints/mod.rs +++ b/src/librustc_infer/infer/region_constraints/mod.rs @@ -766,7 +766,7 @@ impl<'tcx> RegionConstraintCollector<'tcx> { b: Region<'tcx>, origin: SubregionOrigin<'tcx>, ) -> Region<'tcx> { - let vars = TwoRegions { a: a, b: b }; + let vars = TwoRegions { a, b }; if let Some(&c) = self.combine_map(t).get(&vars) { return tcx.mk_region(ReVar(c)); } diff --git a/src/librustc_infer/infer/resolve.rs b/src/librustc_infer/infer/resolve.rs index e2207d08ee61b..562fbc246f7ee 100644 --- a/src/librustc_infer/infer/resolve.rs +++ b/src/librustc_infer/infer/resolve.rs @@ -160,7 +160,7 @@ pub fn fully_resolve<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, value: &T) -> Fix where T: TypeFoldable<'tcx>, { - let mut full_resolver = FullTypeResolver { infcx: infcx, err: None }; + let mut full_resolver = FullTypeResolver { infcx, err: None }; let result = value.fold_with(&mut full_resolver); match full_resolver.err { None => Ok(result), diff --git a/src/librustc_infer/infer/sub.rs b/src/librustc_infer/infer/sub.rs index 2b770ced42a55..f6fc38b535887 100644 --- a/src/librustc_infer/infer/sub.rs +++ b/src/librustc_infer/infer/sub.rs @@ -19,7 +19,7 @@ impl<'combine, 'infcx, 'tcx> Sub<'combine, 'infcx, 'tcx> { f: &'combine mut CombineFields<'infcx, 'tcx>, a_is_expected: bool, ) -> Sub<'combine, 'infcx, 'tcx> { - Sub { fields: f, a_is_expected: a_is_expected } + Sub { fields: f, a_is_expected } } fn with_expected_switched R>(&mut self, f: F) -> R { diff --git a/src/librustc_infer/traits/mod.rs b/src/librustc_infer/traits/mod.rs index 61702d74f1a91..800f8e91a7801 100644 --- a/src/librustc_infer/traits/mod.rs +++ b/src/librustc_infer/traits/mod.rs @@ -619,7 +619,7 @@ impl<'tcx> FulfillmentError<'tcx> { obligation: PredicateObligation<'tcx>, code: FulfillmentErrorCode<'tcx>, ) -> FulfillmentError<'tcx> { - FulfillmentError { obligation: obligation, code: code, points_at_arg_span: false } + FulfillmentError { obligation, code, points_at_arg_span: false } } } diff --git a/src/librustc_infer/traits/project.rs b/src/librustc_infer/traits/project.rs index 34889c6984bb0..78483cf6577de 100644 --- a/src/librustc_infer/traits/project.rs +++ b/src/librustc_infer/traits/project.rs @@ -403,7 +403,7 @@ pub type NormalizedTy<'tcx> = Normalized<'tcx, Ty<'tcx>>; impl<'tcx, T> Normalized<'tcx, T> { pub fn with(self, value: U) -> Normalized<'tcx, U> { - Normalized { value: value, obligations: self.obligations } + Normalized { value, obligations: self.obligations } } } @@ -1291,7 +1291,7 @@ fn confirm_generator_candidate<'cx, 'tcx>( substs: trait_ref.substs, item_def_id: obligation.predicate.item_def_id, }, - ty: ty, + ty, } }); diff --git a/src/librustc_infer/traits/select.rs b/src/librustc_infer/traits/select.rs index fd94e3b69940c..c0d8f3cfd4f86 100644 --- a/src/librustc_infer/traits/select.rs +++ b/src/librustc_infer/traits/select.rs @@ -2923,7 +2923,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ty::Predicate::ClosureKind(closure_def_id, substs, kind), )); - Ok(VtableClosureData { closure_def_id, substs: substs, nested: obligations }) + Ok(VtableClosureData { closure_def_id, substs, nested: obligations }) } /// In the case of closure types and fn pointers, diff --git a/src/librustc_infer/traits/util.rs b/src/librustc_infer/traits/util.rs index 1dca01b3468ae..cd4595e76ccec 100644 --- a/src/librustc_infer/traits/util.rs +++ b/src/librustc_infer/traits/util.rs @@ -55,7 +55,7 @@ struct PredicateSet<'tcx> { impl PredicateSet<'tcx> { fn new(tcx: TyCtxt<'tcx>) -> Self { - Self { tcx: tcx, set: Default::default() } + Self { tcx, set: Default::default() } } fn insert(&mut self, pred: &ty::Predicate<'tcx>) -> bool { diff --git a/src/librustc_lint/levels.rs b/src/librustc_lint/levels.rs index 7da69f3ed26f2..e0db2ae64ff21 100644 --- a/src/librustc_lint/levels.rs +++ b/src/librustc_lint/levels.rs @@ -377,10 +377,10 @@ impl<'s> LintLevelsBuilder<'s> { let prev = self.cur; if !specs.is_empty() { self.cur = self.sets.list.len() as u32; - self.sets.list.push(LintSet::Node { specs: specs, parent: prev }); + self.sets.list.push(LintSet::Node { specs, parent: prev }); } - BuilderPush { prev: prev, changed: prev != self.cur } + BuilderPush { prev, changed: prev != self.cur } } /// Called after `push` when the scope of a set of attributes are exited. diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index ea0cc2f0c8bf2..7624b1d562f08 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -493,7 +493,7 @@ impl<'tcx> EncodeContext<'tcx> { edition: tcx.sess.edition(), has_global_allocator: tcx.has_global_allocator(LOCAL_CRATE), has_panic_handler: tcx.has_panic_handler(LOCAL_CRATE), - has_default_lib_allocator: has_default_lib_allocator, + has_default_lib_allocator, plugin_registrar_fn: tcx.plugin_registrar_fn(LOCAL_CRATE).map(|id| id.index), proc_macro_decls_static: if is_proc_macro { let id = tcx.proc_macro_decls_static(LOCAL_CRATE).unwrap(); diff --git a/src/librustc_mir/borrow_check/diagnostics/mod.rs b/src/librustc_mir/borrow_check/diagnostics/mod.rs index cd6834a5a4d00..fefef69d63cbd 100644 --- a/src/librustc_mir/borrow_check/diagnostics/mod.rs +++ b/src/librustc_mir/borrow_check/diagnostics/mod.rs @@ -175,7 +175,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { if self.body.local_decls[local].is_ref_for_guard() => { self.append_place_to_string( - PlaceRef { local: local, projection: &[] }, + PlaceRef { local, projection: &[] }, buf, autoderef, &including_downcast, diff --git a/src/librustc_mir/borrow_check/region_infer/values.rs b/src/librustc_mir/borrow_check/region_infer/values.rs index 3126d44014b4e..675463cb1c1f9 100644 --- a/src/librustc_mir/borrow_check/region_infer/values.rs +++ b/src/librustc_mir/borrow_check/region_infer/values.rs @@ -140,7 +140,7 @@ impl LivenessValues { /// Each of the regions in num_region_variables will be initialized with an /// empty set of points and no causal information. crate fn new(elements: Rc) -> Self { - Self { points: SparseBitMatrix::new(elements.num_points), elements: elements } + Self { points: SparseBitMatrix::new(elements.num_points), elements } } /// Iterate through each region that has a value in this set. diff --git a/src/librustc_mir/borrow_check/universal_regions.rs b/src/librustc_mir/borrow_check/universal_regions.rs index af4ea759f4f8b..67b00e9ffdd5f 100644 --- a/src/librustc_mir/borrow_check/universal_regions.rs +++ b/src/librustc_mir/borrow_check/universal_regions.rs @@ -486,7 +486,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { defining_ty, unnormalized_output_ty, unnormalized_input_tys, - yield_ty: yield_ty, + yield_ty, } } diff --git a/src/librustc_mir/dataflow/graphviz.rs b/src/librustc_mir/dataflow/graphviz.rs index 45d2b1a71f0f2..a9ef7ef6c528a 100644 --- a/src/librustc_mir/dataflow/graphviz.rs +++ b/src/librustc_mir/dataflow/graphviz.rs @@ -72,7 +72,7 @@ pub struct Edge { fn outgoing(body: &Body<'_>, bb: BasicBlock) -> Vec { (0..body[bb].terminator().successors().count()) - .map(|index| Edge { source: bb, index: index }) + .map(|index| Edge { source: bb, index }) .collect() } diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 57aa5de7f7a31..7e36a3cf2bfec 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -474,7 +474,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> { } fn record_move(&mut self, place: &Place<'tcx>, path: MovePathIndex) { - let move_out = self.builder.data.moves.push(MoveOut { path: path, source: self.loc }); + let move_out = self.builder.data.moves.push(MoveOut { path, source: self.loc }); debug!( "gather_move({:?}, {:?}): adding move {:?} of {:?}", self.loc, place, move_out, path diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 4f96cb698915d..4cf179f5fcecf 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -647,7 +647,7 @@ where } local => PlaceTy { // This works even for dead/uninitialized locals; we check further when writing - place: Place::Local { frame: self.cur_frame(), local: local }, + place: Place::Local { frame: self.cur_frame(), local }, layout: self.layout_of_local(self.frame(), local, None)?, }, }; diff --git a/src/librustc_mir/monomorphize/mod.rs b/src/librustc_mir/monomorphize/mod.rs index 3dff06967e50e..7177bf726d403 100644 --- a/src/librustc_mir/monomorphize/mod.rs +++ b/src/librustc_mir/monomorphize/mod.rs @@ -13,7 +13,7 @@ pub fn custom_coerce_unsize_info<'tcx>( let def_id = tcx.lang_items().coerce_unsized_trait().unwrap(); let trait_ref = ty::Binder::bind(ty::TraitRef { - def_id: def_id, + def_id, substs: tcx.mk_substs_trait(source_ty, &[target_ty.into()]), }); diff --git a/src/librustc_mir/transform/add_retag.rs b/src/librustc_mir/transform/add_retag.rs index a5b467c1e101f..45cecc1b125d8 100644 --- a/src/librustc_mir/transform/add_retag.rs +++ b/src/librustc_mir/transform/add_retag.rs @@ -75,8 +75,8 @@ impl<'tcx> MirPass<'tcx> for AddRetag { { let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, - span: span, // FIXME: Consider using just the span covering the function - // argument declaration. + span, // FIXME: Consider using just the span covering the function + // argument declaration. }; // Gather all arguments, skip return value. let places = local_decls diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 3107be1b62207..d060a0eab3db0 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -506,7 +506,7 @@ fn locals_live_across_suspend_points( for (block, data) in body.basic_blocks().iter_enumerated() { if let TerminatorKind::Yield { .. } = data.terminator().kind { - let loc = Location { block: block, statement_index: data.statements.len() }; + let loc = Location { block, statement_index: data.statements.len() }; if !movable { // The `liveness` variable contains the liveness of MIR locals ignoring borrows. diff --git a/src/librustc_mir/transform/rustc_peek.rs b/src/librustc_mir/transform/rustc_peek.rs index 2ae7bd4d72729..22ac3410a75ab 100644 --- a/src/librustc_mir/transform/rustc_peek.rs +++ b/src/librustc_mir/transform/rustc_peek.rs @@ -34,7 +34,7 @@ impl<'tcx> MirPass<'tcx> for SanityCheck { let attributes = tcx.get_attrs(def_id); let param_env = tcx.param_env(def_id); let move_data = MoveData::gather_moves(body, tcx, param_env).unwrap(); - let mdpe = MoveDataParamEnv { move_data: move_data, param_env: param_env }; + let mdpe = MoveDataParamEnv { move_data, param_env }; let flow_inits = MaybeInitializedPlaces::new(tcx, body, &mdpe) .into_engine(tcx, body, def_id) diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index f7239ae55faa2..4531b91e53769 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -872,7 +872,7 @@ where debug!("drop_flag_reset_block({:?},{:?})", self, mode); let block = self.new_block(unwind, TerminatorKind::Goto { target: succ }); - let block_start = Location { block: block, statement_index: 0 }; + let block_start = Location { block, statement_index: 0 }; self.elaborator.clear_drop_flag(block_start, self.path, mode); block } @@ -921,7 +921,7 @@ where let call = TerminatorKind::Call { func: Operand::function_handle(tcx, free_func, substs, self.source_info.span), - args: args, + args, destination: Some((unit_temp, target)), cleanup: None, from_hir_call: false, diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index 6fd8f06fe8f25..1fd5f3c439587 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -297,7 +297,7 @@ where writeln!(w, "{}{:?}{}: {{", INDENT, block, cleanup_text)?; // List of statements in the middle. - let mut current_location = Location { block: block, statement_index: 0 }; + let mut current_location = Location { block, statement_index: 0 }; for statement in &data.statements { extra_data(PassWhere::BeforeLocation(current_location), w)?; let indented_body = format!("{0}{0}{1:?};", INDENT, statement); diff --git a/src/librustc_mir_build/build/matches/simplify.rs b/src/librustc_mir_build/build/matches/simplify.rs index 56aa150dd37d2..80fa0c44860e4 100644 --- a/src/librustc_mir_build/build/matches/simplify.rs +++ b/src/librustc_mir_build/build/matches/simplify.rs @@ -113,7 +113,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // value being matched, taking the variance field into account. candidate.ascriptions.push(Ascription { span: user_ty_span, - user_ty: user_ty, + user_ty, source: match_pair.place, variance, }); diff --git a/src/librustc_mir_build/build/matches/test.rs b/src/librustc_mir_build/build/matches/test.rs index 9f450f8fc7b77..d23a2708dc478 100644 --- a/src/librustc_mir_build/build/matches/test.rs +++ b/src/librustc_mir_build/build/matches/test.rs @@ -64,10 +64,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { PatKind::Slice { ref prefix, ref slice, ref suffix } => { let len = prefix.len() + suffix.len(); let op = if slice.is_some() { BinOp::Ge } else { BinOp::Eq }; - Test { - span: match_pair.pattern.span, - kind: TestKind::Len { len: len as u64, op: op }, - } + Test { span: match_pair.pattern.span, kind: TestKind::Len { len: len as u64, op } } } PatKind::Or { .. } => bug!("or-patterns should have already been handled"), diff --git a/src/librustc_mir_build/build/mod.rs b/src/librustc_mir_build/build/mod.rs index 830877f713e4b..b60a637471e13 100644 --- a/src/librustc_mir_build/build/mod.rs +++ b/src/librustc_mir_build/build/mod.rs @@ -418,7 +418,7 @@ struct GuardFrameLocal { impl GuardFrameLocal { fn new(id: hir::HirId, _binding_mode: BindingMode) -> Self { - GuardFrameLocal { id: id } + GuardFrameLocal { id } } } diff --git a/src/librustc_mir_build/hair/cx/block.rs b/src/librustc_mir_build/hair/cx/block.rs index a883b84f8fe2f..8d7225c8c7b51 100644 --- a/src/librustc_mir_build/hair/cx/block.rs +++ b/src/librustc_mir_build/hair/cx/block.rs @@ -84,7 +84,7 @@ fn mirror_stmts<'a, 'tcx>( result.push(StmtRef::Mirror(Box::new(Stmt { kind: StmtKind::Let { - remainder_scope: remainder_scope, + remainder_scope, init_scope: region::Scope { id: hir_id.local_id, data: region::ScopeData::Node, diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs index a3554ea2ee0a3..6b5e927214f5a 100644 --- a/src/librustc_resolve/late.rs +++ b/src/librustc_resolve/late.rs @@ -2102,7 +2102,7 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { .is_ok() { let def_id = module.def_id().unwrap(); - found_traits.push(TraitCandidate { def_id: def_id, import_ids: smallvec![] }); + found_traits.push(TraitCandidate { def_id, import_ids: smallvec![] }); } } diff --git a/src/librustc_resolve/late/lifetimes.rs b/src/librustc_resolve/late/lifetimes.rs index 193b6d75935b2..7281173e9db78 100644 --- a/src/librustc_resolve/late/lifetimes.rs +++ b/src/librustc_resolve/late/lifetimes.rs @@ -1032,13 +1032,13 @@ struct Shadower { } fn original_label(span: Span) -> Original { - Original { kind: ShadowKind::Label, span: span } + Original { kind: ShadowKind::Label, span } } fn shadower_label(span: Span) -> Shadower { - Shadower { kind: ShadowKind::Label, span: span } + Shadower { kind: ShadowKind::Label, span } } fn original_lifetime(span: Span) -> Original { - Original { kind: ShadowKind::Lifetime, span: span } + Original { kind: ShadowKind::Lifetime, span } } fn shadower_lifetime(param: &hir::GenericParam<'_>) -> Shadower { Shadower { kind: ShadowKind::Lifetime, span: param.span } @@ -1347,7 +1347,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { let missing_named_lifetime_spots = take(&mut self.missing_named_lifetime_spots); let mut this = LifetimeContext { tcx: *tcx, - map: map, + map, scope: &wrap_scope, trait_ref_hack: self.trait_ref_hack, is_in_fn_syntax: self.is_in_fn_syntax, diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 9da8ee548fddd..ec251c224b690 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -334,7 +334,7 @@ impl<'l, 'tcx> SaveContext<'l, 'tcx> { Some(_) => ImplKind::Direct, None => ImplKind::Inherent, }, - span: span, + span, value: String::new(), parent: None, children: items diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index a295e1637aa4c..2005366f83986 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -793,7 +793,7 @@ impl Sig for ast::ForeignItem { text.push_str(&name); text.push(';'); - Ok(Signature { text: text, defs: defs, refs: vec![] }) + Ok(Signature { text, defs, refs: vec![] }) } ast::ForeignItemKind::Macro(..) => Err("macro"), } diff --git a/src/librustc_session/code_stats.rs b/src/librustc_session/code_stats.rs index 9b89c7ae32abc..c263da69c3521 100644 --- a/src/librustc_session/code_stats.rs +++ b/src/librustc_session/code_stats.rs @@ -70,7 +70,7 @@ impl CodeStats { type_description: type_desc.to_string(), align: align.bytes(), overall_size: overall_size.bytes(), - packed: packed, + packed, opt_discr_size: opt_discr_size.map(|s| s.bytes()), variants, }; diff --git a/src/librustc_span/def_id.rs b/src/librustc_span/def_id.rs index 6cdfd0500ca84..66cdf46bd4e5f 100644 --- a/src/librustc_span/def_id.rs +++ b/src/librustc_span/def_id.rs @@ -130,7 +130,7 @@ impl DefId { /// Makes a local `DefId` from the given `DefIndex`. #[inline] pub fn local(index: DefIndex) -> DefId { - DefId { krate: LOCAL_CRATE, index: index } + DefId { krate: LOCAL_CRATE, index } } #[inline] diff --git a/src/librustc_ty/instance.rs b/src/librustc_ty/instance.rs index c2b2196e74c61..8b1ba57e81945 100644 --- a/src/librustc_ty/instance.rs +++ b/src/librustc_ty/instance.rs @@ -47,7 +47,7 @@ pub fn resolve_instance<'tcx>( } } }; - Some(Instance { def: def, substs: substs }) + Some(Instance { def, substs }) }; debug!("resolve(def_id={:?}, substs={:?}) = {:?}", def_id, substs, result); result diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs index ff9fec004bbb5..7570d9d4b28ac 100644 --- a/src/librustc_typeck/check/expr.rs +++ b/src/librustc_typeck/check/expr.rs @@ -404,7 +404,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let needs = Needs::maybe_mut_place(mutbl); let ty = self.check_expr_with_expectation_and_needs(&oprnd, hint, needs); - let tm = ty::TypeAndMut { ty: ty, mutbl: mutbl }; + let tm = ty::TypeAndMut { ty, mutbl }; match kind { _ if tm.ty.references_error() => self.tcx.types.err, hir::BorrowKind::Raw => { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index d8b23998e727f..d2f9f4e068a09 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4234,7 +4234,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let substs = self.fresh_substs_for_item(span, did); let substd_ty = self.instantiate_type_scheme(span, &substs, &ity); - TypeAndSubsts { substs: substs, ty: substd_ty } + TypeAndSubsts { substs, ty: substd_ty } } /// Unifies the output type with the expected type early, for more coercions diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index fcbeb5b210dec..44473fee643c6 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -31,10 +31,10 @@ pub fn infer_predicates<'tcx>( predicates_added = false; let mut visitor = InferVisitor { - tcx: tcx, + tcx, global_inferred_outlives: &mut global_inferred_outlives, predicates_added: &mut predicates_added, - explicit_map: explicit_map, + explicit_map, }; // Visit all the crates and infer predicates diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs index becdeaba50f78..41b8e66d26592 100644 --- a/src/librustdoc/doctree.rs +++ b/src/librustdoc/doctree.rs @@ -44,7 +44,7 @@ impl Module<'hir> { vis: &'hir hir::Visibility<'hir>, ) -> Module<'hir> { Module { - name: name, + name, id: hir::CRATE_HIR_ID, vis, where_outer: rustc_span::DUMMY_SP, diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index d0e1a01b00654..44f8e8bd1717a 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -2461,7 +2461,7 @@ impl RandomState { KEYS.with(|keys| { let (k0, k1) = keys.get(); keys.set((k0.wrapping_add(1), k1)); - RandomState { k0: k0, k1: k1 } + RandomState { k0, k1 } }) } } diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 9787cbb556bd2..f36aa1846a16c 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -96,7 +96,7 @@ impl Cursor { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn new(inner: T) -> Cursor { - Cursor { pos: 0, inner: inner } + Cursor { pos: 0, inner } } /// Consumes this cursor, returning the underlying value. diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index a50dd9575de32..0103e4bd628d7 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -371,7 +371,7 @@ where F: FnMut(&R) -> usize, { let start_len = buf.len(); - let mut g = Guard { len: buf.len(), buf: buf }; + let mut g = Guard { len: buf.len(), buf }; let ret; loop { if g.len == g.buf.len() { @@ -939,7 +939,7 @@ pub trait Read { where Self: Sized, { - Take { inner: self, limit: limit } + Take { inner: self, limit } } } diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 6eeddc28512d9..0cb16b19d7326 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -416,7 +416,7 @@ impl fmt::Debug for Mutex { impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> { unsafe fn new(lock: &'mutex Mutex) -> LockResult> { - poison::map_result(lock.poison.borrow(), |guard| MutexGuard { lock: lock, poison: guard }) + poison::map_result(lock.poison.borrow(), |guard| MutexGuard { lock, poison: guard }) } } diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index fdd29af858185..50f54dbf14306 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -465,16 +465,13 @@ impl From for RwLock { impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { unsafe fn new(lock: &'rwlock RwLock) -> LockResult> { - poison::map_result(lock.poison.borrow(), |_| RwLockReadGuard { lock: lock }) + poison::map_result(lock.poison.borrow(), |_| RwLockReadGuard { lock }) } } impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T> { unsafe fn new(lock: &'rwlock RwLock) -> LockResult> { - poison::map_result(lock.poison.borrow(), |guard| RwLockWriteGuard { - lock: lock, - poison: guard, - }) + poison::map_result(lock.poison.borrow(), |guard| RwLockWriteGuard { lock, poison: guard }) } }