Bump to 0.0.106; Fix false positive in wrong_self_convention (fix #1420)

This commit is contained in:
Manish Goregaokar 2017-01-04 18:01:53 -08:00
parent 3baa435b70
commit 9a301fd508
5 changed files with 19 additions and 8 deletions

View file

@ -1,8 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.
## 0.0.105 — 2016-12-15
* Update to *rustc 1.15.0-nightly (8f02c429a 2016-12-15)*
## 0.0.106 — 2017-01-04
* Fix FP introduced by rustup in [`wrong_self_convention`]
## 0.0.105 — 2017-01-04
* Update to *rustc 1.16.0-nightly (468227129 2017-01-03)*
* New lints: [`deref_addrof`], [`double_parens`], [`pub_enum_variant_names`]
* Fix suggestion in [`new_without_default`]
* FP fix in [`absurd_extreme_comparisons`]

View file

@ -1,6 +1,6 @@
[package]
name = "clippy"
version = "0.0.105"
version = "0.0.106"
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",
"Andre Bogus <bogusandre@gmail.com>",
@ -25,7 +25,7 @@ test = false
[dependencies]
# begin automatic update
clippy_lints = { version = "0.0.105", path = "clippy_lints" }
clippy_lints = { version = "0.0.106", path = "clippy_lints" }
# end automatic update
[dev-dependencies]

View file

@ -1,7 +1,7 @@
[package]
name = "clippy_lints"
# begin automatic update
version = "0.0.105"
version = "0.0.106"
# end automatic update
authors = [
"Manish Goregaokar <manishsmail@gmail.com>",

View file

@ -1342,7 +1342,7 @@ const PATTERN_METHODS: [(&'static str, usize); 17] = [
];
#[derive(Clone, Copy, PartialEq)]
#[derive(Clone, Copy, PartialEq, Debug)]
enum SelfKind {
Value,
Ref,
@ -1358,12 +1358,15 @@ impl SelfKind {
// Thus, we only need to test equality against the impl self type or if it is an explicit
// `Self`. Furthermore, the only possible types for `self: ` are `&Self`, `Self`, `&mut Self`,
// and `Box<Self>`, including the equivalent types with `Foo`.
let is_actually_self = |ty| is_self_ty(ty) || ty == self_ty;
if is_self(arg) {
match self {
SelfKind::Value => is_actually_self(ty),
SelfKind::Ref | SelfKind::RefMut if allow_value_for_ref => is_actually_self(ty),
SelfKind::Ref | SelfKind::RefMut => {
if allow_value_for_ref && is_actually_self(ty) {
return true;
}
match ty.node {
hir::TyRptr(_, ref mt_ty) => {
let mutability_match = if self == SelfKind::Ref {
@ -1372,7 +1375,6 @@ impl SelfKind {
mt_ty.mutbl == hir::MutMutable
};
is_actually_self(&mt_ty.ty) && mutability_match
},
_ => false,
}

View file

@ -13,8 +13,10 @@ struct Foo;
impl Foo {
fn as_i32(self) {}
fn as_u32(&self) {}
fn into_i32(self) {}
fn is_i32(self) {}
fn is_u32(&self) {}
fn to_i32(self) {}
fn from_i32(self) {} //~ERROR: methods called `from_*` usually take no self
@ -34,9 +36,13 @@ struct Bar;
impl Bar {
fn as_i32(self) {} //~ERROR: methods called `as_*` usually take self by reference
fn as_u32(&self) {}
fn into_i32(&self) {} //~ERROR: methods called `into_*` usually take self by value
fn into_u32(self) {}
fn is_i32(self) {} //~ERROR: methods called `is_*` usually take self by reference
fn is_u32(&self) {}
fn to_i32(self) {} //~ERROR: methods called `to_*` usually take self by reference
fn to_u32(&self) {}
fn from_i32(self) {} //~ERROR: methods called `from_*` usually take no self
pub fn as_i64(self) {} //~ERROR: methods called `as_*` usually take self by reference