Skip to content

Commit 4a0c36d

Browse files
committed
Auto merge of #11790 - Alexendoo:destructure-conf, r=Manishearth
Destructure `Conf` in `register_lints` And some other miscellaneous clean-up in the area changelog: none
2 parents 9a4dd10 + f1979d4 commit 4a0c36d

File tree

12 files changed

+138
-192
lines changed

12 files changed

+138
-192
lines changed

CONTRIBUTING.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,10 @@ For example, the [`else_if_without_else`][else_if_without_else] lint is register
146146
pub mod else_if_without_else;
147147
// ...
148148

149-
pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: &Conf) {
149+
pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
150150
// ...
151151
store.register_early_pass(|| Box::new(else_if_without_else::ElseIfWithoutElse));
152152
// ...
153-
154-
store.register_group(true, "clippy::restriction", Some("clippy_restriction"), vec![
155-
// ...
156-
LintId::of(&else_if_without_else::ELSE_IF_WITHOUT_ELSE),
157-
// ...
158-
]);
159153
}
160154
```
161155

book/src/development/adding_lints.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ When using `cargo dev new_lint`, the lint is automatically registered and
270270
nothing more has to be done.
271271

272272
When declaring a new lint by hand and `cargo dev update_lints` is used, the lint
273-
pass may have to be registered manually in the `register_plugins` function in
273+
pass may have to be registered manually in the `register_lints` function in
274274
`clippy_lints/src/lib.rs`:
275275

276276
```rust,ignore

book/src/development/defining_lints.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ However, sometimes we might want to declare a new lint by hand. In this case,
186186
we'd use `cargo dev update_lints` command afterwards.
187187

188188
When a lint is manually declared, we might need to register the lint pass
189-
manually in the `register_plugins` function in `clippy_lints/src/lib.rs`:
189+
manually in the `register_lints` function in `clippy_lints/src/lib.rs`:
190190

191191
```rust
192192
store.register_late_pass(|_| Box::new(foo_functions::FooFunctions));

clippy_config/src/types.rs

+5-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use serde::de::{self, Deserializer, Visitor};
22
use serde::{ser, Deserialize, Serialize};
33
use std::fmt;
4-
use std::hash::{Hash, Hasher};
54

65
#[derive(Clone, Debug, Deserialize)]
76
pub struct Rename {
@@ -33,32 +32,19 @@ impl DisallowedPath {
3332
}
3433
}
3534

36-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Deserialize, Serialize)]
35+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)]
3736
pub enum MatchLintBehaviour {
3837
AllTypes,
3938
WellKnownTypes,
4039
Never,
4140
}
4241

43-
#[derive(Clone, Debug)]
42+
#[derive(Debug)]
4443
pub struct MacroMatcher {
4544
pub name: String,
46-
pub braces: (String, String),
45+
pub braces: (char, char),
4746
}
4847

49-
impl Hash for MacroMatcher {
50-
fn hash<H: Hasher>(&self, state: &mut H) {
51-
self.name.hash(state);
52-
}
53-
}
54-
55-
impl PartialEq for MacroMatcher {
56-
fn eq(&self, other: &Self) -> bool {
57-
self.name == other.name
58-
}
59-
}
60-
impl Eq for MacroMatcher {}
61-
6248
impl<'de> Deserialize<'de> for MacroMatcher {
6349
fn deserialize<D>(deser: D) -> Result<Self, D::Error>
6450
where
@@ -83,7 +69,7 @@ impl<'de> Deserialize<'de> for MacroMatcher {
8369
V: de::MapAccess<'de>,
8470
{
8571
let mut name = None;
86-
let mut brace: Option<String> = None;
72+
let mut brace: Option<char> = None;
8773
while let Some(key) = map.next_key()? {
8874
match key {
8975
Field::Name => {
@@ -104,7 +90,7 @@ impl<'de> Deserialize<'de> for MacroMatcher {
10490
let brace = brace.ok_or_else(|| de::Error::missing_field("brace"))?;
10591
Ok(MacroMatcher {
10692
name,
107-
braces: [("(", ")"), ("{", "}"), ("[", "]")]
93+
braces: [('(', ')'), ('{', '}'), ('[', ']')]
10894
.into_iter()
10995
.find(|b| b.0 == brace)
11096
.map(|(o, c)| (o.to_owned(), c.to_owned()))

clippy_lints/src/disallowed_names.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ pub struct DisallowedNames {
3131
}
3232

3333
impl DisallowedNames {
34-
pub fn new(disallow: FxHashSet<String>) -> Self {
34+
pub fn new(disallowed_names: &[String]) -> Self {
3535
Self {
36-
disallow,
36+
disallow: disallowed_names.iter().cloned().collect(),
3737
test_modules_deep: 0,
3838
}
3939
}

clippy_lints/src/doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ pub struct DocMarkdown {
268268
}
269269

270270
impl DocMarkdown {
271-
pub fn new(valid_idents: FxHashSet<String>) -> Self {
271+
pub fn new(valid_idents: &[String]) -> Self {
272272
Self {
273-
valid_idents,
273+
valid_idents: valid_idents.iter().cloned().collect(),
274274
in_trait_impl: false,
275275
}
276276
}

0 commit comments

Comments
 (0)