-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Move structures from ty/mod.rs
into their own modules
#111503
The head ref may contain hidden characters: "\u{1F338}cutify_ty\u{1F338}"
Conversation
…tlivesPredicate, RegionOutlivesPredicate, TypeOutlivesPredicate}` to their own little module (cute)
…n little module (cute)
…derType}` to their own little module (cute)
… to their own little module (cute)
…InherentImpls, CrateVariancesMap, Destructor, DestructuredConst, ImplHeader, ImplOverlapKind, ImplSubject, InferVarInfo, OpaqueTypeKey, VariantDiscr, VariantFlags}` to their own little modules (cute)
... and add `MainDefinition` to it
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.
Maybe let's see what @cjgillot thinks. Also this should be squashed at the end -- it doesn't necessarily need to be 1 commit, but also I think 40 commits is a bit excessive.
@@ -0,0 +1,3 @@ | |||
use crate::ty::{BoundRegion, Placeholder}; |
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.
You should just move it into sty with the rest of the region variants, then later if you want to break up sty, all the region variants can be moved into a file here. This file in its current state is kinda misleading, lmao
@@ -0,0 +1,103 @@ | |||
use crate::ty::{ |
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.
I still think that this should live in predicates. These are essentially just Into
implementations for Predicate
, and it's easier to just have them live with the types they're defined on.
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.
I feel like we ought to just not have any of the predicate/
files and isntead put it all in predicate.rs
there's barely anything in the submodules and they would fit in fine in predicate.rs
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.
@compiler-errors Most of those are not implemented for Predicate
s though, so I'm not sure I follow...
@BoxyUwU I don't agree, having the same points as before: adding more entities to the same file makes it harder to add something there (it's easy to mess with the order) and harder to navigate... I can understand the reasoning behind having all predicate parts in a single file (after all, it's essentially a single thing split into multiple types), but I can't see the point in merging ToPredicate
, InstantiatedPredicates
and CratePredicatesMap
there too.
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.
Most of those are not implemented for Predicates though, so I'm not sure I follow...
What? Except for the blanket impl, almost all of these are turning PolyXPredicate
s into ty::Predicate
.
@@ -0,0 +1,8 @@ | |||
use crate::ty::{self, VariantIdx}; |
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.
I think this probably should just live with the rest of the consts..
☔ The latest upstream changes (presumably #111570) made this pull request unmergeable. Please resolve the merge conflicts. |
span_bug, | ||
ty::{ResolverAstLowering, TyCtxt}, | ||
}; | ||
use rustc_middle::{resolver_outputs::ResolverAstLowering, span_bug, ty::TyCtxt}; |
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.
Could you make 3 imports of this?
/// Contains information needed to resolve types and (in the future) look up | ||
/// the types of AST nodes. | ||
#[derive(Copy, Clone, PartialEq, Eq, Hash)] | ||
pub struct CReaderCacheKey { |
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.
This is should be in ty::context
, close to its actual use.
|
||
#[derive(Clone, Debug, PartialEq, Eq, Copy, Hash, TyEncodable, TyDecodable, HashStable)] | ||
#[derive(TypeFoldable, TypeVisitable)] | ||
pub struct ClosureSizeProfileData<'tcx> { |
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.
In ty::closure
or typeck_results
, where it is used?
use rustc_hir::def_id::DefId; | ||
|
||
#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable)] | ||
pub struct Destructor { |
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.
In ty::adt
?
/// `tcx.variances_of()` to get the variance for a *particular* | ||
/// item. | ||
#[derive(HashStable, Debug)] | ||
pub struct CrateVariancesMap<'tcx> { |
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.
Variances are mostly used in ty::relate
, aren't they?
/// another. | ||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] | ||
#[derive(HashStable, TyEncodable, TyDecodable)] | ||
pub struct Placeholder<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.
In rustc_type_ir
?
/// like `Foo<isize,usize>`, then the `InstantiatedPredicates` would be `[[], | ||
/// [usize:Bar<isize>]]`. | ||
#[derive(Clone, Debug, TypeFoldable, TypeVisitable)] | ||
pub struct InstantiatedPredicates<'tcx> { |
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 this go in ty::predicate
too?
use crate::ty::TyCtxt; | ||
|
||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, HashStable)] | ||
pub struct SymbolName<'tcx> { |
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.
In mir::mono
?
pub type PlaceholderType = Placeholder<BoundTy>; | ||
|
||
#[derive(Debug, Default, Copy, Clone)] | ||
pub struct InferVarInfo { |
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.
This can be moved to rustc_hir_typeck
.
/// Use this rather than `TyKind`, whenever possible. | ||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)] | ||
#[rustc_diagnostic_item = "Ty"] | ||
#[rustc_pass_by_value] | ||
pub struct Ty<'tcx>(pub(super) Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>); | ||
|
||
pub type PlaceholderType = Placeholder<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.
Those should be in sty until you get to break it.
I see a few open comments so I think this can be switched to waiting on the author @rustbot author |
This is not going anywhere in this state. I'll try to do smaller PRs that only move items of a certain theme, so that it's actually possible to review and do the changes (this is basically impossible to rebase). |
Status update: I did not in fact do smaller PRs. I still think that giant |
Revival of #111208, because github refuses to work correctly.
r? @compiler-errors
cc @cjgillot
I've implemented most of the suggestions from #111208's reviews.
Exceptions:
ToPredicate
andInstantiatedPredicates
ty::query
(and move the macros in likety::query::macros
), but idkI'd also like to split adt stuff at least a little, for example