From f095f802dcd0f5ead14539c3f11985b4a3562912 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 16 Jun 2022 19:39:39 +0400 Subject: Move/rename `lazy::Sync{OnceCell,Lazy}` to `sync::{Once,Lazy}Lock` --- src/driver.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/driver.rs b/src/driver.rs index 7de40fe63ac..67467f89b47 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -21,11 +21,11 @@ use rustc_tools_util::VersionInfo; use std::borrow::Cow; use std::env; -use std::lazy::SyncLazy; use std::ops::Deref; use std::panic; use std::path::{Path, PathBuf}; use std::process::{exit, Command}; +use std::sync::LazyLock; /// If a command-line option matches `find_arg`, then apply the predicate `pred` on its value. If /// true, then return it. The parameter is assumed to be either `--arg=value` or `--arg value`. @@ -152,7 +152,7 @@ You can use tool lints to allow or deny lints from your code, eg.: const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/new"; -static ICE_HOOK: SyncLazy) + Sync + Send + 'static>> = SyncLazy::new(|| { +static ICE_HOOK: LazyLock) + Sync + Send + 'static>> = LazyLock::new(|| { let hook = panic::take_hook(); panic::set_hook(Box::new(|info| report_clippy_ice(info, BUG_REPORT_URL))); hook @@ -219,7 +219,7 @@ fn toolchain_path(home: Option, toolchain: Option) -> Option = env::args().collect(); -- cgit 1.4.1-3-g733a5 From 4182803b8635a55d1a9c3de1f2fb9e72af4a6973 Mon Sep 17 00:00:00 2001 From: xFrednet Date: Thu, 23 Jun 2022 09:44:53 +0200 Subject: Check for `--force-warn` in Clippy's driver run condition --- src/driver.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/driver.rs b/src/driver.rs index 7de40fe63ac..88991b340b1 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -60,6 +60,7 @@ fn test_arg_value() { assert_eq!(arg_value(args, "--bar", |p| p == "foo"), None); assert_eq!(arg_value(args, "--foobar", |p| p == "foo"), None); assert_eq!(arg_value(args, "--foobar", |p| p == "123"), Some("123")); + assert_eq!(arg_value(args, "--foobar", |p| p.contains("12")), Some("123")); assert_eq!(arg_value(args, "--foo", |_| true), None); } @@ -334,15 +335,13 @@ pub fn main() { // - IF Clippy is run on the main crate, not on deps (`!cap_lints_allow`) THEN // - IF `--no-deps` is not set (`!no_deps`) OR // - IF `--no-deps` is set and Clippy is run on the specified primary package - let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some(); + let cap_lints_allow = arg_value(&orig_args, "--cap-lints", |val| val == "allow").is_some() + && arg_value(&orig_args, "--force-warn", |val| val.contains("clippy::")).is_none(); let in_primary_package = env::var("CARGO_PRIMARY_PACKAGE").is_ok(); let clippy_enabled = !cap_lints_allow && (!no_deps || in_primary_package); if clippy_enabled { args.extend(clippy_args); - } - - if clippy_enabled { rustc_driver::RunCompiler::new(&args, &mut ClippyCallbacks { clippy_args_var }).run() } else { rustc_driver::RunCompiler::new(&args, &mut RustcCallbacks { clippy_args_var }).run() -- cgit 1.4.1-3-g733a5 From bf9b39ae7df5cca418fd2afc25b30a5632b32c23 Mon Sep 17 00:00:00 2001 From: Philipp Krones Date: Thu, 30 Jun 2022 10:28:04 +0200 Subject: Fix dogfood --- clippy_utils/src/hir_utils.rs | 6 +++++- src/driver.rs | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/clippy_utils/src/hir_utils.rs b/clippy_utils/src/hir_utils.rs index 74ef2c1bebb..793e3cc58c2 100644 --- a/clippy_utils/src/hir_utils.rs +++ b/clippy_utils/src/hir_utils.rs @@ -16,6 +16,10 @@ use rustc_middle::ty::TypeckResults; use rustc_span::{sym, Symbol}; use std::hash::{Hash, Hasher}; +/// Callback that is called when two expressions are not equal in the sense of `SpanlessEq`, but +/// other conditions would make them equal. +type SpanlessEqCallback<'a> = dyn FnMut(&Expr<'_>, &Expr<'_>) -> bool + 'a; + /// Type used to check whether two ast are the same. This is different from the /// operator `==` on ast types as this operator would compare true equality with /// ID and span. @@ -26,7 +30,7 @@ pub struct SpanlessEq<'a, 'tcx> { cx: &'a LateContext<'tcx>, maybe_typeck_results: Option<(&'tcx TypeckResults<'tcx>, &'tcx TypeckResults<'tcx>)>, allow_side_effects: bool, - expr_fallback: Option, &Expr<'_>) -> bool + 'a>>, + expr_fallback: Option>>, } impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { diff --git a/src/driver.rs b/src/driver.rs index d8e0b8ef39a..96d542cfe10 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -153,7 +153,8 @@ You can use tool lints to allow or deny lints from your code, eg.: const BUG_REPORT_URL: &str = "https://github.com/rust-lang/rust-clippy/issues/new"; -static ICE_HOOK: LazyLock) + Sync + Send + 'static>> = LazyLock::new(|| { +type PanicCallback = dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static; +static ICE_HOOK: LazyLock> = LazyLock::new(|| { let hook = panic::take_hook(); panic::set_hook(Box::new(|info| report_clippy_ice(info, BUG_REPORT_URL))); hook -- cgit 1.4.1-3-g733a5