diff options
Diffstat (limited to 'compiler/rustc_data_structures/src')
10 files changed, 33 insertions, 32 deletions
diff --git a/compiler/rustc_data_structures/src/graph/dominators/mod.rs b/compiler/rustc_data_structures/src/graph/dominators/mod.rs index 00913a483db..ea2a4388b92 100644 --- a/compiler/rustc_data_structures/src/graph/dominators/mod.rs +++ b/compiler/rustc_data_structures/src/graph/dominators/mod.rs @@ -22,7 +22,7 @@ struct PreOrderFrame<Iter> { } rustc_index::newtype_index! { - struct PreorderIndex { .. } + struct PreorderIndex {} } pub fn dominators<G: ControlFlowGraph>(graph: G) -> Dominators<G::Node> { @@ -277,12 +277,12 @@ impl<Node: Idx> Dominators<Node> { } pub fn immediate_dominator(&self, node: Node) -> Node { - assert!(self.is_reachable(node), "node {:?} is not reachable", node); + assert!(self.is_reachable(node), "node {node:?} is not reachable"); self.immediate_dominators[node].unwrap() } pub fn dominators(&self, node: Node) -> Iter<'_, Node> { - assert!(self.is_reachable(node), "node {:?} is not reachable", node); + assert!(self.is_reachable(node), "node {node:?} is not reachable"); Iter { dominators: self, node: Some(node) } } diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index b31092eca98..c8e66eb672c 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -233,10 +233,9 @@ where .map(G::Node::new) .map(|node| match this.start_walk_from(node) { WalkReturn::Complete { scc_index } => scc_index, - WalkReturn::Cycle { min_depth } => panic!( - "`start_walk_node({:?})` returned cycle with depth {:?}", - node, min_depth - ), + WalkReturn::Cycle { min_depth } => { + panic!("`start_walk_node({node:?})` returned cycle with depth {min_depth:?}") + } }) .collect(); @@ -272,8 +271,7 @@ where NodeState::NotVisited => return None, NodeState::InCycleWith { parent } => panic!( - "`find_state` returned `InCycleWith({:?})`, which ought to be impossible", - parent + "`find_state` returned `InCycleWith({parent:?})`, which ought to be impossible" ), }) } @@ -369,7 +367,7 @@ where previous_node = previous; } // Only InCycleWith nodes were added to the reverse linked list. - other => panic!("Invalid previous link while compressing cycle: {:?}", other), + other => panic!("Invalid previous link while compressing cycle: {other:?}"), } debug!("find_state: parent_state = {:?}", node_state); @@ -394,7 +392,7 @@ where // NotVisited can not be part of a cycle since it should // have instead gotten explored. NodeState::NotVisited | NodeState::InCycleWith { .. } => { - panic!("invalid parent state: {:?}", node_state) + panic!("invalid parent state: {node_state:?}") } } } diff --git a/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs b/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs index 3a268e4b4f4..4b6aa116520 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/graphviz.rs @@ -30,7 +30,7 @@ impl<O: ForestObligation> ObligationForest<O> { let counter = COUNTER.fetch_add(1, Ordering::AcqRel); - let file_path = dir.as_ref().join(format!("{:010}_{}.gv", counter, description)); + let file_path = dir.as_ref().join(format!("{counter:010}_{description}.gv")); let mut gv_file = BufWriter::new(File::create(file_path).unwrap()); @@ -47,7 +47,7 @@ impl<'a, O: ForestObligation + 'a> dot::Labeller<'a> for &'a ObligationForest<O> } fn node_id(&self, index: &Self::Node) -> dot::Id<'_> { - dot::Id::new(format!("obligation_{}", index)).unwrap() + dot::Id::new(format!("obligation_{index}")).unwrap() } fn node_label(&self, index: &Self::Node) -> dot::LabelText<'_> { diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index 1d4014f05ac..393f1739081 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -205,10 +205,7 @@ impl SelfProfilerRef { /// VerboseTimingGuard returned from this call is dropped. In addition to recording /// a measureme event, "verbose" generic activities also print a timing entry to /// stderr if the compiler is invoked with -Ztime-passes. - pub fn verbose_generic_activity<'a>( - &'a self, - event_label: &'static str, - ) -> VerboseTimingGuard<'a> { + pub fn verbose_generic_activity(&self, event_label: &'static str) -> VerboseTimingGuard<'_> { let message = if self.print_verbose_generic_activities { Some(event_label.to_owned()) } else { None }; @@ -216,11 +213,11 @@ impl SelfProfilerRef { } /// Like `verbose_generic_activity`, but with an extra arg. - pub fn verbose_generic_activity_with_arg<'a, A>( - &'a self, + pub fn verbose_generic_activity_with_arg<A>( + &self, event_label: &'static str, event_arg: A, - ) -> VerboseTimingGuard<'a> + ) -> VerboseTimingGuard<'_> where A: Borrow<str> + Into<String>, { @@ -548,7 +545,7 @@ impl SelfProfiler { // length can behave as a source of entropy for heap addresses, when // ASLR is disabled and the heap is otherwise determinic. let pid: u32 = process::id(); - let filename = format!("{}-{:07}.rustc_profile", crate_name, pid); + let filename = format!("{crate_name}-{pid:07}.rustc_profile"); let path = output_directory.join(&filename); let profiler = Profiler::with_counter(&path, measureme::counters::Counter::by_name(counter_name)?)?; diff --git a/compiler/rustc_data_structures/src/small_c_str.rs b/compiler/rustc_data_structures/src/small_c_str.rs index 3a8ab8ff991..719e4e3d974 100644 --- a/compiler/rustc_data_structures/src/small_c_str.rs +++ b/compiler/rustc_data_structures/src/small_c_str.rs @@ -30,7 +30,7 @@ impl SmallCStr { SmallVec::from_vec(data) }; if let Err(e) = ffi::CStr::from_bytes_with_nul(&data) { - panic!("The string \"{}\" cannot be converted into a CStr: {}", s, e); + panic!("The string \"{s}\" cannot be converted into a CStr: {e}"); } SmallCStr { data } } @@ -39,7 +39,7 @@ impl SmallCStr { pub fn new_with_nul(s: &str) -> SmallCStr { let b = s.as_bytes(); if let Err(e) = ffi::CStr::from_bytes_with_nul(b) { - panic!("The string \"{}\" cannot be converted into a CStr: {}", s, e); + panic!("The string \"{s}\" cannot be converted into a CStr: {e}"); } SmallCStr { data: SmallVec::from_slice(s.as_bytes()) } } @@ -74,7 +74,7 @@ impl<'a> FromIterator<&'a str> for SmallCStr { iter.into_iter().flat_map(|s| s.as_bytes()).copied().collect::<SmallVec<_>>(); data.push(0); if let Err(e) = ffi::CStr::from_bytes_with_nul(&data) { - panic!("The iterator {:?} cannot be converted into a CStr: {}", data, e); + panic!("The iterator {data:?} cannot be converted into a CStr: {e}"); } Self { data } } diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs index 05f059c89d5..c63caa06818 100644 --- a/compiler/rustc_data_structures/src/sorted_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map.rs @@ -1,6 +1,7 @@ use crate::stable_hasher::{HashStable, StableHasher, StableOrd}; use std::borrow::Borrow; use std::cmp::Ordering; +use std::fmt::Debug; use std::mem; use std::ops::{Bound, Index, IndexMut, RangeBounds}; @@ -16,7 +17,7 @@ pub use index_map::SortedIndexMultiMap; /// stores data in a more compact way. It also supports accessing contiguous /// ranges of elements as a slice, and slices of already sorted elements can be /// inserted efficiently. -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)] pub struct SortedMap<K, V> { data: Vec<(K, V)>, } @@ -314,5 +315,11 @@ impl<K: HashStable<CTX> + StableOrd, V: HashStable<CTX>, CTX> HashStable<CTX> fo } } +impl<K: Debug, V: Debug> Debug for SortedMap<K, V> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_map().entries(self.data.iter().map(|(a, b)| (a, b))).finish() + } +} + #[cfg(test)] mod tests; diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index 1a728f82f00..ae4836645fa 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -223,7 +223,7 @@ pub trait ToStableHashKey<HCX> { /// stable across compilation session boundaries. More formally: /// /// ```txt -/// Ord::cmp(a1, b1) == Ord:cmp(a2, b2) +/// Ord::cmp(a1, b1) == Ord::cmp(a2, b2) /// where a2 = decode(encode(a1, context1), context2) /// b2 = decode(encode(b1, context1), context2) /// ``` diff --git a/compiler/rustc_data_structures/src/transitive_relation.rs b/compiler/rustc_data_structures/src/transitive_relation.rs index cf616203842..1ff0d58df14 100644 --- a/compiler/rustc_data_structures/src/transitive_relation.rs +++ b/compiler/rustc_data_structures/src/transitive_relation.rs @@ -199,7 +199,7 @@ impl<T: Eq + Hash + Copy> TransitiveRelation<T> { /// Viewing the relation as a graph, computes the "mutual /// immediate postdominator" of a set of points (if one /// exists). See `postdom_upper_bound` for details. - pub fn mutual_immediate_postdominator<'a>(&'a self, mut mubs: Vec<T>) -> Option<T> { + pub fn mutual_immediate_postdominator(&self, mut mubs: Vec<T>) -> Option<T> { loop { match mubs.len() { 0 => return None, diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index c015f1232cd..14257e4d5c6 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -178,7 +178,7 @@ impl<V: Eq + Hash> UnordSet<V> { } #[inline] - pub fn items<'a>(&'a self) -> UnordItems<&'a V, impl Iterator<Item = &'a V>> { + pub fn items(&self) -> UnordItems<&V, impl Iterator<Item = &V>> { UnordItems(self.inner.iter()) } @@ -255,7 +255,7 @@ impl<K: Eq + Hash, V> UnordMap<K, V> { } #[inline] - pub fn items<'a>(&'a self) -> UnordItems<(&'a K, &'a V), impl Iterator<Item = (&'a K, &'a V)>> { + pub fn items(&self) -> UnordItems<(&K, &V), impl Iterator<Item = (&K, &V)>> { UnordItems(self.inner.iter()) } @@ -311,7 +311,7 @@ impl<V> UnordBag<V> { } #[inline] - pub fn items<'a>(&'a self) -> UnordItems<&'a V, impl Iterator<Item = &'a V>> { + pub fn items(&self) -> UnordItems<&V, impl Iterator<Item = &V>> { UnordItems(self.inner.iter()) } diff --git a/compiler/rustc_data_structures/src/vec_map.rs b/compiler/rustc_data_structures/src/vec_map.rs index 2417df66bb9..d1a99bcaeb7 100644 --- a/compiler/rustc_data_structures/src/vec_map.rs +++ b/compiler/rustc_data_structures/src/vec_map.rs @@ -71,8 +71,7 @@ where // This should return just one element, otherwise it's a bug assert!( filter.next().is_none(), - "Collection {:#?} should have just one matching element", - self + "Collection {self:#?} should have just one matching element" ); Some(value) } |
