-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
|
There was a problem hiding this 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.
crates/red_knot/src/lint.rs
Outdated
@@ -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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
6050bc1
to
8f75726
Compare
* 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)
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