Skip to content

Commit dbfcbf4

Browse files
committed
Auto merge of #12167 - weihanglo:beta-backport, r=<try>
[beta-1.70] backport #12165 Beta backports: - #12165 - Adjusted a bit since `TomlDebugInfo::None` was not there in 1.70.0. It was a simple u32 `0`. In order to make CI pass, the following PRs are also cherry-picked: - #12136
2 parents ec8a8a0 + cb0bdbb commit dbfcbf4

File tree

6 files changed

+30
-35
lines changed

6 files changed

+30
-35
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
}

src/cargo/core/profiles.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,12 @@ impl DebugInfo {
784784
}
785785

786786
/// Reset to the lowest level: no debuginfo.
787+
/// If it is explicitly set, keep it explicit.
787788
pub(crate) fn weaken(self) -> Self {
788-
DebugInfo::None
789+
match self {
790+
DebugInfo::None => DebugInfo::None,
791+
_ => DebugInfo::Explicit(0),
792+
}
789793
}
790794
}
791795

tests/testsuite/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3885,7 +3885,7 @@ fn compiler_json_error_format() {
38853885
},
38863886
"profile": {
38873887
"debug_assertions": true,
3888-
"debuginfo": null,
3888+
"debuginfo": 0,
38893889
"opt_level": "0",
38903890
"overflow_checks": true,
38913891
"test": false

tests/testsuite/profile_targets.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -83,26 +83,23 @@ fn profile_selection_build() {
8383
// - bdep `panic` is not set because it thinks `build.rs` is a plugin.
8484
// - build_script_build is built without panic because it thinks `build.rs` is a plugin.
8585
// - We make sure that the build dependencies bar, bdep, and build.rs
86-
// are built without debuginfo.
86+
// are built with debuginfo=0.
8787
p.cargo("build -vv")
8888
.with_stderr_unordered("\
8989
[COMPILING] bar [..]
9090
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
91-
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
91+
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
9292
[COMPILING] bdep [..]
93-
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
93+
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
9494
[COMPILING] foo [..]
95-
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 [..]
95+
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
9696
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
9797
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
9898
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
9999
[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
100100
[FINISHED] dev [unoptimized + debuginfo] [..]
101101
"
102102
)
103-
.with_stderr_line_without(&["[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]-C codegen-units=5 [..]"], &["-C debuginfo"])
104-
.with_stderr_line_without(&["[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]-C codegen-units=5 [..]"], &["-C debuginfo"])
105-
.with_stderr_line_without(&["[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]-C codegen-units=5 [..]"], &["-C debuginfo"])
106103
.run();
107104
p.cargo("build -vv")
108105
.with_stderr_unordered(
@@ -158,7 +155,7 @@ fn profile_selection_build_all_targets() {
158155
// - Benchmark dependencies are compiled in `dev` mode, which may be
159156
// surprising. See issue rust-lang/cargo#4929.
160157
// - We make sure that the build dependencies bar, bdep, and build.rs
161-
// are built without debuginfo.
158+
// are built with debuginfo=0.
162159
//
163160
// - Dependency profiles:
164161
// Pkg Target Profile Reason
@@ -184,11 +181,11 @@ fn profile_selection_build_all_targets() {
184181
[COMPILING] bar [..]
185182
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]
186183
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]
187-
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
184+
[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
188185
[COMPILING] bdep [..]
189-
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 [..]
186+
[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
190187
[COMPILING] foo [..]
191-
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 [..]
188+
[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=0[..]
192189
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
193190
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
194191
[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]`
@@ -202,9 +199,6 @@ fn profile_selection_build_all_targets() {
202199
[FINISHED] dev [unoptimized + debuginfo] [..]
203200
"
204201
)
205-
.with_stderr_line_without(&["[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]-C codegen-units=5 [..]"], &["-C debuginfo"])
206-
.with_stderr_line_without(&["[RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]-C codegen-units=5 [..]"], &["-C debuginfo"])
207-
.with_stderr_line_without(&["[RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]-C codegen-units=5 [..]"], &["-C debuginfo"])
208202
.run();
209203
p.cargo("build -vv")
210204
.with_stderr_unordered(

0 commit comments

Comments
 (0)