mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 05:03:21 +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) {
|
||||
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::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 &&
|
||||
sig.decl.inputs.len() == n_args &&
|
||||
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!(
|
||||
"defining a method called `{}` on this type; consider implementing \
|
||||
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 {
|
||||
if_chain! {
|
||||
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 {
|
||||
let lint = if item.vis == hir::Visibility::Public {
|
||||
WRONG_PUB_SELF_CONVENTION
|
||||
|
|
|
@ -108,12 +108,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
|
|||
// can't be implemented by default
|
||||
return;
|
||||
}
|
||||
if !sig.generics.ty_params.is_empty() {
|
||||
// when the result of `new()` depends on a type parameter we should not require
|
||||
// an
|
||||
// impl of `Default`
|
||||
return;
|
||||
}
|
||||
//TODO: There is no sig.generics anymore and I don't know how to fix this.
|
||||
//if !sig.generics.ty_params.is_empty() {
|
||||
// // when the result of `new()` depends on a type parameter we should not require
|
||||
// // an
|
||||
// // impl of `Default`
|
||||
// return;
|
||||
//}
|
||||
if decl.inputs.is_empty() && name == "new" && cx.access_levels.is_reachable(id) {
|
||||
let self_ty = cx.tcx
|
||||
.type_of(cx.tcx.hir.local_def_id(cx.tcx.hir.get_parent(id)));
|
||||
|
|
Loading…
Reference in a new issue