Fix fuzzer build (#14911)

This commit is contained in:
Micha Reiser 2024-12-11 14:06:51 +01:00 committed by GitHub
parent 881375a8d9
commit 01d16e8941
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,7 +9,8 @@ use libfuzzer_sys::{fuzz_target, Corpus};
use red_knot_python_semantic::types::check_types; use red_knot_python_semantic::types::check_types;
use red_knot_python_semantic::{ use red_knot_python_semantic::{
Db as SemanticDb, Program, ProgramSettings, PythonVersion, SearchPathSettings, default_lint_registry, lint::RuleSelection, Db as SemanticDb, Program, ProgramSettings,
PythonVersion, SearchPathSettings,
}; };
use ruff_db::files::{system_path_to_file, File, Files}; use ruff_db::files::{system_path_to_file, File, Files};
use ruff_db::system::{DbWithTestSystem, System, SystemPathBuf, TestSystem}; use ruff_db::system::{DbWithTestSystem, System, SystemPathBuf, TestSystem};
@ -27,6 +28,7 @@ struct TestDb {
system: TestSystem, system: TestSystem,
vendored: VendoredFileSystem, vendored: VendoredFileSystem,
events: std::sync::Arc<std::sync::Mutex<Vec<salsa::Event>>>, events: std::sync::Arc<std::sync::Mutex<Vec<salsa::Event>>>,
rule_selection: std::sync::Arc<RuleSelection>,
} }
impl TestDb { impl TestDb {
@ -37,6 +39,7 @@ impl TestDb {
vendored: red_knot_vendored::file_system().clone(), vendored: red_knot_vendored::file_system().clone(),
events: std::sync::Arc::default(), events: std::sync::Arc::default(),
files: Files::default(), files: Files::default(),
rule_selection: RuleSelection::from_registry(&default_lint_registry()).into(),
} }
} }
} }
@ -80,6 +83,10 @@ impl SemanticDb for TestDb {
fn is_file_open(&self, file: File) -> bool { fn is_file_open(&self, file: File) -> bool {
!file.path(self).is_vendored_path() !file.path(self).is_vendored_path()
} }
fn rule_selection(&self) -> &RuleSelection {
&self.rule_selection
}
} }
#[salsa::db] #[salsa::db]