Skip to content

Commit aba6b13

Browse files
committed
Renames lint to redundant-sizedness-bound
- Changes name from needless-maybe-sized to redundant-sizedness-bound to reflect extended functionality.
1 parent fdfd2bc commit aba6b13

File tree

4 files changed

+72
-72
lines changed

4 files changed

+72
-72
lines changed

compiler/rustc_lint/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ mod lints;
6060
mod macro_expr_fragment_specifier_2024_migration;
6161
mod map_unit_fn;
6262
mod multiple_supertrait_upcastable;
63-
mod needless_maybe_sized;
6463
mod non_ascii_idents;
6564
mod non_fmt_panic;
6665
mod non_local_def;
@@ -72,6 +71,7 @@ mod passes;
7271
mod precedence;
7372
mod ptr_nulls;
7473
mod redundant_semicolon;
74+
mod redundant_sizedness_bound;
7575
mod reference_casting;
7676
mod shadowed_into_iter;
7777
mod static_mut_refs;
@@ -102,7 +102,6 @@ use lifetime_syntax::*;
102102
use macro_expr_fragment_specifier_2024_migration::*;
103103
use map_unit_fn::*;
104104
use multiple_supertrait_upcastable::*;
105-
use needless_maybe_sized::NeedlessMaybeSized;
106105
use non_ascii_idents::*;
107106
use non_fmt_panic::NonPanicFmt;
108107
use non_local_def::*;
@@ -113,6 +112,7 @@ use pass_by_value::*;
113112
use precedence::*;
114113
use ptr_nulls::*;
115114
use redundant_semicolon::*;
115+
use redundant_sizedness_bound::RedundantSizednessBound;
116116
use reference_casting::*;
117117
use rustc_hir::def_id::LocalModDefId;
118118
use rustc_middle::query::Providers;
@@ -249,7 +249,7 @@ late_lint_methods!(
249249
UnqualifiedLocalImports: UnqualifiedLocalImports,
250250
CheckTransmutes: CheckTransmutes,
251251
LifetimeSyntax: LifetimeSyntax,
252-
NeedlessMaybeSized: NeedlessMaybeSized,
252+
RedundantSizednessBound: RedundantSizednessBound,
253253
]
254254
]
255255
);

compiler/rustc_lint/src/needless_maybe_sized.rs renamed to compiler/rustc_lint/src/redundant_sizedness_bound.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_span::symbol::Ident;
1010
use crate::{LateContext, LateLintPass, LintContext};
1111

1212
declare_lint! {
13-
/// The `needless_maybe_sized` lint detects `?Sized` bounds applied to type parameters that cannot be unsized.
13+
/// The `redundant_sizedness_bound` lint detects `?Sized` bounds applied to type parameters that cannot be unsized.
1414
///
1515
/// ### Example
1616
///
@@ -25,11 +25,11 @@ declare_lint! {
2525
///
2626
/// The `?Sized` bound is misleading because it cannot be satisfied by an
2727
/// unsized type. This lint notifies the user of said redundant bound.
28-
pub NEEDLESS_MAYBE_SIZED,
28+
pub REDUNDANT_SIZEDNESS_BOUND,
2929
Warn,
3030
"a `?Sized` bound that is unusable due to a `Sized` requirement"
3131
}
32-
declare_lint_pass!(NeedlessMaybeSized => [NEEDLESS_MAYBE_SIZED]);
32+
declare_lint_pass!(RedundantSizednessBound => [REDUNDANT_SIZEDNESS_BOUND]);
3333

3434
struct Bound<'tcx> {
3535
/// The [`DefId`] of the type parameter the bound refers to
@@ -104,7 +104,7 @@ fn path_to_sized_bound(cx: &LateContext<'_>, trait_bound: &PolyTraitRef<'_>) ->
104104
search(cx, &mut path).then_some(path)
105105
}
106106

