Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle backcompat hazard with toml crate #6761

Merged
merged 1 commit into from
Mar 19, 2019
Merged
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
18 changes: 18 additions & 0 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,24 @@ in the future.",
return Ok(ret);
}

let mut third_parser = toml::de::Deserializer::new(toml);
third_parser.set_allow_duplicate_after_longer_table(true);
if let Ok(ret) = toml::Value::deserialize(&mut third_parser) {
let msg = format!(
"\
TOML file found which contains invalid syntax and will soon not parse
at `{}`.

The TOML spec requires that each table header is defined at most once, but
historical versions of Cargo have erroneously accepted this file. The table
definitions will need to be merged together with one table header to proceed,
and this will become a hard error in the future.",
file.display()
);
config.shell().warn(&msg)?;
return Ok(ret);
}

let first_error = failure::Error::from(first_error);
Err(first_error.context("could not parse input as TOML").into())
}
Expand Down