Skip to content

Commit 6f856bf

Browse files
committed
Deprecates needless-maybe-sized in clippy
- Uses clippy dev tool to rename and deprecate needless-maybe-sized in clippy. - Removes needless-maybe-sized from late pass lint register.
1 parent 7e4af47 commit 6f856bf

16 files changed

+104
-749
lines changed

src/tools/clippy/clippy_lints/src/declared_lints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[
548548
crate::needless_for_each::NEEDLESS_FOR_EACH_INFO,
549549
crate::needless_if::NEEDLESS_IF_INFO,
550550
crate::needless_late_init::NEEDLESS_LATE_INIT_INFO,
551-
crate::needless_maybe_sized::NEEDLESS_MAYBE_SIZED_INFO,
552551
crate::needless_parens_on_range_literals::NEEDLESS_PARENS_ON_RANGE_LITERALS_INFO,
553552
crate::needless_pass_by_ref_mut::NEEDLESS_PASS_BY_REF_MUT_INFO,
554553
crate::needless_pass_by_value::NEEDLESS_PASS_BY_VALUE_INFO,

src/tools/clippy/clippy_lints/src/deprecated_lints.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ declare_with_version! { RENAMED(RENAMED_VERSION) = [
138138
("clippy::mem_discriminant_non_enum", "enum_intrinsics_non_enums"),
139139
#[clippy::version = "1.80.0"]
140140
("clippy::mismatched_target_os", "unexpected_cfgs"),
141+
#[clippy::version = "1.90.0"]
142+
("clippy::needless_maybe_sized", "redundant_sizedness_bound"),
141143
#[clippy::version = ""]
142144
("clippy::new_without_default_derive", "clippy::new_without_default"),
143145
#[clippy::version = ""]

src/tools/clippy/clippy_lints/src/disallowed_macros.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use clippy_config::Conf;
32
use clippy_config::types::{DisallowedPath, create_disallowed_map};
43
use clippy_utils::diagnostics::{span_lint_and_then, span_lint_hir_and_then};

src/tools/clippy/clippy_lints/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ mod needless_else;
264264
mod needless_for_each;
265265
mod needless_if;
266266
mod needless_late_init;
267-
mod needless_maybe_sized;
268267
mod needless_parens_on_range_literals;
269268
mod needless_pass_by_ref_mut;
270269
mod needless_pass_by_value;
@@ -741,7 +740,6 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co
741740
store.register_late_pass(|_| Box::new(no_mangle_with_rust_abi::NoMangleWithRustAbi));
742741
store.register_late_pass(|_| Box::new(collection_is_never_read::CollectionIsNeverRead));
743742
store.register_late_pass(|_| Box::new(missing_assert_message::MissingAssertMessage));
744-
store.register_late_pass(|_| Box::new(needless_maybe_sized::NeedlessMaybeSized));
745743
store.register_late_pass(|_| Box::new(redundant_async_block::RedundantAsyncBlock));
746744
store.register_late_pass(|_| Box::new(let_with_type_underscore::UnderscoreTyped));
747745
store.register_late_pass(move |_| Box::new(manual_main_separator_str::ManualMainSeparatorStr::new(conf)));

src/tools/clippy/clippy_lints/src/needless_maybe_sized.rs

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,7 @@ use rustc_middle::ty::{ClauseKind, PredicatePolarity};
77
use rustc_session::declare_lint_pass;
88
use rustc_span::symbol::Ident;
99

10-
declare_clippy_lint! {
11-
/// ### What it does
12-
/// Lints `?Sized` bounds applied to type parameters that cannot be unsized
13-
///
14-
/// ### Why is this bad?
15-
/// The `?Sized` bound is misleading because it cannot be satisfied by an
16-
/// unsized type
17-
///
18-
/// ### Example
19-
/// ```rust
20-
/// // `T` cannot be unsized because `Clone` requires it to be `Sized`
21-
/// fn f<T: Clone + ?Sized>(t: &T) {}
22-
/// ```
23-
/// Use instead:
24-
/// ```rust
25-
/// fn f<T: Clone>(t: &T) {}
26-
///
27-
/// // or choose alternative bounds for `T` so that it can be unsized
28-
/// ```
29-
#[clippy::version = "1.81.0"]
30-
pub NEEDLESS_MAYBE_SIZED,
31-
suspicious,
32-
"a `?Sized` bound that is unusable due to a `Sized` requirement"
33-
}
34-
declare_lint_pass!(NeedlessMaybeSized => [NEEDLESS_MAYBE_SIZED]);
10+
declare_lint_pass!(RedundantSizednessBound => [REDUNDANT_SIZEDNESS_BOUND]);
3511

3612
#[allow(clippy::struct_field_names)]
3713
struct Bound<'tcx> {
@@ -109,7 +85,7 @@ fn path_to_sized_bound(cx: &LateContext<'_>, trait_bound: &PolyTraitRef<'_>) ->
10985
search(cx, &mut path).then_some(path)
11086
}
11187

112-
impl LateLintPass<'_> for NeedlessMaybeSized {
88+
impl LateLintPass<'_> for RedundantSizednessBound {
11389
fn check_generics(&mut self, cx: &LateContext<'_>, generics: &Generics<'_>) {
11490
let Some(sized_trait) = cx.tcx.lang_items().sized_trait() else {
11591
return;
@@ -130,7 +106,7 @@ impl LateLintPass<'_> for NeedlessMaybeSized {
130106
{
131107
span_lint_and_then(
132108
cx,
133-
NEEDLESS_MAYBE_SIZED,
109+
REDUNDANT_SIZEDNESS_BOUND,
134110
sized_bound.trait_bound.span,
135111
"`?Sized` bound is ignored because of a `Sized` requirement",
136112
|diag| {

src/tools/clippy/tests/ui-toml/type_repetition_in_bounds/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(clippy::needless_maybe_sized)]
1+
#![allow(redundant_sizedness_bound)]
22
#![warn(clippy::type_repetition_in_bounds)]
33

44
fn f<T>()

src/tools/clippy/tests/ui/derive.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#![expect(incomplete_features)] // `unsafe_fields` is incomplete for the time being
1010
#![feature(unsafe_fields)] // `clone()` cannot be derived automatically on unsafe fields
1111

12-
1312
#[derive(Copy)]
1413
struct Qux;
1514

src/tools/clippy/tests/ui/derive.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: you are implementing `Clone` explicitly on a `Copy` type
2-
--> tests/ui/derive.rs:16:1
2+
--> tests/ui/derive.rs:15:1
33
|
44
LL | / impl Clone for Qux {
55
LL | |
@@ -10,7 +10,7 @@ LL | | }
1010
| |_^
1111
|
1212
note: consider deriving `Clone` or removing `Copy`
13-
--> tests/ui/derive.rs:16:1
13+
--> tests/ui/derive.rs:15:1
1414
|
1515
LL | / impl Clone for Qux {
1616
LL | |
@@ -23,7 +23,7 @@ LL | | }
2323
= help: to override `-D warnings` add `#[allow(clippy::expl_impl_clone_on_copy)]`
2424

2525
error: you are implementing `Clone` explicitly on a `Copy` type
26-
--> tests/ui/derive.rs:42:1
26+
--> tests/ui/derive.rs:41:1
2727
|
2828
LL | / impl<'a> Clone for Lt<'a> {
2929
LL | |
@@ -34,7 +34,7 @@ LL | | }
3434
| |_^
3535
|
3636
note: consider deriving `Clone` or removing `Copy`
37-
--> tests/ui/derive.rs:42:1
37+
--> tests/ui/derive.rs:41:1
3838
|
3939
LL | / impl<'a> Clone for Lt<'a> {
4040
LL | |
@@ -45,7 +45,7 @@ LL | | }
4545
| |_^
4646

4747
error: you are implementing `Clone` explicitly on a `Copy` type
48-
--> tests/ui/derive.rs:55:1
48+
--> tests/ui/derive.rs:54:1
4949
|
5050
LL | / impl Clone for BigArray {
5151
LL | |
@@ -56,7 +56,7 @@ LL | | }
5656
| |_^
5757
|
5858
note: consider deriving `Clone` or removing `Copy`
59-
--> tests/ui/derive.rs:55:1
59+
--> tests/ui/derive.rs:54:1
6060
|
6161
LL | / impl Clone for BigArray {
6262
LL | |
@@ -67,7 +67,7 @@ LL | | }
6767
| |_^
6868

6969
error: you are implementing `Clone` explicitly on a `Copy` type
70-
--> tests/ui/derive.rs:68:1
70+
--> tests/ui/derive.rs:67:1
7171
|
7272
LL | / impl Clone for FnPtr {
7373
LL | |
@@ -78,7 +78,7 @@ LL | | }
7878
| |_^
7979
|
8080
note: consider deriving `Clone` or removing `Copy`
81-
--> tests/ui/derive.rs:68:1
81+
--> tests/ui/derive.rs:67:1
8282
|
8383
LL | / impl Clone for FnPtr {
8484
LL | |
@@ -89,7 +89,7 @@ LL | | }
8989
| |_^
9090

9191
error: you are implementing `Clone` explicitly on a `Copy` type
92-
--> tests/ui/derive.rs:90:1
92+
--> tests/ui/derive.rs:89:1
9393
|
9494
LL | / impl<T: Clone> Clone for Generic2<T> {
9595
LL | |
@@ -100,7 +100,7 @@ LL | | }
100100
| |_^
101101
|
102102
note: consider deriving `Clone` or removing `Copy`
103-
--> tests/ui/derive.rs:90:1
103+
--> tests/ui/derive.rs:89:1
104104
|
105105
LL | / impl<T: Clone> Clone for Generic2<T> {
106106
LL | |

src/tools/clippy/tests/ui/needless_doc_main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
/// unimplemented!();
1010
/// }
1111
/// ```
12-
///
12+
///
1313
/// With an explicit return type it should lint too
1414
/// ```edition2015
1515
/// fn main() -> () {
1616
//~^ ERROR: needless `fn main` in doctest
1717
/// unimplemented!();
1818
/// }
1919
/// ```
20-
///
20+
///
2121
/// This should, too.
2222
/// ```rust
2323
/// fn main() {
2424
//~^ ERROR: needless `fn main` in doctest
2525
/// unimplemented!();
2626
/// }
2727
/// ```
28-
///
28+
///
2929
/// This one too.
3030
/// ```no_run
3131
/// // the fn is not always the first line

src/tools/clippy/tests/ui/needless_maybe_sized.fixed

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)