-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.A-workspacesArea: workspacesArea: workspacesC-enhancementCategory: enhancementCategory: enhancement
Description
We warn about unused keys in Cargo.toml, unless it is a virtual manifest:
Lines 140 to 159 in d2d6e67
Ok((mut manifest, paths)) => { | |
for key in unused { | |
manifest.add_warning(format!("unused manifest key: {}", key)); | |
} | |
if !manifest.targets().iter().any(|t| !t.is_custom_build()) { | |
bail!("no targets specified in the manifest\n \ | |
either src/lib.rs, src/main.rs, a [lib] section, or \ | |
[[bin]] section must be present") | |
} | |
Ok((EitherManifest::Real(manifest), paths)) | |
} | |
Err(e) => { | |
match TomlManifest::to_virtual_manifest(&manifest, | |
source_id, | |
&layout, | |
config) { | |
Ok((m, paths)) => Ok((EitherManifest::Virtual(m), paths)), | |
Err(..) => Err(e), | |
} | |
} |
We probably should warn about unused keys in virtual manifest as well!
The test might look like this:
//tests/build.rs, next to `fn unused_keys()`
#[test]
fn unused_keys_in_virtual_manifest() {
let p = project("foo")
.file("Cargo.toml", r#"
[workspace]
members = ["bar"]
bulid = "foo"
"#)
.file("bar/Cargo.toml", r#"
[project]
version = "0.0.1"
name = "bar"
authors = []
"#)
.file("bar/src/lib.rs", r"");
assert_that(p.cargo_process("build").arg("--all"),
execs().with_status(0)
.with_stderr("\
warning: unused manifest key: workspace.bulid
[COMPILING] bar [..]
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
"));
}
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Error and warning messages generated by Cargo itself.Area: Error and warning messages generated by Cargo itself.A-workspacesArea: workspacesArea: workspacesC-enhancementCategory: enhancementCategory: enhancement