Skip to content

Commit 9d9146a

Browse files
committed
Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwco
refactor: use shorthand fields refactor: use shorthand for single fields everywhere (excluding tests).
2 parents e222d1d + eca11b9 commit 9d9146a

File tree

57 files changed

+68
-68
lines changed

Some content is hidden

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

57 files changed

+68
-68
lines changed

src/liballoc/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl String {
502502
#[stable(feature = "rust1", since = "1.0.0")]
503503
pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
504504
match str::from_utf8(&vec) {
505-
Ok(..) => Ok(String { vec: vec }),
505+
Ok(..) => Ok(String { vec }),
506506
Err(e) => {
507507
Err(FromUtf8Error {
508508
bytes: vec,

src/libpanic_unwind/dwarf/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct Unaligned<T>(T);
2929

3030
impl DwarfReader {
3131
pub fn new(ptr: *const u8) -> DwarfReader {
32-
DwarfReader { ptr: ptr }
32+
DwarfReader { ptr }
3333
}
3434

3535
// DWARF streams are packed, so e.g. a u32 would not necessarily be aligned

src/libpanic_unwind/seh64_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct PanicData {
4141
}
4242

4343
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
44-
let panic_ctx = Box::new(PanicData { data: data });
44+
let panic_ctx = Box::new(PanicData { data });
4545
let params = [Box::into_raw(panic_ctx) as c::ULONG_PTR];
4646
c::RaiseException(RUST_PANIC,
4747
c::EXCEPTION_NONCONTINUABLE,

src/librustc/infer/resolve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct OpportunisticTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
2626

2727
impl<'a, 'gcx, 'tcx> OpportunisticTypeResolver<'a, 'gcx, 'tcx> {
2828
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
29-
OpportunisticTypeResolver { infcx: infcx }
29+
OpportunisticTypeResolver { infcx }
3030
}
3131
}
3232

@@ -54,7 +54,7 @@ pub struct OpportunisticTypeAndRegionResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
5454

5555
impl<'a, 'gcx, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'gcx, 'tcx> {
5656
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
57-
OpportunisticTypeAndRegionResolver { infcx: infcx }
57+
OpportunisticTypeAndRegionResolver { infcx }
5858
}
5959
}
6060

src/librustc/infer/type_variable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
169169
// Hack: we only need this so that `types_escaping_snapshot`
170170
// can see what has been unified; see the Delegate impl for
171171
// more details.
172-
self.values.record(Instantiate { vid: vid });
172+
self.values.record(Instantiate { vid });
173173
}
174174

175175
/// Creates a new type variable.

src/librustc/infer/unify_key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl UnifyValue for RegionVidKey {
4343
value2.min_vid
4444
};
4545

46-
Ok(RegionVidKey { min_vid: min_vid })
46+
Ok(RegionVidKey { min_vid })
4747
}
4848
}
4949

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl<'a, 'tcx> Index<'tcx> {
469469
/// Cross-references the feature names of unstable APIs with enabled
470470
/// features and possibly prints errors.
471471
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
472-
let mut checker = Checker { tcx: tcx };
472+
let mut checker = Checker { tcx };
473473
tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor());
474474
}
475475

src/librustc/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2986,7 +2986,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
29862986
use mir::TerminatorKind::*;
29872987

29882988
let kind = match self.kind {
2989-
Goto { target } => Goto { target: target },
2989+
Goto { target } => Goto { target },
29902990
SwitchInt {
29912991
ref discr,
29922992
switch_ty,

src/librustc/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub enum PlaceTy<'tcx> {
3232

3333
impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
3434
pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {
35-
PlaceTy::Ty { ty: ty }
35+
PlaceTy::Ty { ty }
3636
}
3737

3838
pub fn to_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {

src/librustc/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fn project_and_unify_type<'cx, 'gcx, 'tcx>(
266266
},
267267
Err(err) => {
268268
debug!("project_and_unify_type: equating types encountered error {:?}", err);
269-
Err(MismatchedProjectionTypes { err: err })
269+
Err(MismatchedProjectionTypes { err })
270270
}
271271
}
272272
}

src/librustc/traits/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3526,7 +3526,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
35263526
_ => bug!(),
35273527
};
35283528

3529-
Ok(VtableBuiltinData { nested: nested })
3529+
Ok(VtableBuiltinData { nested })
35303530
}
35313531

35323532
///////////////////////////////////////////////////////////////////////////

