Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ out
*Cargo.lock
!/clippy_test_deps/Cargo.lock
/target
/clippy_dummy/target
/clippy_lints/target
/clippy_lints_internal/target
/clippy_test_deps/target
/clippy_utils/target
/clippy_dev/target
/lintcheck/target
Expand Down
5 changes: 3 additions & 2 deletions clippy_dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
)]
#![expect(clippy::missing_panics_doc)]

extern crate rustc_arena;
extern crate rustc_data_structures;
#[expect(unused_extern_crates, reason = "required to link to rustc crates")]
extern crate rustc_driver;

extern crate rustc_arena;
extern crate rustc_data_structures;
extern crate rustc_lexer;

pub mod dogfood;
Expand Down
2 changes: 2 additions & 0 deletions clippy_dummy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ categories = ["development-tools", "development-tools::cargo-plugins"]

[build-dependencies]
term = "1"

[workspace]
4 changes: 2 additions & 2 deletions clippy_lints/src/option_env_unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ declare_clippy_lint! {
///
/// ### Example
/// ```rust,no_run
/// let _ = option_env!("HOME").unwrap();
/// let _ = option_env!("CARGO").unwrap();
/// ```
///
/// Is better expressed as:
///
/// ```rust,no_run
/// let _ = env!("HOME");
/// let _ = env!("CARGO");
/// ```
#[clippy::version = "1.43.0"]
pub OPTION_ENV_UNWRAP,
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/zombie_processes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ declare_clippy_lint! {
/// In other words, the `wait()` call must be unconditionally reachable after the spawn expression.
///
/// ### Example
/// ```rust
/// ```rust,no_run
/// use std::process::Command;
///
/// let _child = Command::new("ls").spawn().expect("failed to execute child");
/// ```
/// Use instead:
/// ```rust
/// ```rust,no_run
/// use std::process::Command;
///
/// let mut child = Command::new("ls").spawn().expect("failed to execute child");
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints_internal/src/repeated_is_diagnostic_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ declare_tool_lint! {
/// While the query is cached, it's still better to avoid calling it multiple times if possible.
///
/// ### Example
/// ```no_run
/// ```ignore
/// ty.is_diag_item(cx, sym::Option) || ty.is_diag_item(cx, sym::Result)
/// cx.tcx.is_diagnostic_item(sym::Option, did) || cx.tcx.is_diagnostic_item(sym::Result, did)
///
Expand Down Expand Up @@ -64,7 +64,7 @@ declare_tool_lint! {
/// }
/// ```
/// Use instead:
/// ```no_run
/// ```ignore
/// matches!(ty.opt_diag_name(cx), Some(sym::Option | sym::Result))
/// matches!(cx.tcx.get_diagnostic_name(did), Some(sym::Option | sym::Result))
///
Expand Down
10 changes: 3 additions & 7 deletions clippy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
rustc::internal
)]

// FIXME: switch to something more ergonomic here, once available.
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
#[expect(unused_extern_crates, reason = "required to link to rustc crates")]
extern crate rustc_driver;

extern crate rustc_abi;
extern crate rustc_ast;
extern crate rustc_attr_parsing;
extern crate rustc_const_eval;
extern crate rustc_data_structures;
#[expect(
unused_extern_crates,
reason = "The `rustc_driver` crate seems to be required in order to use the `rust_ast` crate."
)]
extern crate rustc_driver;
extern crate rustc_errors;
extern crate rustc_hir;
extern crate rustc_hir_analysis;
Expand Down
3 changes: 3 additions & 0 deletions declare_clippy_lint/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![feature(macro_metavar_expr_concat, rustc_private)]

#[expect(unused_extern_crates, reason = "required to link to rustc crates")]
extern crate rustc_driver;

extern crate rustc_lint;

use rustc_lint::{Lint, LintId, LintStore};
Expand Down
2 changes: 0 additions & 2 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// and on rustc internal lints
rustc::internal)]

// FIXME: switch to something more ergonomic here, once available.
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
extern crate rustc_driver;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u sure?

@Jarcho Jarcho Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a thing that will never be fixed, so it's not very helpful to have a note for it.

extern crate rustc_interface;
extern crate rustc_session;
Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// We need this feature as it changes `dylib` linking behavior and allows us to link to
// `rustc_driver`.
#![feature(rustc_private)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would find the dylib not very obvious.. you sure?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feature doesn't change linking behaviour. Importing rustc_driver is what links to the dylib.

// warn on lints, that are included in `rust-lang/rust`s bootstrap
#![warn(rust_2018_idioms, unused_lifetimes)]
Expand Down
3 changes: 1 addition & 2 deletions tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ impl TestContext {
}

