Skip to content

Commit 65a2124

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Rename CstAssign -> CstAssignTarget
Summary: Because it is typedef to `AssignTargetP`: ``` type CstAssignTarget = AstAssignTargetP<CstPayload>; ``` Minor code cleanup. Reviewed By: cjhopman Differential Revision: D48957721 fbshipit-source-id: f2e4a5498daf5431383a5176e3fd5bfe62931728
1 parent ccd7b44 commit 65a2124

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

starlark/src/eval/compiler/compr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Compiler<'_, '_, '_> {
103103
match next_for {
104104
None => {
105105
let last = ClauseCompiled {
106-
var: self.assign(&for_.var),
106+
var: self.assign_target(&for_.var),
107107
over,
108108
ifs,
109109
};
@@ -112,7 +112,7 @@ impl Compiler<'_, '_, '_> {
112112
Some(f) => {
113113
res.push(ClauseCompiled {
114114
over: self.expr(&f.over),
115-
var: self.assign(&f.var),
115+
var: self.assign_target(&f.var),
116116
ifs,
117117
});
118118
}

starlark/src/eval/compiler/scope/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ use crate::environment::Globals;
5454
use crate::environment::Module;
5555
use crate::errors::did_you_mean::did_you_mean;
5656
use crate::eval::compiler::def::CopySlotFromParent;
57-
use crate::eval::compiler::scope::payload::CstAssign;
5857
use crate::eval::compiler::scope::payload::CstAssignIdent;
58+
use crate::eval::compiler::scope::payload::CstAssignTarget;
5959
use crate::eval::compiler::scope::payload::CstExpr;
6060
use crate::eval::compiler::scope::payload::CstIdent;
6161
use crate::eval::compiler::scope::payload::CstParameter;
@@ -570,7 +570,7 @@ impl<'f> ModuleScopeBuilder<'f> {
570570
}
571571
}
572572

573-
fn resolve_idents_in_assign(&mut self, assign: &mut CstAssign) {
573+
fn resolve_idents_in_assign(&mut self, assign: &mut CstAssignTarget) {
574574
assign.visit_expr_mut(|expr| self.resolve_idents_in_expr(expr));
575575
}
576576

@@ -762,7 +762,7 @@ impl<'f> ModuleScopeBuilder<'f> {
762762
self.unscopes.push(Unscope::default());
763763
}
764764

765-
fn add_compr<'x>(&mut self, var: impl IntoIterator<Item = &'x mut CstAssign>) {
765+
fn add_compr<'x>(&mut self, var: impl IntoIterator<Item = &'x mut CstAssignTarget>) {
766766
let scope_id = self.top_scope_id();
767767
let mut locals = SmallMap::new();
768768
for var in var {
@@ -992,7 +992,7 @@ impl AssignIdentCollect for AssignIdent {
992992

993993
trait AssignTargetCollectDefinesLvalue {
994994
fn collect_defines_lvalue<'a>(
995-
expr: &'a mut CstAssign,
995+
expr: &'a mut CstAssignTarget,
996996
in_loop: InLoop,
997997
scope_data: &mut ModuleScopeData,
998998
frozen_heap: &FrozenHeap,
@@ -1004,7 +1004,7 @@ impl AssignTargetCollectDefinesLvalue for AssignTarget {
10041004
// Collect variables defined in an expression on the LHS of an assignment (or
10051005
// for variable etc)
10061006
fn collect_defines_lvalue<'a>(
1007-
expr: &'a mut CstAssign,
1007+
expr: &'a mut CstAssignTarget,
10081008
in_loop: InLoop,
10091009
scope_data: &mut ModuleScopeData,
10101010
frozen_heap: &FrozenHeap,

starlark/src/eval/compiler/scope/payload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl CstAssignIdentExt for CstAssignIdent {
145145

146146
pub(crate) type CstExpr = AstExprP<CstPayload>;
147147
pub(crate) type CstTypeExpr = AstTypeExprP<CstPayload>;
148-
pub(crate) type CstAssign = AstAssignTargetP<CstPayload>;
148+
pub(crate) type CstAssignTarget = AstAssignTargetP<CstPayload>;
149149
pub(crate) type CstAssignIdent = AstAssignIdentP<CstPayload>;
150150
pub(crate) type CstIdent = AstIdentP<CstPayload>;
151151
pub(crate) type CstArgument = AstArgumentP<CstPayload>;

starlark/src/eval/compiler/scope/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use starlark_syntax::syntax::uniplate::Visit;
2929

3030
use crate::environment::names::MutableNames;
3131
use crate::environment::Globals;
32-
use crate::eval::compiler::scope::payload::CstAssign;
3332
use crate::eval::compiler::scope::payload::CstAssignIdent;
33+
use crate::eval::compiler::scope::payload::CstAssignTarget;
3434
use crate::eval::compiler::scope::payload::CstExpr;
3535
use crate::eval::compiler::scope::payload::CstStmt;
3636
use crate::eval::compiler::scope::AssignCount;
@@ -115,7 +115,7 @@ fn test_with_module(program: &str, expected: &str, module: &MutableNames) {
115115
});
116116
}
117117

118-
fn visit_assign(&mut self, assign: &CstAssign) {
118+
fn visit_assign(&mut self, assign: &CstAssignTarget) {
119119
assign.visit_lvalue(|ident| self.visit_lvalue(ident));
120120
}
121121

starlark/src/eval/compiler/stmt.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ use crate::eval::compiler::expr::ExprLogicalBinOp;
4545
use crate::eval::compiler::expr_bool::ExprCompiledBool;
4646
use crate::eval::compiler::known::list_to_tuple;
4747
use crate::eval::compiler::opt_ctx::OptCtx;
48-
use crate::eval::compiler::scope::payload::CstAssign;
48+
use crate::eval::compiler::scope::payload::CstAssignTarget;
4949
use crate::eval::compiler::scope::payload::CstExpr;
5050
use crate::eval::compiler::scope::payload::CstStmt;
5151
use crate::eval::compiler::scope::Captured;
@@ -393,7 +393,7 @@ impl IrSpanned<AssignCompiledValue> {
393393
}
394394

395395
impl Compiler<'_, '_, '_> {
396-
pub fn assign(&mut self, expr: &CstAssign) -> IrSpanned<AssignCompiledValue> {
396+
pub fn assign_target(&mut self, expr: &CstAssignTarget) -> IrSpanned<AssignCompiledValue> {
397397
let span = FrameSpan::new(FrozenFileSpan::new(self.codemap, expr.span));
398398
let assign = match &expr.node {
399399
AssignTargetP::Dot(e, s) => {
@@ -408,7 +408,7 @@ impl Compiler<'_, '_, '_> {
408408
AssignCompiledValue::Index(e, idx)
409409
}
410410
AssignTargetP::Tuple(v) => {
411-
let v = v.map(|x| self.assign(x));
411+
let v = v.map(|x| self.assign_target(x));
412412
AssignCompiledValue::Tuple(v)
413413
}
414414
AssignTargetP::Identifier(ident) => {
@@ -436,7 +436,7 @@ impl Compiler<'_, '_, '_> {
436436
fn assign_modify(
437437
&mut self,
438438
span_stmt: Span,
439-
lhs: &CstAssign,
439+
lhs: &CstAssignTarget,
440440
rhs: IrSpanned<ExprCompiled>,
441441
op: AssignOp,
442442
) -> StmtsCompiled {
@@ -728,7 +728,7 @@ impl Compiler<'_, '_, '_> {
728728
),
729729
span,
730730
};
731-
let lhs = self.assign(&Spanned {
731+
let lhs = self.assign_target(&Spanned {
732732
span: name.span,
733733
node: AssignTargetP::Identifier(name.clone()),
734734
});
@@ -739,7 +739,7 @@ impl Compiler<'_, '_, '_> {
739739
}
740740
StmtP::For(ForP { var, over, body }) => {
741741
let over = list_to_tuple(over);
742-
let var = self.assign(var);
742+
let var = self.assign_target(var);
743743
let over = self.expr(&over);
744744
let st = self.stmt(body, false);
745745
StmtsCompiled::for_stmt(span, var, over, st)
@@ -774,7 +774,7 @@ impl Compiler<'_, '_, '_> {
774774
StmtP::Assign(AssignP { lhs, ty, rhs }) => {
775775
let rhs = self.expr(rhs);
776776
let ty = self.expr_for_type(ty.as_ref());
777-
let lhs = self.assign(lhs);
777+
let lhs = self.assign_target(lhs);
778778
StmtsCompiled::one(IrSpanned {
779779
span,
780780
node: StmtCompiled::Assign(lhs, ty, rhs),

starlark/src/typing/bindings.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ use starlark_syntax::syntax::uniplate::Visit;
3535
use crate::codemap::CodeMap;
3636
use crate::codemap::Span;
3737
use crate::codemap::Spanned;
38-
use crate::eval::compiler::scope::payload::CstAssign;
3938
use crate::eval::compiler::scope::payload::CstAssignIdentExt;
39+
use crate::eval::compiler::scope::payload::CstAssignTarget;
4040
use crate::eval::compiler::scope::payload::CstExpr;
4141
use crate::eval::compiler::scope::payload::CstPayload;
4242
use crate::eval::compiler::scope::payload::CstStmt;
@@ -58,7 +58,7 @@ pub(crate) enum BindExpr<'a> {
5858
/// Get this position from the expression
5959
GetIndex(usize, Box<BindExpr<'a>>),
6060
Iter(Box<BindExpr<'a>>),
61-
AssignModify(&'a CstAssign, AssignOp, &'a CstExpr),
61+
AssignModify(&'a CstAssignTarget, AssignOp, &'a CstExpr),
6262
/// Set this index in the variable
6363
SetIndex(BindingId, &'a CstExpr, Box<BindExpr<'a>>),
6464
ListAppend(BindingId, &'a CstExpr),
@@ -122,7 +122,7 @@ impl<'a, 'b> BindingsCollect<'a, 'b> {
122122

123123
fn assign(
124124
&mut self,
125-
lhs: &'a CstAssign,
125+
lhs: &'a CstAssignTarget,
126126
rhs: BindExpr<'a>,
127127
codemap: &CodeMap,
128128
) -> Result<(), InternalError> {

starlark/src/typing/ctx.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use starlark_syntax::syntax::ast::ForClauseP;
3232
use crate::codemap::Span;
3333
use crate::codemap::Spanned;
3434
use crate::eval::compiler::scope::payload::CstArgument;
35-
use crate::eval::compiler::scope::payload::CstAssign;
35+
use crate::eval::compiler::scope::payload::CstAssignTarget;
3636
use crate::eval::compiler::scope::payload::CstExpr;
3737
use crate::eval::compiler::scope::payload::CstIdent;
3838
use crate::eval::compiler::scope::payload::CstPayload;
@@ -225,7 +225,7 @@ impl TypingContext<'_> {
225225
}
226226

227227
/// Used to get the type of an expression when used as part of a ModifyAssign operation
228-
fn expression_assign(&self, x: &CstAssign) -> Result<Ty, InternalError> {
228+
fn expression_assign(&self, x: &CstAssignTarget) -> Result<Ty, InternalError> {
229229
match &**x {
230230
AssignTargetP::Tuple(_) => Ok(self.approximation("expression_assignment", x)),
231231
AssignTargetP::Index(a_b) => self.expr_index(x.span, &a_b.0, &a_b.1),
@@ -245,7 +245,7 @@ impl TypingContext<'_> {
245245
}
246246
}
247247

248-
fn expression_assign_spanned(&self, x: &CstAssign) -> Result<Spanned<Ty>, InternalError> {
248+
fn expression_assign_spanned(&self, x: &CstAssignTarget) -> Result<Spanned<Ty>, InternalError> {
249249
Ok(Spanned {
250250
span: x.span,
251251
node: self.expression_assign(x)?,

0 commit comments

Comments
 (0)