mirror of https://github.com/rust-lang/cargo
fix(implicit_features): Work with any dep table
This commit is contained in:
parent
301010aaa0
commit
7aac7f875c
|
@ -192,21 +192,18 @@ pub fn check_implicit_features(
|
|||
if lint_level == LintLevel::Forbid || lint_level == LintLevel::Deny {
|
||||
*error_count += 1;
|
||||
}
|
||||
let mut toml_path = vec![dep.kind().kind_table(), dep_name_in_toml.as_str()];
|
||||
let platform = dep.platform().map(|p| p.to_string());
|
||||
if let Some(platform) = platform.as_ref() {
|
||||
toml_path.insert(0, platform);
|
||||
toml_path.insert(0, "target");
|
||||
}
|
||||
let level = lint_level.to_diagnostic_level();
|
||||
let manifest_path = rel_cwd_manifest_path(path, gctx);
|
||||
let message = level.title(IMPLICIT_FEATURES.desc).snippet(
|
||||
Snippet::source(manifest.contents())
|
||||
.origin(&manifest_path)
|
||||
.annotation(
|
||||
level.span(
|
||||
get_span(
|
||||
manifest.document(),
|
||||
&["dependencies", &dep_name_in_toml],
|
||||
false,
|
||||
)
|
||||
.unwrap(),
|
||||
),
|
||||
)
|
||||
.annotation(level.span(get_span(manifest.document(), &toml_path, false).unwrap()))
|
||||
.fold(true),
|
||||
);
|
||||
let renderer = Renderer::styled().term_width(
|
||||
|
|
|
@ -6,6 +6,8 @@ use cargo_test_support::{file, project};
|
|||
#[cargo_test]
|
||||
fn case() {
|
||||
Package::new("bar", "0.1.0").publish();
|
||||
Package::new("baz", "0.1.0").publish();
|
||||
Package::new("target-dep", "0.1.0").publish();
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
|
@ -18,6 +20,12 @@ edition = "2021"
|
|||
[dependencies]
|
||||
bar = { version = "0.1.0", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
baz = { version = "0.1.0", optional = true }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
target-dep = { version = "0.1.0", optional = true }
|
||||
|
||||
[lints.cargo]
|
||||
implicit-features = "warn"
|
||||
"#,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<svg width="944px" height="218px" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg width="944px" height="434px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
|
@ -32,15 +32,39 @@
|
|||
</tspan>
|
||||
<tspan x="10px" y="118px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="136px"><tspan class="fg-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
|
||||
<tspan x="10px" y="136px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="154px"><tspan class="fg-green bold"> Locking</tspan><tspan> 2 packages to latest compatible versions</tspan>
|
||||
<tspan x="10px" y="154px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:11:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="172px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.1.0 ([ROOT]/foo)</tspan>
|
||||
<tspan x="10px" y="172px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="190px"><tspan class="fg-green bold"> Finished</tspan><tspan>[..]</tspan>
|
||||
<tspan x="10px" y="190px"><tspan class="fg-bright-blue bold">11 |</tspan><tspan> baz = { version = "0.1.0", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="208px">
|
||||
<tspan x="10px" y="208px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ---</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="226px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="244px"><tspan class="fg-yellow bold">warning</tspan><tspan>: </tspan><tspan class="bold">implicit features for optional dependencies is deprecated and will be unavailable in the 2024 edition</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="262px"><tspan> </tspan><tspan class="fg-bright-blue bold">--></tspan><tspan> Cargo.toml:14:1</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="280px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="298px"><tspan class="fg-bright-blue bold">14 |</tspan><tspan> target-dep = { version = "0.1.0", optional = true }</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="316px"><tspan class="fg-bright-blue bold"> |</tspan><tspan class="fg-yellow bold"> ----------</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="334px"><tspan class="fg-bright-blue bold"> |</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="352px"><tspan class="fg-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="370px"><tspan class="fg-green bold"> Locking</tspan><tspan> 4 packages to latest compatible versions</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="388px"><tspan class="fg-green bold"> Checking</tspan><tspan> foo v0.1.0 ([ROOT]/foo)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="406px"><tspan class="fg-green bold"> Finished</tspan><tspan> [..]</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="424px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
|
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 3.6 KiB |
Loading…
Reference in New Issue