fn base_config(&self, test_dir: &str, mandatory_annotations: bool) -> Config {
let target_dir = PathBuf::from(var_os("CARGO_TARGET_DIR").unwrap_or_else(|| "target".into()));
let mut config = Config {
output_conflict_handling: error_on_output_conflict,
// Pre-fill filters with TESTNAME; will be later extended with `self.args`.
Expand All @@ -165,7 +164,7 @@ impl TestContext {
} else {
"cargo uibless".into()
}),
out_dir: target_dir.join("ui_test"),
out_dir: Path::new(env!("CARGO_TARGET_TMPDIR")).join("clippy_ui_test"),
..Config::rustc(Path::new("tests").join(test_dir))
};
let defaults = config.comment_defaults.base();
Expand Down
2 changes: 0 additions & 2 deletions tests/config-metadata.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#![feature(rustc_private)]

extern crate rustc_driver;

use clippy_config::{Conf, ConfMetadata};
use itertools::Itertools as _;
use regex::Regex;
Expand Down
2 changes: 2 additions & 0 deletions tests/ui-cargo/cargo_rust_version/fail_both_diff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/cargo_rust_version/fail_both_same/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/cargo_rust_version/fail_cargo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/cargo_rust_version/fail_clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/cargo_rust_version/fail_file_attr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/cargo_rust_version/pass_both_same/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/cargo_rust_version/pass_cargo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/cargo_rust_version/pass_clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/cargo_rust_version/pass_file_attr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/cargo_rust_version/warn_both_diff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ name = "fail-edge-cases"
version = "0.1.0"
edition = "2021"
publish = false

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/definition_in_module_root/fail_mod/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ name = "fail-mod"
version = "0.1.0"
edition = "2021"
publish = false

[workspace]
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ name = "fail-path-attr"
version = "0.1.0"
edition = "2021"
publish = false

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/definition_in_module_root/pass_bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ name = "pass-bin"
version = "0.1.0"
edition = "2021"
publish = false

[workspace]
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ name = "pass-lib-with-definitions"
version = "0.1.0"
edition = "2021"
publish = false

[workspace]
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ name = "pass-path-attr"
version = "0.1.0"
edition = "2021"
publish = false

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/duplicate_mod/fail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ name = "duplicate_mod"
edition = "2021"
publish = false
version = "0.1.0"

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/lint_groups_priority/pass/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ pedantic = { level = "warn", priority = -1 }
style = { level = "warn", priority = 1 }
similar_names = "allow"
dbg_macro = { level = "warn", priority = 2 }

[workspace]
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/module_style/fail_mod/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/module_style/fail_mod_remap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/module_style/fail_no_mod/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/module_style/inline_mod/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/module_style/pass_mod/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/module_style/pass_no_mod/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2024"
publish = false

[workspace]
members = ["foo/bar"]
members = ["foo/bar"]
4 changes: 3 additions & 1 deletion tests/ui-cargo/module_style/with_path_attr_mod/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Should not lint mod tagged with `#[path = ...]`
# Should not lint mod tagged with `#[path = ...]`
[package]
name = "with-path-attr-mod"
version = "0.1.0"
Expand All @@ -8,3 +8,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
4 changes: 3 additions & 1 deletion tests/ui-cargo/module_style/with_path_attr_no_mod/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Should not lint mod tagged with `#[path = ...]`
# Should not lint mod tagged with `#[path = ...]`
[package]
name = "with-path-attr-no-mod"
version = "0.1.0"
Expand All @@ -8,3 +8,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/multiple_config_files/no_warn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/multiple_config_files/warn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/multiple_inherent_impl/config_fail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ edition = "2024"
publish = false

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/multiple_inherent_impl/crate_fail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ edition = "2024"
publish = false

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/multiple_inherent_impl/file_fail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ edition = "2024"
publish = false

[dependencies]

[workspace]
2 changes: 2 additions & 0 deletions tests/ui-cargo/multiple_inherent_impl/module_fail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ edition = "2024"
publish = false

[dependencies]

[workspace]
4 changes: 3 additions & 1 deletion tests/ui-cargo/undocumented_unsafe_blocks/fail/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Reproducing #14553 requires the `# Safety` comment to be in the first line of
# Reproducing #14553 requires the `# Safety` comment to be in the first line of
# the file. Since `unnecessary_safety_comment` is not enabled by default, we
# will set it up here.

Expand All @@ -10,3 +10,5 @@ version = "0.1.0"

[lints.clippy]
unnecessary_safety_comment = "deny"

[workspace]