Combine internal features in clippy_lints

This commit is contained in:
Cameron Steffen 2022-01-09 18:22:38 -06:00
parent 16d848891d
commit e2ce4f9462
14 changed files with 39 additions and 45 deletions

View File

@ -2,7 +2,7 @@
uitest = "test --test compile-test"
dev = "run --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
lintcheck = "run --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
collect-metadata = "test --test dogfood --features metadata-collector-lint -- run_metadata_collection_lint --ignored"
collect-metadata = "test --test dogfood --features internal -- run_metadata_collection_lint --ignored"
[build]
# -Zbinary-dep-depinfo allows us to track which rlib files to use for compiling UI tests

View File

@ -49,13 +49,13 @@ jobs:
echo "LD_LIBRARY_PATH=${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
- name: Build
run: cargo build --features deny-warnings,internal-lints,metadata-collector-lint
run: cargo build --features deny-warnings,internal
- name: Test
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
run: cargo test --features deny-warnings,internal
- name: Test clippy_lints
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
run: cargo test --features deny-warnings,internal
working-directory: clippy_lints
- name: Test clippy_utils

View File

@ -112,13 +112,13 @@ jobs:
echo "$SYSROOT/bin" >> $GITHUB_PATH
- name: Build
run: cargo build --features deny-warnings,internal-lints,metadata-collector-lint
run: cargo build --features deny-warnings,internal
- name: Test
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
run: cargo test --features deny-warnings,internal
- name: Test clippy_lints
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
run: cargo test --features deny-warnings,internal
working-directory: clippy_lints
- name: Test clippy_utils

View File

@ -57,8 +57,7 @@ rustc_tools_util = { version = "0.2", path = "rustc_tools_util" }
[features]
deny-warnings = ["clippy_lints/deny-warnings"]
integration = ["tempfile"]
internal-lints = ["clippy_lints/internal-lints"]
metadata-collector-lint = ["internal-lints", "clippy_lints/metadata-collector-lint"]
internal = ["clippy_lints/internal"]
[package.metadata.rust-analyzer]
# This package uses #[feature(rustc_private)]

View File

@ -321,7 +321,7 @@ fn gen_register_lint_list<'a>(
for (is_public, module_name, lint_name) in details {
if !is_public {
output.push_str(" #[cfg(feature = \"internal-lints\")]\n");
output.push_str(" #[cfg(feature = \"internal\")]\n");
}
output.push_str(&format!(" {}::{},\n", module_name, lint_name));
}

View File

@ -30,8 +30,7 @@ url = { version = "2.2", features = ["serde"] }
[features]
deny-warnings = ["clippy_utils/deny-warnings"]
# build clippy with internal lints enabled, off by default
internal-lints = ["clippy_utils/internal"]
metadata-collector-lint = ["serde_json", "clippy_utils/internal"]
internal = ["clippy_utils/internal", "serde_json"]
[package.metadata.rust-analyzer]
# This crate uses #[feature(rustc_private)]

View File

