Skip to content

Commit 9075a2c

Browse files
committed
Auto merge of #13393 - weihanglo:beta-backport, r=ehuss
[beta-1.77.0] Fix panic on empty spans when parsing Cargo.toml Beta backports: - <#13375> - <#13376> In order to make CI pass, the following PRs are also cherry-picked: - <#13362>
2 parents 7bb7b53 + d1751e0 commit 9075a2c

File tree

7 files changed

+45
-12
lines changed

7 files changed

+45
-12
lines changed

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ tar = { version = "0.4.40", default-features = false }
9696
tempfile = "3.9.0"
9797
thiserror = "1.0.56"
9898
time = { version = "0.3", features = ["parsing", "formatting", "serde"] }
99-
toml = "0.8.8"
100-
toml_edit = { version = "0.21.0", features = ["serde"] }
99+
toml = "0.8.9"
100+
toml_edit = { version = "0.21.1", features = ["serde"] }
101101
tracing = "0.1.37" # be compatible with rustc_log: https://github.com/rust-lang/rust/blob/e51e98dde6a/compiler/rustc_log/Cargo.toml#L9
102102
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
103103
unicase = "2.7.0"

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn read_manifest_from_str(
121121
.rfind('\n')
122122
.map(|s| s + 1)
123123
.unwrap_or(0);
124-
let source_end = contents[span.end - 1..]
124+
let source_end = contents[span.end.saturating_sub(1)..]
125125
.find('\n')
126126
.map(|s| s + span.end)
127127
.unwrap_or(contents.len());

tests/build-std/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn cross_custom() {
155155
r#"
156156
{
157157
"llvm-target": "x86_64-unknown-none-gnu",
158-
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
158+
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
159159
"arch": "x86_64",
160160
"target-endian": "little",
161161
"target-pointer-width": "64",
@@ -196,7 +196,7 @@ fn custom_test_framework() {
196196
r#"
197197
{
198198
"llvm-target": "x86_64-unknown-none-gnu",
199-
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
199+
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
200200
"arch": "x86_64",
201201
"target-endian": "little",
202202
"target-pointer-width": "64",

tests/testsuite/custom_target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub trait Copy {
2222
const SIMPLE_SPEC: &str = r#"
2323
{
2424
"llvm-target": "x86_64-unknown-none-gnu",
25-
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
25+
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
2626
"arch": "x86_64",
2727
"target-endian": "little",
2828
"target-pointer-width": "64",

tests/testsuite/diagnostics.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use cargo_test_support::project;
2+
3+
#[cargo_test]
4+
fn dont_panic_on_render() {
5+
let p = project()
6+
.file(
7+
"Cargo.toml",
8+
r#"
9+
[package]
10+
name = "foo"
11+
version = "0.1.0"
12+
edition = "2021"
13+
[[bench.foo]]
14+
"#,
15+
)
16+
.file("src/lib.rs", "")
17+
.build();
18+
19+
p.cargo("check")
20+
.with_status(101)
21+
.with_stderr(
22+
"\
23+
error: invalid type: map, expected a sequence
24+
--> Cargo.toml:6:3
25+
|
26+
6 | [[bench.foo]]
27+
| ^^^^^
28+
|
29+
",
30+
)
31+
.run();
32+
}

tests/testsuite/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ mod cross_publish;
7979
mod custom_target;
8080
mod death;
8181
mod dep_info;
82+
mod diagnostics;
8283
mod direct_minimal_versions;
8384
mod directory;
8485
mod doc;

0 commit comments

Comments
 (0)