Skip to content

Commit 3dff69d

Browse files
joshtriplettgitbot
authored and
gitbot
committed
Use field init shorthand where possible
Field init shorthand allows writing initializers like `tcx: tcx` as `tcx`. The compiler already uses it extensively. Fix the last few places where it isn't yet used.
1 parent a2d4c61 commit 3dff69d

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

alloc/src/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ impl<T, A: Allocator> Rc<T, A> {
795795
let uninit_ptr: NonNull<_> = (unsafe { &mut *uninit_raw_ptr }).into();
796796
let init_ptr: NonNull<RcInner<T>> = uninit_ptr.cast();
797797

798-
let weak = Weak { ptr: init_ptr, alloc: alloc };
798+
let weak = Weak { ptr: init_ptr, alloc };
799799

800800
// It's important we don't give up ownership of the weak pointer, or
801801
// else the memory might be freed by the time `data_fn` returns. If

alloc/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ impl<T, A: Allocator> Arc<T, A> {
784784
let uninit_ptr: NonNull<_> = (unsafe { &mut *uninit_raw_ptr }).into();
785785
let init_ptr: NonNull<ArcInner<T>> = uninit_ptr.cast();
786786

787-
let weak = Weak { ptr: init_ptr, alloc: alloc };
787+
let weak = Weak { ptr: init_ptr, alloc };
788788

789789
// It's important we don't give up ownership of the weak pointer, or
790790
// else the memory might be freed by the time `data_fn` returns. If

core/src/task/wake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ impl<'a> ContextBuilder<'a> {
322322
// SAFETY: LocalWaker is just Waker without thread safety
323323
let local_waker = unsafe { transmute(waker) };
324324
Self {
325-
waker: waker,
325+
waker,
326326
local_waker,
327327
ext: ExtData::None(()),
328328
_marker: PhantomData,

std/src/sys/pal/hermit/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl FileAttr {
135135
S_IFREG => DT_REG,
136136
_ => DT_UNKNOWN,
137137
};
138-
FileType { mode: mode }
138+
FileType { mode }
139139
}
140140
}
141141

std/src/sys/pal/hermit/thread.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl Thread {
4343
}
4444
Err(io::const_error!(io::ErrorKind::Uncategorized, "Unable to create thread!"))
4545
} else {
46-
Ok(Thread { tid: tid })
46+
Ok(Thread { tid })
4747
};
4848

4949
extern "C" fn thread_start(main: usize) {

std/src/sys/pal/hermit/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Timespec {
2222
const fn new(tv_sec: i64, tv_nsec: i32) -> Timespec {
2323
assert!(tv_nsec >= 0 && tv_nsec < NSEC_PER_SEC);
2424
// SAFETY: The assert above checks tv_nsec is within the valid range
25-
Timespec { t: timespec { tv_sec: tv_sec, tv_nsec: tv_nsec } }
25+
Timespec { t: timespec { tv_sec, tv_nsec } }
2626
}
2727

2828
fn sub_timespec(&self, other: &Timespec) -> Result<Duration, Duration> {

std/src/sys/pal/sgx/fd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct FileDesc {
1212

1313
impl FileDesc {
1414
pub fn new(fd: Fd) -> FileDesc {
15-
FileDesc { fd: fd }
15+
FileDesc { fd }
1616
}
1717

1818
pub fn raw(&self) -> Fd {

0 commit comments

Comments
 (0)