Auto merge of #10632 - Alexendoo:needless-maybe-sized, r=Jarcho
Add `needless_maybe_sized` lint changelog: new lint: [`needless_maybe_sized`] Closes #10600
This commit is contained in:
commit
6cfd4ac955
12 changed files with 771 additions and 10 deletions
|
|
@ -58,7 +58,7 @@ fn group_with_span(delimiter: Delimiter, stream: TokenStream, span: Span) -> Gro
|
|||
const ESCAPE_CHAR: char = '$';
|
||||
|
||||
/// Takes a single token followed by a sequence of tokens. Returns the sequence of tokens with their
|
||||
/// span set to that of the first token. Tokens may be escaped with either `#ident` or `#(tokens)`.
|
||||
/// span set to that of the first token. Tokens may be escaped with either `$ident` or `$(tokens)`.
|
||||
#[proc_macro]
|
||||
pub fn with_span(input: TokenStream) -> TokenStream {
|
||||
let mut iter = input.into_iter();
|
||||
|
|
@ -72,7 +72,7 @@ pub fn with_span(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
|
||||
/// Takes a sequence of tokens and return the tokens with the span set such that they appear to be
|
||||
/// from an external macro. Tokens may be escaped with either `#ident` or `#(tokens)`.
|
||||
/// from an external macro. Tokens may be escaped with either `$ident` or `$(tokens)`.
|
||||
#[proc_macro]
|
||||
pub fn external(input: TokenStream) -> TokenStream {
|
||||
let mut res = TokenStream::new();
|
||||
|
|
@ -84,7 +84,7 @@ pub fn external(input: TokenStream) -> TokenStream {
|
|||
}
|
||||
|
||||
/// Copies all the tokens, replacing all their spans with the given span. Tokens can be escaped
|
||||
/// either by `#ident` or `#(tokens)`.
|
||||
/// either by `$ident` or `$(tokens)`.
|
||||
fn write_with_span(s: Span, mut input: IntoIter, out: &mut TokenStream) -> Result<()> {
|
||||
while let Some(tt) = input.next() {
|
||||
match tt {
|
||||
|
|
|
|||
116
tests/ui/needless_maybe_sized.fixed
Normal file
116
tests/ui/needless_maybe_sized.fixed
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
//@aux-build:proc_macros.rs
|
||||
|
||||
#![allow(unused, clippy::multiple_bound_locations)]
|
||||
#![warn(clippy::needless_maybe_sized)]
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::external;
|
||||
|
||||
fn directly<T: Sized>(t: &T) {}
|
||||
|
||||
trait A: Sized {}
|
||||
trait B: A {}
|
||||
|
||||
fn depth_1<T: A>(t: &T) {}
|
||||
fn depth_2<T: B>(t: &T) {}
|
||||
|
||||
// We only need to show one
|
||||
fn multiple_paths<T: A + B>(t: &T) {}
|
||||
|
||||
fn in_where<T>(t: &T)
|
||||
where
|
||||
T: Sized,
|
||||
{
|
||||
}
|
||||
|
||||
fn mixed_1<T: Sized>(t: &T)
|
||||
{
|
||||
}
|
||||
|
||||
fn mixed_2<T>(t: &T)
|
||||
where
|
||||
T: Sized,
|
||||
{
|
||||
}
|
||||
|
||||
fn mixed_3<T>(t: &T)
|
||||
where
|
||||
T: Sized,
|
||||
{
|
||||
}
|
||||
|
||||
struct Struct<T: Sized>(T);
|
||||
|
||||
impl<T: Sized> Struct<T> {
|
||||
fn method<U: Sized>(&self) {}
|
||||
}
|
||||
|
||||
enum Enum<T: Sized + 'static> {
|
||||
Variant(&'static T),
|
||||
}
|
||||
|
||||
union Union<'a, T: Sized> {
|
||||
a: &'a T,
|
||||
}
|
||||
|
||||
trait Trait<T: Sized> {
|
||||
fn trait_method<U: Sized>() {}
|
||||
|
||||
type GAT<U: Sized>;
|
||||
|
||||
type Assoc: Sized + ?Sized; // False negative
|
||||
}
|
||||
|
||||
trait SecondInTrait: Send + Sized {}
|
||||
fn second_in_trait<T: SecondInTrait>() {}
|
||||
|
||||
fn impl_trait(_: &(impl Sized)) {}
|
||||
|
||||
trait GenericTrait<T>: Sized {}
|
||||
fn in_generic_trait<T: GenericTrait<U>, U>() {}
|
||||
|
||||
mod larger_graph {
|
||||
// C1 C2 Sized
|
||||
// \ /\ /
|
||||
// B1 B2
|
||||
// \ /
|
||||
// A1
|
||||
|
||||
trait C1 {}
|
||||
trait C2 {}
|
||||
trait B1: C1 + C2 {}
|
||||
trait B2: C2 + Sized {}
|
||||
trait A1: B1 + B2 {}
|
||||
|
||||
fn larger_graph<T: A1>() {}
|
||||
}
|
||||
|
||||
// Should not lint
|
||||
|
||||
fn sized<T: Sized>() {}
|
||||
fn maybe_sized<T: ?Sized>() {}
|
||||
|
||||
struct SeparateBounds<T: ?Sized>(T);
|
||||
impl<T: Sized> SeparateBounds<T> {}
|
||||
|
||||
trait P {}
|
||||
trait Q: P {}
|
||||
|
||||
fn ok_depth_1<T: P + ?Sized>() {}
|
||||
fn ok_depth_2<T: Q + ?Sized>() {}
|
||||
|
||||
external! {
|
||||
fn in_macro<T: Clone + ?Sized>(t: &T) {}
|
||||
|
||||
fn with_local_clone<T: $Clone + ?Sized>(t: &T) {}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct InDerive<T: ?Sized> {
|
||||
t: T,
|
||||
}
|
||||
|
||||
struct Refined<T: ?Sized>(T);
|
||||
impl<T: Sized> Refined<T> {}
|
||||
|
||||
fn main() {}
|
||||
119
tests/ui/needless_maybe_sized.rs
Normal file
119
tests/ui/needless_maybe_sized.rs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
//@aux-build:proc_macros.rs
|
||||
|
||||
#![allow(unused, clippy::multiple_bound_locations)]
|
||||
#![warn(clippy::needless_maybe_sized)]
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::external;
|
||||
|
||||
fn directly<T: Sized + ?Sized>(t: &T) {}
|
||||
|
||||
trait A: Sized {}
|
||||
trait B: A {}
|
||||
|
||||
fn depth_1<T: A + ?Sized>(t: &T) {}
|
||||
fn depth_2<T: B + ?Sized>(t: &T) {}
|
||||
|
||||
// We only need to show one
|
||||
fn multiple_paths<T: A + B + ?Sized>(t: &T) {}
|
||||
|
||||
fn in_where<T>(t: &T)
|
||||
where
|
||||
T: Sized + ?Sized,
|
||||
{
|
||||
}
|
||||
|
||||
fn mixed_1<T: Sized>(t: &T)
|
||||
where
|
||||
T: ?Sized,
|
||||
{
|
||||
}
|
||||
|
||||
fn mixed_2<T: ?Sized>(t: &T)
|
||||
where
|
||||
T: Sized,
|
||||
{
|
||||
}
|
||||
|
||||
fn mixed_3<T>(t: &T)
|
||||
where
|
||||
T: Sized,
|
||||
T: ?Sized,
|
||||
{
|
||||
}
|
||||
|
||||
struct Struct<T: Sized + ?Sized>(T);
|
||||
|
||||
impl<T: Sized + ?Sized> Struct<T> {
|
||||
fn method<U: Sized + ?Sized>(&self) {}
|
||||
}
|
||||
|
||||
enum Enum<T: Sized + ?Sized + 'static> {
|
||||
Variant(&'static T),
|
||||
}
|
||||
|
||||
union Union<'a, T: Sized + ?Sized> {
|
||||
a: &'a T,
|
||||
}
|
||||
|
||||
trait Trait<T: Sized + ?Sized> {
|
||||
fn trait_method<U: Sized + ?Sized>() {}
|
||||
|
||||
type GAT<U: Sized + ?Sized>;
|
||||
|
||||
type Assoc: Sized + ?Sized; // False negative
|
||||
}
|
||||
|
||||
trait SecondInTrait: Send + Sized {}
|
||||
fn second_in_trait<T: ?Sized + SecondInTrait>() {}
|
||||
|
||||
fn impl_trait(_: &(impl Sized + ?Sized)) {}
|
||||
|
||||
trait GenericTrait<T>: Sized {}
|
||||
fn in_generic_trait<T: GenericTrait<U> + ?Sized, U>() {}
|
||||
|
||||
mod larger_graph {
|
||||
// C1 C2 Sized
|
||||
// \ /\ /
|
||||
// B1 B2
|
||||
// \ /
|
||||
// A1
|
||||
|
||||
trait C1 {}
|
||||
trait C2 {}
|
||||
trait B1: C1 + C2 {}
|
||||
trait B2: C2 + Sized {}
|
||||
trait A1: B1 + B2 {}
|
||||
|
||||
fn larger_graph<T: A1 + ?Sized>() {}
|
||||
}
|
||||
|
||||
// Should not lint
|
||||
|
||||
fn sized<T: Sized>() {}
|
||||
fn maybe_sized<T: ?Sized>() {}
|
||||
|
||||
struct SeparateBounds<T: ?Sized>(T);
|
||||
impl<T: Sized> SeparateBounds<T> {}
|
||||
|
||||
trait P {}
|
||||
trait Q: P {}
|
||||
|
||||
fn ok_depth_1<T: P + ?Sized>() {}
|
||||
fn ok_depth_2<T: Q + ?Sized>() {}
|
||||
|
||||
external! {
|
||||
fn in_macro<T: Clone + ?Sized>(t: &T) {}
|
||||
|
||||
fn with_local_clone<T: $Clone + ?Sized>(t: &T) {}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct InDerive<T: ?Sized> {
|
||||
t: T,
|
||||
}
|
||||
|
||||
struct Refined<T: ?Sized>(T);
|
||||
impl<T: Sized> Refined<T> {}
|
||||
|
||||
fn main() {}
|
||||
353
tests/ui/needless_maybe_sized.stderr
Normal file
353
tests/ui/needless_maybe_sized.stderr
Normal file
|
|
@ -0,0 +1,353 @@
|
|||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:9:24
|
||||
|
|
||||
LL | fn directly<T: Sized + ?Sized>(t: &T) {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:9:16
|
||||
|
|
||||
LL | fn directly<T: Sized + ?Sized>(t: &T) {}
|
||||
| ^^^^^
|
||||
= note: `-D clippy::needless-maybe-sized` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::needless_maybe_sized)]`
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn directly<T: Sized + ?Sized>(t: &T) {}
|
||||
LL + fn directly<T: Sized>(t: &T) {}
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:14:19
|
||||
|
|
||||
LL | fn depth_1<T: A + ?Sized>(t: &T) {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:14:15
|
||||
|
|
||||
LL | fn depth_1<T: A + ?Sized>(t: &T) {}
|
||||
| ^
|
||||
= note: ...because `A` has the bound `Sized`
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn depth_1<T: A + ?Sized>(t: &T) {}
|
||||
LL + fn depth_1<T: A>(t: &T) {}
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:15:19
|
||||
|
|
||||
LL | fn depth_2<T: B + ?Sized>(t: &T) {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:15:15
|
||||
|
|
||||
LL | fn depth_2<T: B + ?Sized>(t: &T) {}
|
||||
| ^
|
||||
= note: ...because `B` has the bound `A`
|
||||
= note: ...because `A` has the bound `Sized`
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn depth_2<T: B + ?Sized>(t: &T) {}
|
||||
LL + fn depth_2<T: B>(t: &T) {}
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:18:30
|
||||
|
|
||||
LL | fn multiple_paths<T: A + B + ?Sized>(t: &T) {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:18:22
|
||||
|
|
||||
LL | fn multiple_paths<T: A + B + ?Sized>(t: &T) {}
|
||||
| ^
|
||||
= note: ...because `A` has the bound `Sized`
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn multiple_paths<T: A + B + ?Sized>(t: &T) {}
|
||||
LL + fn multiple_paths<T: A + B>(t: &T) {}
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:22:16
|
||||
|
|
||||
LL | T: Sized + ?Sized,
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:22:8
|
||||
|
|
||||
LL | T: Sized + ?Sized,
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - T: Sized + ?Sized,
|
||||
LL + T: Sized,
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:28:8
|
||||
|
|
||||
LL | T: ?Sized,
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:26:15
|
||||
|
|
||||
LL | fn mixed_1<T: Sized>(t: &T)
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - where
|
||||
LL - T: ?Sized,
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:32:15
|
||||
|
|
||||
LL | fn mixed_2<T: ?Sized>(t: &T)
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:34:8
|
||||
|
|
||||
LL | T: Sized,
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn mixed_2<T: ?Sized>(t: &T)
|
||||
LL + fn mixed_2<T>(t: &T)
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:41:8
|
||||
|
|
||||
LL | T: ?Sized,
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:40:8
|
||||
|
|
||||
LL | T: Sized,
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - T: Sized,
|
||||
LL - T: ?Sized,
|
||||
LL + T: Sized,
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:45:26
|
||||
|
|
||||
LL | struct Struct<T: Sized + ?Sized>(T);
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:45:18
|
||||
|
|
||||
LL | struct Struct<T: Sized + ?Sized>(T);
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - struct Struct<T: Sized + ?Sized>(T);
|
||||
LL + struct Struct<T: Sized>(T);
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:47:17
|
||||
|
|
||||
LL | impl<T: Sized + ?Sized> Struct<T> {
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:47:9
|
||||
|
|
||||
LL | impl<T: Sized + ?Sized> Struct<T> {
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - impl<T: Sized + ?Sized> Struct<T> {
|
||||
LL + impl<T: Sized> Struct<T> {
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:48:26
|
||||
|
|
||||
LL | fn method<U: Sized + ?Sized>(&self) {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `U` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:48:18
|
||||
|
|
||||
LL | fn method<U: Sized + ?Sized>(&self) {}
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn method<U: Sized + ?Sized>(&self) {}
|
||||
LL + fn method<U: Sized>(&self) {}
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:51:22
|
||||
|
|
||||
LL | enum Enum<T: Sized + ?Sized + 'static> {
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:51:14
|
||||
|
|
||||
LL | enum Enum<T: Sized + ?Sized + 'static> {
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - enum Enum<T: Sized + ?Sized + 'static> {
|
||||
LL + enum Enum<T: Sized + 'static> {
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:55:28
|
||||
|
|
||||
LL | union Union<'a, T: Sized + ?Sized> {
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:55:20
|
||||
|
|
||||
LL | union Union<'a, T: Sized + ?Sized> {
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - union Union<'a, T: Sized + ?Sized> {
|
||||
LL + union Union<'a, T: Sized> {
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:59:24
|
||||
|
|
||||
LL | trait Trait<T: Sized + ?Sized> {
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:59:16
|
||||
|
|
||||
LL | trait Trait<T: Sized + ?Sized> {
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - trait Trait<T: Sized + ?Sized> {
|
||||
LL + trait Trait<T: Sized> {
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:60:32
|
||||
|
|
||||
LL | fn trait_method<U: Sized + ?Sized>() {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `U` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:60:24
|
||||
|
|
||||
LL | fn trait_method<U: Sized + ?Sized>() {}
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn trait_method<U: Sized + ?Sized>() {}
|
||||
LL + fn trait_method<U: Sized>() {}
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:62:25
|
||||
|
|
||||
LL | type GAT<U: Sized + ?Sized>;
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `U` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:62:17
|
||||
|
|
||||
LL | type GAT<U: Sized + ?Sized>;
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - type GAT<U: Sized + ?Sized>;
|
||||
LL + type GAT<U: Sized>;
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:68:23
|
||||
|
|
||||
LL | fn second_in_trait<T: ?Sized + SecondInTrait>() {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:68:32
|
||||
|
|
||||
LL | fn second_in_trait<T: ?Sized + SecondInTrait>() {}
|
||||
| ^^^^^^^^^^^^^
|
||||
= note: ...because `SecondInTrait` has the bound `Sized`
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn second_in_trait<T: ?Sized + SecondInTrait>() {}
|
||||
LL + fn second_in_trait<T: SecondInTrait>() {}
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:70:33
|
||||
|
|
||||
LL | fn impl_trait(_: &(impl Sized + ?Sized)) {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `impl Sized + ?Sized` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:70:25
|
||||
|
|
||||
LL | fn impl_trait(_: &(impl Sized + ?Sized)) {}
|
||||
| ^^^^^
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn impl_trait(_: &(impl Sized + ?Sized)) {}
|
||||
LL + fn impl_trait(_: &(impl Sized)) {}
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:73:42
|
||||
|
|
||||
LL | fn in_generic_trait<T: GenericTrait<U> + ?Sized, U>() {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:73:24
|
||||
|
|
||||
LL | fn in_generic_trait<T: GenericTrait<U> + ?Sized, U>() {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
= note: ...because `GenericTrait` has the bound `Sized`
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn in_generic_trait<T: GenericTrait<U> + ?Sized, U>() {}
|
||||
LL + fn in_generic_trait<T: GenericTrait<U>, U>() {}
|
||||
|
|
||||
|
||||
error: `?Sized` bound is ignored because of a `Sized` requirement
|
||||
--> tests/ui/needless_maybe_sized.rs:88:29
|
||||
|
|
||||
LL | fn larger_graph<T: A1 + ?Sized>() {}
|
||||
| ^^^^^^
|
||||
|
|
||||
note: `T` cannot be unsized because of the bound
|
||||
--> tests/ui/needless_maybe_sized.rs:88:24
|
||||
|
|
||||
LL | fn larger_graph<T: A1 + ?Sized>() {}
|
||||
| ^^
|
||||
= note: ...because `A1` has the bound `B2`
|
||||
= note: ...because `B2` has the bound `Sized`
|
||||
help: change the bounds that require `Sized`, or remove the `?Sized` bound
|
||||
|
|
||||
LL - fn larger_graph<T: A1 + ?Sized>() {}
|
||||
LL + fn larger_graph<T: A1>() {}
|
||||
|
|
||||
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
|
|
@ -1,5 +1,9 @@
|
|||
#![deny(clippy::type_repetition_in_bounds)]
|
||||
#![allow(clippy::extra_unused_type_parameters, clippy::multiple_bound_locations)]
|
||||
#![allow(
|
||||
clippy::extra_unused_type_parameters,
|
||||
clippy::multiple_bound_locations,
|
||||
clippy::needless_maybe_sized
|
||||
)]
|
||||
|
||||
use serde::Deserialize;
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this type has already been used as a bound predicate
|
||||
--> tests/ui/type_repetition_in_bounds.rs:10:5
|
||||
--> tests/ui/type_repetition_in_bounds.rs:14:5
|
||||
|
|
||||
LL | T: Clone,
|
||||
| ^^^^^^^^
|
||||
|
|
@ -12,7 +12,7 @@ LL | #![deny(clippy::type_repetition_in_bounds)]
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this type has already been used as a bound predicate
|
||||
--> tests/ui/type_repetition_in_bounds.rs:28:5
|
||||
--> tests/ui/type_repetition_in_bounds.rs:32:5
|
||||
|
|
||||
LL | Self: Copy + Default + Ord,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -20,7 +20,7 @@ LL | Self: Copy + Default + Ord,
|
|||
= help: consider combining the bounds: `Self: Clone + Copy + Default + Ord`
|
||||
|
||||
error: this type has already been used as a bound predicate
|
||||
--> tests/ui/type_repetition_in_bounds.rs:103:5
|
||||
--> tests/ui/type_repetition_in_bounds.rs:107:5
|
||||
|
|
||||
LL | T: Clone,
|
||||
| ^^^^^^^^
|
||||
|
|
@ -28,7 +28,7 @@ LL | T: Clone,
|
|||
= help: consider combining the bounds: `T: ?Sized + Clone`
|
||||
|
||||
error: this type has already been used as a bound predicate
|
||||
--> tests/ui/type_repetition_in_bounds.rs:109:5
|
||||
--> tests/ui/type_repetition_in_bounds.rs:113:5
|
||||
|
|
||||
LL | T: ?Sized,
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -36,7 +36,7 @@ LL | T: ?Sized,
|
|||
= help: consider combining the bounds: `T: Clone + ?Sized`
|
||||
|
||||
error: this type has already been used as a bound predicate
|
||||
--> tests/ui/type_repetition_in_bounds.rs:135:9
|
||||
--> tests/ui/type_repetition_in_bounds.rs:139:9
|
||||
|
|
||||
LL | T: Trait<Option<usize>, Box<[String]>, bool> + 'static,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue