Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions library/alloc/src/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1646,9 +1646,8 @@ impl<'a, T> CursorMut<'a, T> {
#[unstable(feature = "linked_list_cursors", issue = "58533")]
pub fn splice_after(&mut self, list: LinkedList<T>) {
unsafe {
let (splice_head, splice_tail, splice_len) = match list.detach_all_nodes() {
Some(parts) => parts,
_ => return,
let Some((splice_head, splice_tail, splice_len)) = list.detach_all_nodes() else {
return;
};
let node_next = match self.current {
None => self.list.head,
Expand Down
4 changes: 1 addition & 3 deletions library/alloc/src/raw_vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,9 +788,7 @@ impl<A: Allocator> RawVecInner<A> {
elem_layout: Layout,
) -> Result<(), TryReserveError> {
// SAFETY: Precondition passed to caller
let (ptr, layout) = if let Some(mem) = unsafe { self.current_memory(elem_layout) } {
mem
} else {
let Some((ptr, layout)) = (unsafe { self.current_memory(elem_layout) }) else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is obviously fine, to be clear.

return Ok(());
};

Expand Down
21 changes: 9 additions & 12 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,16 +619,14 @@ impl String {
pub fn from_utf8_lossy(v: &[u8]) -> Cow<'_, str> {
let mut iter = v.utf8_chunks();

let first_valid = if let Some(chunk) = iter.next() {
let valid = chunk.valid();
if chunk.invalid().is_empty() {
debug_assert_eq!(valid.len(), v.len());
return Cow::Borrowed(valid);
}
valid
} else {
let Some(chunk) = iter.next() else {
return Cow::Borrowed("");
};
let first_valid = chunk.valid();
if chunk.invalid().is_empty() {
debug_assert_eq!(first_valid.len(), v.len());
return Cow::Borrowed(first_valid);
}

const REPLACEMENT: &str = "\u{FFFD}";

Expand Down Expand Up @@ -720,11 +718,10 @@ impl String {
// FIXME: the function can be simplified again when #48994 is closed.
let mut ret = String::with_capacity(v.len());
for c in char::decode_utf16(v.iter().cloned()) {
if let Ok(c) = c {
ret.push(c);
} else {
let Ok(c) = c else {
return Err(FromUtf16Error(()));
}
};
ret.push(c);
}
Ok(ret)
}
Expand Down
9 changes: 4 additions & 5 deletions library/alloc/src/vec/splice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,11 @@ impl<T, A: Allocator> Drain<'_, T, A> {
};

for place in range_slice {
if let Some(new_item) = replace_with.next() {
unsafe { ptr::write(place, new_item) };
vec.len += 1;
} else {
let Some(new_item) = replace_with.next() else {
return false;
}
};
unsafe { ptr::write(place, new_item) };
vec.len += 1;
}
true
}
Expand Down
6 changes: 1 addition & 5 deletions library/core/src/num/dec2flt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,7 @@ fn biased_fp_to_float<F: RawFloat>(x: BiasedFp) -> F {
#[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above
pub fn dec2flt<F: RawFloat>(s: &str) -> Result<F, ParseFloatError> {
let mut s = s.as_bytes();
let c = if let Some(&c) = s.first() {
c
} else {
return Err(pfe_empty());
};
let Some(&c) = s.first() else { return Err(pfe_empty()) };
let negative = c == b'-';
if c == b'-' || c == b'+' {
s = &s[1..];
Expand Down
7 changes: 3 additions & 4 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,10 @@ impl Duration {
let mut nanos = self.nanos.as_inner() + rhs.nanos.as_inner();
if nanos >= NANOS_PER_SEC {
nanos -= NANOS_PER_SEC;
if let Some(new_secs) = secs.checked_add(1) {
secs = new_secs;
} else {
let Some(new_secs) = secs.checked_add(1) else {
return None;
}
};
secs = new_secs;
}
debug_assert!(nanos < NANOS_PER_SEC);
Some(Duration::new(secs, nanos))
Expand Down
5 changes: 1 addition & 4 deletions library/std/src/sys/pal/windows/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,7 @@ impl<'a> AsyncPipe<'a> {

impl<'a> Drop for AsyncPipe<'a> {
fn drop(&mut self) {
match self.state {
State::Reading => {}
_ => return,
}
let State::Reading = self.state else { return };

// If we have a pending read operation, then we have to make sure that
// it's *done* before we actually drop this type. The kernel requires
Expand Down
Loading