fix: clippy warning of rust 1.8.4 (#14984)

# Description

I'm on rust toolchain 1.8.4, and I can see clippy warnings that can't be
caught by the ci workflow, primarily related to lifetime params.

I think it doesn't hurt to fix those in advance.

# User-Facing Changes

# Tests + Formatting

# After Submitting
This commit is contained in:
zc he
2025-02-02 21:56:54 +08:00
committed by GitHub
parent 5291f978c2
commit 339c5b7c83
16 changed files with 54 additions and 56 deletions

View File

@ -354,7 +354,7 @@ impl EngineState {
pub fn active_overlay_ids<'a, 'b>(
&'b self,
removed_overlays: &'a [Vec<u8>],
) -> impl DoubleEndedIterator<Item = &OverlayId> + 'a
) -> impl DoubleEndedIterator<Item = &'b OverlayId> + 'a
where
'b: 'a,
{
@ -368,7 +368,7 @@ impl EngineState {
pub fn active_overlays<'a, 'b>(
&'b self,
removed_overlays: &'a [Vec<u8>],
) -> impl DoubleEndedIterator<Item = &OverlayFrame> + 'a
) -> impl DoubleEndedIterator<Item = &'b OverlayFrame> + 'a
where
'b: 'a,
{
@ -379,7 +379,7 @@ impl EngineState {
pub fn active_overlay_names<'a, 'b>(
&'b self,
removed_overlays: &'a [Vec<u8>],
) -> impl DoubleEndedIterator<Item = &[u8]> + 'a
) -> impl DoubleEndedIterator<Item = &'b [u8]> + 'a
where
'b: 'a,
{
@ -1061,7 +1061,7 @@ impl EngineState {
}
}
impl<'a> GetSpan for &'a EngineState {
impl GetSpan for &EngineState {
/// Get existing span
fn get_span(&self, span_id: SpanId) -> Span {
*self

View File

@ -120,7 +120,7 @@ impl ScopeFrame {
pub fn active_overlays<'a, 'b>(
&'b self,
removed_overlays: &'a mut Vec<Vec<u8>>,
) -> impl DoubleEndedIterator<Item = &OverlayFrame> + 'a
) -> impl DoubleEndedIterator<Item = &'b OverlayFrame> + 'a
where
'b: 'a,
{

View File

@ -153,7 +153,7 @@ impl<'a> StackIoGuard<'a> {
}
}
impl<'a> Deref for StackIoGuard<'a> {
impl Deref for StackIoGuard<'_> {
type Target = Stack;
fn deref(&self) -> &Self::Target {
@ -161,7 +161,7 @@ impl<'a> Deref for StackIoGuard<'a> {
}
}
impl<'a> DerefMut for StackIoGuard<'a> {
impl DerefMut for StackIoGuard<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.stack
}
@ -202,7 +202,7 @@ impl<'a> StackCollectValueGuard<'a> {
}
}
impl<'a> Deref for StackCollectValueGuard<'a> {
impl Deref for StackCollectValueGuard<'_> {
type Target = Stack;
fn deref(&self) -> &Self::Target {
@ -210,7 +210,7 @@ impl<'a> Deref for StackCollectValueGuard<'a> {
}
}
impl<'a> DerefMut for StackCollectValueGuard<'a> {
impl DerefMut for StackCollectValueGuard<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.stack
}
@ -258,7 +258,7 @@ impl<'a> StackCallArgGuard<'a> {
}
}
impl<'a> Deref for StackCallArgGuard<'a> {
impl Deref for StackCallArgGuard<'_> {
type Target = Stack;
fn deref(&self) -> &Self::Target {
@ -266,7 +266,7 @@ impl<'a> Deref for StackCallArgGuard<'a> {
}
}
impl<'a> DerefMut for StackCallArgGuard<'a> {
impl DerefMut for StackCallArgGuard<'_> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.stack
}

View File

@ -399,7 +399,7 @@ impl<'a> StateWorkingSet<'a> {
}
// if no files with span were found, fall back on permanent ones
return self.permanent_state.get_span_contents(span);
self.permanent_state.get_span_contents(span)
}
pub fn enter_scope(&mut self) {
@ -1105,13 +1105,13 @@ impl<'a> GetSpan for &'a StateWorkingSet<'a> {
}
}
impl<'a> miette::SourceCode for &StateWorkingSet<'a> {
impl miette::SourceCode for &StateWorkingSet<'_> {
fn read_span<'b>(
&'b self,
span: &miette::SourceSpan,
context_lines_before: usize,
context_lines_after: usize,
) -> Result<Box<dyn miette::SpanContents + 'b>, miette::MietteError> {
) -> Result<Box<dyn miette::SpanContents<'b> + 'b>, miette::MietteError> {
let debugging = std::env::var("MIETTE_DEBUG").is_ok();
if debugging {
let finding_span = "Finding span in StateWorkingSet";

View File

@ -96,7 +96,7 @@ impl std::fmt::Debug for CliError<'_> {
}
}
impl<'src> miette::Diagnostic for CliError<'src> {
impl miette::Diagnostic for CliError<'_> {
fn code<'a>(&'a self) -> Option<Box<dyn std::fmt::Display + 'a>> {
self.0.code()
}

View File

@ -7,7 +7,7 @@ pub struct FmtIrBlock<'a> {
pub(super) ir_block: &'a IrBlock,
}
impl<'a> fmt::Display for FmtIrBlock<'a> {
impl fmt::Display for FmtIrBlock<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let plural = |count| if count == 1 { "" } else { "s" };
writeln!(
@ -55,7 +55,7 @@ pub struct FmtInstruction<'a> {
pub(super) data: &'a [u8],
}
impl<'a> fmt::Display for FmtInstruction<'a> {
impl fmt::Display for FmtInstruction<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
const WIDTH: usize = 22;
@ -321,7 +321,7 @@ impl fmt::Display for RedirectMode {
struct FmtData<'a>(&'a [u8], DataSlice);
impl<'a> fmt::Display for FmtData<'a> {
impl fmt::Display for FmtData<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Ok(s) = std::str::from_utf8(&self.0[self.1]) {
// Write as string
@ -338,7 +338,7 @@ struct FmtLiteral<'a> {
data: &'a [u8],
}
impl<'a> fmt::Display for FmtLiteral<'a> {
impl fmt::Display for FmtLiteral<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.literal {
Literal::Bool(b) => write!(f, "bool({b:?})"),
@ -387,7 +387,7 @@ struct FmtPattern<'a> {
pattern: &'a Pattern,
}
impl<'a> fmt::Display for FmtPattern<'a> {
impl fmt::Display for FmtPattern<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.pattern {
Pattern::Record(bindings) => {

View File

@ -2512,7 +2512,7 @@ impl PartialOrd for Value {
impl PartialEq for Value {
fn eq(&self, other: &Self) -> bool {
self.partial_cmp(other).map_or(false, Ordering::is_eq)
self.partial_cmp(other).is_some_and(Ordering::is_eq)
}
}

View File

@ -440,13 +440,13 @@ impl<'a> Iterator for Iter<'a> {
}
}
impl<'a> DoubleEndedIterator for Iter<'a> {
impl DoubleEndedIterator for Iter<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(|(col, val): &(_, _)| (col, val))
}
}
impl<'a> ExactSizeIterator for Iter<'a> {
impl ExactSizeIterator for Iter<'_> {
fn len(&self) -> usize {
self.iter.len()
}
@ -482,13 +482,13 @@ impl<'a> Iterator for IterMut<'a> {
}
}
impl<'a> DoubleEndedIterator for IterMut<'a> {
impl DoubleEndedIterator for IterMut<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(|(col, val)| (&*col, val))
}
}
impl<'a> ExactSizeIterator for IterMut<'a> {
impl ExactSizeIterator for IterMut<'_> {
fn len(&self) -> usize {
self.iter.len()
}
@ -524,13 +524,13 @@ impl<'a> Iterator for Columns<'a> {
}
}
impl<'a> DoubleEndedIterator for Columns<'a> {
impl DoubleEndedIterator for Columns<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(|(col, _)| col)
}
}
impl<'a> ExactSizeIterator for Columns<'a> {
impl ExactSizeIterator for Columns<'_> {
fn len(&self) -> usize {
self.iter.len()
}
@ -584,13 +584,13 @@ impl<'a> Iterator for Values<'a> {
}
}
impl<'a> DoubleEndedIterator for Values<'a> {
impl DoubleEndedIterator for Values<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
self.iter.next_back().map(|(_, val)| val)
}
}
impl<'a> ExactSizeIterator for Values<'a> {
impl ExactSizeIterator for Values<'_> {
fn len(&self) -> usize {
self.iter.len()
}