aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ide_assists/src/handlers/extract_function.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/ide_assists/src/handlers/extract_function.rs b/crates/ide_assists/src/handlers/extract_function.rs
index d84f51eae..8e295098f 100644
--- a/crates/ide_assists/src/handlers/extract_function.rs
+++ b/crates/ide_assists/src/handlers/extract_function.rs
@@ -729,6 +729,14 @@ fn reference_is_exclusive(
729 729
730/// checks if this expr requires `&mut` access, recurses on field access 730/// checks if this expr requires `&mut` access, recurses on field access
731fn expr_require_exclusive_access(ctx: &AssistContext, expr: &ast::Expr) -> Option<bool> { 731fn expr_require_exclusive_access(ctx: &AssistContext, expr: &ast::Expr) -> Option<bool> {
732 match expr {
733 ast::Expr::MacroCall(_) => {
734 // FIXME: expand macro and check output for mutable usages of the variable?
735 return None;
736 }
737 _ => (),
738 }
739
732 let parent = expr.syntax().parent()?; 740 let parent = expr.syntax().parent()?;
733 741
734 if let Some(bin_expr) = ast::BinExpr::cast(parent.clone()) { 742 if let Some(bin_expr) = ast::BinExpr::cast(parent.clone()) {
@@ -804,6 +812,11 @@ fn path_element_of_reference(
804 stdx::never!(false, "cannot find path parent of variable usage: {:?}", token); 812 stdx::never!(false, "cannot find path parent of variable usage: {:?}", token);
805 None 813 None
806 })?; 814 })?;
815 stdx::always!(
816 matches!(path, ast::Expr::PathExpr(_) | ast::Expr::MacroCall(_)),
817 "unexpected expression type for variable usage: {:?}",
818 path
819 );
807 Some(path) 820 Some(path)
808} 821}
809 822