+ // This is purely an optimization -- layout_of is a pretty expensive operation,
+ // but if we can determine the size without calling it, we don't need all that complexity
+ // (hashing, caching, etc.). As such, try to skip it.
+ let size = match ty.kind {
+ ty::Bool => Size::from_bytes(1),
+ ty::Char => Size::from_bytes(4),
+ ty::Int(ity) => {
+ Integer::from_attr(&tcx, SignedInt(ity)).size()
+ }
+ ty::Uint(uty) => {
+ Integer::from_attr(&tcx, UnsignedInt(uty)).size()
+ }
+ _ => tcx.layout_of(param_env.with_reveal_all().and(ty)).ok()?.size,
+ };