Skip to content

Commit

Permalink
Auto merge of rust-lang#6152 - flip1995:ice_6139, r=ebroto
Browse files Browse the repository at this point in the history
Fixes ICE 6139

Fixes rust-lang#6139

Kind of hacky, but this should be fine.

changelog: none
  • Loading branch information
bors committed Oct 9, 2020
2 parents 947516f + a98f9d2 commit 08bd3f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,11 @@ impl Types {
_ => None,
});
let ty_ty = hir_ty_to_ty(cx.tcx, boxed_ty);
// HACK(flip1995): This is a fix for an ICE occuring when `ty_ty` is a
// trait object with a lifetime, e.g. `dyn T<'_>`. Since trait objects
// don't have a known size, this shouldn't introduce FNs. But there
// should be a better solution.
if !matches!(ty_ty.kind(), ty::Dynamic(..));
if ty_ty.is_sized(cx.tcx.at(ty.span), cx.param_env);
if let Ok(ty_ty_size) = cx.layout_of(ty_ty).map(|l| l.size.bytes());
if ty_ty_size <= self.vec_box_size_threshold;
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/crashes/ice-6139.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
trait T<'a> {}

fn foo(_: Vec<Box<dyn T<'_>>>) {}

fn main() {
foo(vec![]);
}

0 comments on commit 08bd3f0

Please sign in to comment.