mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
fix(diagnostic): Don't panic on empty spans
There is another level to this bug where we better point to where the error occurs.
This commit is contained in:
parent
f2a4a3e88b
commit
1c05d412af
@ -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());
|
||||
|
@ -18,6 +18,13 @@ edition = "2021"
|
||||
|
||||
p.cargo("check")
|
||||
.with_status(101)
|
||||
.with_stderr_contains("attempt to subtract with overflow")
|
||||
.with_stderr(
|
||||
"\
|
||||
error: invalid type: map, expected a sequence
|
||||
--> Cargo.toml:1:1
|
||||
|
|
||||
|
|
||||
",
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user