Skip to content

Commit 111eaa1

Browse files
committed
Handle backcompat hazard with toml crate
The 0.5.0 release contained a [bugfix](toml-rs/toml-rs#280) which previously successfully parsed invalid TOML files, so we'll need to manually handle that in Cago to ensure that we don't accidentally regress crates, but rather instead give them an appropriate amount of time to get fixed.
1 parent d071687 commit 111eaa1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,24 @@ in the future.",
142142
return Ok(ret);
143143
}
144144

145+
let mut third_parser = toml::de::Deserializer::new(toml);
146+
third_parser.set_allow_duplicate_after_longer_table(true);
147+
if let Ok(ret) = toml::Value::deserialize(&mut third_parser) {
148+
let msg = format!(
149+
"\
150+
TOML file found which contains invalid syntax and will soon not parse
151+
at `{}`.
152+
153+
The TOML spec requires that each table header is defined at most once, but
154+
historical versions of Cargo have erroneously accepted this file. The table
155+
definitions will need to be merged together with one table header to proceed,
156+
and this will become a hard error in the future.",
157+
file.display()
158+
);
159+
config.shell().warn(&msg)?;
160+
return Ok(ret);
161+
}
162+
145163
let first_error = failure::Error::from(first_error);
146164
Err(first_error.context("could not parse input as TOML").into())
147165
}

0 commit comments

Comments
 (0)