Skip to content

Commit b2d445b

Browse files
authored
Merge pull request #22225 from A4-Tacks/arith-op-fixup
fix: check original type for replace_arith_op
2 parents 67e3c11 + 8a29cd0 commit b2d445b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

crates/ide-assists/src/handlers/replace_arith_op.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn replace_arith(acc: &mut Assists, ctx: &AssistContext<'_, '_>, kind: ArithKind
130130

131131
fn is_primitive_int(ctx: &AssistContext<'_, '_>, expr: &ast::Expr) -> bool {
132132
match ctx.sema.type_of_expr(expr) {
133-
Some(ty) => ty.adjusted().is_int_or_uint(),
133+
Some(ty) => ty.original.strip_reference().is_int_or_uint(),
134134
_ => false,
135135
}
136136
}
@@ -221,6 +221,7 @@ mod tests {
221221
check_assist(
222222
replace_arith_with_checked,
223223
r#"
224+
//- minicore: add, builtin_impls
224225
fn main() {
225226
let x = 1 $0+ 2;
226227
}
@@ -238,6 +239,7 @@ fn main() {
238239
check_assist(
239240
replace_arith_with_saturating,
240241
r#"
242+
//- minicore: add, builtin_impls
241243
fn main() {
242244
let x = 1 $0+ 2;
243245
}
@@ -272,6 +274,7 @@ fn main() {
272274
check_assist(
273275
replace_arith_with_wrapping,
274276
r#"
277+
//- minicore: add, builtin_impls
275278
fn main() {
276279
let x = 1 $0+ 2;
277280
}
@@ -289,6 +292,7 @@ fn main() {
289292
check_assist(
290293
replace_arith_with_wrapping,
291294
r#"
295+
//- minicore: add, builtin_impls
292296
fn main() {
293297
let x = 1*3 $0+ 2;
294298
}
@@ -306,6 +310,7 @@ fn main() {
306310
check_assist(
307311
replace_arith_with_wrapping,
308312
r#"
313+
//- minicore: add, builtin_impls
309314
fn main() {
310315
let mut x = 1;
311316
x $0+= 2;
@@ -325,6 +330,7 @@ fn main() {
325330
check_assist_not_applicable(
326331
replace_arith_with_checked,
327332
r#"
333+
//- minicore: add, builtin_impls
328334
fn main() {
329335
let x = 1 $0+$0 2;
330336
}

0 commit comments

Comments
 (0)