Skip to content

Commit 6fadcab

Browse files
committed
Remove the tons of allows
1 parent ea0daf8 commit 6fadcab

Some content is hidden

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

49 files changed

+215
-270
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: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@run-rustfix
22
#![deny(clippy::internal)]
33
#![allow(
4-
clippy::absolute_symbol_paths,
54
clippy::missing_clippy_version_attribute,
65
clippy::let_unit_value
76
)]

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/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_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-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;

tests/ui-toml/toml_disallowed_types/conf_disallowed_types.stderr

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,129 @@
11
error: `std::sync::atomic::AtomicU32` is not allowed according to config
2-
--> $DIR/conf_disallowed_types.rs:8:1
2+
--> $DIR/conf_disallowed_types.rs:7:1
33
|
44
LL | use std::sync::atomic::AtomicU32;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::disallowed-types` implied by `-D warnings`
88

99
error: `std::time::Instant` is not allowed according to config
10-
--> $DIR/conf_disallowed_types.rs:9:1
10+
--> $DIR/conf_disallowed_types.rs:8:1
1111
|
1212
LL | use std::time::Instant as Sneaky;
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

1515
error: `std::time::Instant` is not allowed according to config
16-
--> $DIR/conf_disallowed_types.rs:13:33
16+
--> $DIR/conf_disallowed_types.rs:12:33
1717
|
1818
LL | fn bad_return_type() -> fn() -> Sneaky {
1919
| ^^^^^^
2020

2121
error: `std::time::Instant` is not allowed according to config
22-
--> $DIR/conf_disallowed_types.rs:17:28
22+
--> $DIR/conf_disallowed_types.rs:16:28
2323
|
2424
LL | fn bad_arg_type(_: impl Fn(Sneaky) -> foo::atomic::AtomicU32) {}
2525
| ^^^^^^
2626

2727
error: `std::sync::atomic::AtomicU32` is not allowed according to config
28-
--> $DIR/conf_disallowed_types.rs:17:39
28+
--> $DIR/conf_disallowed_types.rs:16:39
2929
|
3030
LL | fn bad_arg_type(_: impl Fn(Sneaky) -> foo::atomic::AtomicU32) {}
3131
| ^^^^^^^^^^^^^^^^^^^^^^
3232

3333
error: `std::io::Read` is not allowed according to config
34-
--> $DIR/conf_disallowed_types.rs:19:22
34+
--> $DIR/conf_disallowed_types.rs:18:22
3535
|
3636
LL | fn trait_obj(_: &dyn std::io::Read) {}
3737
| ^^^^^^^^^^^^^
3838

3939
error: `usize` is not allowed according to config
40-
--> $DIR/conf_disallowed_types.rs:21:33
40+
--> $DIR/conf_disallowed_types.rs:20:33
4141
|
4242
LL | fn full_and_single_path_prim(_: usize, _: bool) {}
4343
| ^^^^^
4444

4545
error: `bool` is not allowed according to config
46-
--> $DIR/conf_disallowed_types.rs:21:43
46+
--> $DIR/conf_disallowed_types.rs:20:43
4747
|
4848
LL | fn full_and_single_path_prim(_: usize, _: bool) {}
4949
| ^^^^
5050

5151
error: `usize` is not allowed according to config
52-
--> $DIR/conf_disallowed_types.rs:23:28
52+
--> $DIR/conf_disallowed_types.rs:22:28
5353
|
5454
LL | fn const_generics<const C: usize>() {}
5555
| ^^^^^
5656

5757
error: `usize` is not allowed according to config
58-
--> $DIR/conf_disallowed_types.rs:25:24
58+
--> $DIR/conf_disallowed_types.rs:24:24
5959
|
6060
LL | struct GenArg<const U: usize>([u8; U]);
6161
| ^^^^^
6262

6363
error: `std::net::Ipv4Addr` is not allowed according to config
64-
--> $DIR/conf_disallowed_types.rs:29:10
64+
--> $DIR/conf_disallowed_types.rs:28:10
6565
|
6666
LL | fn ip(_: std::net::Ipv4Addr) {}
6767
| ^^^^^^^^^^^^^^^^^^
6868
|
6969
= note: no IPv4 allowed (from clippy.toml)
7070

7171
error: `std::net::TcpListener` is not allowed according to config
72-
--> $DIR/conf_disallowed_types.rs:31:16
72+
--> $DIR/conf_disallowed_types.rs:30:16
7373
|
7474
LL | fn listener(_: std::net::TcpListener) {}
7575
| ^^^^^^^^^^^^^^^^^^^^^
7676

7777
error: `std::collections::HashMap` is not allowed according to config
78-
--> $DIR/conf_disallowed_types.rs:35:48
78+
--> $DIR/conf_disallowed_types.rs:34:48
7979
|
8080
LL | let _: std::collections::HashMap<(), ()> = std::collections::HashMap::new();
8181
| ^^^^^^^^^^^^^^^^^^^^^^^^^
8282

8383
error: `std::collections::HashMap` is not allowed according to config
84-
--> $DIR/conf_disallowed_types.rs:35:12
84+
--> $DIR/conf_disallowed_types.rs:34:12
8585
|
8686
LL | let _: std::collections::HashMap<(), ()> = std::collections::HashMap::new();
8787
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8888

8989
error: `std::time::Instant` is not allowed according to config
90-
--> $DIR/conf_disallowed_types.rs:36:13
90+
--> $DIR/conf_disallowed_types.rs:35:13
9191
|
9292
LL | let _ = Sneaky::now();
9393
| ^^^^^^
9494

9595
error: `std::sync::atomic::AtomicU32` is not allowed according to config
96-
--> $DIR/conf_disallowed_types.rs:37:13
96+
--> $DIR/conf_disallowed_types.rs:36:13
9797
|
9898
LL | let _ = foo::atomic::AtomicU32::new(0);
9999
| ^^^^^^^^^^^^^^^^^^^^^^
100100

101101
error: `std::sync::atomic::AtomicU32` is not allowed according to config
102-
--> $DIR/conf_disallowed_types.rs:38:17
102+
--> $DIR/conf_disallowed_types.rs:37:17
103103
|
104104
LL | static FOO: std::sync::atomic::AtomicU32 = foo::atomic::AtomicU32::new(1);
105105
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106106

107107
error: `std::sync::atomic::AtomicU32` is not allowed according to config
108-
--> $DIR/conf_disallowed_types.rs:38:48
108+
--> $DIR/conf_disallowed_types.rs:37:48
109109
|
110110
LL | static FOO: std::sync::atomic::AtomicU32 = foo::atomic::AtomicU32::new(1);
111111
| ^^^^^^^^^^^^^^^^^^^^^^
112112

113113
error: `syn::TypePath` is not allowed according to config
114-
--> $DIR/conf_disallowed_types.rs:39:43
114+
--> $DIR/conf_disallowed_types.rs:38:43
115115
|
116116
LL | let _: std::collections::BTreeMap<(), syn::TypePath> = Default::default();
117117
| ^^^^^^^^^^^^^
118118

119119
error: `syn::Ident` is not allowed according to config
120-
--> $DIR/conf_disallowed_types.rs:40:13
120+
--> $DIR/conf_disallowed_types.rs:39:13
121121
|
122122
LL | let _ = syn::Ident::new("", todo!());
123123
| ^^^^^^^^^^
124124

125125
error: `usize` is not allowed according to config
126-
--> $DIR/conf_disallowed_types.rs:42:12
126+
--> $DIR/conf_disallowed_types.rs:41:12
127127
|
128128
LL | let _: usize = 64_usize;
129129
| ^^^^^

tests/ui/cast_alignment.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
#![feature(rustc_private)]
44
#![feature(core_intrinsics)]
5-
#![allow(clippy::absolute_symbol_paths)]
65
extern crate libc;
76

87
#[warn(clippy::cast_ptr_alignment)]

tests/ui/cast_alignment.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes)
2-
--> $DIR/cast_alignment.rs:20:5
2+
--> $DIR/cast_alignment.rs:19:5
33
|
44
LL | (&1u8 as *const u8) as *const u16;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D clippy::cast-ptr-alignment` implied by `-D warnings`
88

