You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: Make Parser methods immutable using interior mutability
Changed all parsing methods to take '&self' instead of '\&mut self'.
Mutable parser state (token index and parser state) now uses
for interior mutability.
This refactoring is preparation for the borrowed tokenizer work. When
holding borrowed tokens from the parser (with lifetime tied to '\&self'),
we cannot call methods requiring '\&mut self' due to Rust's borrowing
rules. Using interior mutability resolves this conflict by allowing
state mutations through shared references.
Copy file name to clipboardExpand all lines: src/ast/spans.rs
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -2383,7 +2383,7 @@ pub mod tests {
2383
2383
#[test]
2384
2384
fntest_join(){
2385
2385
let dialect = &GenericDialect;
2386
-
letmuttest = SpanTest::new(
2386
+
let test = SpanTest::new(
2387
2387
dialect,
2388
2388
"SELECT id, name FROM users LEFT JOIN companies ON users.company_id = companies.id",
2389
2389
);
@@ -2408,7 +2408,7 @@ pub mod tests {
2408
2408
#[test]
2409
2409
pubfntest_union(){
2410
2410
let dialect = &GenericDialect;
2411
-
letmuttest = SpanTest::new(
2411
+
let test = SpanTest::new(
2412
2412
dialect,
2413
2413
"SELECT a FROM postgres.public.source UNION SELECT a FROM postgres.public.source",
2414
2414
);
@@ -2425,7 +2425,7 @@ pub mod tests {
2425
2425
#[test]
2426
2426
pubfntest_subquery(){
2427
2427
let dialect = &GenericDialect;
2428
-
letmuttest = SpanTest::new(
2428
+
let test = SpanTest::new(
2429
2429
dialect,
2430
2430
"SELECT a FROM (SELECT a FROM postgres.public.source) AS b",
2431
2431
);
@@ -2450,7 +2450,7 @@ pub mod tests {
2450
2450
#[test]
2451
2451
pubfntest_cte(){
2452
2452
let dialect = &GenericDialect;
2453
-
letmuttest = SpanTest::new(dialect,"WITH cte_outer AS (SELECT a FROM postgres.public.source), cte_ignored AS (SELECT a FROM cte_outer), cte_inner AS (SELECT a FROM cte_outer) SELECT a FROM cte_inner");
2453
+
let test = SpanTest::new(dialect,"WITH cte_outer AS (SELECT a FROM postgres.public.source), cte_ignored AS (SELECT a FROM cte_outer), cte_inner AS (SELECT a FROM cte_outer) SELECT a FROM cte_inner");
2454
2454
2455
2455
let query = test.0.parse_query().unwrap();
2456
2456
@@ -2462,7 +2462,7 @@ pub mod tests {
2462
2462
#[test]
2463
2463
pubfntest_snowflake_lateral_flatten(){
2464
2464
let dialect = &SnowflakeDialect;
2465
-
letmuttest = SpanTest::new(dialect,"SELECT FLATTENED.VALUE:field::TEXT AS FIELD FROM SNOWFLAKE.SCHEMA.SOURCE AS S, LATERAL FLATTEN(INPUT => S.JSON_ARRAY) AS FLATTENED");
2465
+
let test = SpanTest::new(dialect,"SELECT FLATTENED.VALUE:field::TEXT AS FIELD FROM SNOWFLAKE.SCHEMA.SOURCE AS S, LATERAL FLATTEN(INPUT => S.JSON_ARRAY) AS FLATTENED");
2466
2466
2467
2467
let query = test.0.parse_select().unwrap();
2468
2468
@@ -2474,7 +2474,7 @@ pub mod tests {
2474
2474
#[test]
2475
2475
pubfntest_wildcard_from_cte(){
2476
2476
let dialect = &GenericDialect;
2477
-
letmuttest = SpanTest::new(
2477
+
let test = SpanTest::new(
2478
2478
dialect,
2479
2479
"WITH cte AS (SELECT a FROM postgres.public.source) SELECT cte.* FROM cte",
2480
2480
);
@@ -2500,7 +2500,7 @@ pub mod tests {
2500
2500
#[test]
2501
2501
fntest_case_expr_span(){
2502
2502
let dialect = &GenericDialect;
2503
-
letmuttest = SpanTest::new(dialect,"CASE 1 WHEN 2 THEN 3 ELSE 4 END");
2503
+
let test = SpanTest::new(dialect,"CASE 1 WHEN 2 THEN 3 ELSE 4 END");
0 commit comments