Move internal lints to their own crate (#13223)

This makes it so switching the internal feature on/off no longer
rebuilds `clippy_lints`.

r? @flip1995

changelog: none
This commit is contained in:
Timo 2025-04-18 12:04:08 +00:00 committed by GitHub
commit 781fdab9a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
63 changed files with 295 additions and 333 deletions

View file

@ -66,7 +66,7 @@ jobs:
run: cargo test --features internal -- --skip dogfood
- name: Test clippy_lints
run: cargo test --features internal
run: cargo test
working-directory: clippy_lints
- name: Test clippy_utils

View file

@ -42,7 +42,7 @@ jobs:
run: cargo test --features internal
- name: Test clippy_lints
run: cargo test --features internal
run: cargo test
working-directory: clippy_lints
- name: Test clippy_utils

View file

@ -27,6 +27,7 @@ clippy_config = { path = "clippy_config" }
clippy_lints = { path = "clippy_lints" }
clippy_utils = { path = "clippy_utils" }
rustc_tools_util = { path = "rustc_tools_util", version = "0.4.2" }
clippy_lints_internal = { path = "clippy_lints_internal", optional = true }
tempfile = { version = "3.3", optional = true }
termize = "0.1"
color-print = "0.3.4"
@ -58,8 +59,8 @@ tokio = { version = "1", features = ["io-util"] }
rustc_tools_util = { path = "rustc_tools_util", version = "0.4.2" }
[features]
integration = ["tempfile"]
internal = ["clippy_lints/internal", "tempfile"]
integration = ["dep:tempfile"]
internal = ["dep:clippy_lints_internal", "dep:tempfile"]
[package.metadata.rust-analyzer]
# This package uses #[feature(rustc_private)]

View file

@ -9,7 +9,7 @@ lint involves some boilerplate code.
A lint type is the category of items and expressions in which your lint focuses on.
As of the writing of this documentation update, there are 12 _types_ of lints
As of the writing of this documentation update, there are 11 _types_ of lints
besides the numerous standalone lints living under `clippy_lints/src/`:
- `cargo`
@ -23,7 +23,6 @@ besides the numerous standalone lints living under `clippy_lints/src/`:
- `transmute`
- `types`
- `unit_types`
- `utils / internal` (Clippy internal lints)
These types group together lints that share some common behaviors. For instance,
`functions` groups together lints that deal with some aspects of functions in

View file

@ -170,7 +170,6 @@ enum DevCommand {
"restriction",
"cargo",
"nursery",
"internal",
],
default_value = "nursery",
)]

View file

