diff options
| author | bors <bors@rust-lang.org> | 2020-11-24 16:07:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-11-24 16:07:11 +0000 |
| commit | 5b40ce3f2d30280476bc30c6d9c90c3aa08e1445 (patch) | |
| tree | bf93aef535ea6bf0136818c177b93181a22ede8f | |
| parent | 295fe28057fedcfd9671a17880732c79ffa16d00 (diff) | |
| parent | c6a577ea116d06f22f44bfb6aa635780fc9ec174 (diff) | |
| download | rust-5b40ce3f2d30280476bc30c6d9c90c3aa08e1445.tar.gz rust-5b40ce3f2d30280476bc30c6d9c90c3aa08e1445.zip | |
Auto merge of #6374 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: [`panic`],[`unimplemented`],[`unreachable`],[`todo`] now also handle the `core::` version of those macros correctly.
| -rw-r--r-- | clippy_lints/src/utils/mod.rs | 3 | ||||
| -rw-r--r-- | tests/ui/crashes/implements-trait.rs | 5 | ||||
| -rw-r--r-- | tests/ui/logic_bug.rs | 2 | ||||
| -rw-r--r-- | tests/ui/nonminimal_bool.rs | 2 | ||||
| -rw-r--r-- | tests/ui/nonminimal_bool_methods.rs | 2 | ||||
| -rw-r--r-- | tests/ui/wildcard_enum_match_arm.fixed | 3 | ||||
| -rw-r--r-- | tests/ui/wildcard_enum_match_arm.rs | 3 | ||||
| -rw-r--r-- | tests/ui/wildcard_enum_match_arm.stderr | 10 |
8 files changed, 20 insertions, 10 deletions
diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 5bd64dcb541..e9c71e23a67 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -365,6 +365,9 @@ pub fn implements_trait<'tcx>( return false; } let ty = cx.tcx.erase_regions(ty); + if ty.has_escaping_bound_vars() { + return false; + } let ty_params = cx.tcx.mk_substs(ty_params.iter()); cx.tcx.type_implements_trait((trait_id, ty, ty_params, cx.param_env)) } diff --git a/tests/ui/crashes/implements-trait.rs b/tests/ui/crashes/implements-trait.rs new file mode 100644 index 00000000000..4502b0147a8 --- /dev/null +++ b/tests/ui/crashes/implements-trait.rs @@ -0,0 +1,5 @@ +#[allow(clippy::needless_borrowed_reference)] +fn main() { + let mut v = Vec::<String>::new(); + let _ = v.iter_mut().filter(|&ref a| a.is_empty()); +} diff --git a/tests/ui/logic_bug.rs b/tests/ui/logic_bug.rs index b4163d776e7..a01c6ef99db 100644 --- a/tests/ui/logic_bug.rs +++ b/tests/ui/logic_bug.rs @@ -1,4 +1,4 @@ -#![allow(unused, clippy::many_single_char_names)] +#![allow(unused, clippy::many_single_char_names, clippy::diverging_sub_expression)] #![warn(clippy::logic_bug)] fn main() { diff --git a/tests/ui/nonminimal_bool.rs b/tests/ui/nonminimal_bool.rs index 7ea154cb9b0..971be26278f 100644 --- a/tests/ui/nonminimal_bool.rs +++ b/tests/ui/nonminimal_bool.rs @@ -1,4 +1,4 @@ -#![allow(unused, clippy::many_single_char_names)] +#![allow(unused, clippy::many_single_char_names, clippy::diverging_sub_expression)] #![warn(clippy::nonminimal_bool)] fn main() { diff --git a/tests/ui/nonminimal_bool_methods.rs b/tests/ui/nonminimal_bool_methods.rs index 4de48cd0879..90758740290 100644 --- a/tests/ui/nonminimal_bool_methods.rs +++ b/tests/ui/nonminimal_bool_methods.rs @@ -1,4 +1,4 @@ -#![allow(unused, clippy::many_single_char_names)] +#![allow(unused, clippy::many_single_char_names, clippy::diverging_sub_expression)] #![warn(clippy::nonminimal_bool)] fn methods_with_negation() { diff --git a/tests/ui/wildcard_enum_match_arm.fixed b/tests/ui/wildcard_enum_match_arm.fixed index 4f8754a9301..c266f684a36 100644 --- a/tests/ui/wildcard_enum_match_arm.fixed +++ b/tests/ui/wildcard_enum_match_arm.fixed @@ -7,7 +7,8 @@ dead_code, clippy::single_match, clippy::wildcard_in_or_patterns, - clippy::unnested_or_patterns + clippy::unnested_or_patterns, + clippy::diverging_sub_expression )] use std::io::ErrorKind; diff --git a/tests/ui/wildcard_enum_match_arm.rs b/tests/ui/wildcard_enum_match_arm.rs index 5e66644ceca..2dbf726d5d0 100644 --- a/tests/ui/wildcard_enum_match_arm.rs +++ b/tests/ui/wildcard_enum_match_arm.rs @@ -7,7 +7,8 @@ dead_code, clippy::single_match, clippy::wildcard_in_or_patterns, - clippy::unnested_or_patterns + clippy::unnested_or_patterns, + clippy::diverging_sub_expression )] use std::io::ErrorKind; diff --git a/tests/ui/wildcard_enum_match_arm.stderr b/tests/ui/wildcard_enum_match_arm.stderr index e03b3be43ed..0da2b68ba0b 100644 --- a/tests/ui/wildcard_enum_match_arm.stderr +++ b/tests/ui/wildcard_enum_match_arm.stderr @@ -1,5 +1,5 @@ error: wildcard match will miss any future added variants - --> $DIR/wildcard_enum_match_arm.rs:38:9 + --> $DIR/wildcard_enum_match_arm.rs:39:9 | LL | _ => eprintln!("Not red"), | ^ help: try this: `Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan` @@ -11,25 +11,25 @@ LL | #![deny(clippy::wildcard_enum_match_arm)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: wildcard match will miss any future added variants - --> $DIR/wildcard_enum_match_arm.rs:42:9 + --> $DIR/wildcard_enum_match_arm.rs:43:9 | LL | _not_red => eprintln!("Not red"), | ^^^^^^^^ help: try this: `_not_red @ Color::Green | _not_red @ Color::Blue | _not_red @ Color::Rgb(..) | _not_red @ Color::Cyan` error: wildcard match will miss any future added variants - --> $DIR/wildcard_enum_match_arm.rs:46:9 + --> $DIR/wildcard_enum_match_arm.rs:47:9 | LL | not_red => format!("{:?}", not_red), | ^^^^^^^ help: try this: `not_red @ Color::Green | not_red @ Color::Blue | not_red @ Color::Rgb(..) | not_red @ Color::Cyan` error: wildcard match will miss any future added variants - --> $DIR/wildcard_enum_match_arm.rs:62:9 + --> $DIR/wildcard_enum_match_arm.rs:63:9 | LL | _ => "No red", | ^ help: try this: `Color::Red | Color::Green | Color::Blue | Color::Rgb(..) | Color::Cyan` error: match on non-exhaustive enum doesn't explicitly match all known variants - --> $DIR/wildcard_enum_match_arm.rs:79:9 + --> $DIR/wildcard_enum_match_arm.rs:80:9 | LL | _ => {}, | ^ help: try this: `std::io::ErrorKind::PermissionDenied | std::io::ErrorKind::ConnectionRefused | std::io::ErrorKind::ConnectionReset | std::io::ErrorKind::ConnectionAborted | std::io::ErrorKind::NotConnected | std::io::ErrorKind::AddrInUse | std::io::ErrorKind::AddrNotAvailable | std::io::ErrorKind::BrokenPipe | std::io::ErrorKind::AlreadyExists | std::io::ErrorKind::WouldBlock | std::io::ErrorKind::InvalidInput | std::io::ErrorKind::InvalidData | std::io::ErrorKind::TimedOut | std::io::ErrorKind::WriteZero | std::io::ErrorKind::Interrupted | std::io::ErrorKind::Other | std::io::ErrorKind::UnexpectedEof | _` |
