File tree Expand file tree Collapse file tree
crates/ide-assists/src/handlers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2088,7 +2088,11 @@ fn fix_param_usages(
20882088 for ( param, usages) in usages_for_param {
20892089 for usage in usages {
20902090 match usage. syntax ( ) . ancestors ( ) . skip ( 1 ) . find_map ( ast:: Expr :: cast) {
2091- Some ( ast:: Expr :: MethodCallExpr ( _) | ast:: Expr :: FieldExpr ( _) ) => {
2091+ Some (
2092+ ast:: Expr :: MethodCallExpr ( _)
2093+ | ast:: Expr :: FieldExpr ( _)
2094+ | ast:: Expr :: IndexExpr ( _) ,
2095+ ) => {
20922096 // do nothing
20932097 }
20942098 Some ( ast:: Expr :: RefExpr ( node) )
@@ -3211,6 +3215,32 @@ fn $0fun_name(n: &mut i32) {
32113215 ) ;
32123216 }
32133217
3218+ #[ test]
3219+ fn mut_index_from_outer_scope ( ) {
3220+ check_assist (
3221+ extract_function,
3222+ r#"
3223+ //- minicore: index
3224+ fn foo() {
3225+ let mut arr = [1i32];
3226+ $0arr[0] = 3;$0
3227+ let _ = arr;
3228+ }
3229+ "# ,
3230+ r#"
3231+ fn foo() {
3232+ let mut arr = [1i32];
3233+ fun_name(&mut arr);
3234+ let _ = arr;
3235+ }
3236+
3237+ fn $0fun_name(arr: &mut [i32; 1]) {
3238+ arr[0] = 3;
3239+ }
3240+ "# ,
3241+ ) ;
3242+ }
3243+
32143244 #[ test]
32153245 fn mut_field_from_outer_scope ( ) {
32163246 check_assist (
You can’t perform that action at this time.
0 commit comments