src/librustc/ty/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct Match<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
3434

3535
impl<'a, 'gcx, 'tcx> Match<'a, 'gcx, 'tcx> {
3636
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Match<'a, 'gcx, 'tcx> {
37-
Match { tcx: tcx }
37+
Match { tcx }
3838
}
3939
}
4040

src/librustc/ty/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
8282
}
8383

8484
fn has_type_flags(&self, flags: TypeFlags) -> bool {
85-
self.visit_with(&mut HasTypeFlagsVisitor { flags: flags })
85+
self.visit_with(&mut HasTypeFlagsVisitor { flags })
8686
}
8787
fn has_projections(&self) -> bool {
8888
self.has_type_flags(TypeFlags::HAS_PROJECTION)

src/librustc_codegen_llvm/llvm/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl ObjectFile {
190190
pub fn new(llmb: &'static mut MemoryBuffer) -> Option<ObjectFile> {
191191
unsafe {
192192
let llof = LLVMCreateObjectFile(llmb)?;
193-
Some(ObjectFile { llof: llof })
193+
Some(ObjectFile { llof })
194194
}
195195
}
196196
}

src/librustc_codegen_llvm/mir/analyze.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub fn cleanup_kinds<'a, 'tcx>(mir: &mir::Mir<'tcx>) -> IndexVec<mir::BasicBlock
346346
funclet, succ, kind);
347347
match kind {
348348
CleanupKind::NotCleanup => {
349-
result[succ] = CleanupKind::Internal { funclet: funclet };
349+
result[succ] = CleanupKind::Internal { funclet };
350350
}
351351
CleanupKind::Funclet => {
352352
if funclet != succ {

src/librustc_codegen_utils/symbol_names_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn report_symbol_names<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
3232
}
3333

3434
tcx.dep_graph.with_ignore(|| {
35-
let mut visitor = SymbolNamesTest { tcx: tcx };
35+
let mut visitor = SymbolNamesTest { tcx };
3636
tcx.hir.krate().visit_all_item_likes(&mut visitor);
3737
})
3838
}

src/librustc_data_structures/flock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ cfg_if! {
214214
unsafe { libc::close(fd); }
215215
Err(err)
216216
} else {
217-
Ok(Lock { fd: fd })
217+
Ok(Lock { fd })
218218
}
219219
}
220220
}

src/librustc_data_structures/svh.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl Svh {
3131
/// compute the SVH from some HIR, you want the `calculate_svh`
3232
/// function found in `librustc_incremental`.
3333
pub fn new(hash: u64) -> Svh {
34-
Svh { hash: hash }
34+
Svh { hash }
3535
}
3636

3737
pub fn as_u64(&self) -> u64 {

src/librustc_lint/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ impl LintPass for ImproperCTypes {
795795

796796
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
797797
fn check_foreign_item(&mut self, cx: &LateContext, it: &hir::ForeignItem) {
798-
let mut vis = ImproperCTypesVisitor { cx: cx };
798+
let mut vis = ImproperCTypesVisitor { cx };
799799
let abi = cx.tcx.hir.get_foreign_abi(it.id);
800800
if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic {
801801
match it.node {

src/librustc_metadata/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
323323
index.record(DefId::local(CRATE_DEF_INDEX),
324324
IsolatedEncoder::encode_info_for_mod,
325325
FromId(CRATE_NODE_ID, (&krate.module, &krate.attrs, &vis)));
326-
let mut visitor = EncodeVisitor { index: index };
326+
let mut visitor = EncodeVisitor { index };
327327
krate.visit_all_item_likes(&mut visitor.as_deep_visitor());
328328
for macro_def in &krate.exported_macros {
329329
visitor.visit_macro_def(macro_def);

src/librustc_mir/build/scope.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
453453
}
454454
let scope = &self.scopes[len - scope_count];
455455
self.cfg.terminate(block, scope.source_info(span),
456-
TerminatorKind::Goto { target: target });
456+
TerminatorKind::Goto { target });
457457
}
458458

459459
/// Creates a path that performs all required cleanup for dropping a generator.
@@ -1019,7 +1019,7 @@ fn build_diverge_scope<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
10191019
} else {
10201020
let block = cfg.start_new_cleanup_block();
10211021
cfg.push_end_region(tcx, block, source_info(span), scope.region_scope);
1022-
cfg.terminate(block, source_info(span), TerminatorKind::Goto { target: target });
1022+
cfg.terminate(block, source_info(span), TerminatorKind::Goto { target });
10231023
*cached_block = Some(block);
10241024
block
10251025
}

src/librustc_mir/dataflow/impls/borrowed_locals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct HaveBeenBorrowedLocals<'a, 'tcx: 'a> {
2828
impl<'a, 'tcx: 'a> HaveBeenBorrowedLocals<'a, 'tcx> {
2929
pub fn new(mir: &'a Mir<'tcx>)
3030
-> Self {
31-
HaveBeenBorrowedLocals { mir: mir }
31+
HaveBeenBorrowedLocals { mir }
3232
}
3333

3434
pub fn mir(&self) -> &Mir<'tcx> {

src/librustc_mir/dataflow/impls/storage_liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct MaybeStorageLive<'a, 'tcx: 'a> {
2121
impl<'a, 'tcx: 'a> MaybeStorageLive<'a, 'tcx> {
2222
pub fn new(mir: &'a Mir<'tcx>)
2323
-> Self {
24-
MaybeStorageLive { mir: mir }
24+
MaybeStorageLive { mir }
2525
}
2626

2727
pub fn mir(&self) -> &Mir<'tcx> {

src/librustc_mir/hair/pattern/check_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a, 'tcx> Visitor<'tcx> for OuterVisitor<'a, 'tcx> {
5252
}
5353

5454
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
55-
tcx.hir.krate().visit_all_item_likes(&mut OuterVisitor { tcx: tcx }.as_deep_visitor());
55+
tcx.hir.krate().visit_all_item_likes(&mut OuterVisitor { tcx }.as_deep_visitor());
5656
tcx.sess.abort_if_errors();
5757
}
5858

src/librustc_mir/hair/pattern/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
571571
})
572572
.collect();
573573

