Skip to content

Commit

Permalink
Rollup merge of #69782 - matthiaskrgr:redundant_field_name_rep, r=cra…
Browse files Browse the repository at this point in the history
…mertj

Don't redundantly repeat field names (clippy::redundant_field_names)
  • Loading branch information
Centril authored Mar 7, 2020
2 parents ca90c3d + 83980ac commit 709325a
Show file tree
Hide file tree
Showing 61 changed files with 88 additions and 100 deletions.
2 changes: 1 addition & 1 deletion src/liballoc/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ impl<T> LinkedList<T> {
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 }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
17 changes: 7 additions & 10 deletions src/libproc_macro/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<S, T>(mut self, spans: S, message: T) -> Diagnostic
where S: MultiSpan, T: Into<String>
where
S: MultiSpan,
T: Into<String>,
{
self.children.push(Diagnostic::spanned(spans, $level, message));
self
Expand All @@ -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`.
Expand All @@ -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<T: Into<String>>(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
Expand All @@ -107,12 +109,7 @@ impl Diagnostic {
S: MultiSpan,
T: Into<String>,
{
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);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl DefPath {
}
}
data.reverse();
DefPath { data: data, krate: krate }
DefPath { data, krate }
}

/// Returns a string representation of the `DefPath` without
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ pub trait DefIdTree: Copy {

impl<'tcx> DefIdTree for TyCtxt<'tcx> {
fn parent(self, id: DefId) -> Option<DefId> {
self.def_key(id).parent.map(|index| DefId { index: index, ..id })
self.def_key(id).parent.map(|index| DefId { index, ..id })
}
}

Expand Down Expand Up @@ -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]
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/ty/normalize_erasing_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
}
}
Expand All @@ -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 })
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/equate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/glb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/lub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/region_constraints/leak_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/region_constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/infer/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, F: FnOnce(&mut Self) -> R>(&mut self, f: F) -> R {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_infer/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ pub type NormalizedTy<'tcx> = Normalized<'tcx, Ty<'tcx>>;

impl<'tcx, T> Normalized<'tcx, T> {
pub fn with<U>(self, value: U) -> Normalized<'tcx, U> {
Normalized { value: value, obligations: self.obligations }
Normalized { value, obligations: self.obligations }
}
}

Expand Down Expand Up @@ -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,
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_infer/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_lint/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<N: Idx> LivenessValues<N> {
/// 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<RegionValueElements>) -> 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.
Expand Down
Loading

0 comments on commit 709325a

Please sign in to comment.