dev: fix lint warnings introduced by #2062 (#2096)
Some checks failed
tinymist::auto_tag / auto-tag (push) Has been cancelled
tinymist::ci / Duplicate Actions Detection (push) Has been cancelled
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Has been cancelled
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Has been cancelled
tinymist::ci / prepare-build (push) Has been cancelled
tinymist::gh_pages / build-gh-pages (push) Has been cancelled
tinymist::ci / announce (push) Has been cancelled
tinymist::ci / build (push) Has been cancelled

> Hm. Sorry about the lint failures here, they slipped my attention
locally since they show up as warnings, not errors, in my editor. I'm
happy to put a PR fixing them later unless you get to it first.
>
> Not too sure how to deal with the unused DiagWorker::check method,
since it is used, just in a test-only module. We can certainly mark it
as #[cfg(test)] but that feels a little nasty.


https://github.com/Myriad-Dreamin/tinymist/pull/2062#issuecomment-3237812684

I ended up inlining the logic of `DiagWorker::check` into the test.
This commit is contained in:
Joseph Liu 2025-08-29 22:50:23 -04:00 committed by GitHub
parent 4324f8fd70
commit 731cd23ec8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 16 deletions

View file

@ -14,6 +14,6 @@ impl SemanticRequest for CheckRequest {
fn request(self, ctx: &mut LocalContext) -> Option<Self::Response> { fn request(self, ctx: &mut LocalContext) -> Option<Self::Response> {
let worker = DiagWorker::new(ctx); let worker = DiagWorker::new(ctx);
Some(worker.full_check().convert_all(self.snap.diagnostics())) Some(worker.check().convert_all(self.snap.diagnostics()))
} }
} }

View file

@ -126,14 +126,20 @@ mod tests {
source: &Source, source: &Source,
request_range: &LspRange, request_range: &LspRange,
) -> CodeActionContext { ) -> CodeActionContext {
let Warned { output, warnings } = typst::compile::<PagedDocument>(&ctx.world); let Warned {
let errors = output.err().unwrap_or_default(); output,
let compiler_diagnostics = warnings.iter().chain(errors.iter()); warnings: compiler_warnings,
} = typst::compile::<PagedDocument>(&ctx.world);
let compiler_errors = output.err().unwrap_or_default();
// Run the linter for additional diagnostics as well. let lint_warnings = ctx.lint(source);
let diagnostics = DiagWorker::new(ctx) let diagnostics = DiagWorker::new(ctx)
.check(source) .convert_all(
.convert_all(compiler_diagnostics) compiler_errors
.iter()
.chain(compiler_warnings.iter())
.chain(lint_warnings.iter()),
)
.into_values() .into_values()
.flatten(); .flatten();

View file

@ -46,16 +46,8 @@ impl<'w> DiagWorker<'w> {
} }
} }
/// Runs code check on the given document.
pub fn check(mut self, source: &Source) -> Self {
for diag in self.ctx.lint(&source) {
self.handle(&diag);
}
self
}
/// Runs code check on the main document and all its dependencies. /// Runs code check on the main document and all its dependencies.
pub fn full_check(mut self) -> Self { pub fn check(mut self) -> Self {
for dep in self.ctx.world.depended_files() { for dep in self.ctx.world.depended_files() {
if WorkspaceResolver::is_package_file(dep) { if WorkspaceResolver::is_package_file(dep) {
continue; continue;