574-
PatternKind::Leaf { subpatterns: subpatterns }
574+
PatternKind::Leaf { subpatterns }
575575
}
576576
ty::Error => { // Avoid ICE (#50577)
577577
return Pattern { span: pat.span, ty, kind: Box::new(PatternKind::Wild) };
@@ -778,13 +778,13 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
778778
subpatterns,
779779
}
780780
} else {
781-
PatternKind::Leaf { subpatterns: subpatterns }
781+
PatternKind::Leaf { subpatterns }
782782
}
783783
}
784784

785785
Def::Struct(..) | Def::StructCtor(..) | Def::Union(..) |
786786
Def::TyAlias(..) | Def::AssociatedTy(..) | Def::SelfTy(..) | Def::SelfCtor(..) => {
787-
PatternKind::Leaf { subpatterns: subpatterns }
787+
PatternKind::Leaf { subpatterns }
788788
}
789789

790790
_ => {

src/librustc_mir/transform/elaborate_drops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl<'b, 'tcx> ElaborateDropsCtxt<'b, 'tcx> {
495495
let target = self.patch.new_block(BasicBlockData {
496496
statements: vec![assign],
497497
terminator: Some(Terminator {
498-
kind: TerminatorKind::Goto { target: target },
498+
kind: TerminatorKind::Goto { target },
499499
..*terminator
500500
}),
501501
is_cleanup: false,

src/librustc_mir/transform/simplify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl MirPass for SimplifyLocals {
302302

303303
let map = make_local_map(&mut mir.local_decls, marker.locals);
304304
// Update references to all vars and tmps now
305-
LocalUpdater { map: map }.visit_mir(mir);
305+
LocalUpdater { map }.visit_mir(mir);
306306
mir.local_decls.shrink_to_fit();
307307
}
308308
}

src/librustc_mir/transform/simplify_branches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl MirPass for SimplifyBranches {
5757
TerminatorKind::Assert {
5858
target, cond: Operand::Constant(ref c), expected, ..
5959
} if (c.literal.assert_bool(tcx) == Some(true)) == expected => {
60-
TerminatorKind::Goto { target: target }
60+
TerminatorKind::Goto { target }
6161
},
6262
TerminatorKind::FalseEdges { real_target, .. } => {
6363
TerminatorKind::Goto { target: real_target }

src/librustc_passes/ast_validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -672,5 +672,5 @@ pub fn check_crate(session: &Session, krate: &Crate) {
672672
is_banned: false,
673673
}, krate);
674674

675-
visit::walk_crate(&mut AstValidator { session: session }, krate)
675+
visit::walk_crate(&mut AstValidator { session }, krate)
676676
}

src/librustc_resolve/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4422,7 +4422,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
44224422
// declared as public (due to pruning, we don't explore
44234423
// outside crate private modules => no need to check this)
44244424
if !in_module_is_extern || name_binding.vis == ty::Visibility::Public {
4425-
candidates.push(ImportSuggestion { path: path });
4425+
candidates.push(ImportSuggestion { path });
44264426
}
44274427
}
44284428
}
@@ -4519,7 +4519,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
45194519
span: name_binding.span,
45204520
segments: path_segments,
45214521
};
4522-
result = Some((module, ImportSuggestion { path: path }));
4522+
result = Some((module, ImportSuggestion { path }));
45234523
} else {
45244524
// add the module to the lookup
45254525
if seen_modules.insert(module.def_id().unwrap()) {

src/librustc_save_analysis/json_dumper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'b> JsonDumper<CallbackOutput<'b>> {
7171
config: Config,
7272
) -> JsonDumper<CallbackOutput<'b>> {
7373
JsonDumper {
74-
output: CallbackOutput { callback: callback },
74+
output: CallbackOutput { callback },
7575
config: config.clone(),
7676
result: Analysis::new(config),
7777
}

src/librustc_typeck/check/wfcheck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
993993
AdtField { ty: field_ty, span: field.span }
994994
})
995995
.collect();
996-
AdtVariant { fields: fields }
996+
AdtVariant { fields }
997997
}
998998

