Skip to content

Commit 1816361

Browse files
committed
Auto merge of rust-lang#8257 - camsteffen:internal-features, r=giraffate
Combine internal cargo features changelog: none This is just simpler and I don't see any downsides.
2 parents 88cfd70 + e2ce4f9 commit 1816361

File tree

17 files changed

+58
-65
lines changed

17 files changed

+58
-65
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
uitest = "test --test compile-test"
33
dev = "run --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
44
lintcheck = "run --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
5-
collect-metadata = "test --test dogfood --features metadata-collector-lint -- run_metadata_collection_lint --ignored"
5+
collect-metadata = "test --test dogfood --features internal -- run_metadata_collection_lint --ignored"
66

77
[build]
88
# -Zbinary-dep-depinfo allows us to track which rlib files to use for compiling UI tests

.github/workflows/clippy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ jobs:
4949
echo "LD_LIBRARY_PATH=${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" >> $GITHUB_ENV
5050
5151
- name: Build
52-
run: cargo build --features deny-warnings,internal-lints,metadata-collector-lint
52+
run: cargo build --features deny-warnings,internal
5353

5454
- name: Test
55-
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
55+
run: cargo test --features deny-warnings,internal
5656

5757
- name: Test clippy_lints
58-
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
58+
run: cargo test --features deny-warnings,internal
5959
working-directory: clippy_lints
6060

6161
- name: Test clippy_utils
62-
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
62+
run: cargo test --features deny-warnings,internal
6363
working-directory: clippy_utils
6464

6565
- name: Test rustc_tools_util

.github/workflows/clippy_bors.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,17 @@ jobs:
112112
echo "$SYSROOT/bin" >> $GITHUB_PATH
113113
114114
- name: Build
115-
run: cargo build --features deny-warnings,internal-lints,metadata-collector-lint
115+
run: cargo build --features deny-warnings,internal
116116

117117
- name: Test
118-
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
118+
run: cargo test --features deny-warnings,internal
119119

120120
- name: Test clippy_lints
121-
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
121+
run: cargo test --features deny-warnings,internal
122122
working-directory: clippy_lints
123123

124124
- name: Test clippy_utils
125-
run: cargo test --features deny-warnings,internal-lints,metadata-collector-lint
125+
run: cargo test --features deny-warnings,internal
126126
working-directory: clippy_utils
127127

128128
- name: Test rustc_tools_util

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ rustc_tools_util = { version = "0.2", path = "rustc_tools_util" }
5757
[features]
5858
deny-warnings = ["clippy_lints/deny-warnings"]
5959
integration = ["tempfile"]
60-
internal-lints = ["clippy_lints/internal-lints"]
61-
metadata-collector-lint = ["internal-lints", "clippy_lints/metadata-collector-lint"]
60+
internal = ["clippy_lints/internal"]
6261

6362
[package.metadata.rust-analyzer]
6463
# This package uses #[feature(rustc_private)]

clippy_dev/src/update_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ fn gen_register_lint_list<'a>(
321321

322322
for (is_public, module_name, lint_name) in details {
323323
if !is_public {
324-
output.push_str(" #[cfg(feature = \"internal-lints\")]\n");
324+
output.push_str(" #[cfg(feature = \"internal\")]\n");
325325
}
326326
output.push_str(&format!(" {}::{},\n", module_name, lint_name));
327327
}

clippy_lints/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ url = { version = "2.2", features = ["serde"] }
3030
[features]
3131
deny-warnings = ["clippy_utils/deny-warnings"]
3232
# build clippy with internal lints enabled, off by default
33-
internal-lints = ["clippy_utils/internal-lints"]
34-
metadata-collector-lint = ["serde_json", "clippy_utils/metadata-collector-lint"]
33+
internal = ["clippy_utils/internal", "serde_json"]
3534

3635
[package.metadata.rust-analyzer]
3736
# This crate uses #[feature(rustc_private)]

clippy_lints/src/lib.register_lints.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@
33
// Manual edits will be overwritten.
44

