Skip to content

Commit 739413c

Browse files
committed
Remove the tons of allows
1 parent ea0daf8 commit 739413c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+241
-299
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5465,5 +5465,5 @@ Released 2018-09-13
54655465
[`accept-comment-above-attributes`]: https://doc.rust-lang.org/clippy/lint_configuration.html#accept-comment-above-attributes
54665466
[`allow-one-hash-in-raw-strings`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-one-hash-in-raw-strings
54675467
[`absolute-symbol-paths-max-segments`]: https://doc.rust-lang.org/clippy/lint_configuration.html#absolute-symbol-paths-max-segments
5468-
[`absolute-symbol-paths-allow-std`]: https://doc.rust-lang.org/clippy/lint_configuration.html#absolute-symbol-paths-allow-std
5468+
[`absolute-symbol-paths-allowed-crates`]: https://doc.rust-lang.org/clippy/lint_configuration.html#absolute-symbol-paths-allowed-crates
54695469
<!-- end autogenerated links to configuration documentation -->

book/src/lint_configuration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,10 +740,10 @@ The maximum number of segments a path can have before being linted
740740
* [`absolute_symbol_paths`](https://rust-lang.github.io/rust-clippy/master/index.html#absolute_symbol_paths)
741741

742742

743-
## `absolute-symbol-paths-allow-std`
744-
Whether to allow paths originating from `core`/`std`/`alloc`
743+
## `absolute-symbol-paths-allowed-crates`
744+
Which crates to allow absolute symbols, `crate` will allow the local crate
745745

746-
**Default Value:** `false` (`bool`)
746+
**Default Value:** `{}` (`rustc_data_structures::fx::FxHashSet<String>`)
747747

748748
---
749749
**Affected lints:**

clippy_lints/src/absolute_symbol_paths.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ use rustc_span::symbol::kw;
1010

1111
declare_clippy_lint! {
1212
/// ### What it does
13-
/// Checks for usage of symbols through absolute paths, like `std::env::current_dir`.
13+
/// Checks for usage of items through absolute paths, like `std::env::current_dir`.
1414
///
1515
/// ### Why is this bad?
1616
/// Many codebases have their own style when it comes to symbol importing, but one that is
1717
/// seldom used is using absolute paths *everywhere*. This is generally considered unidiomatic,
1818
/// and you should add a `use` statement.
1919
///
20+
/// The default maximum segments (2) is pretty strict, you may want to increase this in
21+
/// clippy.toml.
22+
///
2023
/// Note: One exception to this is code from macro expansion - this does not lint such cases, as
2124
/// using absolute paths is the proper way of referencing symbols in one.
2225
///

clippy_lints/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
#![feature(stmt_expr_attributes)]
1111
#![recursion_limit = "512"]
1212
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
13-
#![allow(
14-
clippy::absolute_symbol_paths,
15-
clippy::missing_docs_in_private_items,
16-
clippy::must_use_candidate
17-
)]
13+
#![allow(clippy::missing_docs_in_private_items, clippy::must_use_candidate)]
1814
#![warn(trivial_casts, trivial_numeric_casts)]
1915
// warn on lints, that are included in `rust-lang/rust`s bootstrap
2016
#![warn(rust_2018_idioms, unused_lifetimes)]

clippy_lints/src/utils/conf.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,9 @@ define_Conf! {
553553
(allow_one_hash_in_raw_strings: bool = false),
554554
/// Lint: ABSOLUTE_SYMBOL_PATHS.
555555
///
556-
/// The maximum number of segments a path can have before being linted
557-
(absolute_symbol_paths_max_segments: u64 = 3),
556+
/// The maximum number of segments a path can have before being linted, anything above this will
557+
/// be linted.
558+
(absolute_symbol_paths_max_segments: u64 = 2),
558559
/// Lint: ABSOLUTE_SYMBOL_PATHS.
559560
///
560561
/// Which crates to allow absolute symbols, `crate` will allow the local crate

clippy_utils/src/check_proc_macro.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ pub trait WithSearchPat<'cx> {
354354
fn span(&self) -> Span;
355355
}
356356
macro_rules! impl_with_search_pat {
357-
($cx:ident: $ty:ident with $fn:ident $(($tcx:ident))? && $span_method:ident$($par:tt)?) => {
357+
($cx:ident: $ty:ident with $fn:ident $(($tcx:ident))?) => {
358358
impl<'cx> WithSearchPat<'cx> for $ty<'cx> {
359359
type Context = $cx<'cx>;
360360
#[allow(unused_variables)]
@@ -363,19 +363,18 @@ macro_rules! impl_with_search_pat {
363363
$fn($($tcx,)? self)
364364
}
365365
fn span(&self) -> Span {
366-
self.$span_method$($par)?
366+
self.span
367367
}
368368
}
369369
};
370370
}
371-
impl_with_search_pat!(LateContext: Expr with expr_search_pat(tcx) && span);
372-
impl_with_search_pat!(LateContext: Item with item_search_pat && span);
373-
impl_with_search_pat!(LateContext: TraitItem with trait_item_search_pat && span);
374-
impl_with_search_pat!(LateContext: ImplItem with impl_item_search_pat && span);
375-
impl_with_search_pat!(LateContext: FieldDef with field_def_search_pat && span);
376-
impl_with_search_pat!(LateContext: Variant with variant_search_pat && span);
377-
impl_with_search_pat!(LateContext: Ty with ty_search_pat && span);
378-
impl_with_search_pat!(LateContext: QPath with qpath_search_pat && span());
371+
impl_with_search_pat!(LateContext: Expr with expr_search_pat(tcx));
372+
impl_with_search_pat!(LateContext: Item with item_search_pat);
373+
impl_with_search_pat!(LateContext: TraitItem with trait_item_search_pat);
374+
impl_with_search_pat!(LateContext: ImplItem with impl_item_search_pat);
375+
impl_with_search_pat!(LateContext: FieldDef with field_def_search_pat);
376+
impl_with_search_pat!(LateContext: Variant with variant_search_pat);
377+
impl_with_search_pat!(LateContext: Ty with ty_search_pat);
379378

380379
impl<'cx> WithSearchPat<'cx> for (&FnKind<'cx>, &Body<'cx>, HirId, Span) {
381380
type Context = LateContext<'cx>;

tests/ui-cargo/module_style/fail_mod/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(clippy::absolute_symbol_paths)]
21
#![warn(clippy::self_named_module_files)]
32

43
mod bad;

tests/ui-internal/interning_defined_symbol.fixed

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
//@run-rustfix
22
#![deny(clippy::internal)]
3-
#![allow(
4-
clippy::absolute_symbol_paths,
5-
clippy::missing_clippy_version_attribute,
6-
clippy::let_unit_value
7-
)]
3+
#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)]
84
#![feature(rustc_private)]
95

