-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Move struct placeholder pt2 #150271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Move struct placeholder pt2 #150271
Conversation
This comment has been minimized.
This comment has been minimized.
753b92c to
2077c6b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| mapped_regions: IndexMap<I::PlaceholderRegion, ty::BoundRegion>, | ||
| mapped_types: IndexMap<I::PlaceholderTy, ty::BoundTy>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does PlaceholderRegion and PlaceholderTy still exist? 🤔
|
|
||
| pub type PlaceholderConst<I: Interner> = ty::Placeholder<I, BoundConst>; | ||
|
|
||
| impl<I: Interner> PlaceholderLike<I> for PlaceholderConst<I> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no longer need the trait, can just use inherent methods now
|
The reason
Try to replace the manual impl with a derive and see if anything breaks. If it does break, add |
d262f5c to
d36238d
Compare
This comment has been minimized.
This comment has been minimized.
d36238d to
a03a907
Compare
This comment has been minimized.
This comment has been minimized.
a03a907 to
b4de573
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
044bbd5 to
cdff0b9
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
implementation of `HashStable`
…es I moved over to `binder.rs`
…ment `HashStable` for required emums and structs
e30f48d to
9dec2e9
Compare
This comment has been minimized.
This comment has been minimized.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| let mut full_binders: Vec<ty::BoundVariableKind<'tcx>> = | ||
| self.rbv.late_bound_vars.get_mut_or_insert_default(hir_id.local_id).clone(); | ||
|
|
||
| full_binders.extend(supertrait_bound_vars); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why these changes
| assert!(matches!(index_kind, ty::BoundVarIndexKind::Canonical)); | ||
| opt_values[bv.var()] = Some(*original_value); | ||
| opt_values | ||
| [<ty::BoundConst as rustc_type_ir::inherent::BoundVarLike<I>>::var(bv)] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should just be bv.var() still. We shouldn't need the BoundVarLike trait anymore, do we?
| #[derive_where(Clone, Ord, Eq, PartialEq, Hash; I: Interner, T)] | ||
| #[derive_where(PartialOrd; I: Interner, T: Ord)] | ||
| #[derive_where(Copy; I: Interner, T: Copy, T)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
existing: what are these derive_where 😅 they are an inconsistent mess xd
| T: HashStable<CTX>, | ||
| { | ||
| fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) { | ||
| self.universe.hash_stable(hcx, hasher); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| self.universe.hash_stable(hcx, hasher); | |
| let Placeholder { universe, bound, _tcx } = self; | |
| universe.hash_stable(hcx, hasher); | |
| bound.hash_stable(hcx, hasher); |
while unlikely, this makes sure that we won't forget to update this function when adding a field to placeholder
| #[derive_where(Clone, PartialEq, Eq, Hash; I: Interner)] | ||
| #[derive_where(Copy; I: Interner)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the Copy separate here
| I::Symbol: Hash, | ||
| I::DefId: Hash, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's wrong. these things need to be HashStable. Directly hashing DefIds has different results in different compilation sessions, causing your ICE
| #[derive_where(Clone, PartialEq, Eq, Debug, Hash; I: Interner)] | ||
| #[derive_where(Copy; I: Interner)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sus derive_where
| #[derive_where(Clone, PartialEq, Eq, Debug, Hash; I: Interner)] | ||
| #[derive_where(Copy; I: Interner)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
| #[derive_where(Clone, PartialEq, Eq, Hash; I: Interner)] | ||
| #[derive_where(Copy; I: Interner)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etc
|
|
||
| pub type PlaceholderRegion<I> = ty::Placeholder<I, BoundRegion<I>>; | ||
|
|
||
| impl<I: Interner> PlaceholderLike<I> for PlaceholderRegion<I> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove PlaceholderLike, can be inherent methods
| } | ||
| } | ||
|
|
||
| impl<I: Interner> BoundVarLike<I> for BoundRegion<I> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| #[derive_where(Clone, PartialEq, Eq, Hash; I: Interner)] | ||
| #[derive_where(Copy; I: Interner)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
derive_where
| } | ||
| ty::GenericArgKind::Const(ct) => { | ||
| matches!(ct.kind(), ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, bc) if bc.var().as_usize() == bv) | ||
| matches!(ct.kind(), ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, bc) if <ty::BoundConst as BoundVarLike<I>>::var(bc).as_usize() == bv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no :<
| } | ||
| ty::GenericArgKind::Const(ct) => { | ||
| if matches!(ct.kind(), ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, bc) if var == bc.var()) | ||
| if matches!(ct.kind(), ty::ConstKind::Bound(ty::BoundVarIndexKind::Canonical, bc) if var == <ty::BoundConst as BoundVarLike<I>>::var(bc)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also no
| } | ||
|
|
||
| type DefId: DefId<Self>; | ||
| type DefId: DefId<Self> + Hash; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add HashStable as a requirement to DefId behind a cfg(nightly)
edit: actually, looking at other HashStable<CTX> impls, this just shouldn't be necessary 🤔 we can just add I::DefId: HashStable<CTX> as a where-bound in the impl?
| let name = self.opt_item_name(id).unwrap_or_else(|| { | ||
| bug!("item_name: no name for {:?}", self.def_path(id)); | ||
| }); | ||
| if name != kw::UnderscoreLifetime { Some(name) } else { None } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not add opt_item_name to the interner instead 🤔
I guess we'd need to import kw::UnderscopeLifetime to rustc_middle?
maybe instead add a fn is_kw_underscore_lifetime to I::Symbol/trait Symbol?
r? ghost