Skip to content

Commit 52f5392

Browse files
committed
Remove redundant position
1 parent 6a9b936 commit 52f5392

13 files changed

Lines changed: 54 additions & 75 deletions

compiler-core/src/ast/typed.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,9 @@ pub enum TypedExpr {
7676
type_: Arc<Type>,
7777
fun: Box<Self>,
7878
arguments: Vec<CallArg<Self>>,
79-
/// Specifies the source location of the argument list, if present. Can
80-
/// be None in cases where the function call has been inferred as part
81-
/// of a pipeline.
82-
///
83-
/// The endpoints of the span will sit before and after the list's
84-
/// parentheses.
85-
argument_parentheses: Option<SrcSpan>,
79+
/// Specifies the source position of the argument list, if present. Can
80+
/// be None in cases where the function call is part of a pipeline.
81+
open_parenthesis: Option<u32>,
8682
},
8783

8884
BinOp {

compiler-core/src/ast/untyped.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub enum UntypedExpr {
5656
location: SrcSpan,
5757
fun: Box<Self>,
5858
arguments: Vec<CallArg<Self>>,
59-
argument_parentheses: SrcSpan,
59+
open_parenthesis: u32,
6060
},
6161

6262
BinOp {

compiler-core/src/ast/visit.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ pub trait Visit<'ast> {
205205
type_: &'ast Arc<Type>,
206206
fun: &'ast TypedExpr,
207207
arguments: &'ast [TypedCallArg],
208-
argument_parentheses: &'ast Option<SrcSpan>,
208+
open_parenthesis: &'ast Option<u32>,
209209
) {
210-
visit_typed_expr_call(self, location, type_, fun, arguments, argument_parentheses);
210+
visit_typed_expr_call(self, location, type_, fun, arguments, open_parenthesis);
211211
}
212212

213213
fn visit_typed_expr_bin_op(
@@ -1271,8 +1271,8 @@ where
12711271
type_,
12721272
fun,
12731273
arguments,
1274-
argument_parentheses,
1275-
} => v.visit_typed_expr_call(location, type_, fun, arguments, argument_parentheses),
1274+
open_parenthesis,
1275+
} => v.visit_typed_expr_call(location, type_, fun, arguments, open_parenthesis),
12761276
TypedExpr::BinOp {
12771277
location,
12781278
type_,
@@ -1511,7 +1511,7 @@ pub fn visit_typed_expr_call<'a, V>(
15111511
_type_: &'a Arc<Type>,
15121512
fun: &'a TypedExpr,
15131513
arguments: &'a [TypedCallArg],
1514-
_arguments_start: &'a Option<SrcSpan>,
1514+
_arguments_start: &'a Option<u32>,
15151515
) where
15161516
V: Visit<'a> + ?Sized,
15171517
{

compiler-core/src/ast_folder.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ pub trait UntypedExprFolder: TypeAstFolder + UntypedConstantFolder + PatternFold
297297
location,
298298
fun,
299299
arguments,
300-
argument_parentheses,
301-
} => self.fold_call(location, fun, arguments, argument_parentheses),
300+
open_parenthesis,
301+
} => self.fold_call(location, fun, arguments, open_parenthesis),
302302

303303
UntypedExpr::BinOp {
304304
location,
@@ -451,7 +451,7 @@ pub trait UntypedExprFolder: TypeAstFolder + UntypedConstantFolder + PatternFold
451451
location,
452452
fun,
453453
arguments,
454-
argument_parentheses,
454+
open_parenthesis,
455455
} => {
456456
let fun = Box::new(self.fold_expr(*fun));
457457
let arguments = arguments
@@ -465,7 +465,7 @@ pub trait UntypedExprFolder: TypeAstFolder + UntypedConstantFolder + PatternFold
465465
location,
466466
fun,
467467
arguments,
468-
argument_parentheses,
468+
open_parenthesis,
469469
}
470470
}
471471

@@ -787,13 +787,13 @@ pub trait UntypedExprFolder: TypeAstFolder + UntypedConstantFolder + PatternFold
787787
location: SrcSpan,
788788
fun: Box<UntypedExpr>,
789789
arguments: Vec<CallArg<UntypedExpr>>,
790-
argument_parentheses: SrcSpan,
790+
open_parenthesis: u32,
791791
) -> UntypedExpr {
792792
UntypedExpr::Call {
793793
location,
794794
fun,
795795
arguments,
796-
argument_parentheses,
796+
open_parenthesis,
797797
}
798798
}
799799

compiler-core/src/inline.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,8 @@ impl Inliner<'_> {
584584
type_,
585585
fun,
586586
arguments,
587-
argument_parentheses,
588-
} => self.call(location, type_, fun, arguments, argument_parentheses),
587+
open_parenthesis,
588+
} => self.call(location, type_, fun, arguments, open_parenthesis),
589589