106
extern crate rustc_span;

tests/ui-internal/interning_defined_symbol.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
//@run-rustfix
22
#![deny(clippy::internal)]
3-
#![allow(
4-
clippy::absolute_symbol_paths,
5-
clippy::missing_clippy_version_attribute,
6-
clippy::let_unit_value
7-
)]
3+
#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)]
84
#![feature(rustc_private)]
95

106
extern crate rustc_span;

tests/ui-internal/interning_defined_symbol.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: interning a defined symbol
2-
--> $DIR/interning_defined_symbol.rs:22:13
2+
--> $DIR/interning_defined_symbol.rs:18:13
33
|
44
LL | let _ = Symbol::intern("f32");
55
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::f32`
@@ -12,19 +12,19 @@ LL | #![deny(clippy::internal)]
1212
= note: `#[deny(clippy::interning_defined_symbol)]` implied by `#[deny(clippy::internal)]`
1313

1414
error: interning a defined symbol
15-
--> $DIR/interning_defined_symbol.rs:25:13
15+
--> $DIR/interning_defined_symbol.rs:21:13
1616
|
1717
LL | let _ = sym!(f32);
1818
| ^^^^^^^^^ help: try: `rustc_span::sym::f32`
1919

2020
error: interning a defined symbol
21-
--> $DIR/interning_defined_symbol.rs:28:13
21+
--> $DIR/interning_defined_symbol.rs:24:13
2222
|
2323
LL | let _ = Symbol::intern("proc-macro");
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::proc_dash_macro`
2525

2626
error: interning a defined symbol
27-
--> $DIR/interning_defined_symbol.rs:31:13
27+
--> $DIR/interning_defined_symbol.rs:27:13
2828
|
2929
LL | let _ = Symbol::intern("self");
3030
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::symbol::kw::SelfLower`

