Auto merge of #8257 - camsteffen:internal-features, r=giraffate
Combine internal cargo features changelog: none This is just simpler and I don't see any downsides.
This commit is contained in:
commit
1816361738
@ -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
|
||||
|
8
.github/workflows/clippy.yml
vendored
8
.github/workflows/clippy.yml
vendored
@ -49,17 +49,17 @@ 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
|
||||
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
|
||||
run: cargo test --features deny-warnings,internal
|
||||
working-directory: clippy_utils
|
||||
|
||||
- name: Test rustc_tools_util
|
||||
|
8
.github/workflows/clippy_bors.yml
vendored
8
.github/workflows/clippy_bors.yml
vendored
@ -112,17 +112,17 @@ 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
|
||||
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
|
||||
run: cargo test --features deny-warnings,internal
|
||||
working-directory: clippy_utils
|
||||
|
||||
- name: Test rustc_tools_util
|
||||
|
@ -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)]
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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-lints"]
|
||||
metadata-collector-lint = ["serde_json", "clippy_utils/metadata-collector-lint"]
|
||||
internal = ["clippy_utils/internal", "serde_json"]
|
||||
|
||||
[package.metadata.rust-analyzer]
|
||||
# This crate uses #[feature(rustc_private)]
|
||||
|
@ -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,
|
||||
|
@ -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, it’s 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));
|
||||
|
@ -113,7 +113,7 @@ fn visit_map<V>(self, mut map: V) -> Result<Self::Value, V::Error> where V: MapA
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "metadata-collector-lint")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub mod metadata {
|
||||
use crate::utils::internal_lints::metadata_collector::ClippyConfiguration;
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
use std::borrow::{Borrow, Cow};
|
||||
|
||||
#[cfg(feature = "metadata-collector-lint")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub mod metadata_collector;
|
||||
|
||||
declare_clippy_lint! {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -11,8 +11,7 @@ rustc-semver = "1.1"
|
||||
|
||||
[features]
|
||||
deny-warnings = []
|
||||
internal-lints = []
|
||||
metadata-collector-lint = []
|
||||
internal = []
|
||||
|
||||
[package.metadata.rust-analyzer]
|
||||
# This crate uses #[feature(rustc_private)]
|
||||
|
@ -198,7 +198,7 @@ pub fn span_lint_hir_and_then(
|
||||
/// |
|
||||
/// = note: `-D fold-any` implied by `-D warnings`
|
||||
/// ```
|
||||
#[cfg_attr(feature = "internal-lints", allow(clippy::collapsible_span_lint_calls))]
|
||||
#[cfg_attr(feature = "internal", allow(clippy::collapsible_span_lint_calls))]
|
||||
pub fn span_lint_and_sugg<'a, T: LintContext>(
|
||||
cx: &'a T,
|
||||
lint: &'static Lint,
|
||||
|
@ -5,16 +5,16 @@
|
||||
//! See <https://github.com/rust-lang/rust-clippy/issues/5393> for more information.
|
||||
|
||||
pub const ANY_TRAIT: [&str; 3] = ["core", "any", "Any"];
|
||||
#[cfg(feature = "metadata-collector-lint")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const APPLICABILITY: [&str; 2] = ["rustc_lint_defs", "Applicability"];
|
||||
#[cfg(feature = "metadata-collector-lint")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const APPLICABILITY_VALUES: [[&str; 3]; 4] = [
|
||||
["rustc_lint_defs", "Applicability", "Unspecified"],
|
||||
["rustc_lint_defs", "Applicability", "HasPlaceholders"],
|
||||
["rustc_lint_defs", "Applicability", "MaybeIncorrect"],
|
||||
["rustc_lint_defs", "Applicability", "MachineApplicable"],
|
||||
];
|
||||
#[cfg(feature = "metadata-collector-lint")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const DIAGNOSTIC_BUILDER: [&str; 3] = ["rustc_errors", "diagnostic_builder", "DiagnosticBuilder"];
|
||||
pub const ARC_PTR_EQ: [&str; 4] = ["alloc", "sync", "Arc", "ptr_eq"];
|
||||
#[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
|
||||
@ -45,7 +45,7 @@
|
||||
pub const DOUBLE_ENDED_ITERATOR: [&str; 4] = ["core", "iter", "traits", "DoubleEndedIterator"];
|
||||
pub const DROP: [&str; 3] = ["core", "mem", "drop"];
|
||||
pub const DURATION: [&str; 3] = ["core", "time", "Duration"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const EARLY_CONTEXT: [&str; 2] = ["rustc_lint", "EarlyContext"];
|
||||
#[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
|
||||
pub const EPRINT_MACRO: [&str; 3] = ["std", "macros", "eprint"];
|
||||
@ -71,9 +71,9 @@
|
||||
pub const HASHMAP_CONTAINS_KEY: [&str; 6] = ["std", "collections", "hash", "map", "HashMap", "contains_key"];
|
||||
pub const HASHMAP_ENTRY: [&str; 5] = ["std", "collections", "hash", "map", "Entry"];
|
||||
pub const HASHMAP_INSERT: [&str; 6] = ["std", "collections", "hash", "map", "HashMap", "insert"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const IDENT: [&str; 3] = ["rustc_span", "symbol", "Ident"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const IDENT_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Ident", "as_str"];
|
||||
pub const INDEX: [&str; 3] = ["core", "ops", "Index"];
|
||||
pub const INDEX_MUT: [&str; 3] = ["core", "ops", "IndexMut"];
|
||||
@ -85,11 +85,11 @@
|
||||
pub const ITER_REPEAT: [&str; 5] = ["core", "iter", "sources", "repeat", "repeat"];
|
||||
#[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
|
||||
pub const ITERTOOLS_NEXT_TUPLE: [&str; 3] = ["itertools", "Itertools", "next_tuple"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const KW_MODULE: [&str; 3] = ["rustc_span", "symbol", "kw"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const LATE_CONTEXT: [&str; 2] = ["rustc_lint", "LateContext"];
|
||||
#[cfg(any(feature = "internal-lints", feature = "metadata-collector-lint"))]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const LINT: [&str; 2] = ["rustc_lint_defs", "Lint"];
|
||||
pub const MEM_DISCRIMINANT: [&str; 3] = ["core", "mem", "discriminant"];
|
||||
pub const MEM_FORGET: [&str; 3] = ["core", "mem", "forget"];
|
||||
@ -179,17 +179,17 @@
|
||||
pub const STR_FROM_UTF8: [&str; 4] = ["core", "str", "converts", "from_utf8"];
|
||||
pub const STR_LEN: [&str; 4] = ["core", "str", "<impl str>", "len"];
|
||||
pub const STR_STARTS_WITH: [&str; 4] = ["core", "str", "<impl str>", "starts_with"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const SYMBOL: [&str; 3] = ["rustc_span", "symbol", "Symbol"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const SYMBOL_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Symbol", "as_str"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const SYMBOL_INTERN: [&str; 4] = ["rustc_span", "symbol", "Symbol", "intern"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const SYMBOL_TO_IDENT_STRING: [&str; 4] = ["rustc_span", "symbol", "Symbol", "to_ident_string"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const SYM_MODULE: [&str; 3] = ["rustc_span", "symbol", "sym"];
|
||||
#[cfg(feature = "internal-lints")]
|
||||
#[cfg(feature = "internal")]
|
||||
pub const SYNTAX_CONTEXT: [&str; 3] = ["rustc_span", "hygiene", "SyntaxContext"];
|
||||
pub const TO_OWNED_METHOD: [&str; 4] = ["alloc", "borrow", "ToOwned", "to_owned"];
|
||||
pub const TO_STRING_METHOD: [&str; 4] = ["alloc", "string", "ToString", "to_string"];
|
||||
|
@ -15,7 +15,7 @@
|
||||
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] = &[
|
||||
|
@ -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"]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user