Skip to content

Commit ae262ec

Browse files
authored
fix: avoid reloading files to pcx (foundry-rs#11076)
* fix: avoid reuploading files (without lang check) * improve docs
1 parent ecdb1ea commit ae262ec

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

crates/lint/src/linter/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ use crate::inline_config::InlineConfig;
2929
/// - `init`: Creates a new solar `Session` with the appropriate linter configuration.
3030
/// - `early_lint`: Scans the source files (using the AST) emitting a diagnostic for lints found.
3131
/// - `late_lint`: Scans the source files (using the HIR) emitting a diagnostic for lints found.
32+
///
33+
/// # Note:
34+
///
35+
/// - For `early_lint` and `late_lint`, the `ParsingContext` should have the sources pre-loaded.
3236
pub trait Linter: Send + Sync + Clone {
3337
type Language: Language;
3438
type Lint: Lint;

crates/lint/src/sol/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,12 @@ impl Linter for SolidityLinter {
199199
sess
200200
}
201201

202-
/// Run AST-based lints
203-
fn early_lint<'sess>(&self, input: &[PathBuf], mut pcx: ParsingContext<'sess>) {
202+
/// Run AST-based lints.
203+
///
204+
/// Note: the `ParsingContext` should already have the sources loaded.
205+
fn early_lint<'sess>(&self, input: &[PathBuf], pcx: ParsingContext<'sess>) {
204206
let sess = pcx.sess;
205207
_ = sess.enter_parallel(|| -> Result<(), diagnostics::ErrorGuaranteed> {
206-
// Load all files into the parsing ctx
207-
pcx.load_files(input)?;
208-
209208
// Parse the sources
210209
let ast_arena = solar_sema::thread_local::ThreadLocal::new();
211210
let ast_result = pcx.parse(&ast_arena);
@@ -223,13 +222,12 @@ impl Linter for SolidityLinter {
223222
});
224223
}
225224

226-
/// Run HIR-based lints
227-
fn late_lint<'sess>(&self, input: &[PathBuf], mut pcx: ParsingContext<'sess>) {
225+
/// Run HIR-based lints.
226+
///
227+
/// Note: the `ParsingContext` should already have the sources loaded.
228+
fn late_lint<'sess>(&self, input: &[PathBuf], pcx: ParsingContext<'sess>) {
228229
let sess = pcx.sess;
229230
_ = sess.enter_parallel(|| -> Result<(), diagnostics::ErrorGuaranteed> {
230-
// Load all files into the parsing ctx
231-
pcx.load_files(input)?;
232-
233231
// Parse and lower to HIR
234232
let hir_arena = solar_sema::thread_local::ThreadLocal::new();
235233
let hir_result = pcx.parse_and_lower(&hir_arena);

0 commit comments

Comments
 (0)