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`

0 commit comments

Comments
 (0)