Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sbillig committed Jun 2, 2022
1 parent b2c36f7 commit 0df7ddc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions crates/analyzer/src/traversal/assignments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ pub fn assign(scope: &mut BlockScope, stmt: &Node<fe::FuncStmt>) -> Result<(), F
fn find_name_def(scope: &BlockScope, expr: &Node<fe::Expr>) -> Option<(SmolStr, Span)> {
match &expr.kind {
fe::Expr::Attribute { value, .. } | fe::Expr::Subscript { value, .. } => {
find_name_def(scope, &value)
find_name_def(scope, value)
}
fe::Expr::Name(name) => {
let thing = scope.resolve_name(&name, expr.span).ok()??;
let thing = scope.resolve_name(name, expr.span).ok()??;
thing.name_span(scope.db()).map(|span| (name.clone(), span))
}
_ => None,
Expand All @@ -89,7 +89,7 @@ fn check_assign_target(scope: &mut BlockScope, target: &Node<fe::Expr>) -> Resul

match &target.kind {
Attribute { value: container, .. } | Subscript { value: container, .. } => {
if !scope.expr_is_mutable(&container) {
if !scope.expr_is_mutable(container) {
let mut labels = vec![Label::primary(container.span, "not mutable")];
if let Some((name, span)) = find_name_def(scope, container) {
labels.push(Label::secondary(span, &format!("consider changing this to be mutable: `mut {}`", name)));
Expand Down
6 changes: 2 additions & 4 deletions crates/analyzer/src/traversal/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ fn expr_named_thing(
);
match expected_type {
Some(typ) => {
let location = Location::assign_location(&typ);
let location = Location::assign_location(typ);
// I guess we'll say this is mutable, to minimize downstream errors.
let mutability = !typ.is_base();
Ok(ExpressionAttributes::new(typ.clone(), location, mutability))
Expand Down Expand Up @@ -1404,9 +1404,7 @@ fn expr_call_method(
Label::secondary(target.span, "not mutable"),
Label::secondary(
span,
&format!(
"consider changing this to be mutable: `mut self`"
),
"consider changing this to be mutable: `mut self`",
),
],
vec![],
Expand Down

0 comments on commit 0df7ddc

Please sign in to comment.