Skip to content

Commit 08bd3f0

Browse files
committed
Auto merge of rust-lang#6152 - flip1995:ice_6139, r=ebroto
Fixes ICE 6139 Fixes rust-lang#6139 Kind of hacky, but this should be fine. changelog: none
2 parents 947516f + a98f9d2 commit 08bd3f0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

clippy_lints/src/types.rs

+5
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,11 @@ impl Types {
541541
_ => None,
542542
});
543543
let ty_ty = hir_ty_to_ty(cx.tcx, boxed_ty);
544+
// HACK(flip1995): This is a fix for an ICE occuring when `ty_ty` is a
545+
// trait object with a lifetime, e.g. `dyn T<'_>`. Since trait objects
546+
// don't have a known size, this shouldn't introduce FNs. But there
547+
// should be a better solution.
548+
if !matches!(ty_ty.kind(), ty::Dynamic(..));
544549
if ty_ty.is_sized(cx.tcx.at(ty.span), cx.param_env);
545550
if let Ok(ty_ty_size) = cx.layout_of(ty_ty).map(|l| l.size.bytes());
546551
if ty_ty_size <= self.vec_box_size_threshold;

tests/ui/crashes/ice-6139.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trait T<'a> {}
2+
3+
fn foo(_: Vec<Box<dyn T<'_>>>) {}
4+
5+
fn main() {
6+
foo(vec![]);
7+
}

0 commit comments

Comments
 (0)