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
@@ -2407,7 +2407,7 @@ pub mod tests {
2407
2407
#[test]
2408
2408
fntest_join(){
2409
2409
let dialect = &GenericDialect;
2410
-
letmuttest = SpanTest::new(
2410
+
let test = SpanTest::new(
2411
2411
dialect,
2412
2412
"SELECT id, name FROM users LEFT JOIN companies ON users.company_id = companies.id",
2413
2413
);
@@ -2432,7 +2432,7 @@ pub mod tests {
2432
2432
#[test]
2433
2433
pubfntest_union(){
2434
2434
let dialect = &GenericDialect;
2435
-
letmuttest = SpanTest::new(
2435
+
let test = SpanTest::new(
2436
2436
dialect,
2437
2437
"SELECT a FROM postgres.public.source UNION SELECT a FROM postgres.public.source",
2438
2438
);
@@ -2449,7 +2449,7 @@ pub mod tests {
2449
2449
#[test]
2450
2450
pubfntest_subquery(){
2451
2451
let dialect = &GenericDialect;
2452
-
letmuttest = SpanTest::new(
2452
+
let test = SpanTest::new(
2453
2453
dialect,
2454
2454
"SELECT a FROM (SELECT a FROM postgres.public.source) AS b",
2455
2455
);
@@ -2474,7 +2474,7 @@ pub mod tests {
2474
2474
#[test]
2475
2475
pubfntest_cte(){
2476
2476
let dialect = &GenericDialect;
2477
-
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");
2477
+
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");
2478
2478
2479
2479
let query = test.0.parse_query().unwrap();
2480
2480
@@ -2486,7 +2486,7 @@ pub mod tests {
2486
2486
#[test]
2487
2487
pubfntest_snowflake_lateral_flatten(){
2488
2488
let dialect = &SnowflakeDialect;
2489
-
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");
2489
+
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");
2490
2490
2491
2491
let query = test.0.parse_select().unwrap();
2492
2492
@@ -2498,7 +2498,7 @@ pub mod tests {
2498
2498
#[test]
2499
2499
pubfntest_wildcard_from_cte(){
2500
2500
let dialect = &GenericDialect;
2501
-
letmuttest = SpanTest::new(
2501
+
let test = SpanTest::new(
2502
2502
dialect,
2503
2503
"WITH cte AS (SELECT a FROM postgres.public.source) SELECT cte.* FROM cte",
2504
2504
);
@@ -2524,7 +2524,7 @@ pub mod tests {
2524
2524
#[test]
2525
2525
fntest_case_expr_span(){
2526
2526
let dialect = &GenericDialect;
2527
-
letmuttest = SpanTest::new(dialect,"CASE 1 WHEN 2 THEN 3 ELSE 4 END");
2527
+
let test = SpanTest::new(dialect,"CASE 1 WHEN 2 THEN 3 ELSE 4 END");
0 commit comments