diff options
| author | flip1995 <philipp.krones@embecosm.com> | 2020-11-23 13:52:27 +0100 |
|---|---|---|
| committer | flip1995 <philipp.krones@embecosm.com> | 2020-11-23 13:52:27 +0100 |
| commit | 284c359c6141404c186a37e5537ffa849b2dcc23 (patch) | |
| tree | 0fcc0bfc272f6d565ab4cdf0cfb128f730511d5a | |
| parent | d3d2018eadff575566604c9b883a52fd56dde1c0 (diff) | |
| download | rust-284c359c6141404c186a37e5537ffa849b2dcc23.tar.gz rust-284c359c6141404c186a37e5537ffa849b2dcc23.zip | |
Fix ICE in utils::implements_trait
This only happend when debug_assertions were enabled in rustc
| -rw-r--r-- | clippy_lints/src/utils/mod.rs | 3 | ||||
| -rw-r--r-- | tests/ui/crashes/implements-trait.rs | 5 |
2 files changed, 8 insertions, 0 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()); +} |