tests/ui-internal/unnecessary_def_path.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@run-rustfix
22
//@aux-build:paths.rs
3-
#![allow(clippy::absolute_symbol_paths)]
43
#![deny(clippy::internal)]
54
#![feature(rustc_private)]
65

tests/ui-internal/unnecessary_def_path.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@run-rustfix
22
//@aux-build:paths.rs
3-
#![allow(clippy::absolute_symbol_paths)]
43
#![deny(clippy::internal)]
54
#![feature(rustc_private)]
65

tests/ui-internal/unnecessary_def_path.stderr

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,98 @@
11
error: use of a def path to a diagnostic item
2-
--> $DIR/unnecessary_def_path.rs:38:13
2+
--> $DIR/unnecessary_def_path.rs:37:13
33
|
44
LL | let _ = match_type(cx, ty, &OPTION);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)`
66
|
77
note: the lint level is defined here
8-
--> $DIR/unnecessary_def_path.rs:4:9
8+
--> $DIR/unnecessary_def_path.rs:3:9
99
|
1010
LL | #![deny(clippy::internal)]
1111
| ^^^^^^^^^^^^^^^^
1212
= note: `#[deny(clippy::unnecessary_def_path)]` implied by `#[deny(clippy::internal)]`
1313

1414
error: use of a def path to a diagnostic item
15-
--> $DIR/unnecessary_def_path.rs:39:13
15+
--> $DIR/unnecessary_def_path.rs:38:13
1616
|
1717
LL | let _ = match_type(cx, ty, RESULT);
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)`
1919

2020
error: use of a def path to a diagnostic item
21-
--> $DIR/unnecessary_def_path.rs:40:13
21+
--> $DIR/unnecessary_def_path.rs:39:13
2222
|
2323
LL | let _ = match_type(cx, ty, &["core", "result", "Result"]);
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)`
2525

2626
error: use of a def path to a diagnostic item
27-
--> $DIR/unnecessary_def_path.rs:44:13
27+
--> $DIR/unnecessary_def_path.rs:43:13
2828
|
2929
LL | let _ = clippy_utils::ty::match_type(cx, ty, rc_path);
3030
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Rc)`
3131

3232
error: use of a def path to a diagnostic item
33-
--> $DIR/unnecessary_def_path.rs:46:13
33+
--> $DIR/unnecessary_def_path.rs:45:13
3434
|
3535
LL | let _ = match_type(cx, ty, &paths::OPTION);
3636
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)`
3737

3838
error: use of a def path to a diagnostic item
39-
--> $DIR/unnecessary_def_path.rs:47:13
39+
--> $DIR/unnecessary_def_path.rs:46:13
4040
|
4141
LL | let _ = match_type(cx, ty, paths::RESULT);
4242
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)`
4343

4444
error: use of a def path to a `LangItem`
45-
--> $DIR/unnecessary_def_path.rs:49:13
45+
--> $DIR/unnecessary_def_path.rs:48:13
4646
|
4747
LL | let _ = match_type(cx, ty, &["alloc", "boxed", "Box"]);
4848
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_lang_item(cx, ty, LangItem::OwnedBox)`
4949

5050
error: use of a def path to a diagnostic item
51-
--> $DIR/unnecessary_def_path.rs:50:13
51+
--> $DIR/unnecessary_def_path.rs:49:13
5252
|
5353
LL | let _ = match_type(cx, ty, &["core", "mem", "maybe_uninit", "MaybeUninit", "uninit"]);
5454
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::maybe_uninit_uninit)`
5555

5656
error: use of a def path to a `LangItem`
57-
--> $DIR/unnecessary_def_path.rs:52:13
57+
--> $DIR/unnecessary_def_path.rs:51:13
5858
|
5959
LL | let _ = match_def_path(cx, did, &["alloc", "boxed", "Box"]);
6060
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OwnedBox) == Some(did)`
6161

6262
error: use of a def path to a diagnostic item
63-
--> $DIR/unnecessary_def_path.rs:53:13
63+
--> $DIR/unnecessary_def_path.rs:52:13
6464
|
6565
LL | let _ = match_def_path(cx, did, &["core", "option", "Option"]);
6666
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.is_diagnostic_item(sym::Option, did)`
6767

6868
error: use of a def path to a `LangItem`
69-
--> $DIR/unnecessary_def_path.rs:54:13
69+
--> $DIR/unnecessary_def_path.rs:53:13
7070
|
7171
LL | let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]);
7272
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OptionSome) == Some(did)`
7373
|
7474
= help: if this `DefId` came from a constructor expression or pattern then the parent `DefId` should be used instead
7575

