mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-16 07:15:17 +00:00
Introduce SourceFile to avoid cloning the message filename (#3904)
This commit is contained in:
parent
056c212975
commit
c33c9dc585
15 changed files with 296 additions and 271 deletions
|
@ -16,6 +16,7 @@ use ruff::settings::{flags, AllSettings};
|
|||
use ruff::{fs, packaging, resolver, warn_user_once, IOError, Range};
|
||||
use ruff_diagnostics::Diagnostic;
|
||||
use ruff_python_ast::imports::ImportMap;
|
||||
use ruff_python_ast::source_code::SourceFileBuilder;
|
||||
|
||||
use crate::args::Overrides;
|
||||
use crate::cache;
|
||||
|
@ -116,14 +117,15 @@ pub fn run(
|
|||
);
|
||||
let settings = resolver.resolve(path, pyproject_strategy);
|
||||
if settings.rules.enabled(Rule::IOError) {
|
||||
let file = SourceFileBuilder::new(&path.to_string_lossy()).finish();
|
||||
|
||||
Diagnostics::new(
|
||||
vec![Message::from_diagnostic(
|
||||
Diagnostic::new(
|
||||
IOError { message },
|
||||
Range::new(Location::default(), Location::default()),
|
||||
),
|
||||
format!("{}", path.display()),
|
||||
None,
|
||||
file,
|
||||
1,
|
||||
)],
|
||||
ImportMap::default(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue