mirror of
https://github.com/rust-lang/rust.git
synced 2025-12-03 03:58:52 +00:00
repr(transparent) check: do not compute check_unsuited more than once `field_infos` is an iterator that we execute multiple times. However, we usually ignore the `unsuited` field -- we only need it in the last iteration. So move the computation of that field to that iteration to avoid computing it multiple times. Computing `unsuited` involves a recursive traversal over the types of all non-trivial fields, so there can be non-trivial amounts of work here. (I benchmarked this in https://github.com/rust-lang/rust/pull/148243 and saw no changes, probably because we don't have a benchmark with many repr(transparent) types. But still, computing this each time just seemed silly.)
For high-level intro to how type checking works in rustc, see the type checking chapter of the rustc dev guide.