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
@@ -2371,7 +2371,7 @@ pub mod tests {
2371
2371
#[test]
2372
2372
fntest_join(){
2373
2373
let dialect = &GenericDialect;
2374
-
letmuttest = SpanTest::new(
2374
+
let test = SpanTest::new(
2375
2375
dialect,
2376
2376
"SELECT id, name FROM users LEFT JOIN companies ON users.company_id = companies.id",
2377
2377
);
@@ -2396,7 +2396,7 @@ pub mod tests {
2396
2396
#[test]
2397
2397
pubfntest_union(){
2398
2398
let dialect = &GenericDialect;
2399
-
letmuttest = SpanTest::new(
2399
+
let test = SpanTest::new(
2400
2400
dialect,
2401
2401
"SELECT a FROM postgres.public.source UNION SELECT a FROM postgres.public.source",
2402
2402
);
@@ -2413,7 +2413,7 @@ pub mod tests {
2413
2413
#[test]
2414
2414
pubfntest_subquery(){
2415
2415
let dialect = &GenericDialect;
2416
-
letmuttest = SpanTest::new(
2416
+
let test = SpanTest::new(
2417
2417
dialect,
2418
2418
"SELECT a FROM (SELECT a FROM postgres.public.source) AS b",
2419
2419
);
@@ -2438,7 +2438,7 @@ pub mod tests {
2438
2438
#[test]
2439
2439
pubfntest_cte(){
2440
2440
let dialect = &GenericDialect;
2441
-
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");
2441
+
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");
2442
2442
2443
2443
let query = test.0.parse_query().unwrap();
2444
2444
@@ -2450,7 +2450,7 @@ pub mod tests {
2450
2450
#[test]
2451
2451
pubfntest_snowflake_lateral_flatten(){
2452
2452
let dialect = &SnowflakeDialect;
2453
-
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");
2453
+
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");
2454
2454
2455
2455
let query = test.0.parse_select().unwrap();
2456
2456
@@ -2462,7 +2462,7 @@ pub mod tests {
2462
2462
#[test]
2463
2463
pubfntest_wildcard_from_cte(){
2464
2464
let dialect = &GenericDialect;
2465
-
letmuttest = SpanTest::new(
2465
+
let test = SpanTest::new(
2466
2466
dialect,
2467
2467
"WITH cte AS (SELECT a FROM postgres.public.source) SELECT cte.* FROM cte",
2468
2468
);
@@ -2488,7 +2488,7 @@ pub mod tests {
2488
2488
#[test]
2489
2489
fntest_case_expr_span(){
2490
2490
let dialect = &GenericDialect;
2491
-
letmuttest = SpanTest::new(dialect,"CASE 1 WHEN 2 THEN 3 ELSE 4 END");
2491
+
let test = SpanTest::new(dialect,"CASE 1 WHEN 2 THEN 3 ELSE 4 END");
0 commit comments