Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn read_manifest_from_str(
.rfind('\n')
.map(|s| s + 1)
.unwrap_or(0);
let source_end = contents[span.end - 1..]
let source_end = contents[span.end.saturating_sub(1)..]
.find('\n')
.map(|s| s + span.end)
.unwrap_or(contents.len());
Expand Down
30 changes: 30 additions & 0 deletions tests/testsuite/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use cargo_test_support::project;

#[cargo_test]
fn dont_panic_on_render() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
[[bench.foo]]
"#,
)
.file("src/lib.rs", "")
.build();

p.cargo("check")
.with_status(101)
.with_stderr(
"\
error: invalid type: map, expected a sequence
--> Cargo.toml:1:1
|
|
",
)
.run();
}
1 change: 1 addition & 0 deletions tests/testsuite/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ mod cross_publish;
mod custom_target;
mod death;
mod dep_info;
mod diagnostics;
mod direct_minimal_versions;
mod directory;
mod doc;
Expand Down