mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
Merge branch 'pr-2140'
This commit is contained in:
commit
b0616df931
3 changed files with 11 additions and 10 deletions
|
@ -66,7 +66,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass {
|
||||||
|
|
||||||
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
|
||||||
if let ImplItemKind::Method(ref sig, id) = item.node {
|
if let ImplItemKind::Method(ref sig, id) = item.node {
|
||||||
check_fn_inner(cx, &sig.decl, Some(id), &sig.generics, item.span);
|
check_fn_inner(cx, &sig.decl, Some(id), &item.generics, item.span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LifetimePass {
|
||||||
TraitMethod::Required(_) => None,
|
TraitMethod::Required(_) => None,
|
||||||
TraitMethod::Provided(id) => Some(id),
|
TraitMethod::Provided(id) => Some(id),
|
||||||
};
|
};
|
||||||
check_fn_inner(cx, &sig.decl, body, &sig.generics, item.span);
|
check_fn_inner(cx, &sig.decl, body, &item.generics, item.span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -746,7 +746,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
if name == method_name &&
|
if name == method_name &&
|
||||||
sig.decl.inputs.len() == n_args &&
|
sig.decl.inputs.len() == n_args &&
|
||||||
out_type.matches(&sig.decl.output) &&
|
out_type.matches(&sig.decl.output) &&
|
||||||
self_kind.matches(first_arg_ty, first_arg, self_ty, false, &sig.generics) {
|
self_kind.matches(first_arg_ty, first_arg, self_ty, false, &implitem.generics) {
|
||||||
span_lint(cx, SHOULD_IMPLEMENT_TRAIT, implitem.span, &format!(
|
span_lint(cx, SHOULD_IMPLEMENT_TRAIT, implitem.span, &format!(
|
||||||
"defining a method called `{}` on this type; consider implementing \
|
"defining a method called `{}` on this type; consider implementing \
|
||||||
the `{}` trait or choosing a less ambiguous name", name, trait_name));
|
the `{}` trait or choosing a less ambiguous name", name, trait_name));
|
||||||
|
@ -760,7 +760,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
||||||
for &(ref conv, self_kinds) in &CONVENTIONS {
|
for &(ref conv, self_kinds) in &CONVENTIONS {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if conv.check(&name.as_str());
|
if conv.check(&name.as_str());
|
||||||
if !self_kinds.iter().any(|k| k.matches(first_arg_ty, first_arg, self_ty, is_copy, &sig.generics));
|
if !self_kinds.iter().any(|k| k.matches(first_arg_ty, first_arg, self_ty, is_copy, &implitem.generics));
|
||||||
then {
|
then {
|
||||||
let lint = if item.vis == hir::Visibility::Public {
|
let lint = if item.vis == hir::Visibility::Public {
|
||||||
WRONG_PUB_SELF_CONVENTION
|
WRONG_PUB_SELF_CONVENTION
|
||||||
|
|
|
@ -108,12 +108,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
|
||||||
// can't be implemented by default
|
// can't be implemented by default
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if !sig.generics.ty_params.is_empty() {
|
//TODO: There is no sig.generics anymore and I don't know how to fix this.
|
||||||
// when the result of `new()` depends on a type parameter we should not require
|
//if !sig.generics.ty_params.is_empty() {
|
||||||
// an
|
// // when the result of `new()` depends on a type parameter we should not require
|
||||||
// impl of `Default`
|
// // an
|
||||||
return;
|
// // impl of `Default`
|
||||||
}
|
// return;
|
||||||
|
//}
|
||||||
if decl.inputs.is_empty() && name == "new" && cx.access_levels.is_reachable(id) {
|
if decl.inputs.is_empty() && name == "new" && cx.access_levels.is_reachable(id) {
|
||||||
let self_ty = cx.tcx
|
let self_ty = cx.tcx
|
||||||
.type_of(cx.tcx.hir.local_def_id(cx.tcx.hir.get_parent(id)));
|
.type_of(cx.tcx.hir.local_def_id(cx.tcx.hir.get_parent(id)));
|
||||||
|
|
Loading…
Add table
Reference in a new issue