Skip to content

Commit 98cddc5

Browse files
committed
Auto merge of #7241 - flip1995:warn-deny-warnings, r=camsteffen
Deny warnings in every main sub-crate Pointed out by `@xFrednet` in #7229 (comment) This enables the same (rustc) lints in every main sub-crate: - `clippy` - `clippy_lints` - `clippy_utils` - `clippy_dev` In addition it forwards the `deny-warnings` feature to those sub-crates, so we don't miss warnings that then become a problem during sync. (I wanted to fix that before, but forgot about it, so thanks for pointing it out `@xFrednet!)` changelog: none
2 parents 213b8d9 + 9586ddb commit 98cddc5

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ rustc-workspace-hack = "1.0.0"
4949
rustc_tools_util = { version = "0.2.0", path = "rustc_tools_util" }
5050

5151
[features]
52-
deny-warnings = []
52+
deny-warnings = ["clippy_lints/deny-warnings"]
5353
integration = ["tempfile"]
5454
internal-lints = ["clippy_lints/internal-lints"]
5555
metadata-collector-lint = ["internal-lints", "clippy_lints/metadata-collector-lint"]

clippy_dev/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
21
#![feature(once_cell)]
2+
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
3+
// warn on lints, that are included in `rust-lang/rust`s bootstrap
4+
#![warn(rust_2018_idioms, unused_lifetimes)]
35

46
use itertools::Itertools;
57
use regex::Regex;

clippy_dev/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
2+
// warn on lints, that are included in `rust-lang/rust`s bootstrap
3+
#![warn(rust_2018_idioms, unused_lifetimes)]
24

35
use clap::{App, Arg, ArgMatches, SubCommand};
46
use clippy_dev::{bless, fmt, ide_setup, new_lint, serve, stderr_length_check, update_lints};

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ rustc-semver = "1.1.0"
3030
url = { version = "2.1.0", features = ["serde"] }
3131

3232
[features]
33-
deny-warnings = []
33+
deny-warnings = ["clippy_utils/deny-warnings"]
3434
# build clippy with internal lints enabled, off by default
3535
internal-lints = ["clippy_utils/internal-lints"]
3636
metadata-collector-lint = ["serde_json", "clippy_utils/metadata-collector-lint"]

clippy_utils/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ unicode-normalization = "0.1"
1414
rustc-semver="1.1.0"
1515

1616
[features]
17+
deny-warnings = []
1718
internal-lints = []
1819
metadata-collector-lint = []
1920

clippy_utils/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
#![feature(iter_zip)]
44
#![feature(rustc_private)]
55
#![recursion_limit = "512"]
6+
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
67
#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc, clippy::must_use_candidate)]
8+
// warn on the same lints as `clippy_lints`
9+
#![warn(trivial_casts, trivial_numeric_casts)]
10+
// warn on lints, that are included in `rust-lang/rust`s bootstrap
11+
#![warn(rust_2018_idioms, unused_lifetimes)]
12+
// warn on rustc internal lints
13+
#![warn(rustc::internal)]
714

815
// FIXME: switch to something more ergonomic here, once available.
916
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
@@ -13,7 +20,6 @@ extern crate rustc_attr;
1320
extern crate rustc_data_structures;
1421
extern crate rustc_errors;
1522
extern crate rustc_hir;
16-
extern crate rustc_hir_pretty;
1723
extern crate rustc_infer;
1824
extern crate rustc_lexer;
1925
extern crate rustc_lint;
@@ -1326,7 +1332,7 @@ pub fn if_sequence<'tcx>(mut expr: &'tcx Expr<'tcx>) -> (Vec<&'tcx Expr<'tcx>>,
13261332
}
13271333

13281334
/// Checks if the given function kind is an async function.
1329-
pub fn is_async_fn(kind: FnKind) -> bool {
1335+
pub fn is_async_fn(kind: FnKind<'_>) -> bool {
13301336
matches!(kind, FnKind::ItemFn(_, _, header, _) if header.asyncness == IsAsync::Async)
13311337
}
13321338

clippy_utils/src/ty.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
33
#![allow(clippy::module_name_repetitions)]
44

5-
use std::collections::HashMap;
6-
75
use rustc_ast::ast::Mutability;
6+
use rustc_data_structures::fx::FxHashMap;
87
use rustc_hir as hir;
98
use rustc_hir::def_id::DefId;
109
use rustc_hir::{TyKind, Unsafety};
@@ -184,14 +183,14 @@ pub fn is_must_use_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
184183
/// Checks if `Ty` is normalizable. This function is useful
185184
/// to avoid crashes on `layout_of`.
186185
pub fn is_normalizable<'tcx>(cx: &LateContext<'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> bool {
187-
is_normalizable_helper(cx, param_env, ty, &mut HashMap::new())
186+
is_normalizable_helper(cx, param_env, ty, &mut FxHashMap::default())
188187
}
189188

190189
fn is_normalizable_helper<'tcx>(
191190
cx: &LateContext<'tcx>,
192191
param_env: ty::ParamEnv<'tcx>,
193192
ty: Ty<'tcx>,
194-
cache: &mut HashMap<Ty<'tcx>, bool>,
193+
cache: &mut FxHashMap<Ty<'tcx>, bool>,
195194
) -> bool {
196195
if let Some(&cached_result) = cache.get(ty) {
197196
return cached_result;

0 commit comments

Comments
 (0)