mirror of https://github.com/astral-sh/ruff
red_knot_python_semantic: remove `Deref` impl on `TypeCheckDiagnostics`
I removed this to see how much code was depending internally on the `&[Arc<TypeCheckDiagnostic>]` representation. Thankfully, it was just one place. So I just removed the `Deref` impl in favor of adding an explicit `iter` method. In general, I think using `Deref` for things like this is _somewhat_ of an abuse. The tip-off is if there are `&self` or `&mut self` methods on the type, then it's probably not a good candidate for `Deref`.
This commit is contained in:
parent
d382065f8a
commit
a953373892
|
|
@ -17,7 +17,6 @@ use ruff_text_size::{Ranged, TextRange};
|
|||
use rustc_hash::FxHashSet;
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::Formatter;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Registers all known type check lints.
|
||||
|
|
@ -985,6 +984,10 @@ impl TypeCheckDiagnostics {
|
|||
self.used_suppressions.shrink_to_fit();
|
||||
self.diagnostics.shrink_to_fit();
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> std::slice::Iter<'_, Arc<TypeCheckDiagnostic>> {
|
||||
self.diagnostics.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for TypeCheckDiagnostics {
|
||||
|
|
@ -993,14 +996,6 @@ impl std::fmt::Debug for TypeCheckDiagnostics {
|
|||
}
|
||||
}
|
||||
|
||||
impl Deref for TypeCheckDiagnostics {
|
||||
type Target = [std::sync::Arc<TypeCheckDiagnostic>];
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.diagnostics
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoIterator for TypeCheckDiagnostics {
|
||||
type Item = Arc<TypeCheckDiagnostic>;
|
||||
type IntoIter = std::vec::IntoIter<std::sync::Arc<TypeCheckDiagnostic>>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue