Skip to content

Commit

Permalink
Fix some clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlattimore committed Jan 4, 2025
1 parent b1643a0 commit 26fc381
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/config/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<E>(self, s: &str) -> Result<Self::Value, E>
Expand Down
20 changes: 10 additions & 10 deletions src/cowarc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) enum CowArc<'data, T: ?Sized> {
Borrowed(&'data T),
}

impl<'data, T: ?Sized> CowArc<'data, T> {
impl<T: ?Sized> 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).
Expand All @@ -32,7 +32,7 @@ impl<'data, T: ?Sized> CowArc<'data, T> {
}
}

impl<'data, T: ?Sized> Clone for CowArc<'data, T> {
impl<T: ?Sized> Clone for CowArc<'_, T> {
fn clone(&self) -> Self {
match self {
Self::Heap(arg0) => Self::Heap(Arc::clone(arg0)),
Expand All @@ -41,7 +41,7 @@ impl<'data, T: ?Sized> Clone for CowArc<'data, T> {
}
}

impl<'data, V: Clone> CowArc<'data, [V]> {
impl<V: Clone> 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]> {
Expand All @@ -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> {
Expand All @@ -63,35 +63,35 @@ impl<'data> CowArc<'data, str> {
}
}

impl<'data, T: ?Sized> Deref for CowArc<'data, T> {
impl<T: ?Sized> Deref for CowArc<'_, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
self.data()
}
}

impl<'data, T: PartialEq + ?Sized> PartialEq for CowArc<'data, T> {
impl<T: PartialEq + ?Sized> 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<T: Hash + ?Sized> Hash for CowArc<'_, T> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.data().hash(state);
}
}

impl<'data, T: PartialOrd + ?Sized> PartialOrd for CowArc<'data, T> {
impl<T: PartialOrd + ?Sized> PartialOrd for CowArc<'_, T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.data().partial_cmp(other.data())
}
}

impl<'data, T: Eq + ?Sized> Eq for CowArc<'data, T> {}
impl<T: Eq + ?Sized> Eq for CowArc<'_, T> {}

impl<'data, T: Ord + ?Sized> Ord for CowArc<'data, T> {
impl<T: Ord + ?Sized> Ord for CowArc<'_, T> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.data().cmp(other.data())
}
Expand Down
2 changes: 1 addition & 1 deletion src/crate_index/lib_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct LibTreeBuilder<'a> {
pkg_name_to_ids: &'a FxHashMap<Arc<str>, Vec<PackageId>>,
}

impl<'a> LibTreeBuilder<'a> {
impl LibTreeBuilder<'_> {
fn build(mut self, dir: &Path) -> Result<LibTree> {
let output = Command::new("cargo")
.current_dir(dir)
Expand Down
14 changes: 7 additions & 7 deletions src/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Namespace {
}
}

impl<'input> DebugName<'input> {
impl DebugName<'_> {
pub(crate) fn names_iterator(&self) -> NamesIterator<NonMangledIterator> {
NamesIterator::new(NonMangledIterator::new(
&self.namespace.parts,
Expand Down Expand Up @@ -186,7 +186,7 @@ pub(crate) struct NamePartsIterator<'it, 'data, I: Clone + Iterator<Item = Deman
ended: bool,
}

impl<'it, 'data, I> Iterator for NamePartsIterator<'it, 'data, I>
impl<'data, I> Iterator for NamePartsIterator<'_, 'data, I>
where
I: Clone + Iterator<Item = DemangleToken<'data>>,
{
Expand All @@ -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<Item = DemangleToken<'data>>,
{
Expand Down Expand Up @@ -343,7 +343,7 @@ impl<'data, I: Clone + Iterator<Item = DemangleToken<'data>>> Iterator
}
}

impl<'input> DebugName<'input> {
impl DebugName<'_> {
pub(crate) fn to_heap(&self) -> DebugName<'static> {
DebugName {
namespace: self.namespace.clone(),
Expand Down Expand Up @@ -377,7 +377,7 @@ enum NamesIteratorState<I> {
},
}

impl<'input> SymbolAndName<'input> {
impl SymbolAndName<'_> {
pub(crate) fn symbol_or_debug_name(&self) -> Result<SymbolOrDebugName> {
if let Some(debug_name) = self.debug_name.as_ref() {
return Ok(SymbolOrDebugName::DebugName(debug_name.to_heap()));
Expand All @@ -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)?;
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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))?;
Expand All @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/symbol_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl ScanOutputs {
}
}

impl<'input, 'backtracer> ApiUsageCollector<'input, 'backtracer> {
impl<'input> ApiUsageCollector<'input, '_> {
fn process_file(
&mut self,
filename: &Path,
Expand Down Expand Up @@ -552,7 +552,7 @@ enum LocationFetcher<'a> {
AlreadyResolved(&'a SourceLocation),
}

impl<'a> LocationFetcher<'a> {
impl LocationFetcher<'_> {
fn location(&self) -> Result<SourceLocation> {
match self {
LocationFetcher::FrameWithFallback {
Expand Down Expand Up @@ -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<Self, ()> {
let addr2line::Location {
Expand All @@ -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.
Expand Down Expand Up @@ -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()),
Expand All @@ -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),
Expand Down
10 changes: 5 additions & 5 deletions src/symbol_graph/dwarf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SourceLocation> {
let line = self
.line
Expand Down Expand Up @@ -254,7 +254,7 @@ struct UnitState<'input, 'dwarf> {
subprogram_namespaces: FxHashMap<UnitOffset, Namespace>,
}

impl<'input, 'dwarf> UnitState<'input, 'dwarf> {
impl<'input> UnitState<'input, '_> {
fn attr_string(
&self,
attr: AttributeValue<EndianSlice<'input, LittleEndian>, usize>,
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -403,7 +403,7 @@ struct DwarfScanner<'input> {
units: Vec<gimli::Unit<EndianSlice<'input, LittleEndian>>>,
}

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 {
Expand Down

0 comments on commit 26fc381

Please sign in to comment.