55
store.register_lints(&[
6-
#[cfg(feature = "internal-lints")]
6+
#[cfg(feature = "internal")]
77
utils::internal_lints::CLIPPY_LINTS_INTERNAL,
8-
#[cfg(feature = "internal-lints")]
8+
#[cfg(feature = "internal")]
99
utils::internal_lints::COLLAPSIBLE_SPAN_LINT_CALLS,
10-
#[cfg(feature = "internal-lints")]
10+
#[cfg(feature = "internal")]
1111
utils::internal_lints::COMPILER_LINT_FUNCTIONS,
12-
#[cfg(feature = "internal-lints")]
12+
#[cfg(feature = "internal")]
1313
utils::internal_lints::DEFAULT_LINT,
14-
#[cfg(feature = "internal-lints")]
14+
#[cfg(feature = "internal")]
1515
utils::internal_lints::IF_CHAIN_STYLE,
16-
#[cfg(feature = "internal-lints")]
16+
#[cfg(feature = "internal")]
1717
utils::internal_lints::INTERNING_DEFINED_SYMBOL,
18-
#[cfg(feature = "internal-lints")]
18+
#[cfg(feature = "internal")]
1919
utils::internal_lints::INVALID_CLIPPY_VERSION_ATTRIBUTE,
20-
#[cfg(feature = "internal-lints")]
20+
#[cfg(feature = "internal")]
2121
utils::internal_lints::INVALID_PATHS,
22-
#[cfg(feature = "internal-lints")]
22+
#[cfg(feature = "internal")]
2323
utils::internal_lints::LINT_WITHOUT_LINT_PASS,
24-
#[cfg(feature = "internal-lints")]
24+
#[cfg(feature = "internal")]
2525
utils::internal_lints::MATCH_TYPE_ON_DIAGNOSTIC_ITEM,
26-
#[cfg(feature = "internal-lints")]
26+
#[cfg(feature = "internal")]
2727
utils::internal_lints::MISSING_CLIPPY_VERSION_ATTRIBUTE,
28-
#[cfg(feature = "internal-lints")]
28+
#[cfg(feature = "internal")]
2929
utils::internal_lints::OUTER_EXPN_EXPN_DATA,
30-
#[cfg(feature = "internal-lints")]
30+
#[cfg(feature = "internal")]
3131
utils::internal_lints::PRODUCE_ICE,
32-
#[cfg(feature = "internal-lints")]
32+
#[cfg(feature = "internal")]
3333
utils::internal_lints::UNNECESSARY_SYMBOL_STR,
3434
absurd_extreme_comparisons::ABSURD_EXTREME_COMPARISONS,
3535
approx_const::APPROX_CONSTANT,

clippy_lints/src/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,9 @@ macro_rules! declare_clippy_lint {
153153
};
154154
}
155155

156-
#[cfg(feature = "metadata-collector-lint")]
156+
#[cfg(feature = "internal")]
157157
mod deprecated_lints;
158-
#[cfg_attr(
159-
any(feature = "internal-lints", feature = "metadata-collector-lint"),
160-
allow(clippy::missing_clippy_version_attribute)
161-
)]
158+
#[cfg_attr(feature = "internal", allow(clippy::missing_clippy_version_attribute))]
162159
mod utils;
163160

164161
// 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:
472469
include!("lib.register_restriction.rs");
473470
include!("lib.register_pedantic.rs");
474471

475-
#[cfg(feature = "internal-lints")]
472+
#[cfg(feature = "internal")]
476473
include!("lib.register_internal.rs");
477474

478475
include!("lib.register_all.rs");
@@ -484,7 +481,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
484481
include!("lib.register_cargo.rs");
485482
include!("lib.register_nursery.rs");
486483

