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
compiler/rustc_type_ir/src/binder.rs
Outdated
| feature = "nightly", | ||
| derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext) | ||
| )] | ||
| #[cfg_attr(feature = "nightly", derive(HashStable_NoContext))] |
compiler/rustc_type_ir/src/binder.rs
Outdated
| #[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
|
|
||
| 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
compiler/rustc_type_ir/src/binder.rs
Outdated
| 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
There was a problem hiding this comment.
I've moved this back as I don't know how to make this work without doing so. I get the errors;
error[E0210]: type parameter `E` must be used as the type parameter for some local type (e.g., `MyStruct<E>`)
--> compiler/rustc_middle/src/ty/codec.rs:142:12
|
142 | impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Ty<'tcx> {
| ^ type parameter `E` must be used as the type parameter for some local type
|
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter
error[E0210]: type parameter `D` must be used as the type parameter for some local type (e.g., `MyStruct<D>`)
--> compiler/rustc_middle/src/ty/codec.rs:234:12
|
234 | impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Ty<'tcx> {
| ^ type parameter `D` must be used as the type parameter for some local type
|
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
= note: only traits defined in the current crate can be implemented for a type parameter
The simplest thing I could think of to make the error go away was to move it
| } | ||
|
|
||
| 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.
| 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
There was a problem hiding this comment.
I would expect that with Ty you now have an inherent fn kind method 🤔
| 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
4bb23fa to
f89feb9
Compare
This comment has been minimized.
This comment has been minimized.
f89feb9 to
0780eb0
Compare
This comment has been minimized.
This comment has been minimized.
207dc41 to
bc41000
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cf831bc to
6b77eb6
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6b77eb6 to
6e68fcc
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6e68fcc to
27ceba3
Compare
This comment has been minimized.
This comment has been minimized.
4462ec4 to
80bdb0c
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
80bdb0c to
f13f2dd
Compare
This comment has been minimized.
This comment has been minimized.
8805200 to
a000014
Compare
This comment has been minimized.
This comment has been minimized.
a000014 to
28d7f8f
Compare
28d7f8f to
8b6b679
Compare
r? ghost