7676
error: use of a def path to a diagnostic item
77-
--> $DIR/unnecessary_def_path.rs:56:13
77+
--> $DIR/unnecessary_def_path.rs:55:13
7878
|
7979
LL | let _ = match_trait_method(cx, expr, &["core", "convert", "AsRef"]);
8080
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_trait_method(cx, expr, sym::AsRef)`
8181

8282
error: use of a def path to a diagnostic item
83-
--> $DIR/unnecessary_def_path.rs:58:13
83+
--> $DIR/unnecessary_def_path.rs:57:13
8484
|
8585
LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option"]);
8686
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_path_diagnostic_item(cx, expr, sym::Option)`
8787

8888
error: use of a def path to a `LangItem`
89-
--> $DIR/unnecessary_def_path.rs:59:13
89+
--> $DIR/unnecessary_def_path.rs:58:13
9090
|
9191
LL | let _ = is_expr_path_def_path(cx, expr, &["core", "iter", "traits", "Iterator", "next"]);
9292
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `path_res(cx, expr).opt_def_id().map_or(false, |id| cx.tcx.lang_items().get(LangItem::IteratorNext) == Some(id))`
9393

9494
error: use of a def path to a `LangItem`
95-
--> $DIR/unnecessary_def_path.rs:60:13
95+
--> $DIR/unnecessary_def_path.rs:59:13
9696
|
9797
LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option", "Some"]);
9898
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_res_lang_ctor(cx, path_res(cx, expr), LangItem::OptionSome)`

tests/ui-internal/unnecessary_symbol_str.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![feature(rustc_private)]
33
#![deny(clippy::internal)]
44
#![allow(
5-
clippy::absolute_symbol_paths,
65
clippy::borrow_deref_ref,
76
clippy::unnecessary_operation,
87
unused_must_use,

tests/ui-internal/unnecessary_symbol_str.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![feature(rustc_private)]
33
#![deny(clippy::internal)]
44
#![allow(
5-
clippy::absolute_symbol_paths,
65
clippy::borrow_deref_ref,
76
clippy::unnecessary_operation,
87
unused_must_use,

tests/ui-internal/unnecessary_symbol_str.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unnecessary `Symbol` to string conversion
2-
--> $DIR/unnecessary_symbol_str.rs:17:5
2+
--> $DIR/unnecessary_symbol_str.rs:16:5
33
|
44
LL | Symbol::intern("foo").as_str() == "clippy";
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") == rustc_span::sym::clippy`
@@ -12,25 +12,25 @@ LL | #![deny(clippy::internal)]
1212
= note: `#[deny(clippy::unnecessary_symbol_str)]` implied by `#[deny(clippy::internal)]`
1313

1414
error: unnecessary `Symbol` to string conversion
15-
--> $DIR/unnecessary_symbol_str.rs:18:5
15+
--> $DIR/unnecessary_symbol_str.rs:17:5
1616
|
1717
LL | Symbol::intern("foo").to_string() == "self";
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") == rustc_span::symbol::kw::SelfLower`
1919

2020
error: unnecessary `Symbol` to string conversion
21-
--> $DIR/unnecessary_symbol_str.rs:19:5
21+
--> $DIR/unnecessary_symbol_str.rs:18:5
2222
|
2323
LL | Symbol::intern("foo").to_ident_string() != "Self";
2424
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") != rustc_span::symbol::kw::SelfUpper`
2525

2626
error: unnecessary `Symbol` to string conversion
27-
--> $DIR/unnecessary_symbol_str.rs:20:5
27+
--> $DIR/unnecessary_symbol_str.rs:19:5
2828
|
2929
LL | &*Ident::empty().as_str() == "clippy";
3030
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ident::empty().name == rustc_span::sym::clippy`
3131

3232
error: unnecessary `Symbol` to string conversion
33-
--> $DIR/unnecessary_symbol_str.rs:21:5
33+
--> $DIR/unnecessary_symbol_str.rs:20:5
3434
|
3535
LL | "clippy" == Ident::empty().to_string();
3636
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::clippy == Ident::empty().name`

tests/ui-toml/toml_disallowed_types/conf_disallowed_types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(clippy::absolute_symbol_paths)]
21
#![warn(clippy::disallowed_types)]
32

43
extern crate quote;

0 commit comments

Comments
 (0)