487-
#[cfg(feature = "metadata-collector-lint")]
484+
#[cfg(feature = "internal")]
488485
{
489486
if std::env::var("ENABLE_METADATA_COLLECTION").eq(&Ok("1".to_string())) {
490487
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:
493490
}
494491

495492
// all the internal lints
496-
#[cfg(feature = "internal-lints")]
493+
#[cfg(feature = "internal")]
497494
{
498495
store.register_early_pass(|| Box::new(utils::internal_lints::ClippyLintsInternal));
499496
store.register_early_pass(|| Box::new(utils::internal_lints::ProduceIce));

clippy_lints/src/utils/conf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ macro_rules! define_Conf {
113113
}
114114
}
115115

116-
#[cfg(feature = "metadata-collector-lint")]
116+
#[cfg(feature = "internal")]
117117
pub mod metadata {
118118
use crate::utils::internal_lints::metadata_collector::ClippyConfiguration;
119119

clippy_lints/src/utils/internal_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use rustc_typeck::hir_ty_to_ty;
3535

3636
use std::borrow::{Borrow, Cow};
3737

38-
#[cfg(feature = "metadata-collector-lint")]
38+
#[cfg(feature = "internal")]
3939
pub mod metadata_collector;
4040

4141
declare_clippy_lint! {

clippy_lints/src/utils/internal_lints/metadata_collector.rs

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

clippy_lints/src/utils/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub mod author;
22
pub mod conf;
33
pub mod inspector;
4-
#[cfg(any(feature = "internal-lints", feature = "metadata-collector-lint"))]
4+
#[cfg(feature = "internal")]
55
pub mod internal_lints;

clippy_utils/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ rustc-semver = "1.1"
1111

1212
[features]
1313
deny-warnings = []
14-
internal-lints = []
15-
metadata-collector-lint = []
14+
internal = []
1615

1716
[package.metadata.rust-analyzer]
1817
# This crate uses #[feature(rustc_private)]

clippy_utils/src/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub fn span_lint_hir_and_then(
198198
/// |
199199
/// = note: `-D fold-any` implied by `-D warnings`
200200
/// ```
201-
#[cfg_attr(feature = "internal-lints", allow(clippy::collapsible_span_lint_calls))]
201+
#[cfg_attr(feature = "internal", allow(clippy::collapsible_span_lint_calls))]
202202
pub fn span_lint_and_sugg<'a, T: LintContext>(
203203
cx: &'a T,
204204
lint: &'static Lint,

clippy_utils/src/paths.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
//! See <https://github.com/rust-lang/rust-clippy/issues/5393> for more information.
66
77
pub const ANY_TRAIT: [&str; 3] = ["core", "any", "Any"];
8-
#[cfg(feature = "metadata-collector-lint")]
8+
#[cfg(feature = "internal")]
99
pub const APPLICABILITY: [&str; 2] = ["rustc_lint_defs", "Applicability"];
10-
#[cfg(feature = "metadata-collector-lint")]
10+
#[cfg(feature = "internal")]
1111
pub const APPLICABILITY_VALUES: [[&str; 3]; 4] = [
1212
["rustc_lint_defs", "Applicability", "Unspecified"],
1313
["rustc_lint_defs", "Applicability", "HasPlaceholders"],
1414
["rustc_lint_defs", "Applicability", "MaybeIncorrect"],
1515
["rustc_lint_defs", "Applicability", "MachineApplicable"],
1616
];
17-
#[cfg(feature = "metadata-collector-lint")]
17+
#[cfg(feature = "internal")]
1818
pub const DIAGNOSTIC_BUILDER: [&str; 3] = ["rustc_errors", "diagnostic_builder", "DiagnosticBuilder"];
1919
pub const ARC_PTR_EQ: [&str; 4] = ["alloc", "sync", "Arc", "ptr_eq"];
2020
#[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
@@ -45,7 +45,7 @@ pub const DISPLAY_TRAIT: [&str; 3] = ["core", "fmt", "Display"];
4545
pub const DOUBLE_ENDED_ITERATOR: [&str; 4] = ["core", "iter", "traits", "DoubleEndedIterator"];
4646
pub const DROP: [&str; 3] = ["core", "mem", "drop"];
4747
pub const DURATION: [&str; 3] = ["core", "time", "Duration"];
48-
#[cfg(feature = "internal-lints")]
48+
#[cfg(feature = "internal")]
4949
pub const EARLY_CONTEXT: [&str; 2] = ["rustc_lint", "EarlyContext"];
5050
#[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
5151
pub const EPRINT_MACRO: [&str; 3] = ["std", "macros", "eprint"];
@@ -71,9 +71,9 @@ pub const HASH: [&str; 3] = ["core", "hash", "Hash"];
7171
pub const HASHMAP_CONTAINS_KEY: [&str; 6] = ["std", "collections", "hash", "map", "HashMap", "contains_key"];
7272
pub const HASHMAP_ENTRY: [&str; 5] = ["std", "collections", "hash", "map", "Entry"];
7373
pub const HASHMAP_INSERT: [&str; 6] = ["std", "collections", "hash", "map", "HashMap", "insert"];
74-
#[cfg(feature = "internal-lints")]
74+
#[cfg(feature = "internal")]
7575
pub const IDENT: [&str; 3] = ["rustc_span", "symbol", "Ident"];
76-
#[cfg(feature = "internal-lints")]
76+
#[cfg(feature = "internal")]
7777
pub const IDENT_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Ident", "as_str"];
7878
pub const INDEX: [&str; 3] = ["core", "ops", "Index"];
7979
pub const INDEX_MUT: [&str; 3] = ["core", "ops", "IndexMut"];
@@ -85,11 +85,11 @@ pub const IPADDR_V6: [&str; 5] = ["std", "net", "ip", "IpAddr", "V6"];
8585
pub const ITER_REPEAT: [&str; 5] = ["core", "iter", "sources", "repeat", "repeat"];
8686
#[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
8787
pub const ITERTOOLS_NEXT_TUPLE: [&str; 3] = ["itertools", "Itertools", "next_tuple"];
88-
#[cfg(feature = "internal-lints")]
88+
#[cfg(feature = "internal")]
8989
pub const KW_MODULE: [&str; 3] = ["rustc_span", "symbol", "kw"];
90-
#[cfg(feature = "internal-lints")]
90+
#[cfg(feature = "internal")]
9191
pub const LATE_CONTEXT: [&str; 2] = ["rustc_lint", "LateContext"];
92-
#[cfg(any(feature = "internal-lints", feature = "metadata-collector-lint"))]
92+
#[cfg(feature = "internal")]
9393
pub const LINT: [&str; 2] = ["rustc_lint_defs", "Lint"];
9494
pub const MEM_DISCRIMINANT: [&str; 3] = ["core", "mem", "discriminant"];
9595
pub const MEM_FORGET: [&str; 3] = ["core", "mem", "forget"];
@@ -179,17 +179,17 @@ pub const STR_ENDS_WITH: [&str; 4] = ["core", "str", "<impl str>", "ends_with"];
179179
pub const STR_FROM_UTF8: [&str; 4] = ["core", "str", "converts", "from_utf8"];
180180
pub const STR_LEN: [&str; 4] = ["core", "str", "<impl str>", "len"];
181181
pub const STR_STARTS_WITH: [&str; 4] = ["core", "str", "<impl str>", "starts_with"];
182-
#[cfg(feature = "internal-lints")]
182+
#[cfg(feature = "internal")]
183183
pub const SYMBOL: [&str; 3] = ["rustc_span", "symbol", "Symbol"];
184-
#[cfg(feature = "internal-lints")]
184+
#[cfg(feature = "internal")]
185185
pub const SYMBOL_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Symbol", "as_str"];
186-
#[cfg(feature = "internal-lints")]
186+
#[cfg(feature = "internal")]
187187
pub const SYMBOL_INTERN: [&str; 4] = ["rustc_span", "symbol", "Symbol", "intern"];
188-
#[cfg(feature = "internal-lints")]
188+
#[cfg(feature = "internal")]
189189
pub const SYMBOL_TO_IDENT_STRING: [&str; 4] = ["rustc_span", "symbol", "Symbol", "to_ident_string"];
190-
#[cfg(feature = "internal-lints")]
190+
#[cfg(feature = "internal")]
191191
pub const SYM_MODULE: [&str; 3] = ["rustc_span", "symbol", "sym"];
192-
#[cfg(feature = "internal-lints")]
192+
#[cfg(feature = "internal")]
193193
pub const SYNTAX_CONTEXT: [&str; 3] = ["rustc_span", "hygiene", "SyntaxContext"];
194194
pub const TO_OWNED_METHOD: [&str; 4] = ["alloc", "borrow", "ToOwned", "to_owned"];
195195
pub const TO_STRING_METHOD: [&str; 4] = ["alloc", "string", "ToString", "to_string"];

tests/compile-test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::path::{Path, PathBuf};
1515
mod cargo;
1616

1717
// whether to run internal tests or not
18-
const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal-lints");
18+
const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal");
1919

2020
/// All crates used in UI tests are listed here
2121
static TEST_DEPENDENCIES: &[&str] = &[

tests/dogfood.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ fn dogfood_clippy() {
4242
.args(&["-D", "clippy::pedantic"])
4343
.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
4444

45-
// internal lints only exist if we build with the internal-lints feature
46-
if cfg!(feature = "internal-lints") {
45+
// internal lints only exist if we build with the internal feature
46+
if cfg!(feature = "internal") {
4747
command.args(&["-D", "clippy::internal"]);
4848
}
4949

@@ -180,7 +180,7 @@ fn dogfood_subprojects() {
180180

181181
#[test]
182182
#[ignore]
183-
#[cfg(feature = "metadata-collector-lint")]
183+
#[cfg(feature = "internal")]
184184
fn run_metadata_collection_lint() {
185185
use std::fs::File;
186186
use std::time::SystemTime;
@@ -233,8 +233,8 @@ fn run_clippy_for_project(project: &str) {
233233
.args(&["-D", "clippy::pedantic"])
234234
.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
235235

236-
// internal lints only exist if we build with the internal-lints feature
237-
if cfg!(feature = "internal-lints") {
236+
// internal lints only exist if we build with the internal feature
237+
if cfg!(feature = "internal") {
238238
command.args(&["-D", "clippy::internal"]);
239239
}
240240

0 commit comments

Comments
 (0)