Skip to content

Commit 481ddea

Browse files
committed
add lint: could_be_assoc_type_bounds
1 parent d49501c commit 481ddea

22 files changed

+1048
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5410,6 +5410,7 @@ Released 2018-09-13
54105410
[`const_is_empty`]: https://rust-lang.github.io/rust-clippy/master/index.html#const_is_empty
54115411
[`const_static_lifetime`]: https://rust-lang.github.io/rust-clippy/master/index.html#const_static_lifetime
54125412
[`copy_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#copy_iterator
5413+
[`could_be_assoc_type_bounds`]: https://rust-lang.github.io/rust-clippy/master/index.html#could_be_assoc_type_bounds
54135414
[`crate_in_macro_def`]: https://rust-lang.github.io/rust-clippy/master/index.html#crate_in_macro_def
54145415
[`create_dir`]: https://rust-lang.github.io/rust-clippy/master/index.html#create_dir
54155416
[`crosspointer_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#crosspointer_transmute

book/src/lint_configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
694694
* [`cloned_instead_of_copied`](https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied)
695695
* [`collapsible_match`](https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match)
696696
* [`collapsible_str_replace`](https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_str_replace)
697+
* [`could_be_assoc_type_bounds`](https://rust-lang.github.io/rust-clippy/master/index.html#could_be_assoc_type_bounds)
697698
* [`deprecated_cfg_attr`](https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_cfg_attr)
698699
* [`derivable_impls`](https://rust-lang.github.io/rust-clippy/master/index.html#derivable_impls)
699700
* [`err_expect`](https://rust-lang.github.io/rust-clippy/master/index.html#err_expect)

clippy_config/src/conf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ define_Conf! {
577577
cloned_instead_of_copied,
578578
collapsible_match,
579579
collapsible_str_replace,
580+
could_be_assoc_type_bounds,
580581
deprecated_cfg_attr,
581582
derivable_impls,
582583
err_expect,

clippy_lints/src/could_be_assoc_type_bounds.rs

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
111111
crate::copies::IF_SAME_THEN_ELSE_INFO,
112112
crate::copies::SAME_FUNCTIONS_IN_IF_CONDITION_INFO,
113113
crate::copy_iterator::COPY_ITERATOR_INFO,
114+
crate::could_be_assoc_type_bounds::COULD_BE_ASSOC_TYPE_BOUNDS_INFO,
114115
crate::crate_in_macro_def::CRATE_IN_MACRO_DEF_INFO,
115116
crate::create_dir::CREATE_DIR_INFO,
116117
crate::dbg_macro::DBG_MACRO_INFO,

clippy_lints/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ mod collection_is_never_read;
100100
mod comparison_chain;
101101
mod copies;
102102
mod copy_iterator;
103+
mod could_be_assoc_type_bounds;
103104
mod crate_in_macro_def;
104105
mod create_dir;
105106
mod dbg_macro;
@@ -963,5 +964,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
963964
store.register_late_pass(|_| Box::new(manual_ignore_case_cmp::ManualIgnoreCaseCmp));
964965
store.register_late_pass(|_| Box::new(unnecessary_literal_bound::UnnecessaryLiteralBound));
965966
store.register_late_pass(move |_| Box::new(arbitrary_source_item_ordering::ArbitrarySourceItemOrdering::new(conf)));
967+
store.register_late_pass(move |_| Box::new(could_be_assoc_type_bounds::ManualAssocTypeBounds::new(conf)));
966968
// add lints here, do not remove this comment, it's used in `new_lint`
967969
}

clippy_utils/src/hir_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl HirEqInterExpr<'_, '_, '_> {
455455
left.ident.name == right.ident.name && self.eq_expr(left.expr, right.expr)
456456
}
457457

458-
fn eq_generic_arg(&mut self, left: &GenericArg<'_>, right: &GenericArg<'_>) -> bool {
458+
pub fn eq_generic_arg(&mut self, left: &GenericArg<'_>, right: &GenericArg<'_>) -> bool {
459459
match (left, right) {
460460
(GenericArg::Const(l), GenericArg::Const(r)) => self.eq_const_arg(l, r),
461461
(GenericArg::Lifetime(l_lt), GenericArg::Lifetime(r_lt)) => Self::eq_lifetime(l_lt, r_lt),

clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub mod usage;
7979
pub mod visitors;
8080

8181
pub use self::attrs::*;
82-
pub use self::check_proc_macro::{is_from_proc_macro, is_span_if, is_span_match};
82+
pub use self::check_proc_macro::{WithSearchPat, is_from_proc_macro, is_span_if, is_span_match};
8383
pub use self::hir_utils::{
8484
HirEqInterExpr, SpanlessEq, SpanlessHash, both, count_eq, eq_expr_value, hash_expr, hash_stmt, is_bool, over,
8585
};

clippy_utils/src/msrvs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ msrv_aliases! {
2121
1,83,0 { CONST_EXTERN_FN, CONST_FLOAT_BITS_CONV, CONST_FLOAT_CLASSIFY }
2222
1,82,0 { IS_NONE_OR, REPEAT_N }
2323
1,81,0 { LINT_REASONS_STABILIZATION }
24-
1,80,0 { BOX_INTO_ITER}
24+
1,80,0 { BOX_INTO_ITER }
25+
1,79,0 { ASSOCIATED_TYPE_BOUNDS }
2526
1,77,0 { C_STR_LITERALS }
2627
1,76,0 { PTR_FROM_REF, OPTION_RESULT_INSPECT }
2728
1,73,0 { MANUAL_DIV_CEIL }

clippy_utils/src/ty.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
251251
ty: Ty<'tcx>,
252252
trait_id: DefId,
253253
callee_id: Option<DefId>,
254-
args: impl IntoIterator<Item = impl Into<Option<GenericArg<'tcx>>>>,
254+
args: impl IntoIterator<Item: Into<Option<GenericArg<'tcx>>>>,
255255
) -> bool {
256256
// Clippy shouldn't have infer types
257257
assert!(!ty.has_infer());
@@ -1073,7 +1073,7 @@ pub fn make_projection<'tcx>(
10731073
tcx: TyCtxt<'tcx>,
10741074
container_id: DefId,
10751075
assoc_ty: Symbol,
1076-
args: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
1076+
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
10771077
) -> Option<AliasTy<'tcx>> {
10781078
fn helper<'tcx>(
10791079
tcx: TyCtxt<'tcx>,
@@ -1114,7 +1114,7 @@ pub fn make_normalized_projection<'tcx>(
11141114
param_env: ParamEnv<'tcx>,
11151115
container_id: DefId,
11161116
assoc_ty: Symbol,
1117-
args: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
1117+
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
11181118
) -> Option<Ty<'tcx>> {
11191119
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
11201120
#[cfg(debug_assertions)]
@@ -1241,7 +1241,7 @@ pub fn make_normalized_projection_with_regions<'tcx>(
12411241
param_env: ParamEnv<'tcx>,
12421242
container_id: DefId,
12431243
assoc_ty: Symbol,
1244-
args: impl IntoIterator<Item = impl Into<GenericArg<'tcx>>>,
1244+
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
12451245
) -> Option<Ty<'tcx>> {
12461246
fn helper<'tcx>(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>, ty: AliasTy<'tcx>) -> Option<Ty<'tcx>> {
12471247
#[cfg(debug_assertions)]

0 commit comments

Comments
 (0)