Skip to content

Commit fa41a1e

Browse files
dvermdyouknowone
authored andcommitted
Fix ast types' _fields and use 0-based column
1 parent 952d70b commit fa41a1e

56 files changed

Lines changed: 480 additions & 480 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎ast/asdl_rs.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ def gen_classdef(self, name, fields, attrs, depth, base="AstNode"):
449449
f"ctx.new_str(ascii!({json.dumps(f.name)})).into()" for f in fields
450450
)
451451
self.emit(
452-
f"class.set_attr(identifier!(ctx, _fields), ctx.new_list(vec![{fields}]).into());",
452+
f"class.set_attr(identifier!(ctx, _fields), ctx.new_tuple(vec![{fields}]).into());",
453453
depth + 2,
454454
)
455455
attrs = ",".join(

‎core/src/location.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl Location {
4343

4444
pub fn reset(&mut self) {
4545
self.row = 1;
46-
self.column = 1;
46+
self.column = 0;
4747
}
4848

4949
pub fn go_right(&mut self) {

‎parser/src/parser.rs‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ pub fn parse_program(source: &str, source_path: &str) -> Result<ast::Suite, Pars
3535
/// assert_eq!(
3636
/// expr,
3737
/// ast::Expr {
38-
/// location: ast::Location::new(1, 3),
39-
/// end_location: Some(ast::Location::new(1, 6)),
38+
/// location: ast::Location::new(1, 2),
39+
/// end_location: Some(ast::Location::new(1, 5)),
4040
/// custom: (),
4141
/// node: ast::ExprKind::BinOp {
4242
/// left: Box::new(ast::Expr {
43-
/// location: ast::Location::new(1, 1),
44-
/// end_location: Some(ast::Location::new(1, 2)),
43+
/// location: ast::Location::new(1, 0),
44+
/// end_location: Some(ast::Location::new(1, 1)),
4545
/// custom: (),
4646
/// node: ast::ExprKind::Constant {
4747
/// value: ast::Constant::Int(1.into()),
@@ -50,8 +50,8 @@ pub fn parse_program(source: &str, source_path: &str) -> Result<ast::Suite, Pars
5050
/// }),
5151
/// op: ast::Operator::Add,
5252
/// right: Box::new(ast::Expr {
53-
/// location: ast::Location::new(1, 5),
54-
/// end_location: Some(ast::Location::new(1, 6)),
53+
/// location: ast::Location::new(1, 4),
54+
/// end_location: Some(ast::Location::new(1, 5)),
5555
/// custom: (),
5656
/// node: ast::ExprKind::Constant {
5757
/// value: ast::Constant::Int(2.into()),

‎parser/src/snapshots/rustpython_parser__context__tests__ann_assign_name.snap‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ expression: parse_ast
66
Located {
77
location: Location {
88
row: 1,
9-
column: 1,
9+
column: 0,
1010
},
1111
end_location: Some(
1212
Location {
1313
row: 1,
14-
column: 11,
14+
column: 10,
1515
},
1616
),
1717
custom: (),
1818
node: AnnAssign {
1919
target: Located {
2020
location: Location {
2121
row: 1,
22-
column: 1,
22+
column: 0,
2323
},
2424
end_location: Some(
2525
Location {
2626
row: 1,
27-
column: 2,
27+
column: 1,
2828
},
2929
),
3030
custom: (),
@@ -36,12 +36,12 @@ expression: parse_ast
3636
annotation: Located {
3737
location: Location {
3838
row: 1,
39-
column: 4,
39+
column: 3,
4040
},
4141
end_location: Some(
4242
Location {
4343
row: 1,
44-
column: 7,
44+
column: 6,
4545
},
4646
),
4747
custom: (),
@@ -54,12 +54,12 @@ expression: parse_ast
5454
Located {
5555
location: Location {
5656
row: 1,
57-
column: 10,
57+
column: 9,
5858
},
5959
end_location: Some(
6060
Location {
6161
row: 1,
62-
column: 11,
62+
column: 10,
6363
},
6464
),
6565
custom: (),

‎parser/src/snapshots/rustpython_parser__context__tests__assign_attribute.snap‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ expression: parse_ast
66
Located {
77
location: Location {
88
row: 1,
9-
column: 1,
9+
column: 0,
1010
},
1111
end_location: Some(
1212
Location {
1313
row: 1,
14-
column: 16,
14+
column: 15,
1515
},
1616
),
1717
custom: (),
@@ -20,25 +20,25 @@ expression: parse_ast
2020
Located {
2121
location: Location {
2222
row: 1,
23-
column: 1,
23+
column: 0,
2424
},
2525
end_location: Some(
2626
Location {
2727
row: 1,
28-
column: 4,
28+
column: 3,
2929
},
3030
),
3131
custom: (),
3232
node: Attribute {
3333
value: Located {
3434
location: Location {
3535
row: 1,
36-
column: 1,
36+
column: 0,
3737
},
3838
end_location: Some(
3939
Location {
4040
row: 1,
41-
column: 2,
41+
column: 1,
4242
},
4343
),
4444
custom: (),
@@ -55,12 +55,12 @@ expression: parse_ast
5555
value: Located {
5656
location: Location {
5757
row: 1,
58-
column: 8,
58+
column: 7,
5959
},
6060
end_location: Some(
6161
Location {
6262
row: 1,
63-
column: 15,
63+
column: 14,
6464
},
6565
),
6666
custom: (),
@@ -69,12 +69,12 @@ expression: parse_ast
6969
Located {
7070
location: Location {
7171
row: 1,
72-
column: 8,
72+
column: 7,
7373
},
7474
end_location: Some(
7575
Location {
7676
row: 1,
77-
column: 9,
77+
column: 8,
7878
},
7979
),
8080
custom: (),
@@ -88,12 +88,12 @@ expression: parse_ast
8888
Located {
8989
location: Location {
9090
row: 1,
91-
column: 11,
91+
column: 10,
9292
},
9393
end_location: Some(
9494
Location {
9595
row: 1,
96-
column: 12,
96+
column: 11,
9797
},
9898
),
9999
custom: (),
@@ -107,12 +107,12 @@ expression: parse_ast
107107
Located {
108108
location: Location {
109109
row: 1,
110-
column: 14,
110+
column: 13,
111111
},
112112
end_location: Some(
113113
Location {
114114
row: 1,
115-
column: 15,
115+
column: 14,
116116
},
117117
),
118118
custom: (),

‎parser/src/snapshots/rustpython_parser__context__tests__assign_for.snap‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ expression: parse_ast
66
Located {
77
location: Location {
88
row: 1,
9-
column: 1,
9+
column: 0,
1010
},
1111
end_location: Some(
1212
Location {
1313
row: 1,
14-
column: 25,
14+
column: 24,
1515
},
1616
),
1717
custom: (),
1818
node: For {
1919
target: Located {
2020
location: Location {
2121
row: 1,
22-
column: 5,
22+
column: 4,
2323
},
2424
end_location: Some(
2525
Location {
2626
row: 1,
27-
column: 6,
27+
column: 5,
2828
},
2929
),
3030
custom: (),
@@ -36,12 +36,12 @@ expression: parse_ast
3636
iter: Located {
3737
location: Location {
3838
row: 1,
39-
column: 11,
39+
column: 10,
4040
},
4141
end_location: Some(
4242
Location {
4343
row: 1,
44-
column: 18,
44+
column: 17,
4545
},
4646
),
4747
custom: (),
@@ -50,12 +50,12 @@ expression: parse_ast
5050
Located {
5151
location: Location {
5252
row: 1,
53-
column: 11,
53+
column: 10,
5454
},
5555
end_location: Some(
5656
Location {
5757
row: 1,
58-
column: 12,
58+
column: 11,
5959
},
6060
),
6161
custom: (),
@@ -69,12 +69,12 @@ expression: parse_ast
6969
Located {
7070
location: Location {
7171
row: 1,
72-
column: 14,
72+
column: 13,
7373
},
7474
end_location: Some(
7575
Location {
7676
row: 1,
77-
column: 15,
77+
column: 14,
7878
},
7979
),
8080
custom: (),
@@ -88,12 +88,12 @@ expression: parse_ast
8888
Located {
8989
location: Location {
9090
row: 1,
91-
column: 17,
91+
column: 16,
9292
},
9393
end_location: Some(
9494
Location {
9595
row: 1,
96-
column: 18,
96+
column: 17,
9797
},
9898
),
9999
custom: (),
@@ -112,12 +112,12 @@ expression: parse_ast
112112
Located {
113113
location: Location {
114114
row: 1,
115-
column: 21,
115+
column: 20,
116116
},
117117
end_location: Some(
118118
Location {
119119
row: 1,
120-
column: 25,
120+
column: 24,
121121
},
122122
),
123123
custom: (),

0 commit comments

Comments
 (0)