Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

red-knot: Use parse_unchecked to get all parse errors #11725

Merged
merged 3 commits into from
Jun 4, 2024

Conversation

MichaReiser
Copy link
Member

Summary

The parser now supports to return all parse errors instead of just the first. Let's use that and also reuse the ast's Parsed module instead of defining our own.

Test Plan

cargo test

@MichaReiser MichaReiser added the red-knot Multi-file analysis & type inference label Jun 3, 2024
Copy link
Contributor

github-actions bot commented Jun 3, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Love a PR that removes more lines of code than it adds.

@@ -86,7 +87,7 @@ pub(crate) fn lint_semantic(db: &dyn LintDb, file_id: FileId) -> QueryResult<Dia
let context = SemanticLintContext {
file_id: *file_id,
source,
parsed,
parsed: &*parsed,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the reborrow here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parsed returns an Arc<Parsed<...>>. We could either pass in the owned Arc, or just the reference as I do here because we never need to clone (and the context already has lifetimes anyway)

crates/red_knot/src/parse.rs Outdated Show resolved Hide resolved
@MichaReiser MichaReiser force-pushed the red-knot-use-parse-unchecked branch from 6050bc1 to 8f75726 Compare June 4, 2024 05:59
@MichaReiser MichaReiser enabled auto-merge (squash) June 4, 2024 05:59
@MichaReiser MichaReiser merged commit 64165be into main Jun 4, 2024
16 checks passed
@MichaReiser MichaReiser deleted the red-knot-use-parse-unchecked branch June 4, 2024 06:04
carljm added a commit that referenced this pull request Jun 4, 2024
* main:
  CI: add job to run tests under minimum supported rust version (msrv) (#11737)
  Lexer should consider BOM for the start offset (#11732)
  Use cursor offset for lexer checkpoint (#11734)
  red-knot: Change `resolve_global_symbol` to take `Module` as an argument (#11723)
  red-knot: Use `parse_unchecked` to get all parse errors (#11725)
  Respect per-file ignores for blanket and redirected noqa rules (#11728)
  [`pygrep_hooks`] Check blanket ignores via file-level pragmas (`PGH004`) (#11540)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red-knot Multi-file analysis & type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants