mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:26:23 +00:00
red-knot: Use parse_unchecked
to get all parse errors (#11725)
This commit is contained in:
parent
0c75548146
commit
64165bee43
8 changed files with 58 additions and 125 deletions
|
@ -64,7 +64,6 @@
|
|||
//! [parsing]: https://en.wikipedia.org/wiki/Parsing
|
||||
//! [lexer]: crate::lexer
|
||||
|
||||
use std::cell::OnceCell;
|
||||
use std::ops::Deref;
|
||||
|
||||
pub use crate::error::{FStringErrorType, ParseError, ParseErrorType};
|
||||
|
@ -308,7 +307,7 @@ impl Parsed<Mod> {
|
|||
/// returns [`None`].
|
||||
///
|
||||
/// [`Some(Parsed<ModModule>)`]: Some
|
||||
fn try_into_module(self) -> Option<Parsed<ModModule>> {
|
||||
pub fn try_into_module(self) -> Option<Parsed<ModModule>> {
|
||||
match self.syntax {
|
||||
Mod::Module(module) => Some(Parsed {
|
||||
syntax: module,
|
||||
|
@ -327,7 +326,7 @@ impl Parsed<Mod> {
|
|||
/// Otherwise, it returns [`None`].
|
||||
///
|
||||
/// [`Some(Parsed<ModExpression>)`]: Some
|
||||
fn try_into_expression(self) -> Option<Parsed<ModExpression>> {
|
||||
pub fn try_into_expression(self) -> Option<Parsed<ModExpression>> {
|
||||
match self.syntax {
|
||||
Mod::Module(_) => None,
|
||||
Mod::Expression(expression) => Some(Parsed {
|
||||
|
@ -370,14 +369,14 @@ pub struct Tokens {
|
|||
raw: Vec<Token>,
|
||||
|
||||
/// Index of the first [`TokenKind::Unknown`] token or the length of the token vector.
|
||||
first_unknown_or_len: OnceCell<usize>,
|
||||
first_unknown_or_len: std::sync::OnceLock<usize>,
|
||||
}
|
||||
|
||||
impl Tokens {
|
||||
pub(crate) fn new(tokens: Vec<Token>) -> Tokens {
|
||||
Tokens {
|
||||
raw: tokens,
|
||||
first_unknown_or_len: OnceCell::new(),
|
||||
first_unknown_or_len: std::sync::OnceLock::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue