fix ci/cd error

This commit is contained in:
relaxcn
2025-06-14 17:24:09 +08:00
parent bf1a276db3
commit 2dfab750e7
4 changed files with 40 additions and 10 deletions
+10 -4
View File
@@ -262,12 +262,18 @@ fn is_expr_used_with_type_annotation<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx E
/// Check if the expression is an associated function without a type instance.
/// Example:
/// ```
/// Default::default()
/// // Or
/// trait Def {
/// fn def() -> Self;
/// fn def() -> Self;
/// }
/// impl Def for usize {
/// fn def() -> Self {
/// 0
/// }
/// }
/// fn test() {
/// let _ = 0usize + &Default::default();
/// let _ = 0usize + &Def::def();
/// }
/// Def::def()
/// ```
fn is_assoc_fn_without_type_instance<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>) -> bool {
if let ExprKind::Call(func, _) = peel_hir_expr_refs(expr).0.kind
+6
View File
@@ -318,6 +318,9 @@ fn issue_14932() {
0usize + &Default::default(); // no error
<usize as Default>::default();
//~^ identity_op
let _ = usize::default();
//~^ identity_op
@@ -346,6 +349,9 @@ fn issue_14932_3() {
0usize + &Def::def(); // no error
<usize as Def>::def();
//~^ identity_op
let _ = usize::def();
//~^ identity_op
+6
View File
@@ -318,6 +318,9 @@ fn issue_14932() {
0usize + &Default::default(); // no error
0usize + &<usize as Default>::default();
//~^ identity_op
let _ = 0usize + &usize::default();
//~^ identity_op
@@ -346,6 +349,9 @@ fn issue_14932_3() {
0usize + &Def::def(); // no error
0usize + &<usize as Def>::def();
//~^ identity_op
let _ = 0usize + &usize::def();
//~^ identity_op
+18 -6
View File
@@ -380,34 +380,46 @@ LL | let _: u64 = 1u64 + ((x as i32 + y as i32) as u64 + 0u64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `((x as i32 + y as i32) as u64)`
error: this operation has no effect
--> tests/ui/identity_op.rs:321:13
--> tests/ui/identity_op.rs:321:5
|
LL | 0usize + &<usize as Default>::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `<usize as Default>::default()`
error: this operation has no effect
--> tests/ui/identity_op.rs:324:13
|
LL | let _ = 0usize + &usize::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `usize::default()`
error: this operation has no effect
--> tests/ui/identity_op.rs:324:21
--> tests/ui/identity_op.rs:327:21
|
LL | let _n: usize = 0usize + &Default::default();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `Default::default()`
error: this operation has no effect
--> tests/ui/identity_op.rs:330:5
--> tests/ui/identity_op.rs:333:5
|
LL | 0usize + &Default::default()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `Default::default()`
error: this operation has no effect
--> tests/ui/identity_op.rs:349:13
--> tests/ui/identity_op.rs:352:5
|
LL | 0usize + &<usize as Def>::def();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `<usize as Def>::def()`
error: this operation has no effect
--> tests/ui/identity_op.rs:355:13
|
LL | let _ = 0usize + &usize::def();
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `usize::def()`
error: this operation has no effect
--> tests/ui/identity_op.rs:352:21
--> tests/ui/identity_op.rs:358:21
|
LL | let _n: usize = 0usize + &Def::def();
| ^^^^^^^^^^^^^^^^^^^^ help: consider reducing it to: `Def::def()`
error: aborting due to 68 previous errors
error: aborting due to 70 previous errors