@ -3,33 +3,33 @@
// Manual edits will be overwritten.
store.register_lints(&[
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::CLIPPY_LINTS_INTERNAL,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::COLLAPSIBLE_SPAN_LINT_CALLS,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::COMPILER_LINT_FUNCTIONS,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::DEFAULT_LINT,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::IF_CHAIN_STYLE,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::INTERNING_DEFINED_SYMBOL,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::INVALID_CLIPPY_VERSION_ATTRIBUTE,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::INVALID_PATHS,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::LINT_WITHOUT_LINT_PASS,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::MATCH_TYPE_ON_DIAGNOSTIC_ITEM,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::MISSING_CLIPPY_VERSION_ATTRIBUTE,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::OUTER_EXPN_EXPN_DATA,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::PRODUCE_ICE,
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
utils::internal_lints::UNNECESSARY_SYMBOL_STR,
absurd_extreme_comparisons::ABSURD_EXTREME_COMPARISONS,
approx_const::APPROX_CONSTANT,

View File

@ -153,12 +153,9 @@ macro_rules! declare_clippy_lint {
};
}
#[cfg(feature = "metadata-collector-lint")]
#[cfg(feature = "internal")]
mod deprecated_lints;
#[cfg_attr(
any(feature = "internal-lints", feature = "metadata-collector-lint"),
allow(clippy::missing_clippy_version_attribute)
)]
#[cfg_attr(feature = "internal", allow(clippy::missing_clippy_version_attribute))]
mod utils;
// begin lints modules, do not remove this comment, its used in `update_lints`
@ -472,7 +469,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
include!("lib.register_restriction.rs");
include!("lib.register_pedantic.rs");
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
include!("lib.register_internal.rs");
include!("lib.register_all.rs");
@ -484,7 +481,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
include!("lib.register_cargo.rs");
include!("lib.register_nursery.rs");
#[cfg(feature = "metadata-collector-lint")]
#[cfg(feature = "internal")]
{
if std::env::var("ENABLE_METADATA_COLLECTION").eq(&Ok("1".to_string())) {
store.register_late_pass(|| Box::new(utils::internal_lints::metadata_collector::MetadataCollector::new()));
@ -493,7 +490,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
}
// all the internal lints
#[cfg(feature = "internal-lints")]
#[cfg(feature = "internal")]
{
store.register_early_pass(|| Box::new(utils::internal_lints::ClippyLintsInternal));
store.register_early_pass(|| Box::new(utils::internal_lints::ProduceIce));

View File

@ -113,7 +113,7 @@ macro_rules! define_Conf {
}
}
#[cfg(feature = "metadata-collector-lint")]
#[cfg(feature = "internal")]
pub mod metadata {
use crate::utils::internal_lints::metadata_collector::ClippyConfiguration;

View File

@ -35,7 +35,7 @@ use rustc_typeck::hir_ty_to_ty;
use std::borrow::{Borrow, Cow};
#[cfg(feature = "metadata-collector-lint")]
#[cfg(feature = "internal")]
pub mod metadata_collector;
declare_clippy_lint! {

View File

@ -1,8 +1,7 @@
//! This lint is used to collect metadata about clippy lints. This metadata is exported as a json
//! file and then used to generate the [clippy lint list](https://rust-lang.github.io/rust-clippy/master/index.html)
//!
//! This module and therefor the entire lint is guarded by a feature flag called
//! `metadata-collector-lint`
//! This module and therefore the entire lint is guarded by a feature flag called `internal`
//!
//! The module transforms all lint names to ascii lowercase to ensure that we don't have mismatches
//! during any comparison or mapping. (Please take care of this, it's not fun to spend time on such

View File

@ -1,5 +1,5 @@
pub mod author;
pub mod conf;
pub mod inspector;
#[cfg(any(feature = "internal-lints", feature = "metadata-collector-lint"))]
#[cfg(feature = "internal")]
pub mod internal_lints;

View File

@ -15,7 +15,7 @@ use std::path::{Path, PathBuf};
mod cargo;
// whether to run internal tests or not
const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal-lints");
const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal");
/// All crates used in UI tests are listed here
static TEST_DEPENDENCIES: &[&str] = &[

View File

@ -42,8 +42,8 @@ fn dogfood_clippy() {
.args(&["-D", "clippy::pedantic"])
.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
// internal lints only exist if we build with the internal-lints feature
if cfg!(feature = "internal-lints") {
// internal lints only exist if we build with the internal feature
if cfg!(feature = "internal") {
command.args(&["-D", "clippy::internal"]);
}
@ -180,7 +180,7 @@ fn dogfood_subprojects() {
#[test]
#[ignore]
#[cfg(feature = "metadata-collector-lint")]
#[cfg(feature = "internal")]
fn run_metadata_collection_lint() {
use std::fs::File;
use std::time::SystemTime;
@ -233,8 +233,8 @@ fn run_clippy_for_project(project: &str) {
.args(&["-D", "clippy::pedantic"])
.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
// internal lints only exist if we build with the internal-lints feature
if cfg!(feature = "internal-lints") {
// internal lints only exist if we build with the internal feature
if cfg!(feature = "internal") {
command.args(&["-D", "clippy::internal"]);
}