Conversation
3ef4cf0 to
c64839d
Compare
This comment has been minimized.
This comment has been minimized.
| where | ||
| F: FnOnce(&mut Self) -> R; | ||
| pub trait TyEncoder<'tcx>: ir_codec::TyEncoder<'tcx, Interner = TyCtxt<'tcx>> {} | ||
| impl<'tcx, T> TyEncoder<'tcx> for T where T: ir_codec::TyEncoder<'tcx, Interner = TyCtxt<'tcx>> {} |
There was a problem hiding this comment.
why does this trait have to be moved? This is surprising to me
Might be good to write in the PR description what you're moving and why.
As in, sth like
- moving
Ty - also uses other types
Xwhich now need to be moved - has function which relies on
tcx, add methodfn XXXtotrait Interner
| feature = "nightly", | ||
| derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext) | ||
| )] | ||
| #[cfg_attr(feature = "nightly", derive(HashStable_NoContext))] |
| #[rustc_diagnostic_item = "Ty"] | ||
| #[rustc_pass_by_value] | ||
| #[rustc_has_incoherent_inherent_impls] | ||
| pub struct Ty<I: Interner>(pub I::Interned<WithCachedTypeInfo<TyKind<I>>>); |
There was a problem hiding this comment.
should be in a mod ty or mod sty to mirror rustc_middle
compiler/rustc_type_ir/src/binder.rs
Outdated
| #[cfg_attr(feature = "nightly", derive(HashStable_NoContext))] | ||
| #[rustc_diagnostic_item = "Ty"] | ||
| #[rustc_pass_by_value] | ||
| #[rustc_has_incoherent_inherent_impls] |
There was a problem hiding this comment.
dubious :3 i guess that's a way to simply the migration. Removing this before merge/add a TODO rn
There was a problem hiding this comment.
Yeah I was experimenting with things. This in my opinion is 'cheating', I'll remove it
| #[inline] | ||
| pub fn interned(self) -> I::Interned<WithCachedTypeInfo<TyKind<I>>> { | ||
| self.0 | ||
| } |
compiler/rustc_type_ir/src/binder.rs
Outdated
| } | ||
|
|
||
| #[inline] | ||
| #[allow(rustc::pass_by_value)] |
|
|
||
| impl<I: Interner> TypeSuperVisitable<I> for Ty<I> | ||
| where | ||
| I::Interned<WithCachedTypeInfo<TyKind<I>>>: Deref<Target = WithCachedTypeInfo<TyKind<I>>>, |
There was a problem hiding this comment.
should be item bound of I::Interned, same with all other where-bounds here
| I::Region: TypeFoldable<I> + TypeVisitable<I>, | ||
| I::Term: From<Ty<I>>, | ||
| I::Tys: TypeFoldable<I> + TypeVisitable<I>, | ||
| I::Interned<WithCachedTypeInfo<TyKind<I>>>: |
| /// This offset is also chosen so that the first byte is never < 0x80. | ||
| pub const SHORTHAND_OFFSET: usize = 0x80; | ||
|
|
||
| pub trait TyEncoder<'tcx>: SpanEncoder { |
There was a problem hiding this comment.
this feels rustc specific and is not used by r-a afaik, so I'd prefer keeping this in rustc_middle for now
| } | ||
|
|
||
| pub trait Interned<T>: Clone + Copy + Hash + PartialEq + Eq + Debug { | ||
| fn new_unchecked(t: &T) -> Self; |
There was a problem hiding this comment.
🤔 where is that used, surprising that we'd ever want to use this in rustc_next_trait_solver
| + Hash | ||
| + Eq | ||
| + PartialEq | ||
| + Deref<Target = T>; |
There was a problem hiding this comment.
should be a super trait bounds of a single Interned trait
compiler/rustc_type_ir/src/lib.rs
Outdated
| #![cfg_attr(feature = "nightly", rustc_diagnostic_item = "type_ir")] | ||
| // tidy-alphabetical-start | ||
| #![allow(rustc::direct_use_of_rustc_type_ir)] | ||
| #![allow(rustc::pass_by_value)] |
c64839d to
9b563d7
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| BlobDecoder, BytePos, ByteSymbol, DUMMY_SP, Pos, RemapPathScopeComponents, SpanData, | ||
| SpanDecoder, Symbol, SyntaxContext, kw, | ||
| }; | ||
| use rustc_type_ir::codec::TyDecoder; |
There was a problem hiding this comment.
TyDecoder should stay in rustc_middle 🤔
| def_id: DefId, | ||
| args: Self::GenericArgs, | ||
| ) -> Ty<'tcx> { | ||
| Ty::new_coroutine_witness_for_coroutine(self, def_id, args) |
There was a problem hiding this comment.
why method on Interner insetead of Ty?
| } | ||
|
|
||
| fn ty_discriminant_ty(self, ty: Ty<'tcx>) -> Ty<'tcx> { | ||
| ty.discriminant_ty(self) |
| fn u8_type(self) -> Ty<'tcx> { | ||
| self.types.u8 | ||
| } |
There was a problem hiding this comment.
can you, potentially in an earlier PR so that we can test it for perf, stop using self.types.X and instead use Ty::new_uint(..). This should inline to the same thing and means whether we have a precomputed interned type for u8 is not handled by the interner
| use rustc_macros::{Lift, extension}; | ||
| use rustc_session::cstore::{ExternCrate, ExternCrateSource}; | ||
| use rustc_span::{Ident, RemapPathScopeComponents, Symbol, kw, sym}; | ||
| use rustc_type_ir::inherent::{GenericArgs as _, IntoKind as _}; |
There was a problem hiding this comment.
why? we should never import these traits 🤔
There was a problem hiding this comment.
I believe it is due to have implemented IntoKind on Ty to expose the kind() method but then not made a pub fn kind(&self) pass-through method that previously existed. I would think once I've implemented the pass-through I can remove this. As for GenericArgs, it could possibly a similar reason
| tcx, | ||
| trait_def_id, | ||
| [self_ty, Ty::new_tup(tcx, args)], | ||
| [self_ty, ty::Ty::new_tup(tcx, args)], |
There was a problem hiding this comment.
this should lint 🤔 as we want people to consistently use Ty and import it from rustc_middle::ty. We should have some #[cfg_if("nightly", rustc_diagnostic_item = "Ty")] attribute on Ty
| write!(p, ")")?; | ||
|
|
||
| if !sig.output().is_unit() { | ||
| if !matches!(sig.output().kind(), ty::Tuple(tys) if tys.is_empty()) { |
| type GenericArgsSlice: Copy + Debug + Hash + Eq + SliceLike<Item = Self::GenericArg>; | ||
| type GenericArg: GenericArg<Self>; | ||
| type Term: Term<Self>; | ||
| type Term: Term<Self> + From<Ty<Self>>; |
There was a problem hiding this comment.
From<Ty<Self>> should be super-trait of Term instead
4bb23fa to
f89feb9
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
r? ghost