999999
fn enum_variants(&self, enum_def: &hir::EnumDef) -> Vec<AdtVariant<'tcx>> {

src/librustc_typeck/coherence/orphan.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
1717
use rustc::hir;
1818

1919
pub fn check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
20-
let mut orphan = OrphanChecker { tcx: tcx };
20+
let mut orphan = OrphanChecker { tcx };
2121
tcx.hir.krate().visit_all_item_likes(&mut orphan);
2222
}
2323

src/librustc_typeck/coherence/unsafety.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc::hir::itemlikevisit::ItemLikeVisitor;
1616
use rustc::hir::{self, Unsafety};
1717

1818
pub fn check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
19-
let mut unsafety = UnsafetyChecker { tcx: tcx };
19+
let mut unsafety = UnsafetyChecker { tcx };
2020
tcx.hir.krate().visit_all_item_likes(&mut unsafety);
2121
}
2222

src/librustc_typeck/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct OnlySelfBounds(bool);
6464
// Main entry point
6565

6666
pub fn collect_item_types<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
67-
let mut visitor = CollectItemTypesVisitor { tcx: tcx };
67+
let mut visitor = CollectItemTypesVisitor { tcx };
6868
tcx.hir
6969
.krate()
7070
.visit_all_item_likes(&mut visitor.as_deep_visitor());

src/librustc_typeck/impl_wf_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn impl_wf_check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
6262
// We will tag this as part of the WF check -- logically, it is,
6363
// but it's one that we must perform earlier than the rest of
6464
// WfCheck.
65-
tcx.hir.krate().visit_all_item_likes(&mut ImplWfCheck { tcx: tcx });
65+
tcx.hir.krate().visit_all_item_likes(&mut ImplWfCheck { tcx });
6666
}
6767

6868
struct ImplWfCheck<'a, 'tcx: 'a> {

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2966,7 +2966,7 @@ impl<'tcx> Clean<Item> for ty::VariantDef {
29662966
source: cx.tcx.def_span(self.did).clean(cx),
29672967
visibility: Some(Inherited),
29682968
def_id: self.did,
2969-
inner: VariantItem(Variant { kind: kind }),
2969+
inner: VariantItem(Variant { kind }),
29702970
stability: get_stability(cx, self.did),
29712971
deprecation: get_deprecation(cx, self.did),
29722972
}

src/libstd/collections/hash/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3418,7 +3418,7 @@ mod test_map {
34183418
slot.borrow_mut()[k] += 1;
34193419
});
34203420

3421-
Droppable { k: k }
3421+
Droppable { k }
34223422
}
34233423
}
34243424

src/libstd/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ impl OpenOptions {
877877

878878
fn _open(&self, path: &Path) -> io::Result<File> {
879879
let inner = fs_imp::File::open(path, &self.0)?;
880-
Ok(File { inner: inner })
880+
Ok(File { inner })
881881
}
882882
}
883883

0 commit comments

Comments
 (0)