mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 05:03:21 +00:00
Add extra_unused_type_parameters
lint
This commit is contained in:
parent
006a4cc767
commit
fba16e2e3a
19 changed files with 384 additions and 66 deletions
|
@ -4383,6 +4383,7 @@ Released 2018-09-13
|
|||
[`extend_from_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_from_slice
|
||||
[`extend_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_with_drain
|
||||
[`extra_unused_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
|
||||
[`extra_unused_type_parameters`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_parameters
|
||||
[`fallible_impl_from`]: https://rust-lang.github.io/rust-clippy/master/index.html#fallible_impl_from
|
||||
[`field_reassign_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
|
||||
[`filetype_is_file`]: https://rust-lang.github.io/rust-clippy/master/index.html#filetype_is_file
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
|
||||
|
||||
[There are over 550 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
|
||||
[There are over 600 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
|
||||
|
||||
Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html).
|
||||
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
A collection of lints to catch common mistakes and improve your
|
||||
[Rust](https://github.com/rust-lang/rust) code.
|
||||
|
||||
[There are over 550 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
|
||||
[There are over 600 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
|
||||
|
||||
Lints are divided into categories, each with a default [lint
|
||||
level](https://doc.rust-lang.org/rustc/lints/levels.html). You can choose how
|
||||
|
|
|
@ -156,6 +156,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
|
|||
crate::exhaustive_items::EXHAUSTIVE_STRUCTS_INFO,
|
||||
crate::exit::EXIT_INFO,
|
||||
crate::explicit_write::EXPLICIT_WRITE_INFO,
|
||||
crate::extra_unused_type_parameters::EXTRA_UNUSED_TYPE_PARAMETERS_INFO,
|
||||
crate::fallible_impl_from::FALLIBLE_IMPL_FROM_INFO,
|
||||
crate::float_literal::EXCESSIVE_PRECISION_INFO,
|
||||
crate::float_literal::LOSSY_FLOAT_LITERAL_INFO,
|
||||
|
|
178
clippy_lints/src/extra_unused_type_parameters.rs
Normal file
178
clippy_lints/src/extra_unused_type_parameters.rs
Normal file
|
@ -0,0 +1,178 @@
|
|||
use clippy_utils::diagnostics::span_lint_and_help;
|
||||
use clippy_utils::trait_ref_of_method;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::MultiSpan;
|
||||
use rustc_hir::intravisit::{walk_impl_item, walk_item, walk_param_bound, walk_ty, Visitor};
|
||||
use rustc_hir::{
|
||||
GenericParamKind, Generics, ImplItem, ImplItemKind, Item, ItemKind, PredicateOrigin, Ty, TyKind, WherePredicate,
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::hir::nested_filter;
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
use rustc_span::{def_id::DefId, Span};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
/// Checks for type parameters in generics that are never used anywhere else.
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
/// Functions cannot infer the value of unused type parameters; therefore, calling them
|
||||
/// requires using a turbofish, which serves no purpose but to satisfy the compiler.
|
||||
///
|
||||
/// ### Example
|
||||
/// ```rust
|
||||
/// // unused type parameters
|
||||
/// fn unused_ty<T>(x: u8) {
|
||||
/// // ..
|
||||
/// }
|
||||
/// ```
|
||||
/// Use instead:
|
||||
/// ```rust
|
||||
/// fn no_unused_ty(x: u8) {
|
||||
/// // ..
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.69.0"]
|
||||
pub EXTRA_UNUSED_TYPE_PARAMETERS,
|
||||
complexity,
|
||||
"unused type parameters in function definitions"
|
||||
}
|
||||
declare_lint_pass!(ExtraUnusedTypeParameters => [EXTRA_UNUSED_TYPE_PARAMETERS]);
|
||||
|
||||
/// A visitor struct that walks a given function and gathers generic type parameters, plus any
|
||||
/// trait bounds those parameters have.
|
||||
struct TypeWalker<'cx, 'tcx> {
|
||||
cx: &'cx LateContext<'tcx>,
|
||||
/// Collection of all the type parameters and their spans.
|
||||
ty_params: FxHashMap<DefId, Span>,
|
||||
/// Collection of any (inline) trait bounds corresponding to each type parameter.
|
||||
bounds: FxHashMap<DefId, Span>,
|
||||
/// The entire `Generics` object of the function, useful for querying purposes.
|
||||
generics: &'tcx Generics<'tcx>,
|
||||
/// The value of this will remain `true` if *every* parameter:
|
||||
/// 1. Is a type parameter, and
|
||||
/// 2. Goes unused in the function.
|
||||
/// Otherwise, if any type parameters end up being used, or if any lifetime or const-generic
|
||||
/// parameters are present, this will be set to `false`.
|
||||
all_params_unused: bool,
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx> TypeWalker<'cx, 'tcx> {
|
||||
fn new(cx: &'cx LateContext<'tcx>, generics: &'tcx Generics<'tcx>) -> Self {
|
||||
let mut all_params_unused = true;
|
||||
let ty_params = generics
|
||||
.params
|
||||
.iter()
|
||||
.filter_map(|param| {
|
||||
if let GenericParamKind::Type { .. } = param.kind {
|
||||
Some((param.def_id.into(), param.span))
|
||||
} else {
|
||||
if !param.is_elided_lifetime() {
|
||||
all_params_unused = false;
|
||||
}
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
Self {
|
||||
cx,
|
||||
ty_params,
|
||||
bounds: FxHashMap::default(),
|
||||
generics,
|
||||
all_params_unused,
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_lint(&self) {
|
||||
let (msg, help) = match self.ty_params.len() {
|
||||
0 => return,
|
||||
1 => (
|
||||
"type parameter goes unused in function definition",
|
||||
"consider removing the parameter",
|
||||
),
|
||||
_ => (
|
||||
"type parameters go unused in function definition",
|
||||
"consider removing the parameters",
|
||||
),
|
||||
};
|
||||
|
||||
let source_map = self.cx.tcx.sess.source_map();
|
||||
let span = if self.all_params_unused {
|
||||
self.generics.span.into() // Remove the entire list of generics
|
||||
} else {
|
||||
MultiSpan::from_spans(
|
||||
self.ty_params
|
||||
.iter()
|
||||
.map(|(def_id, &span)| {
|
||||
// Extend the span past any trait bounds, and include the comma at the end.
|
||||
let span_to_extend = self.bounds.get(def_id).copied().map_or(span, Span::shrink_to_hi);
|
||||
let comma_range = source_map.span_extend_to_next_char(span_to_extend, '>', false);
|
||||
let comma_span = source_map.span_through_char(comma_range, ',');
|
||||
span.with_hi(comma_span.hi())
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
};
|
||||
|
||||
span_lint_and_help(self.cx, EXTRA_UNUSED_TYPE_PARAMETERS, span, msg, None, help);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx> Visitor<'tcx> for TypeWalker<'cx, 'tcx> {
|
||||
type NestedFilter = nested_filter::OnlyBodies;
|
||||
|
||||
fn visit_ty(&mut self, t: &'tcx Ty<'tcx>) {
|
||||
if let Some((def_id, _)) = t.peel_refs().as_generic_param() {
|
||||
if self.ty_params.remove(&def_id).is_some() {
|
||||
self.all_params_unused = false;
|
||||
}
|
||||
} else if let TyKind::OpaqueDef(id, _, _) = t.kind {
|
||||
// Explicitly walk OpaqueDef. Normally `walk_ty` would do the job, but it calls
|
||||
// `visit_nested_item`, which checks that `Self::NestedFilter::INTER` is set. We're
|
||||
// using `OnlyBodies`, so the check ends up failing and the type isn't fully walked.
|
||||
let item = self.nested_visit_map().item(id);
|
||||
walk_item(self, item);
|
||||
} else {
|
||||
walk_ty(self, t);
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_where_predicate(&mut self, predicate: &'tcx WherePredicate<'tcx>) {
|
||||
if let WherePredicate::BoundPredicate(predicate) = predicate {
|
||||
// Collect spans for bounds that appear in the list of generics (not in a where-clause)
|
||||
// for use in forming the help message
|
||||
if let Some((def_id, _)) = predicate.bounded_ty.peel_refs().as_generic_param()
|
||||
&& let PredicateOrigin::GenericParam = predicate.origin
|
||||
{
|
||||
self.bounds.insert(def_id, predicate.span);
|
||||
}
|
||||
// Only walk the right-hand side of where-bounds
|
||||
for bound in predicate.bounds {
|
||||
walk_param_bound(self, bound);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn nested_visit_map(&mut self) -> Self::Map {
|
||||
self.cx.tcx.hir()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for ExtraUnusedTypeParameters {
|
||||
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
|
||||
if let ItemKind::Fn(_, generics, _) = item.kind {
|
||||
let mut walker = TypeWalker::new(cx, generics);
|
||||
walk_item(&mut walker, item);
|
||||
walker.emit_lint();
|
||||
}
|
||||
}
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'tcx>) {
|
||||
// Only lint on inherent methods, not trait methods.
|
||||
if let ImplItemKind::Fn(..) = item.kind && trait_ref_of_method(cx, item.owner_id.def_id).is_none() {
|
||||
let mut walker = TypeWalker::new(cx, item.generics);
|
||||
walk_impl_item(&mut walker, item);
|
||||
walker.emit_lint();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -122,6 +122,7 @@ mod excessive_bools;
|
|||
mod exhaustive_items;
|
||||
mod exit;
|
||||
mod explicit_write;
|
||||
mod extra_unused_type_parameters;
|
||||
mod fallible_impl_from;
|
||||
mod float_literal;
|
||||
mod floating_point_arithmetic;
|
||||
|
@ -910,6 +911,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
|
|||
store.register_late_pass(|_| Box::new(permissions_set_readonly_false::PermissionsSetReadonlyFalse));
|
||||
store.register_late_pass(|_| Box::new(size_of_ref::SizeOfRef));
|
||||
store.register_late_pass(|_| Box::new(multiple_unsafe_ops_per_block::MultipleUnsafeOpsPerBlock));
|
||||
store.register_late_pass(|_| Box::new(extra_unused_type_parameters::ExtraUnusedTypeParameters));
|
||||
// add lints here, do not remove this comment, it's used in `new_lint`
|
||||
}
|
||||
|
||||
|
|
69
tests/ui/extra_unused_type_parameters.rs
Normal file
69
tests/ui/extra_unused_type_parameters.rs
Normal file
|
@ -0,0 +1,69 @@
|
|||
#![allow(unused, clippy::needless_lifetimes)]
|
||||
#![warn(clippy::extra_unused_type_parameters)]
|
||||
|
||||
fn unused_ty<T>(x: u8) {}
|
||||
|
||||
fn unused_multi<T, U>(x: u8) {}
|
||||
|
||||
fn unused_with_lt<'a, T>(x: &'a u8) {}
|
||||
|
||||
fn used_ty<T>(x: T, y: u8) {}
|
||||
|
||||
fn used_ref<'a, T>(x: &'a T) {}
|
||||
|
||||
fn used_ret<T: Default>(x: u8) -> T {
|
||||
T::default()
|
||||
}
|
||||
|
||||
fn unused_bounded<T: Default, U>(x: U) {}
|
||||
|
||||
fn unused_where_clause<T, U>(x: U)
|
||||
where
|
||||
T: Default,
|
||||
{
|
||||
}
|
||||
|
||||
fn some_unused<A, B, C, D: Iterator<Item = (B, C)>, E>(b: B, c: C) {}
|
||||
|
||||
fn used_opaque<A>(iter: impl Iterator<Item = A>) -> usize {
|
||||
iter.count()
|
||||
}
|
||||
|
||||
fn used_ret_opaque<A>() -> impl Iterator<Item = A> {
|
||||
std::iter::empty()
|
||||
}
|
||||
|
||||
fn used_vec_box<T>(x: Vec<Box<T>>) {}
|
||||
|
||||
fn used_body<T: Default + ToString>() -> String {
|
||||
T::default().to_string()
|
||||
}
|
||||
|
||||
fn used_closure<T: Default + ToString>() -> impl Fn() {
|
||||
|| println!("{}", T::default().to_string())
|
||||
}
|
||||
|
||||
struct S;
|
||||
|
||||
impl S {
|
||||
fn unused_ty_impl<T>(&self) {}
|
||||
}
|
||||
|
||||
// Don't lint on trait methods
|
||||
trait Foo {
|
||||
fn bar<T>(&self);
|
||||
}
|
||||
|
||||
impl Foo for S {
|
||||
fn bar<T>(&self) {}
|
||||
}
|
||||
|
||||
fn skip_index<A, Iter>(iter: Iter, index: usize) -> impl Iterator<Item = A>
|
||||
where
|
||||
Iter: Iterator<Item = A>,
|
||||
{
|
||||
iter.enumerate()
|
||||
.filter_map(move |(i, a)| if i == index { None } else { Some(a) })
|
||||
}
|
||||
|
||||
fn main() {}
|
59
tests/ui/extra_unused_type_parameters.stderr
Normal file
59
tests/ui/extra_unused_type_parameters.stderr
Normal file
|
@ -0,0 +1,59 @@
|
|||
error: type parameter goes unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:4:13
|
||||
|
|
||||
LL | fn unused_ty<T>(x: u8) {}
|
||||
| ^^^
|
||||
|
|
||||
= help: consider removing the parameter
|
||||
= note: `-D clippy::extra-unused-type-parameters` implied by `-D warnings`
|
||||
|
||||
error: type parameters go unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:6:16
|
||||
|
|
||||
LL | fn unused_multi<T, U>(x: u8) {}
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: consider removing the parameters
|
||||
|
||||
error: type parameter goes unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:8:23
|
||||
|
|
||||
LL | fn unused_with_lt<'a, T>(x: &'a u8) {}
|
||||
| ^
|
||||
|
|
||||
= help: consider removing the parameter
|
||||
|
||||
error: type parameter goes unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:18:19
|
||||
|
|
||||
LL | fn unused_bounded<T: Default, U>(x: U) {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= help: consider removing the parameter
|
||||
|
||||
error: type parameter goes unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:20:24
|
||||
|
|
||||
LL | fn unused_where_clause<T, U>(x: U)
|
||||
| ^^
|
||||
|
|
||||
= help: consider removing the parameter
|
||||
|
||||
error: type parameters go unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:26:16
|
||||
|
|
||||
LL | fn some_unused<A, B, C, D: Iterator<Item = (B, C)>, E>(b: B, c: C) {}
|
||||
| ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^
|
||||
|
|
||||
= help: consider removing the parameters
|
||||
|
||||
error: type parameter goes unused in function definition
|
||||
--> $DIR/extra_unused_type_parameters.rs:49:22
|
||||
|
|
||||
LL | fn unused_ty_impl<T>(&self) {}
|
||||
| ^^^
|
||||
|
|
||||
= help: consider removing the parameter
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
#![allow(
|
||||
unused,
|
||||
clippy::boxed_local,
|
||||
clippy::extra_unused_type_parameters,
|
||||
clippy::needless_pass_by_value,
|
||||
clippy::unnecessary_wraps,
|
||||
dyn_drop,
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#![allow(
|
||||
unused,
|
||||
clippy::boxed_local,
|
||||
clippy::extra_unused_type_parameters,
|
||||
clippy::needless_pass_by_value,
|
||||
clippy::unnecessary_wraps,
|
||||
dyn_drop,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: the following explicit lifetimes could be elided: 'a, 'b
|
||||
--> $DIR/needless_lifetimes.rs:17:1
|
||||
--> $DIR/needless_lifetimes.rs:18:1
|
||||
|
|
||||
LL | fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -12,7 +12,7 @@ LL + fn distinct_lifetimes(_x: &u8, _y: &u8, _z: u8) {}
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a, 'b
|
||||
--> $DIR/needless_lifetimes.rs:19:1
|
||||
--> $DIR/needless_lifetimes.rs:20:1
|
||||
|
|
||||
LL | fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -24,7 +24,7 @@ LL + fn distinct_and_static(_x: &u8, _y: &u8, _z: &'static u8) {}
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:29:1
|
||||
--> $DIR/needless_lifetimes.rs:30:1
|
||||
|
|
||||
LL | fn in_and_out<'a>(x: &'a u8, _y: u8) -> &'a u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -36,7 +36,7 @@ LL + fn in_and_out(x: &u8, _y: u8) -> &u8 {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'b
|
||||
--> $DIR/needless_lifetimes.rs:41:1
|
||||
--> $DIR/needless_lifetimes.rs:42:1
|
||||
|
|
||||
LL | fn multiple_in_and_out_2a<'a, 'b>(x: &'a u8, _y: &'b u8) -> &'a u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -48,7 +48,7 @@ LL + fn multiple_in_and_out_2a<'a>(x: &'a u8, _y: &u8) -> &'a u8 {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:48:1
|
||||
--> $DIR/needless_lifetimes.rs:49:1
|
||||
|
|
||||
LL | fn multiple_in_and_out_2b<'a, 'b>(_x: &'a u8, y: &'b u8) -> &'b u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -60,7 +60,7 @@ LL + fn multiple_in_and_out_2b<'b>(_x: &u8, y: &'b u8) -> &'b u8 {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'b
|
||||
--> $DIR/needless_lifetimes.rs:65:1
|
||||
--> $DIR/needless_lifetimes.rs:66:1
|
||||
|
|
||||
LL | fn deep_reference_1a<'a, 'b>(x: &'a u8, _y: &'b u8) -> Result<&'a u8, ()> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -72,7 +72,7 @@ LL + fn deep_reference_1a<'a>(x: &'a u8, _y: &u8) -> Result<&'a u8, ()> {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:72:1
|
||||
--> $DIR/needless_lifetimes.rs:73:1
|
||||
|
|
||||
LL | fn deep_reference_1b<'a, 'b>(_x: &'a u8, y: &'b u8) -> Result<&'b u8, ()> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -84,7 +84,7 @@ LL + fn deep_reference_1b<'b>(_x: &u8, y: &'b u8) -> Result<&'b u8, ()> {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:81:1
|
||||
--> $DIR/needless_lifetimes.rs:82:1
|
||||
|
|
||||
LL | fn deep_reference_3<'a>(x: &'a u8, _y: u8) -> Result<&'a u8, ()> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -96,7 +96,7 @@ LL + fn deep_reference_3(x: &u8, _y: u8) -> Result<&u8, ()> {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:86:1
|
||||
--> $DIR/needless_lifetimes.rs:87:1
|
||||
|
|
||||
LL | fn where_clause_without_lt<'a, T>(x: &'a u8, _y: u8) -> Result<&'a u8, ()>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -108,7 +108,7 @@ LL + fn where_clause_without_lt<T>(x: &u8, _y: u8) -> Result<&u8, ()>
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a, 'b
|
||||
--> $DIR/needless_lifetimes.rs:98:1
|
||||
--> $DIR/needless_lifetimes.rs:99:1
|
||||
|
|
||||
LL | fn lifetime_param_2<'a, 'b>(_x: Ref<'a>, _y: &'b u8) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -120,7 +120,7 @@ LL + fn lifetime_param_2(_x: Ref<'_>, _y: &u8) {}
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:122:1
|
||||
--> $DIR/needless_lifetimes.rs:123:1
|
||||
|
|
||||
LL | fn fn_bound_2<'a, F, I>(_m: Lt<'a, I>, _f: F) -> Lt<'a, I>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -132,7 +132,7 @@ LL + fn fn_bound_2<F, I>(_m: Lt<'_, I>, _f: F) -> Lt<'_, I>
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 's
|
||||
--> $DIR/needless_lifetimes.rs:152:5
|
||||
--> $DIR/needless_lifetimes.rs:153:5
|
||||
|
|
||||
LL | fn self_and_out<'s>(&'s self) -> &'s u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -144,7 +144,7 @@ LL + fn self_and_out(&self) -> &u8 {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 't
|
||||
--> $DIR/needless_lifetimes.rs:159:5
|
||||
--> $DIR/needless_lifetimes.rs:160:5
|
||||
|
|
||||
LL | fn self_and_in_out_1<'s, 't>(&'s self, _x: &'t u8) -> &'s u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -156,7 +156,7 @@ LL + fn self_and_in_out_1<'s>(&'s self, _x: &u8) -> &'s u8 {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 's
|
||||
--> $DIR/needless_lifetimes.rs:166:5
|
||||
--> $DIR/needless_lifetimes.rs:167:5
|
||||
|
|
||||
LL | fn self_and_in_out_2<'s, 't>(&'s self, x: &'t u8) -> &'t u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -168,7 +168,7 @@ LL + fn self_and_in_out_2<'t>(&self, x: &'t u8) -> &'t u8 {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 's, 't
|
||||
--> $DIR/needless_lifetimes.rs:170:5
|
||||
--> $DIR/needless_lifetimes.rs:171:5
|
||||
|
|
||||
LL | fn distinct_self_and_in<'s, 't>(&'s self, _x: &'t u8) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -180,7 +180,7 @@ LL + fn distinct_self_and_in(&self, _x: &u8) {}
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:189:1
|
||||
--> $DIR/needless_lifetimes.rs:190:1
|
||||
|
|
||||
LL | fn struct_with_lt<'a>(_foo: Foo<'a>) -> &'a str {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -192,7 +192,7 @@ LL + fn struct_with_lt(_foo: Foo<'_>) -> &str {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'b
|
||||
--> $DIR/needless_lifetimes.rs:207:1
|
||||
--> $DIR/needless_lifetimes.rs:208:1
|
||||
|
|
||||
LL | fn struct_with_lt4a<'a, 'b>(_foo: &'a Foo<'b>) -> &'a str {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -204,7 +204,7 @@ LL + fn struct_with_lt4a<'a>(_foo: &'a Foo<'_>) -> &'a str {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:215:1
|
||||
--> $DIR/needless_lifetimes.rs:216:1
|
||||
|
|
||||
LL | fn struct_with_lt4b<'a, 'b>(_foo: &'a Foo<'b>) -> &'b str {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -216,7 +216,7 @@ LL + fn struct_with_lt4b<'b>(_foo: &Foo<'b>) -> &'b str {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:230:1
|
||||
--> $DIR/needless_lifetimes.rs:231:1
|
||||
|
|
||||
LL | fn trait_obj_elided2<'a>(_arg: &'a dyn Drop) -> &'a str {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -228,7 +228,7 @@ LL + fn trait_obj_elided2(_arg: &dyn Drop) -> &str {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:236:1
|
||||
--> $DIR/needless_lifetimes.rs:237:1
|
||||
|
|
||||
LL | fn alias_with_lt<'a>(_foo: FooAlias<'a>) -> &'a str {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -240,7 +240,7 @@ LL + fn alias_with_lt(_foo: FooAlias<'_>) -> &str {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'b
|
||||
--> $DIR/needless_lifetimes.rs:254:1
|
||||
--> $DIR/needless_lifetimes.rs:255:1
|
||||
|
|
||||
LL | fn alias_with_lt4a<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'a str {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -252,7 +252,7 @@ LL + fn alias_with_lt4a<'a>(_foo: &'a FooAlias<'_>) -> &'a str {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:262:1
|
||||
--> $DIR/needless_lifetimes.rs:263:1
|
||||
|
|
||||
LL | fn alias_with_lt4b<'a, 'b>(_foo: &'a FooAlias<'b>) -> &'b str {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -264,7 +264,7 @@ LL + fn alias_with_lt4b<'b>(_foo: &FooAlias<'b>) -> &'b str {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:266:1
|
||||
--> $DIR/needless_lifetimes.rs:267:1
|
||||
|
|
||||
LL | fn named_input_elided_output<'a>(_arg: &'a str) -> &str {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -276,7 +276,7 @@ LL + fn named_input_elided_output(_arg: &str) -> &str {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:274:1
|
||||
--> $DIR/needless_lifetimes.rs:275:1
|
||||
|
|
||||
LL | fn trait_bound_ok<'a, T: WithLifetime<'static>>(_: &'a u8, _: T) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -288,7 +288,7 @@ LL + fn trait_bound_ok<T: WithLifetime<'static>>(_: &u8, _: T) {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:310:1
|
||||
--> $DIR/needless_lifetimes.rs:311:1
|
||||
|
|
||||
LL | fn out_return_type_lts<'a>(e: &'a str) -> Cow<'a> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -300,7 +300,7 @@ LL + fn out_return_type_lts(e: &str) -> Cow<'_> {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:317:9
|
||||
--> $DIR/needless_lifetimes.rs:318:9
|
||||
|
|
||||
LL | fn needless_lt<'a>(x: &'a u8) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -312,7 +312,7 @@ LL + fn needless_lt(x: &u8) {}
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:321:9
|
||||
--> $DIR/needless_lifetimes.rs:322:9
|
||||
|
|
||||
LL | fn needless_lt<'a>(_x: &'a u8) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -324,7 +324,7 @@ LL + fn needless_lt(_x: &u8) {}
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:334:9
|
||||
--> $DIR/needless_lifetimes.rs:335:9
|
||||
|
|
||||
LL | fn baz<'a>(&'a self) -> impl Foo + 'a {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -336,7 +336,7 @@ LL + fn baz(&self) -> impl Foo + '_ {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:366:5
|
||||
--> $DIR/needless_lifetimes.rs:367:5
|
||||
|
|
||||
LL | fn impl_trait_elidable_nested_anonymous_lifetimes<'a>(i: &'a i32, f: impl Fn(&i32) -> &i32) -> &'a i32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -348,7 +348,7 @@ LL + fn impl_trait_elidable_nested_anonymous_lifetimes(i: &i32, f: impl Fn(&
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:375:5
|
||||
--> $DIR/needless_lifetimes.rs:376:5
|
||||
|
|
||||
LL | fn generics_elidable<'a, T: Fn(&i32) -> &i32>(i: &'a i32, f: T) -> &'a i32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -360,7 +360,7 @@ LL + fn generics_elidable<T: Fn(&i32) -> &i32>(i: &i32, f: T) -> &i32 {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:387:5
|
||||
--> $DIR/needless_lifetimes.rs:388:5
|
||||
|
|
||||
LL | fn where_clause_elidadable<'a, T>(i: &'a i32, f: T) -> &'a i32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -372,7 +372,7 @@ LL + fn where_clause_elidadable<T>(i: &i32, f: T) -> &i32
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:402:5
|
||||
--> $DIR/needless_lifetimes.rs:403:5
|
||||
|
|
||||
LL | fn pointer_fn_elidable<'a>(i: &'a i32, f: fn(&i32) -> &i32) -> &'a i32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -384,7 +384,7 @@ LL + fn pointer_fn_elidable(i: &i32, f: fn(&i32) -> &i32) -> &i32 {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:415:5
|
||||
--> $DIR/needless_lifetimes.rs:416:5
|
||||
|
|
||||
LL | fn nested_fn_pointer_3<'a>(_: &'a i32) -> fn(fn(&i32) -> &i32) -> i32 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -396,7 +396,7 @@ LL + fn nested_fn_pointer_3(_: &i32) -> fn(fn(&i32) -> &i32) -> i32 {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:418:5
|
||||
--> $DIR/needless_lifetimes.rs:419:5
|
||||
|
|
||||
LL | fn nested_fn_pointer_4<'a>(_: &'a i32) -> impl Fn(fn(&i32)) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -408,7 +408,7 @@ LL + fn nested_fn_pointer_4(_: &i32) -> impl Fn(fn(&i32)) {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:440:9
|
||||
--> $DIR/needless_lifetimes.rs:441:9
|
||||
|
|
||||
LL | fn implicit<'a>(&'a self) -> &'a () {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -420,7 +420,7 @@ LL + fn implicit(&self) -> &() {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:443:9
|
||||
--> $DIR/needless_lifetimes.rs:444:9
|
||||
|
|
||||
LL | fn implicit_mut<'a>(&'a mut self) -> &'a () {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -432,7 +432,7 @@ LL + fn implicit_mut(&mut self) -> &() {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:454:9
|
||||
--> $DIR/needless_lifetimes.rs:455:9
|
||||
|
|
||||
LL | fn lifetime_elsewhere<'a>(self: Box<Self>, here: &'a ()) -> &'a () {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -444,7 +444,7 @@ LL + fn lifetime_elsewhere(self: Box<Self>, here: &()) -> &() {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:460:9
|
||||
--> $DIR/needless_lifetimes.rs:461:9
|
||||
|
|
||||
LL | fn implicit<'a>(&'a self) -> &'a ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -456,7 +456,7 @@ LL + fn implicit(&self) -> &();
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:461:9
|
||||
--> $DIR/needless_lifetimes.rs:462:9
|
||||
|
|
||||
LL | fn implicit_provided<'a>(&'a self) -> &'a () {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -468,7 +468,7 @@ LL + fn implicit_provided(&self) -> &() {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:470:9
|
||||
--> $DIR/needless_lifetimes.rs:471:9
|
||||
|
|
||||
LL | fn lifetime_elsewhere<'a>(self: Box<Self>, here: &'a ()) -> &'a ();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -480,7 +480,7 @@ LL + fn lifetime_elsewhere(self: Box<Self>, here: &()) -> &();
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:471:9
|
||||
--> $DIR/needless_lifetimes.rs:472:9
|
||||
|
|
||||
LL | fn lifetime_elsewhere_provided<'a>(self: Box<Self>, here: &'a ()) -> &'a () {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -492,7 +492,7 @@ LL + fn lifetime_elsewhere_provided(self: Box<Self>, here: &()) -> &() {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:480:5
|
||||
--> $DIR/needless_lifetimes.rs:481:5
|
||||
|
|
||||
LL | fn foo<'a>(x: &'a u8, y: &'_ u8) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -504,7 +504,7 @@ LL + fn foo(x: &u8, y: &'_ u8) {}
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:482:5
|
||||
--> $DIR/needless_lifetimes.rs:483:5
|
||||
|
|
||||
LL | fn bar<'a>(x: &'a u8, y: &'_ u8, z: &'_ u8) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -516,7 +516,7 @@ LL + fn bar(x: &u8, y: &'_ u8, z: &'_ u8) {}
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:489:5
|
||||
--> $DIR/needless_lifetimes.rs:490:5
|
||||
|
|
||||
LL | fn one_input<'a>(x: &'a u8) -> &'a u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -528,7 +528,7 @@ LL + fn one_input(x: &u8) -> &u8 {
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:494:5
|
||||
--> $DIR/needless_lifetimes.rs:495:5
|
||||
|
|
||||
LL | fn multiple_inputs_output_not_elided<'a, 'b>(x: &'a u8, y: &'b u8, z: &'b u8) -> &'b u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -540,7 +540,7 @@ LL + fn multiple_inputs_output_not_elided<'b>(x: &u8, y: &'b u8, z: &'b u8)
|
|||
|
|
||||
|
||||
error: the following explicit lifetimes could be elided: 'a
|
||||
--> $DIR/needless_lifetimes.rs:507:13
|
||||
--> $DIR/needless_lifetimes.rs:508:13
|
||||
|
|
||||
LL | fn one_input<'a>(x: &'a u8) -> &'a u8 {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
#![allow(dead_code, clippy::missing_safety_doc, clippy::extra_unused_lifetimes)]
|
||||
#![allow(
|
||||
dead_code,
|
||||
clippy::missing_safety_doc,
|
||||
clippy::extra_unused_lifetimes,
|
||||
clippy::extra_unused_type_parameters
|
||||
)]
|
||||
#![warn(clippy::new_without_default)]
|
||||
|
||||
pub struct Foo;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: you should consider adding a `Default` implementation for `Foo`
|
||||
--> $DIR/new_without_default.rs:7:5
|
||||
--> $DIR/new_without_default.rs:12:5
|
||||
|
|
||||
LL | / pub fn new() -> Foo {
|
||||
LL | | Foo
|
||||
|
@ -17,7 +17,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you should consider adding a `Default` implementation for `Bar`
|
||||
--> $DIR/new_without_default.rs:15:5
|
||||
--> $DIR/new_without_default.rs:20:5
|
||||
|
|
||||
LL | / pub fn new() -> Self {
|
||||
LL | | Bar
|
||||
|
@ -34,7 +34,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you should consider adding a `Default` implementation for `LtKo<'c>`
|
||||
--> $DIR/new_without_default.rs:79:5
|
||||
--> $DIR/new_without_default.rs:84:5
|
||||
|
|
||||
LL | / pub fn new() -> LtKo<'c> {
|
||||
LL | | unimplemented!()
|
||||
|
@ -51,7 +51,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you should consider adding a `Default` implementation for `NewNotEqualToDerive`
|
||||
--> $DIR/new_without_default.rs:172:5
|
||||
--> $DIR/new_without_default.rs:177:5
|
||||
|
|
||||
LL | / pub fn new() -> Self {
|
||||
LL | | NewNotEqualToDerive { foo: 1 }
|
||||
|
@ -68,7 +68,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you should consider adding a `Default` implementation for `FooGenerics<T>`
|
||||
--> $DIR/new_without_default.rs:180:5
|
||||
--> $DIR/new_without_default.rs:185:5
|
||||
|
|
||||
LL | / pub fn new() -> Self {
|
||||
LL | | Self(Default::default())
|
||||
|
@ -85,7 +85,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you should consider adding a `Default` implementation for `BarGenerics<T>`
|
||||
--> $DIR/new_without_default.rs:187:5
|
||||
--> $DIR/new_without_default.rs:192:5
|
||||
|
|
||||
LL | / pub fn new() -> Self {
|
||||
LL | | Self(Default::default())
|
||||
|
@ -102,7 +102,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you should consider adding a `Default` implementation for `Foo<T>`
|
||||
--> $DIR/new_without_default.rs:198:9
|
||||
--> $DIR/new_without_default.rs:203:9
|
||||
|
|
||||
LL | / pub fn new() -> Self {
|
||||
LL | | todo!()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// run-rustfix
|
||||
|
||||
#![warn(clippy::redundant_field_names)]
|
||||
#![allow(clippy::no_effect, dead_code, unused_variables)]
|
||||
#![allow(clippy::extra_unused_type_parameters, clippy::no_effect, dead_code, unused_variables)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate derive_new;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// run-rustfix
|
||||
|
||||
#![warn(clippy::redundant_field_names)]
|
||||
#![allow(clippy::no_effect, dead_code, unused_variables)]
|
||||
#![allow(clippy::extra_unused_type_parameters, clippy::no_effect, dead_code, unused_variables)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate derive_new;
|
||||
|
|
|
@ -26,7 +26,7 @@ fn seek_to_start_false_method(t: &mut StructWithSeekMethod) {
|
|||
|
||||
// This should NOT trigger clippy warning because
|
||||
// StructWithSeekMethod does not implement std::io::Seek;
|
||||
fn seek_to_start_method_owned_false<T>(mut t: StructWithSeekMethod) {
|
||||
fn seek_to_start_method_owned_false(mut t: StructWithSeekMethod) {
|
||||
t.seek(SeekFrom::Start(0));
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ fn seek_to_start_false_trait(t: &mut StructWithSeekTrait) {
|
|||
|
||||
// This should NOT trigger clippy warning because
|
||||
// StructWithSeekMethod does not implement std::io::Seek;
|
||||
fn seek_to_start_false_trait_owned<T>(mut t: StructWithSeekTrait) {
|
||||
fn seek_to_start_false_trait_owned(mut t: StructWithSeekTrait) {
|
||||
t.seek(SeekFrom::Start(0));
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ fn seek_to_start_false_method(t: &mut StructWithSeekMethod) {
|
|||
|
||||
// This should NOT trigger clippy warning because
|
||||
// StructWithSeekMethod does not implement std::io::Seek;
|
||||
fn seek_to_start_method_owned_false<T>(mut t: StructWithSeekMethod) {
|
||||
fn seek_to_start_method_owned_false(mut t: StructWithSeekMethod) {
|
||||
t.seek(SeekFrom::Start(0));
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ fn seek_to_start_false_trait(t: &mut StructWithSeekTrait) {
|
|||
|
||||
// This should NOT trigger clippy warning because
|
||||
// StructWithSeekMethod does not implement std::io::Seek;
|
||||
fn seek_to_start_false_trait_owned<T>(mut t: StructWithSeekTrait) {
|
||||
fn seek_to_start_false_trait_owned(mut t: StructWithSeekTrait) {
|
||||
t.seek(SeekFrom::Start(0));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#![deny(clippy::type_repetition_in_bounds)]
|
||||
#![allow(clippy::extra_unused_type_parameters)]
|
||||
|
||||
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
|
||||
--> $DIR/type_repetition_in_bounds.rs:8:5
|
||||
--> $DIR/type_repetition_in_bounds.rs:9: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
|
||||
--> $DIR/type_repetition_in_bounds.rs:25:5
|
||||
--> $DIR/type_repetition_in_bounds.rs:26: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
|
||||
--> $DIR/type_repetition_in_bounds.rs:85:5
|
||||
--> $DIR/type_repetition_in_bounds.rs:86: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
|
||||
--> $DIR/type_repetition_in_bounds.rs:90:5
|
||||
--> $DIR/type_repetition_in_bounds.rs:91:5
|
||||
|
|
||||
LL | T: ?Sized,
|
||||
| ^^^^^^^^^
|
||||
|
|
Loading…
Reference in a new issue