Skip to content

Commit 651799a

Browse files
committed
Auto merge of #12136 - loongarch-rs:useless-drop, r=hi-rustin
Remove useless drop of copy type ### What does this PR try to resolve? This PR aims to remove useless drop of copy type to clear warnings that reported after rust-lang/rust#109732 ``` warning: calls to `std::mem::drop` with a value that implements `Copy` does nothing --> src/cargo/core/compiler/job_queue/mod.rs:1048:21 | 1048 | drop(write!( | ______________________^____- | | _____________________| | || 1049 | || message, 1050 | || " (run `{command} --{args}` to apply {suggestions})" 1051 | || )) | ||_____________________-^ | |______________________| | argument has type `Result<(), std::fmt::Error>` | = note: use `let _ = ...` to ignore the expression or result = note: `#[warn(drop_copy)]` on by default ``` ### How should we test and review this PR? ```bash cargo build && cargo test # without any warnings ``` ### Additional information None
2 parents e41605b + 6a9cb23 commit 651799a

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

crates/cargo-test-support/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ pub fn panic_error(what: &str, err: impl Into<anyhow::Error>) -> ! {
5959
fn pe(what: &str, err: anyhow::Error) -> ! {
6060
let mut result = format!("{}\nerror: {}", what, err);
6161
for cause in err.chain().skip(1) {
62-
drop(writeln!(result, "\nCaused by:"));
63-
drop(write!(result, "{}", cause));
62+
let _ = writeln!(result, "\nCaused by:");
63+
let _ = write!(result, "{}", cause);
6464
}
6565
panic!("\n{}", result);
6666
}

src/cargo/core/compiler/job_queue/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1045,10 +1045,10 @@ impl<'cfg> DrainState<'cfg> {
10451045
if fixable > 1 {
10461046
suggestions.push_str("s")
10471047
}
1048-
drop(write!(
1048+
let _ = write!(
10491049
message,
10501050
" (run `{command} --{args}` to apply {suggestions})"
1051-
))
1051+
);
10521052
}
10531053
}
10541054
}

src/cargo/core/features.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -585,19 +585,19 @@ impl Features {
585585
feature_name, feature.version
586586
);
587587
if self.is_local {
588-
drop(writeln!(
588+
let _ = writeln!(
589589
msg,
590590
"Remove the feature from Cargo.toml to remove this error."
591-
));
591+
);
592592
} else {
593-
drop(writeln!(
593+
let _ = writeln!(
594594
msg,
595595
"This package cannot be used with this version of Cargo, \
596596
as the unstable feature `{}` is no longer supported.",
597597
feature_name
598-
));
598+
);
599599
}
600-
drop(writeln!(msg, "{}", see_docs()));
600+
let _ = writeln!(msg, "{}", see_docs());
601601
bail!(msg);
602602
}
603603
}
@@ -629,32 +629,29 @@ impl Features {
629629

630630
if self.nightly_features_allowed {
631631
if self.is_local {
632-
drop(writeln!(
632+
let _ = writeln!(
633633
msg,
634634
"Consider adding `cargo-features = [\"{}\"]` \
635635
to the top of Cargo.toml (above the [package] table) \
636636
to tell Cargo you are opting in to use this unstable feature.",
637637
feature_name
638-
));
638+
);
639639
} else {
640-
drop(writeln!(
641-
msg,
642-
"Consider trying a more recent nightly release."
643-
));
640+
let _ = writeln!(msg, "Consider trying a more recent nightly release.");
644641
}
645642
} else {
646-
drop(writeln!(
643+
let _ = writeln!(
647644
msg,
648645
"Consider trying a newer version of Cargo \
649646
(this may require the nightly release)."
650-
));
647+
);
651648
}
652-
drop(writeln!(
649+
let _ = writeln!(
653650
msg,
654651
"See https://doc.rust-lang.org/nightly/cargo/{} for more information \
655652
about the status of this feature.",
656653
feature.docs
657-
));
654+
);
658655

659656
bail!("{}", msg);
660657
}

0 commit comments

Comments
 (0)