Update Clippy by flip1995 · Pull Request #94329 · rust-lang/rust (original) (raw)
Specifically, change Ty
from this:
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
to this
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
means we can move a lot of methods away from
TyS
, leavingTyS
as a barely-used type, which is appropriate given that it's not meant to be used directly. - The uniqueness requirement is now explicit, via the
Interned
type. E.g. the pointer-basedEq
andHash
comes fromInterned
, rather than viaTyS
, which wasn't obvious at all.
Much of this commit is boring churn. The interesting changes are in these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs
Specifically:
- Most mentions of
TyS
are removed. It's very much a dumb struct now;Ty
has all the smarts. TyS
now hascrate
visibility instead ofpub
.TyS::make_for_test
is removed in favour of the staticBOOL_TY
, which just works better with the new structure.- The
Eq
/Ord
/Hash
impls are removed fromTyS
.Interned
s impls ofEq
/Hash
now suffice.Ord
is now partly onInterned
(pointer-based, for theEqual
case) and partly onTyS
(contents-based, for the other cases). - There are many tedious sigil adjustments, i.e. adding or removing
*
or&
. They seem to be unavoidable.