@ -38,9 +38,8 @@ fn generate_lint_files(
deprecated_lints: &[DeprecatedLint],
renamed_lints: &[RenamedLint],
) {
let internal_lints = Lint::internal_lints(lints);
let mut usable_lints = Lint::usable_lints(lints);
usable_lints.sort_by_key(|lint| lint.name.clone());
let mut lints = lints.to_owned();
lints.sort_by_key(|lint| lint.name.clone());
replace_region_in_file(
update_mode,
@ -48,7 +47,7 @@ fn generate_lint_files(
"[There are over ",
" lints included in this crate!]",
|res| {
write!(res, "{}", round_to_fifty(usable_lints.len())).unwrap();
write!(res, "{}", round_to_fifty(lints.len())).unwrap();
},
);
@ -58,7 +57,7 @@ fn generate_lint_files(
"[There are over ",
" lints included in this crate!]",
|res| {
write!(res, "{}", round_to_fifty(usable_lints.len())).unwrap();
write!(res, "{}", round_to_fifty(lints.len())).unwrap();
},
);
@ -68,7 +67,7 @@ fn generate_lint_files(
"<!-- begin autogenerated links to lint list -->\n",
"<!-- end autogenerated links to lint list -->",
|res| {
for lint in usable_lints
for lint in lints
.iter()
.map(|l| &*l.name)
.chain(deprecated_lints.iter().filter_map(|l| l.name.strip_prefix("clippy::")))
@ -87,7 +86,7 @@ fn generate_lint_files(
"// begin lints modules, do not remove this comment, its used in `update_lints`\n",
"// end lints modules, do not remove this comment, its used in `update_lints`",
|res| {
for lint_mod in usable_lints.iter().map(|l| &l.module).unique().sorted() {
for lint_mod in lints.iter().map(|l| &l.module).unique().sorted() {
writeln!(res, "mod {lint_mod};").unwrap();
}
},
@ -96,7 +95,7 @@ fn generate_lint_files(
process_file(
"clippy_lints/src/declared_lints.rs",
update_mode,
&gen_declared_lints(internal_lints.iter(), usable_lints.iter()),
&gen_declared_lints(lints.iter()),
);
let content = gen_deprecated_lints_test(deprecated_lints);
@ -107,10 +106,9 @@ fn generate_lint_files(
}
pub fn print_lints() {
let (lint_list, _, _) = gather_all();
let usable_lints = Lint::usable_lints(&lint_list);
let usable_lint_count = usable_lints.len();
let grouped_by_lint_group = Lint::by_lint_group(usable_lints.into_iter());
let (lints, _, _) = gather_all();
let lint_count = lints.len();
let grouped_by_lint_group = Lint::by_lint_group(lints.into_iter());
for (lint_group, mut lints) in grouped_by_lint_group {
println!("\n## {lint_group}");
@ -122,7 +120,7 @@ pub fn print_lints() {
}
}
println!("there are {usable_lint_count} lints");
println!("there are {lint_count} lints");
}
/// Runs the `rename_lint` command.
@ -528,22 +526,6 @@ impl Lint {
}
}
/// Returns all non-deprecated lints and non-internal lints
#[must_use]
fn usable_lints(lints: &[Self]) -> Vec<Self> {
lints
.iter()
.filter(|l| !l.group.starts_with("internal"))
.cloned()
.collect()
}
/// Returns all internal lints
#[must_use]
fn internal_lints(lints: &[Self]) -> Vec<Self> {
lints.iter().filter(|l| l.group == "internal").cloned().collect()
}
/// Returns the lints in a `HashMap`, grouped by the different lint groups
#[must_use]
fn by_lint_group(lints: impl Iterator<Item = Self>) -> HashMap<String, Vec<Self>> {
@ -580,23 +562,14 @@ impl RenamedLint {
/// Generates the code for registering lints
#[must_use]
fn gen_declared_lints<'a>(
internal_lints: impl Iterator<Item = &'a Lint>,
usable_lints: impl Iterator<Item = &'a Lint>,
) -> String {
let mut details: Vec<_> = internal_lints
.map(|l| (false, &l.module, l.name.to_uppercase()))
.chain(usable_lints.map(|l| (true, &l.module, l.name.to_uppercase())))
.collect();
fn gen_declared_lints<'a>(lints: impl Iterator<Item = &'a Lint>) -> String {
let mut details: Vec<_> = lints.map(|l| (&l.module, l.name.to_uppercase())).collect();
details.sort_unstable();
let mut output = GENERATED_FILE_COMMENT.to_string();
output.push_str("pub static LINTS: &[&crate::LintInfo] = &[\n");
for (is_public, module_name, lint_name) in details {
if !is_public {
output.push_str(" #[cfg(feature = \"internal\")]\n");
}
for (module_name, lint_name) in details {
let _: fmt::Result = writeln!(output, " crate::{module_name}::{lint_name}_INFO,");
}
output.push_str("];\n");
@ -937,41 +910,6 @@ mod tests {
assert_eq!(expected, result);
}
#[test]
fn test_usable_lints() {
let lints = vec![
Lint::new(
"should_assert_eq2",
"Not Deprecated",
"\"abc\"",
"module_name",
Range::default(),
),
Lint::new(
"should_assert_eq2",
"internal",
"\"abc\"",
"module_name",
Range::default(),
),
Lint::new(
"should_assert_eq2",
"internal_style",
"\"abc\"",
"module_name",
Range::default(),
),
];
let expected = vec![Lint::new(
"should_assert_eq2",
"Not Deprecated",
"\"abc\"",
"module_name",
Range::default(),
)];
assert_eq!(expected, Lint::usable_lints(&lints));
}
#[test]
fn test_by_lint_group() {
let lints = vec![

View file

@ -19,10 +19,7 @@ itertools = "0.12"
quine-mc_cluskey = "0.2"
regex-syntax = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", optional = true }
tempfile = { version = "3.3.0", optional = true }
toml = "0.7.3"
regex = { version = "1.5", optional = true }
unicode-normalization = "0.1"
unicode-script = { version = "0.5", default-features = false }
semver = "1.0"
@ -31,10 +28,6 @@ url = "2.2"
[dev-dependencies]
walkdir = "2.3"
[features]
# build clippy with internal lints enabled, off by default
internal = ["serde_json", "tempfile", "regex"]
[package.metadata.rust-analyzer]
# This crate uses #[feature(rustc_private)]
rustc_private = true

View file

@ -165,17 +165,4 @@ macro_rules! declare_clippy_lint {
$(, $eval_always)?
}
};
(
$(#[doc = $lit:literal])*
pub $lint_name:ident,
internal,
$desc:literal
) => {
declare_clippy_lint! {@
$(#[doc = $lit])*
pub $lint_name, Allow, crate::LintCategory::Internal, $desc,
None, "0.0.0"
}
};
}

View file

@ -3,36 +3,6 @@
// Manual edits will be overwritten.
pub static LINTS: &[&crate::LintInfo] = &[
#[cfg(feature = "internal")]
crate::utils::internal_lints::almost_standard_lint_formulation::ALMOST_STANDARD_LINT_FORMULATION_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::collapsible_calls::COLLAPSIBLE_SPAN_LINT_CALLS_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::interning_defined_symbol::INTERNING_DEFINED_SYMBOL_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::interning_defined_symbol::UNNECESSARY_SYMBOL_STR_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::invalid_paths::INVALID_PATHS_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::lint_without_lint_pass::DEFAULT_LINT_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::lint_without_lint_pass::INVALID_CLIPPY_VERSION_ATTRIBUTE_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::lint_without_lint_pass::LINT_WITHOUT_LINT_PASS_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::lint_without_lint_pass::MISSING_CLIPPY_VERSION_ATTRIBUTE_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::msrv_attr_impl::MISSING_MSRV_ATTR_IMPL_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::outer_expn_data_pass::OUTER_EXPN_EXPN_DATA_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::produce_ice::PRODUCE_ICE_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::slow_symbol_comparisons::SLOW_SYMBOL_COMPARISONS_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::unnecessary_def_path::UNNECESSARY_DEF_PATH_INFO,
#[cfg(feature = "internal")]
crate::utils::internal_lints::unsorted_clippy_utils_paths::UNSORTED_CLIPPY_UTILS_PATHS_INFO,
crate::absolute_paths::ABSOLUTE_PATHS_INFO,
crate::almost_complete_range::ALMOST_COMPLETE_RANGE_INFO,
crate::approx_const::APPROX_CONSTANT_INFO,

View file

@ -65,7 +65,6 @@ mod declare_clippy_lint;
#[macro_use]
extern crate clippy_utils;
#[cfg_attr(feature = "internal", allow(clippy::missing_clippy_version_attribute))]
mod utils;
pub mod ctfe; // Very important lint, do not remove (rust#125116)
@ -413,21 +412,6 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_lint::{Lint, LintId};
use utils::attr_collector::{AttrCollector, AttrStorage};
/// Register all pre expansion lints
///
/// Pre-expansion lints run before any macro expansion has happened.
///
/// Note that due to the architecture of the compiler, currently `cfg_attr` attributes on crate
/// level (i.e `#![cfg_attr(...)]`) will still be expanded even when using a pre-expansion pass.
///
/// Used in `./src/driver.rs`.
pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
// NOTE: Do not add any more pre-expansion passes. These should be removed eventually.
store.register_pre_expansion_pass(move || Box::new(attrs::EarlyAttributes::new(conf)));
store.register_early_pass(move || Box::new(attrs::PostExpansionEarlyAttributes::new(conf)));
}
#[derive(Default)]
struct RegistrationGroups {
all: Vec<LintId>,
@ -440,8 +424,6 @@ struct RegistrationGroups {
restriction: Vec<LintId>,
style: Vec<LintId>,
suspicious: Vec<LintId>,
#[cfg(feature = "internal")]
internal: Vec<LintId>,
}
impl RegistrationGroups {
@ -457,8 +439,6 @@ impl RegistrationGroups {
store.register_group(true, "clippy::restriction", Some("clippy_restriction"), self.restriction);
store.register_group(true, "clippy::style", Some("clippy_style"), self.style);
store.register_group(true, "clippy::suspicious", Some("clippy_suspicious"), self.suspicious);
#[cfg(feature = "internal")]
store.register_group(true, "clippy::internal", Some("clippy_internal"), self.internal);
}
}
@ -473,8 +453,6 @@ pub(crate) enum LintCategory {
Restriction,
Style,
Suspicious,
#[cfg(feature = "internal")]
Internal,
}
#[allow(clippy::enum_glob_use)]
@ -496,8 +474,6 @@ impl LintCategory {
Restriction => &mut groups.restriction,
Style => &mut groups.style,
Suspicious => &mut groups.suspicious,
#[cfg(feature = "internal")]
Internal => &mut groups.internal,
}
}
}
@ -531,8 +507,6 @@ impl LintInfo {
Restriction => "restriction",
Style => "style",
Suspicious => "suspicious",
#[cfg(feature = "internal")]
Internal => "internal",
}
}
}
@ -590,6 +564,13 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
store.register_removed(name, reason);
}
// NOTE: Do not add any more pre-expansion passes. These should be removed eventually.
// Due to the architecture of the compiler, currently `cfg_attr` attributes on crate
// level (i.e `#![cfg_attr(...)]`) will still be expanded even when using a pre-expansion pass.
store.register_pre_expansion_pass(move || Box::new(attrs::EarlyAttributes::new(conf)));
store.register_early_pass(move || Box::new(attrs::PostExpansionEarlyAttributes::new(conf)));
let format_args_storage = FormatArgsStorage::default();
let format_args = format_args_storage.clone();
store.register_early_pass(move || {
@ -602,30 +583,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
let attrs = attr_storage.clone();
store.register_early_pass(move || Box::new(AttrCollector::new(attrs.clone())));
// all the internal lints
#[cfg(feature = "internal")]
{
store.register_early_pass(|| {
Box::new(utils::internal_lints::unsorted_clippy_utils_paths::UnsortedClippyUtilsPaths)
});
store.register_early_pass(|| Box::new(utils::internal_lints::produce_ice::ProduceIce));
store.register_late_pass(|_| Box::new(utils::internal_lints::collapsible_calls::CollapsibleCalls));
store.register_late_pass(|_| Box::new(utils::internal_lints::invalid_paths::InvalidPaths));
store.register_late_pass(|_| {
Box::<utils::internal_lints::interning_defined_symbol::InterningDefinedSymbol>::default()
});
store.register_late_pass(|_| {
Box::<utils::internal_lints::lint_without_lint_pass::LintWithoutLintPass>::default()
});
store.register_late_pass(|_| Box::<utils::internal_lints::unnecessary_def_path::UnnecessaryDefPath>::default());
store.register_late_pass(|_| Box::new(utils::internal_lints::outer_expn_data_pass::OuterExpnDataPass));
store.register_late_pass(|_| Box::new(utils::internal_lints::msrv_attr_impl::MsrvAttrImpl));
store.register_late_pass(|_| {
Box::new(utils::internal_lints::almost_standard_lint_formulation::AlmostStandardFormulation::new())
});
store.register_late_pass(|_| Box::new(utils::internal_lints::slow_symbol_comparisons::SlowSymbolComparisons));
}
store.register_late_pass(|_| Box::new(ctfe::ClippyCtfe));
store.register_late_pass(move |_| Box::new(operators::arithmetic_side_effects::ArithmeticSideEffects::new(conf)));

View file

@ -76,7 +76,7 @@ declare_clippy_lint! {
/// This is documented as an antipattern [on the regex documentation](https://docs.rs/regex/latest/regex/#avoid-re-compiling-regexes-especially-in-a-loop)
///
/// ### Example
/// ```no_run
/// ```rust,ignore
/// # let haystacks = [""];
/// # const MY_REGEX: &str = "a.b";
/// for haystack in haystacks {
@ -87,7 +87,7 @@ declare_clippy_lint! {
/// }
/// ```
/// can be replaced with
/// ```no_run
/// ```rust,ignore
/// # let haystacks = [""];
/// # const MY_REGEX: &str = "a.b";
/// let regex = regex::Regex::new(MY_REGEX).unwrap();

View file

@ -1,11 +0,0 @@
pub mod almost_standard_lint_formulation;
pub mod collapsible_calls;
pub mod interning_defined_symbol;
pub mod invalid_paths;
pub mod lint_without_lint_pass;
pub mod msrv_attr_impl;
pub mod outer_expn_data_pass;
pub mod produce_ice;
pub mod slow_symbol_comparisons;
pub mod unnecessary_def_path;
pub mod unsorted_clippy_utils_paths;

View file

@ -2,6 +2,3 @@ pub mod attr_collector;
pub mod author;
pub mod dump_hir;
pub mod format_args_collector;
#[cfg(feature = "internal")]
pub mod internal_lints;

View file

@ -0,0 +1,14 @@
[package]
name = "clippy_lints_internal"
version = "0.0.1"
edition = "2021"
[dependencies]
clippy_config = { path = "../clippy_config" }
clippy_utils = { path = "../clippy_utils" }
regex = { version = "1.5" }
rustc-semver = "1.1"
[package.metadata.rust-analyzer]
# This crate uses #[feature(rustc_private)]
rustc_private = true

View file

@ -1,11 +1,12 @@
use crate::utils::internal_lints::lint_without_lint_pass::is_lint_ref_type;
use crate::lint_without_lint_pass::is_lint_ref_type;
use clippy_utils::diagnostics::span_lint_and_help;
use regex::Regex;
use rustc_hir::{Attribute, Item, ItemKind, Mutability};
use rustc_lint::{LateContext, LateLintPass};
use rustc_lint_defs::declare_tool_lint;
use rustc_session::impl_lint_pass;
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Checks if lint formulations have a standardized format.
///
@ -14,9 +15,10 @@ declare_clippy_lint! {
///
/// ### Example
/// `Checks for use...` can be written as `Checks for usage...` .
pub ALMOST_STANDARD_LINT_FORMULATION,
internal,
"lint formulations must have a standardized format."
pub clippy::ALMOST_STANDARD_LINT_FORMULATION,
Warn,
"lint formulations must have a standardized format.",
report_in_external_macro: true
}
impl_lint_pass!(AlmostStandardFormulation => [ALMOST_STANDARD_LINT_FORMULATION]);

View file

@ -4,12 +4,13 @@ use clippy_utils::{SpanlessEq, is_expr_path_def_path, is_lint_allowed, peel_bloc
use rustc_errors::Applicability;
use rustc_hir::{Closure, Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_lint_defs::declare_tool_lint;
use rustc_session::declare_lint_pass;
use rustc_span::Span;
use std::borrow::{Borrow, Cow};
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Lints `span_lint_and_then` function calls, where the
/// closure argument has only one statement and that statement is a method
@ -64,9 +65,10 @@ declare_clippy_lint! {
/// span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), note_msg);
/// span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, None, note_msg);
/// ```
pub COLLAPSIBLE_SPAN_LINT_CALLS,
internal,
"found collapsible `span_lint_and_then` calls"
pub clippy::COLLAPSIBLE_SPAN_LINT_CALLS,
Warn,
"found collapsible `span_lint_and_then` calls",
report_in_external_macro: true
}
declare_lint_pass!(CollapsibleCalls => [COLLAPSIBLE_SPAN_LINT_CALLS]);

View file

@ -9,6 +9,7 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp};
use rustc_lint::{LateContext, LateLintPass};
use rustc_lint_defs::declare_tool_lint;
use rustc_middle::mir::ConstValue;
use rustc_middle::ty;
use rustc_session::impl_lint_pass;
@ -17,7 +18,7 @@ use rustc_span::symbol::Symbol;
use std::borrow::Cow;
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Checks for interning symbols that have already been pre-interned and defined as constants.
///
@ -33,12 +34,13 @@ declare_clippy_lint! {
/// ```rust,ignore
/// let _ = sym::f32;
/// ```
pub INTERNING_DEFINED_SYMBOL,
internal,
"interning a symbol that is pre-interned and defined as a constant"
pub clippy::INTERNING_DEFINED_SYMBOL,
Warn,
"interning a symbol that is pre-interned and defined as a constant",
report_in_external_macro: true
}
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Checks for unnecessary conversion from Symbol to a string.
///
@ -54,9 +56,10 @@ declare_clippy_lint! {
/// ```rust,ignore
/// symbol == sym::clippy;
/// ```
pub UNNECESSARY_SYMBOL_STR,
internal,
"unnecessary conversion between Symbol and string"
pub clippy::UNNECESSARY_SYMBOL_STR,
Warn,
"unnecessary conversion between Symbol and string",
report_in_external_macro: true
}
#[derive(Default)]

View file

@ -5,12 +5,13 @@ use rustc_hir as hir;
use rustc_hir::Item;
use rustc_hir::def::DefKind;
use rustc_lint::{LateContext, LateLintPass};
use rustc_lint_defs::declare_tool_lint;
use rustc_middle::ty::fast_reject::SimplifiedType;
use rustc_middle::ty::{self, FloatTy};
use rustc_session::declare_lint_pass;
use rustc_span::symbol::Symbol;
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Checks the paths module for invalid paths.
///
@ -19,9 +20,10 @@ declare_clippy_lint! {
///
/// ### Example
/// None.
pub INVALID_PATHS,
internal,
"invalid path"
pub clippy::INVALID_PATHS,
Warn,
"invalid path",
report_in_external_macro: true
}
declare_lint_pass!(InvalidPaths => [INVALID_PATHS]);

View file

@ -0,0 +1,78 @@
#![feature(let_chains, rustc_private)]
#![allow(
clippy::missing_docs_in_private_items,
clippy::must_use_candidate,
rustc::diagnostic_outside_of_impl,
rustc::untranslatable_diagnostic
)]
#![warn(
trivial_casts,
trivial_numeric_casts,
rust_2018_idioms,
unused_lifetimes,
unused_qualifications,
rustc::internal
)]
// Disable this rustc lint for now, as it was also done in rustc
#![allow(rustc::potential_query_instability)]
// None of these lints need a version.
#![allow(clippy::missing_clippy_version_attribute)]
extern crate rustc_ast;
extern crate rustc_attr_parsing;
extern crate rustc_data_structures;
extern crate rustc_errors;
extern crate rustc_hir;
extern crate rustc_lint;
extern crate rustc_lint_defs;
extern crate rustc_middle;
extern crate rustc_session;
extern crate rustc_span;
mod almost_standard_lint_formulation;
mod collapsible_calls;
mod interning_defined_symbol;
mod invalid_paths;
mod lint_without_lint_pass;
mod msrv_attr_impl;
mod outer_expn_data_pass;
mod produce_ice;
mod slow_symbol_comparisons;
mod unnecessary_def_path;
mod unsorted_clippy_utils_paths;
use rustc_lint::{Lint, LintStore};
static LINTS: &[&Lint] = &[
almost_standard_lint_formulation::ALMOST_STANDARD_LINT_FORMULATION,
collapsible_calls::COLLAPSIBLE_SPAN_LINT_CALLS,
interning_defined_symbol::INTERNING_DEFINED_SYMBOL,
interning_defined_symbol::UNNECESSARY_SYMBOL_STR,
invalid_paths::INVALID_PATHS,
lint_without_lint_pass::DEFAULT_LINT,
lint_without_lint_pass::INVALID_CLIPPY_VERSION_ATTRIBUTE,
lint_without_lint_pass::LINT_WITHOUT_LINT_PASS,
lint_without_lint_pass::MISSING_CLIPPY_VERSION_ATTRIBUTE,
msrv_attr_impl::MISSING_MSRV_ATTR_IMPL,
outer_expn_data_pass::OUTER_EXPN_EXPN_DATA,
produce_ice::PRODUCE_ICE,
slow_symbol_comparisons::SLOW_SYMBOL_COMPARISONS,
unnecessary_def_path::UNNECESSARY_DEF_PATH,
unsorted_clippy_utils_paths::UNSORTED_CLIPPY_UTILS_PATHS,
];
pub fn register_lints(store: &mut LintStore) {
store.register_lints(LINTS);
store.register_early_pass(|| Box::new(unsorted_clippy_utils_paths::UnsortedClippyUtilsPaths));
store.register_early_pass(|| Box::new(produce_ice::ProduceIce));
store.register_late_pass(|_| Box::new(collapsible_calls::CollapsibleCalls));
store.register_late_pass(|_| Box::new(invalid_paths::InvalidPaths));
store.register_late_pass(|_| Box::<interning_defined_symbol::InterningDefinedSymbol>::default());
store.register_late_pass(|_| Box::<lint_without_lint_pass::LintWithoutLintPass>::default());
store.register_late_pass(|_| Box::<unnecessary_def_path::UnnecessaryDefPath>::default());
store.register_late_pass(|_| Box::new(outer_expn_data_pass::OuterExpnDataPass));
store.register_late_pass(|_| Box::new(msrv_attr_impl::MsrvAttrImpl));
store.register_late_pass(|_| Box::new(almost_standard_lint_formulation::AlmostStandardFormulation::new()));
store.register_late_pass(|_| Box::new(slow_symbol_comparisons::SlowSymbolComparisons));
}

View file

@ -9,13 +9,14 @@ use rustc_hir::hir_id::CRATE_HIR_ID;
use rustc_hir::intravisit::Visitor;
use rustc_hir::{ExprKind, HirId, Item, MutTy, Mutability, Path, TyKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_lint_defs::declare_tool_lint;
use rustc_middle::hir::nested_filter;
use rustc_session::impl_lint_pass;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Symbol;
use rustc_span::{Span, sym};
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Ensures every lint is associated to a `LintPass`.
///
@ -37,12 +38,14 @@ declare_clippy_lint! {
/// declare_lint_pass!(Pass => [LINT_1, LINT_2]);
/// // missing FORGOTTEN_LINT
/// ```
pub LINT_WITHOUT_LINT_PASS,
internal,
"declaring a lint without associating it in a LintPass"
pub clippy::LINT_WITHOUT_LINT_PASS,
Warn,
"declaring a lint without associating it in a LintPass",
report_in_external_macro: true
}
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Checks for cases of an auto-generated lint without an updated description,
/// i.e. `default lint description`.
@ -59,30 +62,32 @@ declare_clippy_lint! {
/// ```rust,ignore
/// declare_lint! { pub COOL_LINT, nursery, "a great new lint" }
/// ```
pub DEFAULT_LINT,
internal,
"found 'default lint description' in a lint declaration"
pub clippy::DEFAULT_LINT,
Warn,
"found 'default lint description' in a lint declaration",
report_in_external_macro: true
}
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Checks for invalid `clippy::version` attributes.
///
/// Valid values are:
/// * "pre 1.29.0"
/// * any valid semantic version
pub INVALID_CLIPPY_VERSION_ATTRIBUTE,
internal,
"found an invalid `clippy::version` attribute"
pub clippy::INVALID_CLIPPY_VERSION_ATTRIBUTE,
Warn,
"found an invalid `clippy::version` attribute",
report_in_external_macro: true
}
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Checks for declared clippy lints without the `clippy::version` attribute.
///
pub MISSING_CLIPPY_VERSION_ATTRIBUTE,
internal,
"found clippy lint without `clippy::version` attribute"
pub clippy::MISSING_CLIPPY_VERSION_ATTRIBUTE,
Warn,
"found clippy lint without `clippy::version` attribute",
report_in_external_macro: true
}
#[derive(Clone, Debug, Default)]
@ -100,10 +105,6 @@ impl_lint_pass!(LintWithoutLintPass => [
impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass {
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
if is_lint_allowed(cx, DEFAULT_LINT, item.hir_id()) {
return;
}
if let hir::ItemKind::Static(ident, ty, Mutability::Not, body_id) = item.kind {
if is_lint_ref_type(cx, ty) {
check_invalid_clippy_version_attribute(cx, item);

View file

@ -5,16 +5,17 @@ use clippy_utils::{match_def_path, paths};
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_lint_defs::declare_tool_lint;
use rustc_middle::ty::{self, EarlyBinder, GenericArgKind};
use rustc_session::declare_lint_pass;
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Check that the `extract_msrv_attr!` macro is used, when a lint has a MSRV.
///
pub MISSING_MSRV_ATTR_IMPL,
internal,
"checking if all necessary steps were taken when adding a MSRV to a lint"
pub clippy::MISSING_MSRV_ATTR_IMPL,
Warn,
"checking if all necessary steps were taken when adding a MSRV to a lint",
report_in_external_macro: true
}
declare_lint_pass!(MsrvAttrImpl => [MISSING_MSRV_ATTR_IMPL]);

View file

@ -4,10 +4,11 @@ use clippy_utils::{is_lint_allowed, method_calls, paths};
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_lint::{LateContext, LateLintPass};
use rustc_lint_defs::declare_tool_lint;
use rustc_session::declare_lint_pass;
use rustc_span::symbol::Symbol;
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Checks for calls to `cx.outer().expn_data()` and suggests to use
/// the `cx.outer_expn_data()`
@ -24,9 +25,10 @@ declare_clippy_lint! {
/// ```rust,ignore
/// expr.span.ctxt().outer_expn_data()
/// ```
pub OUTER_EXPN_EXPN_DATA,
internal,
"using `cx.outer_expn().expn_data()` instead of `cx.outer_expn_data()`"
pub clippy::OUTER_EXPN_EXPN_DATA,
Warn,
"using `cx.outer_expn().expn_data()` instead of `cx.outer_expn_data()`",
report_in_external_macro: true
}
declare_lint_pass!(OuterExpnDataPass => [OUTER_EXPN_EXPN_DATA]);

View file

@ -1,10 +1,11 @@
use rustc_ast::ast::NodeId;
use rustc_ast::visit::FnKind;
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_lint_defs::declare_tool_lint;
use rustc_session::declare_lint_pass;
use rustc_span::Span;
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Not an actual lint. This lint is only meant for testing our customized internal compiler
/// error message by calling `panic`.
@ -16,9 +17,10 @@ declare_clippy_lint! {
/// ```rust,ignore
/// 🍦🍦🍦🍦🍦
/// ```
pub PRODUCE_ICE,
internal,
"this message should not appear anywhere as we ICE before and don't emit the lint"
pub clippy::PRODUCE_ICE,
Warn,
"this message should not appear anywhere as we ICE before and don't emit the lint",
report_in_external_macro: true
}
declare_lint_pass!(ProduceIce => [PRODUCE_ICE]);

View file

@ -6,10 +6,11 @@ use clippy_utils::ty::match_type;
use rustc_errors::Applicability;
use rustc_hir::{BinOpKind, Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_lint_defs::declare_tool_lint;
use rustc_session::declare_lint_pass;
use rustc_span::{Span, sym};
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
///
/// Detects symbol comparison using `Symbol::intern`.
@ -21,9 +22,10 @@ declare_clippy_lint! {
/// ### Example
///
/// None, see suggestion.
pub SLOW_SYMBOL_COMPARISONS,
internal,
"detects slow comparisons of symbol"
pub clippy::SLOW_SYMBOL_COMPARISONS,
Warn,
"detects slow comparisons of symbol",
report_in_external_macro: true
}
declare_lint_pass!(SlowSymbolComparisons => [SLOW_SYMBOL_COMPARISONS]);

View file

@ -8,6 +8,7 @@ use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::{Expr, ExprKind, LetStmt, Mutability, Node};
use rustc_lint::{LateContext, LateLintPass};
use rustc_lint_defs::declare_tool_lint;
use rustc_middle::mir::ConstValue;
use rustc_middle::mir::interpret::{Allocation, GlobalAlloc};
use rustc_middle::ty::{self, Ty};
@ -17,7 +18,7 @@ use rustc_span::symbol::Symbol;
use std::str;
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Checks for usage of def paths when a diagnostic item or a `LangItem` could be used.
///
@ -34,9 +35,10 @@ declare_clippy_lint! {
/// ```rust,ignore
/// utils::is_type_diagnostic_item(cx, ty, sym::Vec)
/// ```
pub UNNECESSARY_DEF_PATH,
internal,
"using a def path when a diagnostic item or a `LangItem` is available"
pub clippy::UNNECESSARY_DEF_PATH,
Warn,
"using a def path when a diagnostic item or a `LangItem` is available",
report_in_external_macro: true
}
impl_lint_pass!(UnnecessaryDefPath => [UNNECESSARY_DEF_PATH]);

View file

@ -1,9 +1,10 @@
use clippy_utils::diagnostics::span_lint;
use rustc_ast::ast::{Crate, ItemKind, ModKind};
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_lint_defs::declare_tool_lint;
use rustc_session::declare_lint_pass;
declare_clippy_lint! {
declare_tool_lint! {
/// ### What it does
/// Checks that [`clippy_utils::paths`] is sorted lexically
///
@ -12,9 +13,10 @@ declare_clippy_lint! {
///
/// ### Example
/// Wrong ordering of the util::paths constants.
pub UNSORTED_CLIPPY_UTILS_PATHS,
internal,
"various things that will negatively affect your clippy experience"
pub clippy::UNSORTED_CLIPPY_UTILS_PATHS,
Warn,
"various things that will negatively affect your clippy experience",
report_in_external_macro: true
}
declare_lint_pass!(UnsortedClippyUtilsPaths => [UNSORTED_CLIPPY_UTILS_PATHS]);

View file

@ -158,7 +158,8 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
let conf = clippy_config::Conf::read(sess, &conf_path);
clippy_lints::register_lints(lint_store, conf);
clippy_lints::register_pre_expansion_lints(lint_store, conf);
#[cfg(feature = "internal")]
clippy_lints_internal::register_lints(lint_store);
}));
config.extra_symbols = clippy_utils::sym::EXTRA_SYMBOLS.into();

View file

@ -36,6 +36,7 @@ fn dogfood() {
for package in [
"./",
"clippy_dev",
"clippy_lints_internal",
"clippy_lints",
"clippy_utils",
"clippy_config",
@ -82,10 +83,7 @@ fn run_clippy_for_package(project: &str, args: &[&str]) -> bool {
command.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
command.args(["-D", "clippy::dbg_macro"]);
if cfg!(feature = "internal") {
// internal lints only exist if we build with the internal feature
command.args(["-D", "clippy::internal"]);
} else {
if !cfg!(feature = "internal") {
// running a clippy built without internal lints on the clippy source
// that contains e.g. `allow(clippy::invalid_paths)`
command.args(["-A", "unknown_lints"]);

View file

@ -1,2 +1,4 @@
#![allow(clippy::unnecessary_def_path)]
pub static OPTION: [&str; 3] = ["core", "option", "Option"];
pub const RESULT: &[&str] = &["core", "result", "Result"];

View file

@ -1,5 +1,5 @@
#![deny(clippy::internal)]
#![feature(rustc_private)]
#![deny(clippy::invalid_clippy_version_attribute, clippy::missing_clippy_version_attribute)]
#[macro_use]
extern crate rustc_middle;
@ -86,6 +86,15 @@ mod internal_clippy_lints {
}
use crate::internal_clippy_lints::ALLOW_MISSING_ATTRIBUTE_ONE;
declare_lint_pass!(Pass2 => [VALID_ONE, VALID_TWO, VALID_THREE, INVALID_ONE, INVALID_TWO, MISSING_ATTRIBUTE_ONE, MISSING_ATTRIBUTE_TWO, ALLOW_MISSING_ATTRIBUTE_ONE]);
declare_lint_pass!(Pass2 => [
VALID_ONE,
VALID_TWO,
VALID_THREE,
INVALID_ONE,
INVALID_TWO,
MISSING_ATTRIBUTE_ONE,
MISSING_ATTRIBUTE_TWO,
ALLOW_MISSING_ATTRIBUTE_ONE,
]);
fn main() {}

View file

@ -12,11 +12,10 @@ LL | | }
|
= help: please use a valid semantic version, see `doc/adding_lints.md`
note: the lint level is defined here
--> tests/ui-internal/check_clippy_version_attribute.rs:1:9
--> tests/ui-internal/check_clippy_version_attribute.rs:2:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::invalid_clippy_version_attribute)]` implied by `#[deny(clippy::internal)]`
LL | #![deny(clippy::invalid_clippy_version_attribute, clippy::missing_clippy_version_attribute)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
error: this item has an invalid `clippy::version` attribute
@ -47,7 +46,11 @@ LL | | }
| |_^
|
= help: please use a `clippy::version` attribute, see `doc/adding_lints.md`
= note: `#[deny(clippy::missing_clippy_version_attribute)]` implied by `#[deny(clippy::internal)]`
note: the lint level is defined here
--> tests/ui-internal/check_clippy_version_attribute.rs:2:51
|
LL | #![deny(clippy::invalid_clippy_version_attribute, clippy::missing_clippy_version_attribute)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
error: this lint is missing the `clippy::version` attribute or version value

View file

@ -1,4 +1,5 @@
#![warn(clippy::almost_standard_lint_formulation)]
#![deny(clippy::almost_standard_lint_formulation)]
#![allow(clippy::lint_without_lint_pass)]
#![feature(rustc_private)]
#[macro_use]

View file

@ -1,15 +1,18 @@
error: non-standard lint formulation
--> tests/ui-internal/check_formulation.rs:23:5
--> tests/ui-internal/check_formulation.rs:24:5
|
LL | /// Check for lint formulations that are correct
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider using `Checks for`
= note: `-D clippy::almost-standard-lint-formulation` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::almost_standard_lint_formulation)]`
note: the lint level is defined here
--> tests/ui-internal/check_formulation.rs:1:9
|
LL | #![deny(clippy::almost_standard_lint_formulation)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: non-standard lint formulation
--> tests/ui-internal/check_formulation.rs:34:5
--> tests/ui-internal/check_formulation.rs:35:5
|
LL | /// Detects uses of incorrect formulations
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,4 @@
#![deny(clippy::internal)]
#![deny(clippy::collapsible_span_lint_calls)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -1,4 +1,4 @@
#![deny(clippy::internal)]
#![deny(clippy::collapsible_span_lint_calls)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -10,9 +10,8 @@ LL | | });
note: the lint level is defined here
--> tests/ui-internal/collapsible_span_lint_calls.rs:1:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::collapsible_span_lint_calls)]` implied by `#[deny(clippy::internal)]`
LL | #![deny(clippy::collapsible_span_lint_calls)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this call is collapsible
--> tests/ui-internal/collapsible_span_lint_calls.rs:39:9

View file

@ -6,7 +6,7 @@
//@normalize-stderr-test: "rustc 1\.\d+.* running on .*" -> "rustc <version> running on <target>"
//@normalize-stderr-test: "(?ms)query stack during panic:\n.*end of query stack\n" -> ""
#![deny(clippy::internal)]
#![deny(clippy::produce_ice)]
#![allow(clippy::missing_clippy_version_attribute)]
fn it_looks_like_you_are_trying_to_kill_clippy() {}

View file

@ -8,7 +8,7 @@ error: internal compiler error: Would you like some help with that?
LL | fn it_looks_like_you_are_trying_to_kill_clippy() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: delayed at clippy_lints/src/utils/internal_lints/produce_ice.rs - disabled backtrace
note: delayed at clippy_lints_internal/src/produce_ice.rs - disabled backtrace
--> tests/ui-internal/custom_ice_message.rs:12:1
|
LL | fn it_looks_like_you_are_trying_to_kill_clippy() {}

View file

@ -1,4 +1,4 @@
#![deny(clippy::internal)]
#![deny(clippy::default_lint)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -13,9 +13,8 @@ LL | | }
note: the lint level is defined here
--> tests/ui-internal/default_lint.rs:1:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::default_lint)]` implied by `#[deny(clippy::internal)]`
LL | #![deny(clippy::default_lint)]
| ^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `$crate::declare_tool_lint` which comes from the expansion of the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error

View file

@ -1,4 +1,5 @@
#![feature(rustc_private)]
#![deny(clippy::disallowed_methods)]
extern crate rustc_errors;
extern crate rustc_hir;

View file

@ -1,15 +1,18 @@
error: use of a disallowed method `rustc_lint::context::LintContext::span_lint`
--> tests/ui-internal/disallow_span_lint.rs:14:8
--> tests/ui-internal/disallow_span_lint.rs:15:8
|
LL | cx.span_lint(lint, span, |lint| {
| ^^^^^^^^^
|
= note: this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead
= note: `-D clippy::disallowed-methods` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::disallowed_methods)]`
note: the lint level is defined here
--> tests/ui-internal/disallow_span_lint.rs:2:9
|
LL | #![deny(clippy::disallowed_methods)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::node_span_lint`
--> tests/ui-internal/disallow_span_lint.rs:21:9
--> tests/ui-internal/disallow_span_lint.rs:22:9
|
LL | tcx.node_span_lint(lint, hir_id, span, |lint| {
| ^^^^^^^^^^^^^^

View file

@ -1,4 +1,4 @@
#![deny(clippy::internal)]
#![deny(clippy::interning_defined_symbol)]
#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)]
#![feature(rustc_private)]

View file

@ -1,4 +1,4 @@
#![deny(clippy::internal)]
#![deny(clippy::interning_defined_symbol)]
#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)]
#![feature(rustc_private)]

View file

@ -7,9 +7,8 @@ LL | let _ = Symbol::intern("f32");
note: the lint level is defined here
--> tests/ui-internal/interning_defined_symbol.rs:1:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::interning_defined_symbol)]` implied by `#[deny(clippy::internal)]`
LL | #![deny(clippy::interning_defined_symbol)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: interning a defined symbol
--> tests/ui-internal/interning_defined_symbol.rs:21:13

View file

@ -1,4 +1,4 @@
#![deny(clippy::internal)]
#![deny(clippy::missing_msrv_attr_impl)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -1,4 +1,4 @@
#![deny(clippy::internal)]
#![deny(clippy::missing_msrv_attr_impl)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -7,9 +7,8 @@ LL | impl EarlyLintPass for Pass {
note: the lint level is defined here
--> tests/ui-internal/invalid_msrv_attr_impl.rs:1:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::missing_msrv_attr_impl)]` implied by `#[deny(clippy::internal)]`
LL | #![deny(clippy::missing_msrv_attr_impl)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: add `extract_msrv_attr!()` to the `EarlyLintPass` implementation
|
LL ~ impl EarlyLintPass for Pass {

View file

@ -1,4 +1,4 @@
#![warn(clippy::internal)]
#![deny(clippy::invalid_paths)]
#![allow(clippy::missing_clippy_version_attribute, clippy::unnecessary_def_path)]
mod paths {

View file

@ -4,8 +4,11 @@ error: invalid path
LL | pub const TRANSMUTE: [&str; 4] = ["core", "intrinsics", "", "transmute"];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::invalid-paths` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::invalid_paths)]`
note: the lint level is defined here
--> tests/ui-internal/invalid_paths.rs:1:9
|
LL | #![deny(clippy::invalid_paths)]
| ^^^^^^^^^^^^^^^^^^^^^
error: invalid path
--> tests/ui-internal/invalid_paths.rs:19:5

View file

@ -1,4 +1,4 @@
#![deny(clippy::internal)]
#![deny(clippy::lint_without_lint_pass)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -13,9 +13,8 @@ LL | | }
note: the lint level is defined here
--> tests/ui-internal/lint_without_lint_pass.rs:1:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::lint_without_lint_pass)]` implied by `#[deny(clippy::internal)]`
LL | #![deny(clippy::lint_without_lint_pass)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error

View file

@ -1,4 +1,4 @@
#![deny(clippy::internal)]
#![deny(clippy::outer_expn_expn_data)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -1,4 +1,4 @@
#![deny(clippy::internal)]
#![deny(clippy::outer_expn_expn_data)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -7,9 +7,8 @@ LL | let _ = expr.span.ctxt().outer_expn().expn_data();
note: the lint level is defined here
--> tests/ui-internal/outer_expn_data.rs:1:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::outer_expn_expn_data)]` implied by `#[deny(clippy::internal)]`
LL | #![deny(clippy::outer_expn_expn_data)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error

View file

@ -1,5 +1,5 @@
//@aux-build:paths.rs
#![deny(clippy::internal)]
#![deny(clippy::unnecessary_def_path)]
#![feature(rustc_private)]
#![allow(clippy::unnecessary_map_or)]

View file

@ -1,5 +1,5 @@
//@aux-build:paths.rs
#![deny(clippy::internal)]
#![deny(clippy::unnecessary_def_path)]
#![feature(rustc_private)]
#![allow(clippy::unnecessary_map_or)]

View file

@ -7,9 +7,8 @@ LL | let _ = match_type(cx, ty, &OPTION);
note: the lint level is defined here
--> tests/ui-internal/unnecessary_def_path.rs:2:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::unnecessary_def_path)]` implied by `#[deny(clippy::internal)]`
LL | #![deny(clippy::unnecessary_def_path)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: use of a def path to a diagnostic item
--> tests/ui-internal/unnecessary_def_path.rs:39:13

View file

@ -1,6 +1,6 @@
#![feature(rustc_private)]
#![allow(unused)]
#![warn(clippy::unnecessary_def_path)]
#![deny(clippy::unnecessary_def_path)]
extern crate rustc_hir;

View file

@ -5,8 +5,11 @@ LL | const DEREF_TRAIT: [&str; 4] = ["core", "ops", "deref", "Deref"];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: convert all references to use `sym::Deref`
= note: `-D clippy::unnecessary-def-path` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_def_path)]`
note: the lint level is defined here
--> tests/ui-internal/unnecessary_def_path_hardcoded_path.rs:3:9
|
LL | #![deny(clippy::unnecessary_def_path)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: hardcoded path to a language item
--> tests/ui-internal/unnecessary_def_path_hardcoded_path.rs:12:40

View file

@ -1,5 +1,5 @@
#![feature(rustc_private)]
#![deny(clippy::internal)]
#![deny(clippy::unnecessary_symbol_str)]
#![allow(
clippy::slow_symbol_comparisons,
clippy::borrow_deref_ref,

View file

@ -1,5 +1,5 @@
#![feature(rustc_private)]
#![deny(clippy::internal)]
#![deny(clippy::unnecessary_symbol_str)]
#![allow(
clippy::slow_symbol_comparisons,
clippy::borrow_deref_ref,

View file

@ -7,9 +7,8 @@ LL | Symbol::intern("foo").as_str() == "clippy";
note: the lint level is defined here
--> tests/ui-internal/unnecessary_symbol_str.rs:2:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::unnecessary_symbol_str)]` implied by `#[deny(clippy::internal)]`
LL | #![deny(clippy::unnecessary_symbol_str)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: unnecessary `Symbol` to string conversion
--> tests/ui-internal/unnecessary_symbol_str.rs:18:5