From 26fc381664437520bdf50811b1150d7276672090 Mon Sep 17 00:00:00 2001 From: David Lattimore Date: Sat, 4 Jan 2025 13:31:59 +1100 Subject: [PATCH] Fix some clippy warnings --- src/config/permissions.rs | 2 +- src/cowarc.rs | 20 ++++++++++---------- src/crate_index/lib_tree.rs | 2 +- src/names.rs | 14 +++++++------- src/proxy.rs | 2 +- src/symbol.rs | 6 +++--- src/symbol_graph.rs | 12 ++++++------ src/symbol_graph/dwarf.rs | 10 +++++----- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/config/permissions.rs b/src/config/permissions.rs index 6e1e313..231bf08 100644 --- a/src/config/permissions.rs +++ b/src/config/permissions.rs @@ -361,7 +361,7 @@ impl<'de> Deserialize<'de> for PermSel { struct PermSelVisitor; -impl<'de> serde::de::Visitor<'de> for PermSelVisitor { +impl serde::de::Visitor<'_> for PermSelVisitor { type Value = PermSel; fn visit_str(self, s: &str) -> Result diff --git a/src/cowarc.rs b/src/cowarc.rs index 91f5def..4d4def6 100644 --- a/src/cowarc.rs +++ b/src/cowarc.rs @@ -20,7 +20,7 @@ pub(crate) enum CowArc<'data, T: ?Sized> { Borrowed(&'data T), } -impl<'data, T: ?Sized> CowArc<'data, T> { +impl CowArc<'_, T> { /// Returns a reference to the data contained within. Note that the returned reference is valid /// for the lifetime of `self`, not for 'data, since if we're stored on the heap, we can't /// provide a reference that's valid for 'data, which may be longer (and likely 'static). @@ -32,7 +32,7 @@ impl<'data, T: ?Sized> CowArc<'data, T> { } } -impl<'data, T: ?Sized> Clone for CowArc<'data, T> { +impl Clone for CowArc<'_, T> { fn clone(&self) -> Self { match self { Self::Heap(arg0) => Self::Heap(Arc::clone(arg0)), @@ -41,7 +41,7 @@ impl<'data, T: ?Sized> Clone for CowArc<'data, T> { } } -impl<'data, V: Clone> CowArc<'data, [V]> { +impl CowArc<'_, [V]> { /// Create an instance that is heap-allocated and reference counted and thus can be used beyond /// the lifetime 'data. pub(crate) fn to_heap(&self) -> CowArc<'static, [V]> { @@ -52,7 +52,7 @@ impl<'data, V: Clone> CowArc<'data, [V]> { } } -impl<'data> CowArc<'data, str> { +impl CowArc<'_, str> { /// Create an instance that is heap-allocated and reference counted and thus can be used beyond /// the lifetime 'data. pub(crate) fn to_heap(&self) -> CowArc<'static, str> { @@ -63,7 +63,7 @@ impl<'data> CowArc<'data, str> { } } -impl<'data, T: ?Sized> Deref for CowArc<'data, T> { +impl Deref for CowArc<'_, T> { type Target = T; fn deref(&self) -> &Self::Target { @@ -71,27 +71,27 @@ impl<'data, T: ?Sized> Deref for CowArc<'data, T> { } } -impl<'data, T: PartialEq + ?Sized> PartialEq for CowArc<'data, T> { +impl PartialEq for CowArc<'_, T> { fn eq(&self, other: &Self) -> bool { self.data().eq(other.data()) } } -impl<'data, T: Hash + ?Sized> Hash for CowArc<'data, T> { +impl Hash for CowArc<'_, T> { fn hash(&self, state: &mut H) { self.data().hash(state); } } -impl<'data, T: PartialOrd + ?Sized> PartialOrd for CowArc<'data, T> { +impl PartialOrd for CowArc<'_, T> { fn partial_cmp(&self, other: &Self) -> Option { self.data().partial_cmp(other.data()) } } -impl<'data, T: Eq + ?Sized> Eq for CowArc<'data, T> {} +impl Eq for CowArc<'_, T> {} -impl<'data, T: Ord + ?Sized> Ord for CowArc<'data, T> { +impl Ord for CowArc<'_, T> { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.data().cmp(other.data()) } diff --git a/src/crate_index/lib_tree.rs b/src/crate_index/lib_tree.rs index 1e6d2d6..2e0e735 100644 --- a/src/crate_index/lib_tree.rs +++ b/src/crate_index/lib_tree.rs @@ -41,7 +41,7 @@ struct LibTreeBuilder<'a> { pkg_name_to_ids: &'a FxHashMap, Vec>, } -impl<'a> LibTreeBuilder<'a> { +impl LibTreeBuilder<'_> { fn build(mut self, dir: &Path) -> Result { let output = Command::new("cargo") .current_dir(dir) diff --git a/src/names.rs b/src/names.rs index 8e45733..df7fb5d 100644 --- a/src/names.rs +++ b/src/names.rs @@ -81,7 +81,7 @@ impl Namespace { } } -impl<'input> DebugName<'input> { +impl DebugName<'_> { pub(crate) fn names_iterator(&self) -> NamesIterator { NamesIterator::new(NonMangledIterator::new( &self.namespace.parts, @@ -186,7 +186,7 @@ pub(crate) struct NamePartsIterator<'it, 'data, I: Clone + Iterator Iterator for NamePartsIterator<'it, 'data, I> +impl<'data, I> Iterator for NamePartsIterator<'_, 'data, I> where I: Clone + Iterator>, { @@ -207,7 +207,7 @@ where } } -impl<'it, 'data, I> Drop for NamePartsIterator<'it, 'data, I> +impl<'data, I> Drop for NamePartsIterator<'_, 'data, I> where I: Clone + Iterator>, { @@ -343,7 +343,7 @@ impl<'data, I: Clone + Iterator>> Iterator } } -impl<'input> DebugName<'input> { +impl DebugName<'_> { pub(crate) fn to_heap(&self) -> DebugName<'static> { DebugName { namespace: self.namespace.clone(), @@ -377,7 +377,7 @@ enum NamesIteratorState { }, } -impl<'input> SymbolAndName<'input> { +impl SymbolAndName<'_> { pub(crate) fn symbol_or_debug_name(&self) -> Result { if let Some(debug_name) = self.debug_name.as_ref() { return Ok(SymbolOrDebugName::DebugName(debug_name.to_heap())); @@ -396,7 +396,7 @@ impl Display for Name { } } -impl<'input> Display for SymbolAndName<'input> { +impl Display for SymbolAndName<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if let Some(name) = self.debug_name.as_ref() { Display::fmt(&name, f)?; @@ -428,7 +428,7 @@ impl Display for Namespace { } } -impl<'input> Display for DebugName<'input> { +impl Display for DebugName<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&self.namespace, f)?; if !self.namespace.is_empty() { diff --git a/src/proxy.rs b/src/proxy.rs index 78feaef..5afe1e8 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -90,7 +90,7 @@ pub(crate) fn clean(dir: &Path, args: &Args, config: &CommonConfig) -> Result<() Ok(()) } -impl<'a> CargoRunner<'a> { +impl CargoRunner<'_> { /// Invokes `cargo build` in the specified directory with us acting as proxy versions of rustc /// and the linker. If calling this, you must call handle_wrapped_binaries from the start of /// main. diff --git a/src/symbol.rs b/src/symbol.rs index 33364de..a029f71 100644 --- a/src/symbol.rs +++ b/src/symbol.rs @@ -15,7 +15,7 @@ pub(crate) struct Symbol<'data> { bytes: Bytes<'data>, } -impl<'data> Symbol<'data> { +impl Symbol<'_> { pub(crate) fn borrowed(data: &[u8]) -> Symbol { Symbol { bytes: Bytes::Borrowed(data), @@ -86,7 +86,7 @@ impl<'data> Symbol<'data> { } } -impl<'data> Display for Symbol<'data> { +impl Display for Symbol<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if let Ok(sym_string) = self.to_str() { write!(f, "{:#}", demangle(sym_string))?; @@ -97,7 +97,7 @@ impl<'data> Display for Symbol<'data> { } } -impl<'data> Debug for Symbol<'data> { +impl Debug for Symbol<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { if let Ok(sym_string) = self.to_str() { // For valid UTF-8, we just print as a string. We want something that fits on one line, diff --git a/src/symbol_graph.rs b/src/symbol_graph.rs index d4dd05a..9f61b77 100644 --- a/src/symbol_graph.rs +++ b/src/symbol_graph.rs @@ -249,7 +249,7 @@ impl ScanOutputs { } } -impl<'input, 'backtracer> ApiUsageCollector<'input, 'backtracer> { +impl<'input> ApiUsageCollector<'input, '_> { fn process_file( &mut self, filename: &Path, @@ -552,7 +552,7 @@ enum LocationFetcher<'a> { AlreadyResolved(&'a SourceLocation), } -impl<'a> LocationFetcher<'a> { +impl LocationFetcher<'_> { fn location(&self) -> Result { match self { LocationFetcher::FrameWithFallback { @@ -698,7 +698,7 @@ impl<'symbol, 'input: 'symbol> BinInfo<'input> { } } -impl<'a> TryFrom<&addr2line::Location<'a>> for SourceLocation { +impl TryFrom<&addr2line::Location<'_>> for SourceLocation { type Error = (); fn try_from(value: &addr2line::Location) -> std::result::Result { let addr2line::Location { @@ -713,7 +713,7 @@ impl<'a> TryFrom<&addr2line::Location<'a>> for SourceLocation { } } -impl<'input> BinInfo<'input> { +impl BinInfo<'_> { /// Runs `callback` for each name in `symbol` or in the name obtained for the debug information /// for `symbol`. Also supplies information about the name source and a set of APIs that match /// the name. @@ -785,7 +785,7 @@ pub(crate) enum NameSource<'symbol> { DebugName(DebugName<'static>), } -impl<'symbol> NameSource<'symbol> { +impl NameSource<'_> { fn to_owned(&self) -> NameSource<'static> { match self { NameSource::Symbol(symbol) => NameSource::Symbol(symbol.to_heap()), @@ -794,7 +794,7 @@ impl<'symbol> NameSource<'symbol> { } } -impl<'symbol> Display for NameSource<'symbol> { +impl Display for NameSource<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { NameSource::Symbol(symbol) => symbol.fmt(f), diff --git a/src/symbol_graph/dwarf.rs b/src/symbol_graph/dwarf.rs index b3e4b48..ea9b471 100644 --- a/src/symbol_graph/dwarf.rs +++ b/src/symbol_graph/dwarf.rs @@ -47,7 +47,7 @@ pub(crate) struct InlinedFunction<'input> { pub(crate) call_location: CallLocation<'input>, } -impl<'input> CallLocation<'input> { +impl CallLocation<'_> { pub(crate) fn location(&self) -> Result { let line = self .line @@ -254,7 +254,7 @@ struct UnitState<'input, 'dwarf> { subprogram_namespaces: FxHashMap, } -impl<'input, 'dwarf> UnitState<'input, 'dwarf> { +impl<'input> UnitState<'input, '_> { fn attr_string( &self, attr: AttributeValue, usize>, @@ -303,14 +303,14 @@ impl<'input, 'dwarf> UnitState<'input, 'dwarf> { match attr.value() { AttributeValue::UnitRef(unit_offset) => { let unit = self.unit; - return self.get_symbol_and_name_in_unit(unit, unit_offset, max_depth, scanner); + self.get_symbol_and_name_in_unit(unit, unit_offset, max_depth, scanner) } AttributeValue::DebugInfoRef(offset) => { let unit = scanner.unit_containing(offset)?; let unit_offset = offset .to_unit_offset(&unit.header) .ok_or_else(|| anyhow!("Invalid unit offset"))?; - return self.get_symbol_and_name_in_unit(unit, unit_offset, max_depth, scanner); + self.get_symbol_and_name_in_unit(unit, unit_offset, max_depth, scanner) } _ => { bail!("Unsupported abstract_origin type: {:?}", attr.value()); @@ -403,7 +403,7 @@ struct DwarfScanner<'input> { units: Vec>>, } -impl<'input> SymbolDebugInfo<'input> { +impl SymbolDebugInfo<'_> { pub(crate) fn source_location(&self) -> SourceLocation { let mut filename = self.compdir.to_owned(); if let Some(directory) = self.directory {