99
error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes)
10-
--> $DIR/cast_alignment.rs:21:5
10+
--> $DIR/cast_alignment.rs:20:5
1111
|
1212
LL | (&mut 1u8 as *mut u8) as *mut u16;
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414

1515
error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`) (1 < 2 bytes)
16-
--> $DIR/cast_alignment.rs:24:5
16+
--> $DIR/cast_alignment.rs:23:5
1717
|
1818
LL | (&1u8 as *const u8).cast::<u16>();
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

2121
error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`) (1 < 2 bytes)
22-
--> $DIR/cast_alignment.rs:25:5
22+
--> $DIR/cast_alignment.rs:24:5
2323
|
2424
LL | (&mut 1u8 as *mut u8).cast::<u16>();
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/default_trait_access.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@aux-build: proc_macros.rs:proc-macro
33
#![deny(clippy::default_trait_access)]
44
#![allow(dead_code, unused_imports)]
5-
#![allow(clippy::absolute_symbol_paths, clippy::uninlined_format_args)]
5+
#![allow(clippy::uninlined_format_args)]
66

77
extern crate proc_macros;
88

tests/ui/default_trait_access.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@aux-build: proc_macros.rs:proc-macro
33
#![deny(clippy::default_trait_access)]
44
#![allow(dead_code, unused_imports)]
5-
#![allow(clippy::absolute_symbol_paths, clippy::uninlined_format_args)]
5+
#![allow(clippy::uninlined_format_args)]
66

77
extern crate proc_macros;
88

tests/ui/entry.fixed

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
//@needs-asm-support
22
//@run-rustfix
33

4-
#![allow(
5-
unused,
6-
clippy::absolute_symbol_paths,
7-
clippy::needless_pass_by_value,
8-
clippy::collapsible_if
9-
)]
4+
#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]
105
#![warn(clippy::map_entry)]
116

127
use std::arch::asm;

tests/ui/entry.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
//@needs-asm-support
22
//@run-rustfix
33

4-
#![allow(
5-
unused,
6-
clippy::absolute_symbol_paths,
7-
clippy::needless_pass_by_value,
8-
clippy::collapsible_if
9-
)]
4+
#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]
105
#![warn(clippy::map_entry)]
116

127
use std::arch::asm;

0 commit comments

Comments
 (0)