mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-15 10:20:26 +00:00
Convert OldDiagnostic::noqa_code to an Option<String> (#18946)
## Summary I think this should be the last step before combining `OldDiagnostic` and `ruff_db::Diagnostic`. We can't store a `NoqaCode` on `ruff_db::Diagnostic`, so I converted the `noqa_code` field to an `Option<String>` and then propagated this change to all of the callers. I tried to use `&str` everywhere it was possible, so I think the remaining `to_string` calls are necessary. I spent some time trying to convert _everything_ to `&str` but ran into lifetime issues, especially in the `FixTable`. Maybe we can take another look at that if it causes a performance regression, but hopefully these paths aren't too hot. We also avoid some `to_string` calls, so it might even out a bit too. ## Test Plan Existing tests --------- Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
efcb63fe3a
commit
96f3c8d1ab
22 changed files with 217 additions and 148 deletions
|
|
@ -46,6 +46,12 @@ impl PartialEq<&str> for NoqaCode {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq<NoqaCode> for &str {
|
||||
fn eq(&self, other: &NoqaCode) -> bool {
|
||||
other.eq(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl serde::Serialize for NoqaCode {
|
||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||
where
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue