From 23f65b6a2e92209bbce119ca319b4aa73446d482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 18 Mar 2024 18:25:57 +0100 Subject: [PATCH] Fix formatting --- src/concurrency/data_race.rs | 6 +----- src/concurrency/vector_clock.rs | 34 +++++++++++++++------------------ src/diagnostics.rs | 15 ++++++--------- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/concurrency/data_race.rs b/src/concurrency/data_race.rs index f9b77fa25d..9618cdc6b1 100644 --- a/src/concurrency/data_race.rs +++ b/src/concurrency/data_race.rs @@ -564,11 +564,7 @@ impl MemoryCellClocks { true }; self.read.set_at_index(&thread_clocks.clock, index); - if race_free { - Ok(()) - } else { - Err(DataRace) - } + if race_free { Ok(()) } else { Err(DataRace) } } else { Err(DataRace) } diff --git a/src/concurrency/vector_clock.rs b/src/concurrency/vector_clock.rs index 1d332ef650..302ca5eb5e 100644 --- a/src/concurrency/vector_clock.rs +++ b/src/concurrency/vector_clock.rs @@ -74,11 +74,7 @@ impl VTimestamp { } pub fn read_type(&self) -> NaReadType { - if self.time_and_read_type & 1 == 0 { - NaReadType::Read - } else { - NaReadType::Retag - } + if self.time_and_read_type & 1 == 0 { NaReadType::Read } else { NaReadType::Retag } } pub fn set_read_type(&mut self, read_type: NaReadType) { @@ -236,16 +232,14 @@ impl PartialOrd for VClock { for (l, r) in iter { match order { Ordering::Equal => order = l.cmp(r), - Ordering::Less => { + Ordering::Less => if l > r { return None; - } - } - Ordering::Greater => { + }, + Ordering::Greater => if l < r { return None; - } - } + }, } } @@ -260,16 +254,18 @@ impl PartialOrd for VClock { Ordering::Equal => Some(order), // Right has at least 1 element > than the implicit 0, // so the only valid values are Ordering::Less or None. - Ordering::Less => match order { - Ordering::Less | Ordering::Equal => Some(Ordering::Less), - Ordering::Greater => None, - }, + Ordering::Less => + match order { + Ordering::Less | Ordering::Equal => Some(Ordering::Less), + Ordering::Greater => None, + }, // Left has at least 1 element > than the implicit 0, // so the only valid values are Ordering::Greater or None. - Ordering::Greater => match order { - Ordering::Greater | Ordering::Equal => Some(Ordering::Greater), - Ordering::Less => None, - }, + Ordering::Greater => + match order { + Ordering::Greater | Ordering::Equal => Some(Ordering::Greater), + Ordering::Less => None, + }, } } diff --git a/src/diagnostics.rs b/src/diagnostics.rs index 6af69ce773..19e8b524c4 100644 --- a/src/diagnostics.rs +++ b/src/diagnostics.rs @@ -212,12 +212,10 @@ pub fn report_error<'tcx, 'mir>( let title = match info { Exit { code, leak_check } => return Some((*code, *leak_check)), Abort(_) => Some("abnormal termination"), - UnsupportedInIsolation(_) | Int2PtrWithStrictProvenance => { - Some("unsupported operation") - } - StackedBorrowsUb { .. } | TreeBorrowsUb { .. } | DataRace { .. } => { - Some("Undefined Behavior") - } + UnsupportedInIsolation(_) | Int2PtrWithStrictProvenance => + Some("unsupported operation"), + StackedBorrowsUb { .. } | TreeBorrowsUb { .. } | DataRace { .. } => + Some("Undefined Behavior"), Deadlock => Some("deadlock"), MultipleSymbolDefinitions { .. } | SymbolShimClashing { .. } => None, }; @@ -536,9 +534,8 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> { let (stacktrace, _was_pruned) = prune_stacktrace(stacktrace, self); let (title, diag_level) = match &e { - RejectedIsolatedOp(_) => { - ("operation rejected by isolation".to_string(), DiagLevel::Warning) - } + RejectedIsolatedOp(_) => + ("operation rejected by isolation".to_string(), DiagLevel::Warning), Int2Ptr { .. } => ("integer-to-pointer cast".to_string(), DiagLevel::Warning), CreatedPointerTag(..) | PoppedPointerTag(..)