Skip to content

Commit ff808ad

Browse files
committed
more location -> start()
1 parent 0897385 commit ff808ad

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

compiler/codegen/src/compile.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ impl Compiler {
554554

555555
fn compile_statement(&mut self, statement: &ast::Stmt) -> CompileResult<()> {
556556
trace!("Compiling {:?}", statement);
557-
self.set_source_location(statement.location);
557+
self.set_source_location(statement.start());
558558
use ast::StmtKind::*;
559559

560560
match &statement.node {
@@ -598,8 +598,9 @@ impl Compiler {
598598

599599
let from_list = if import_star {
600600
if self.ctx.in_func() {
601-
return Err(self
602-
.error_loc(CodegenErrorType::FunctionImportStar, statement.location));
601+
return Err(
602+
self.error_loc(CodegenErrorType::FunctionImportStar, statement.start())
603+
);
603604
}
604605
vec![ConstantData::Str {
605606
value: "*".to_owned(),
@@ -800,7 +801,7 @@ impl Compiler {
800801
emit!(self, Instruction::Break { target: end });
801802
}
802803
None => {
803-
return Err(self.error_loc(CodegenErrorType::InvalidBreak, statement.location));
804+
return Err(self.error_loc(CodegenErrorType::InvalidBreak, statement.start()));
804805
}
805806
},
806807
Continue => match self.ctx.loop_data {
@@ -809,13 +810,13 @@ impl Compiler {
809810
}
810811
None => {
811812
return Err(
812-
self.error_loc(CodegenErrorType::InvalidContinue, statement.location)
813+
self.error_loc(CodegenErrorType::InvalidContinue, statement.start())
813814
);
814815
}
815816
},
816817
Return { value } => {
817818
if !self.ctx.in_func() {
818-
return Err(self.error_loc(CodegenErrorType::InvalidReturn, statement.location));
819+
return Err(self.error_loc(CodegenErrorType::InvalidReturn, statement.start()));
819820
}
820821
match value {
821822
Some(v) => {
@@ -825,10 +826,8 @@ impl Compiler {
825826
.flags
826827
.contains(bytecode::CodeFlags::IS_GENERATOR)
827828
{
828-
return Err(self.error_loc(
829-
CodegenErrorType::AsyncReturnValue,
830-
statement.location,
831-
));
829+
return Err(self
830+
.error_loc(CodegenErrorType::AsyncReturnValue, statement.start()));
832831
}
833832
self.compile_expression(v)?;
834833
}
@@ -1487,7 +1486,7 @@ impl Compiler {
14871486

14881487
match &item.optional_vars {
14891488
Some(var) => {
1490-
self.set_source_location(var.location);
1489+
self.set_source_location(var.start());
14911490
self.compile_store(var)?;
14921491
}
14931492
None => {
@@ -1763,7 +1762,7 @@ impl Compiler {
17631762
.ok_or_else(|| {
17641763
self.error_loc(
17651764
CodegenErrorType::TooManyStarUnpack,
1766-
target.location,
1765+
target.start(),
17671766
)
17681767
})?;
17691768
let args = bytecode::UnpackExArgs { before, after };
@@ -2038,7 +2037,7 @@ impl Compiler {
20382037

20392038
fn compile_expression(&mut self, expression: &ast::Expr) -> CompileResult<()> {
20402039
trace!("Compiling {:?}", expression);
2041-
self.set_source_location(expression.location);
2040+
self.set_source_location(expression.start());
20422041

20432042
use ast::ExprKind::*;
20442043
match &expression.node {

compiler/codegen/src/symboltable.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl SymbolTableBuilder {
608608
} else {
609609
SymbolUsage::Parameter
610610
};
611-
self.register_name(&parameter.node.arg, usage, parameter.location)
611+
self.register_name(&parameter.node.arg, usage, parameter.start())
612612
}
613613

614614
fn scan_parameters_annotations(&mut self, parameters: &[ast::Arg]) -> SymbolTableResult {
@@ -635,7 +635,7 @@ impl SymbolTableBuilder {
635635

636636
fn scan_statement(&mut self, statement: &ast::Stmt) -> SymbolTableResult {
637637
use ast::StmtKind::*;
638-
let location = statement.location;
638+
let location = statement.start();
639639
if let ImportFrom { module, names, .. } = &statement.node {
640640
if module.as_deref() == Some("__future__") {
641641
for feature in names {
@@ -867,7 +867,7 @@ impl SymbolTableBuilder {
867867
context: ExpressionContext,
868868
) -> SymbolTableResult {
869869
use ast::ExprKind::*;
870-
let location = expression.location;
870+
let location = expression.start();
871871
match &expression.node {
872872
BinOp { left, right, .. } => {
873873
self.scan_expression(left, context)?;
@@ -1004,7 +1004,7 @@ impl SymbolTableBuilder {
10041004
}
10051005
}
10061006
Lambda { args, body } => {
1007-
self.enter_function("lambda", args, expression.location.row())?;
1007+
self.enter_function("lambda", args, expression.start().row())?;
10081008
match context {
10091009
ExpressionContext::IterDefinitionExp => {
10101010
self.scan_expression(body, ExpressionContext::IterDefinitionExp)?;

0 commit comments

Comments
 (0)