590590
TypedExpr::BinOp {
591591
location,
@@ -815,7 +815,7 @@ impl Inliner<'_> {
815815
type_: Arc<Type>,
816816
function: Box<TypedExpr>,
817817
arguments: Vec<TypedCallArg>,
818-
argument_parentheses: Option<SrcSpan>,
818+
open_parenthesis: Option<u32>,
819819
) -> TypedExpr {
820820
let arguments = self.arguments(arguments);
821821

@@ -934,7 +934,7 @@ impl Inliner<'_> {
934934
type_,
935935
fun: Box::new(function),
936936
arguments,
937-
argument_parentheses,
937+
open_parenthesis,
938938
}
939939
}
940940

@@ -1896,7 +1896,7 @@ impl InlinableExpression {
18961896
.iter()
18971897
.map(|argument| argument.to_call_arg(Self::to_expression))
18981898
.collect(),
1899-
argument_parentheses: None,
1899+
open_parenthesis: None,
19001900
},
19011901
}
19021902
}

compiler-core/src/parse.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -992,12 +992,7 @@ where
992992
// Call
993993
let arguments = self.parse_fn_arguments()?;
994994
let (_, end) = self.expect_one(&Token::RightParen)?;
995-
let argument_parentheses = SrcSpan {
996-
start: left_paren,
997-
end,
998-
};
999-
expr =
1000-
make_call(expr, arguments, start, end, argument_parentheses)?;
995+
expr = make_call(expr, arguments, start, end, left_paren)?;
1001996
}
1002997
}
1003998
} else {
@@ -5034,7 +5029,7 @@ pub fn make_call(
50345029
arguments: Vec<ParserArg>,
50355030
start: u32,
50365031
end: u32,
5037-
argument_parentheses: SrcSpan,
5032+
open_parenthesis: u32,
50385033
) -> Result<UntypedExpr, ParseError> {
50395034
let mut hole_location = None;
50405035

@@ -5081,7 +5076,7 @@ pub fn make_call(
50815076
location: SrcSpan { start, end },
50825077
fun: Box::new(fun),
50835078
arguments,
5084-
argument_parentheses,
5079+
open_parenthesis,
50855080
};
50865081

50875082
match hole_location {

compiler-core/src/parse/snapshots/gleam_core__parse__tests__nested_tuple_access_after_function.snap

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
source: compiler-core/src/parse/tests.rs
3+
assertion_line: 1882
34
expression: tuple().0.1
5+
snapshot_kind: text
46
---
57
[
68
Expression(
@@ -29,10 +31,7 @@ expression: tuple().0.1
2931
name: "tuple",
3032
},
3133
arguments: [],
32-
argument_parentheses: SrcSpan {
33-
start: 5,
34-
end: 7,
35-
},
34+
open_parenthesis: 5,
3635
},
3736
},
3837
},

compiler-core/src/parse/snapshots/gleam_core__parse__tests__record_access_no_label.snap

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
source: compiler-core/src/parse/tests.rs
3+
assertion_line: 1370
34
expression: "\ntype Wibble {\n Wibble(wibble: String)\n}\n\nfn wobble() {\n Wibble(\"a\").\n}\n"
5+
snapshot_kind: text
46
---
57
Parsed {
68
module: Module {
@@ -146,10 +148,7 @@ Parsed {
146148
implicit: None,
147149
},
148150
],
149-
argument_parentheses: SrcSpan {
150-
start: 67,
151-
end: 72,
152-
},
151+
open_parenthesis: 67,
153152
},
154153
},
155154
),

compiler-core/src/parse/snapshots/gleam_core__parse__tests__string_concatenation_in_case_clause_guard.snap

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
source: compiler-core/src/parse/tests.rs
3+
assertion_line: 1476
34
expression: "\nlet my_string = \"hello \"\ncase my_string {\n _ if my_string <> \"world\" == \"hello world\" -> io.debug(\"ok\")\n}"
5+
snapshot_kind: text
46
---
57
[
68
Assignment(
@@ -161,10 +163,7 @@ expression: "\nlet my_string = \"hello \"\ncase my_string {\n _ if my_string
161163
implicit: None,
162164
},
163165
],
164-
argument_parentheses: SrcSpan {
165-
start: 101,
166-
end: 107,
167-
},
166+
open_parenthesis: 101,
168167
},
169168
},
170169
],

compiler-core/src/type_/expression.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,13 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
496496
location,
497497
fun,
498498
arguments,
499-
argument_parentheses,
499+
open_parenthesis,
500500
..
501501
} => Ok(self.infer_call(
502502
*fun,
503503
arguments,
504504
location,
505-
Some(argument_parentheses),
505+
Some(open_parenthesis),
506506
CallKind::Function,
507507
)),
508508

@@ -1158,7 +1158,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
11581158
fun: UntypedExpr,
11591159
arguments: Vec<CallArg<UntypedExpr>>,
11601160
location: SrcSpan,
1161-
argument_parentheses: Option<SrcSpan>,
1161+
open_parenthesis: Option<u32>,
11621162
kind: CallKind,
11631163
) -> TypedExpr {
11641164
let (fun, arguments, type_) = self.do_infer_call(fun, arguments, location, kind);
@@ -1216,7 +1216,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
12161216
location,
12171217
type_,
12181218
arguments,
1219-
argument_parentheses,
1219+
open_parenthesis,
12201220
fun: Box::new(fun),
12211221
}
12221222
}

0 commit comments

Comments
 (0)