107-
impl LateLintPass<'_> for NeedlessMaybeSized {
107+
impl LateLintPass<'_> for RedundantSizednessBound {
108108
fn check_generics(&mut self, cx: &LateContext<'_>, generics: &Generics<'_>) {
109109
let Some(sized_trait) = cx.tcx.lang_items().sized_trait() else {
110110
return;
@@ -123,7 +123,7 @@ impl LateLintPass<'_> for NeedlessMaybeSized {
123123
&& let Some(sized_bound) = maybe_sized_params.get(&bound.param)
124124
&& let Some(path) = path_to_sized_bound(cx, bound.trait_bound)
125125
{
126-
cx.span_lint(NEEDLESS_MAYBE_SIZED, sized_bound.trait_bound.span, |diag| {
126+
cx.span_lint(REDUNDANT_SIZEDNESS_BOUND, sized_bound.trait_bound.span, |diag| {
127127
diag.primary_message(
128128
"`?Sized` bound is ignored because of a `Sized` requirement",
129129
);

tests/ui/lint/lint-needless-maybe-sized.rs renamed to tests/ui/lint/lint-redundant-sizedness-bound.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
#![deny(needless_maybe_sized)]
1+
#![deny(redundant_sizedness_bound)]
22

33
fn directly<T: Sized + ?Sized>(t: &T) {}
4-
//~^ ERROR needless_maybe_sized
4+
//~^ ERROR redundant_sizedness_bound
55

66
trait A: Sized {}
77
trait B: A {}
88

99
fn depth_1<T: A + ?Sized>(t: &T) {}
10-
//~^ ERROR needless_maybe_sized
10+
//~^ ERROR redundant_sizedness_bound
1111
fn depth_2<T: B + ?Sized>(t: &T) {}
12-
//~^ ERROR needless_maybe_sized
12+
//~^ ERROR redundant_sizedness_bound
1313

1414
// We only need to show one
1515
fn multiple_paths<T: A + B + ?Sized>(t: &T) {}
16-
//~^ ERROR needless_maybe_sized
16+
//~^ ERROR redundant_sizedness_bound
1717

1818
fn in_where<T>(t: &T)
1919
where
2020
T: Sized + ?Sized,
21-
//~^ ERROR needless_maybe_sized
21+
//~^ ERROR redundant_sizedness_bound
2222
{
2323
}
2424

2525
fn mixed_1<T: Sized>(t: &T)
2626
where
2727
T: ?Sized,
28-
//~^ ERROR needless_maybe_sized
28+
//~^ ERROR redundant_sizedness_bound
2929
{
3030
}
3131

3232
fn mixed_2<T: ?Sized>(t: &T)
33-
//~^ ERROR needless_maybe_sized
33+
//~^ ERROR redundant_sizedness_bound
3434
where
3535
T: Sized,
3636
{
@@ -40,50 +40,50 @@ fn mixed_3<T>(t: &T)
4040
where
4141
T: Sized,
4242
T: ?Sized,
43-
//~^ ERROR needless_maybe_sized
43+
//~^ ERROR redundant_sizedness_bound
4444
{
4545
}
4646

4747
struct Struct<T: Sized + ?Sized>(T);
48-
//~^ ERROR needless_maybe_sized
48+
//~^ ERROR redundant_sizedness_bound
4949

5050
impl<T: Sized + ?Sized> Struct<T> {
51-
//~^ ERROR needless_maybe_sized
51+
//~^ ERROR redundant_sizedness_bound
5252
fn method<U: Sized + ?Sized>(&self) {}
53-
//~^ ERROR needless_maybe_sized
53+
//~^ ERROR redundant_sizedness_bound
5454
}
5555

5656
enum Enum<T: Sized + ?Sized + 'static> {
57-
//~^ ERROR needless_maybe_sized
57+
//~^ ERROR redundant_sizedness_bound
5858
Variant(&'static T),
5959
}
6060

6161
union Union<'a, T: Sized + ?Sized> {
62-
//~^ ERROR needless_maybe_sized
62+
//~^ ERROR redundant_sizedness_bound
6363
a: &'a T,
6464
}
6565

6666
trait Trait<T: Sized + ?Sized> {
67-
//~^ ERROR needless_maybe_sized
67+
//~^ ERROR redundant_sizedness_bound
6868
fn trait_method<U: Sized + ?Sized>() {}
69-
//~^ ERROR needless_maybe_sized
69+
//~^ ERROR redundant_sizedness_bound
7070

7171
type GAT<U: Sized + ?Sized>;
72-
//~^ ERROR needless_maybe_sized
72+
//~^ ERROR redundant_sizedness_bound
7373

7474
type Assoc: Sized + ?Sized; // False negative
7575
}
7676

7777
trait SecondInTrait: Send + Sized {}
7878
fn second_in_trait<T: ?Sized + SecondInTrait>() {}
79-
//~^ ERROR needless_maybe_sized
79+
//~^ ERROR redundant_sizedness_bound
8080

8181
fn impl_trait(_: &(impl Sized + ?Sized)) {}
82-
//~^ ERROR needless_maybe_sized
82+
//~^ ERROR redundant_sizedness_bound
8383

8484
trait GenericTrait<T>: Sized {}
8585
fn in_generic_trait<T: GenericTrait<U> + ?Sized, U>() {}
86-
//~^ ERROR needless_maybe_sized
86+
//~^ ERROR redundant_sizedness_bound
8787

8888
mod larger_graph {
8989
// C1 C2 Sized
@@ -99,7 +99,7 @@ mod larger_graph {
9999
trait A1: B1 + B2 {}
100100

101101
fn larger_graph<T: A1 + ?Sized>() {}
102-
//~^ ERROR needless_maybe_sized
102+
//~^ ERROR redundant_sizedness_bound
103103
}
104104

105105
// Should not lint

0 commit comments

Comments
 (0)