mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 15:14:42 +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
|
@ -237,9 +237,9 @@ Source with applied fixes:
|
|||
|
||||
let messages = messages
|
||||
.into_iter()
|
||||
.filter_map(|msg| Some((msg.noqa_code()?, msg)))
|
||||
.filter_map(|msg| Some((msg.secondary_code()?.to_string(), msg)))
|
||||
.map(|(code, mut diagnostic)| {
|
||||
let rule = Rule::from_code(&code.to_string()).unwrap();
|
||||
let rule = Rule::from_code(&code).unwrap();
|
||||
let fixable = diagnostic.fix().is_some_and(|fix| {
|
||||
matches!(
|
||||
fix.applicability(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue