mirror of https://github.com/rust-lang/cargo
fix(lints): Only warn when seeing lints on stable
This will make it easier for users to test this feature
This commit is contained in:
parent
4279d0d56c
commit
a7555f976e
|
@ -2045,8 +2045,8 @@ impl TomlManifest {
|
|||
let mut inheritable = toml_config.package.clone().unwrap_or_default();
|
||||
inheritable.update_ws_path(package_root.to_path_buf());
|
||||
inheritable.update_deps(toml_config.dependencies.clone());
|
||||
verify_lints(toml_config.lints.as_ref(), &features)?;
|
||||
inheritable.update_lints(toml_config.lints.clone());
|
||||
let lints = verify_lints(toml_config.lints.clone(), &features, config)?;
|
||||
inheritable.update_lints(lints);
|
||||
if let Some(ws_deps) = &inheritable.dependencies {
|
||||
for (name, dep) in ws_deps {
|
||||
unused_dep_keys(
|
||||
|
@ -2315,7 +2315,7 @@ impl TomlManifest {
|
|||
.clone()
|
||||
.map(|mw| mw.resolve("lints", || inherit()?.lints()))
|
||||
.transpose()?;
|
||||
verify_lints(lints.as_ref(), &features)?;
|
||||
let lints = verify_lints(lints.clone(), &features, config)?;
|
||||
let default = TomlLints::default();
|
||||
let mut rustflags = lints
|
||||
.as_ref()
|
||||
|
@ -2773,8 +2773,8 @@ impl TomlManifest {
|
|||
let mut inheritable = toml_config.package.clone().unwrap_or_default();
|
||||
inheritable.update_ws_path(root.to_path_buf());
|
||||
inheritable.update_deps(toml_config.dependencies.clone());
|
||||
verify_lints(toml_config.lints.as_ref(), &features)?;
|
||||
inheritable.update_lints(toml_config.lints.clone());
|
||||
let lints = verify_lints(toml_config.lints.clone(), &features, config)?;
|
||||
inheritable.update_lints(lints);
|
||||
let ws_root_config = WorkspaceRootConfig::new(
|
||||
root,
|
||||
&toml_config.members,
|
||||
|
@ -2919,12 +2919,19 @@ impl TomlManifest {
|
|||
}
|
||||
}
|
||||
|
||||
fn verify_lints(lints: Option<&TomlLints>, features: &Features) -> CargoResult<()> {
|
||||
let Some(lints) = lints else { return Ok(()); };
|
||||
fn verify_lints(
|
||||
lints: Option<TomlLints>,
|
||||
features: &Features,
|
||||
config: &Config,
|
||||
) -> CargoResult<Option<TomlLints>> {
|
||||
let Some(lints) = lints else { return Ok(None); };
|
||||
|
||||
features.require(Feature::lints())?;
|
||||
if let Err(err) = features.require(Feature::lints()) {
|
||||
let _ = config.shell().warn(err);
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
for (tool, lints) in lints {
|
||||
for (tool, lints) in &lints {
|
||||
let supported = ["rust", "clippy", "rustdoc"];
|
||||
if !supported.contains(&tool.as_str()) {
|
||||
let supported = supported.join(", ");
|
||||
|
@ -2947,7 +2954,7 @@ fn verify_lints(lints: Option<&TomlLints>, features: &Features) -> CargoResult<(
|
|||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(Some(lints))
|
||||
}
|
||||
|
||||
fn unused_dep_keys(
|
||||
|
|
|
@ -22,16 +22,15 @@ fn package_requires_option() {
|
|||
.build();
|
||||
|
||||
foo.cargo("check")
|
||||
.with_status(101)
|
||||
.with_stderr("\
|
||||
[..]
|
||||
warning: feature `lints` is required
|
||||
|
||||
Caused by:
|
||||
feature `lints` is required
|
||||
The package requires the Cargo feature called `lints`, but that feature is not stabilized in this version of Cargo ([..]).
|
||||
Consider trying a newer version of Cargo (this may require the nightly release).
|
||||
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#lints for more information about the status of this feature.
|
||||
|
||||
The package requires the Cargo feature called `lints`, but that feature is not stabilized in this version of Cargo ([..]).
|
||||
Consider trying a newer version of Cargo (this may require the nightly release).
|
||||
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#lints for more information about the status of this feature.
|
||||
[CHECKING] [..]
|
||||
[FINISHED] [..]
|
||||
")
|
||||
.run();
|
||||
}
|
||||
|
@ -55,16 +54,15 @@ fn workspace_requires_option() {
|
|||
.build();
|
||||
|
||||
foo.cargo("check")
|
||||
.with_status(101)
|
||||
.with_stderr("\
|
||||
[..]
|
||||
warning: feature `lints` is required
|
||||
|
||||
Caused by:
|
||||
feature `lints` is required
|
||||
The package requires the Cargo feature called `lints`, but that feature is not stabilized in this version of Cargo ([..]).
|
||||
Consider trying a newer version of Cargo (this may require the nightly release).
|
||||
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#lints for more information about the status of this feature.
|
||||
|
||||
The package requires the Cargo feature called `lints`, but that feature is not stabilized in this version of Cargo ([..]).
|
||||
Consider trying a newer version of Cargo (this may require the nightly release).
|
||||
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#lints for more information about the status of this feature.
|
||||
[CHECKING] [..]
|
||||
[FINISHED] [..]
|
||||
")
|
||||
.run();
|
||||
}
|
||||
|
@ -333,7 +331,6 @@ pub fn foo(num: i32) -> u32 {
|
|||
|
||||
foo.cargo("check")
|
||||
.masquerade_as_nightly_cargo(&["lints"])
|
||||
.with_status(0)
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -368,7 +365,6 @@ pub fn foo(num: i32) -> u32 {
|
|||
.arg("-v")
|
||||
.env("RUSTFLAGS", "-Aunsafe_code")
|
||||
.masquerade_as_nightly_cargo(&["lints"])
|
||||
.with_status(0)
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -457,7 +453,6 @@ pub fn foo() -> u32 {
|
|||
|
||||
foo.cargo("check")
|
||||
.masquerade_as_nightly_cargo(&["lints"])
|
||||
.with_status(0)
|
||||
.run();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue