mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Merge pull request #1152 from oli-obk/wrong_self_conv_fn_level
enable changing wrong_self_convention's lint level at the function level
This commit is contained in:
commit
8ac99162ea
2 changed files with 55 additions and 54 deletions
|
@ -538,17 +538,17 @@ impl LateLintPass for Pass {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
|
||||
if in_external_macro(cx, item.span) {
|
||||
fn check_impl_item(&mut self, cx: &LateContext, implitem: &hir::ImplItem) {
|
||||
if in_external_macro(cx, implitem.span) {
|
||||
return;
|
||||
}
|
||||
|
||||
if let hir::ItemImpl(_, _, _, None, _, ref items) = item.node {
|
||||
for implitem in items {
|
||||
let name = implitem.name;
|
||||
let parent = cx.tcx.map.get_parent(implitem.id);
|
||||
let item = cx.tcx.map.expect_item(parent);
|
||||
if_let_chain! {[
|
||||
let hir::ImplItemKind::Method(ref sig, _) = implitem.node,
|
||||
let Some(explicit_self) = sig.decl.inputs.get(0).and_then(hir::Arg::to_self),
|
||||
let hir::ItemImpl(_, _, _, None, _, _) = item.node,
|
||||
], {
|
||||
// check missing trait implementations
|
||||
for &(method_name, n_args, self_kind, out_type, trait_name) in &TRAIT_METHODS {
|
||||
|
@ -599,8 +599,6 @@ impl LateLintPass for Pass {
|
|||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks for the `OR_FUN_CALL` lint.
|
||||
|
|
|
@ -23,6 +23,9 @@ impl Foo {
|
|||
pub fn is_i64(self) {}
|
||||
pub fn to_i64(self) {}
|
||||
pub fn from_i64(self) {} //~ERROR: methods called `from_*` usually take no self
|
||||
// check whether the lint can be allowed at the function level
|
||||
#[allow(wrong_self_convention)]
|
||||
pub fn from_cake(self) {}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue