-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Use rustc_type_ir
directly less in the codebase
#138464
Conversation
changes to the core type system Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor Some changes occurred in compiler/rustc_sanitizers cc @rust-lang/project-exploit-mitigations, @rcvalle changes to These commits modify the If this was unintentional then you should revert the changes before this PR is merged. Some changes occurred to the CTFE machinery Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr Some changes occurred in compiler/rustc_codegen_ssa HIR ty lowering was modified cc @fmease Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred in need_type_info.rs cc @lcnr |
@bors r+ rollup=iffy |
Use `rustc_type_ir` directly less in the codebase cc rust-lang#138449 This is a somewhat opinionated bundle of changes that will make working on rust-lang#138449 more easy, since it cuts out the bulk of the changes that would be necessitated by the lint. Namely: 1. Fold `rustc_middle::ty::fold` and `rustc_middle::ty::visit` into `rustc_middle::ty`. This is because we already reexport some parts of these modules into `rustc_middle::ty`, and there's really no benefit from namespacing away the rest of these modules's functionality given how important folding and visiting is to the type layer. 2. Rename `{Decodable,Encodable}_Generic` to `{Decodable,Encodable}_NoContext`[^why], change it to be "perfect derive" (`synstructure::AddBounds::Fields`), use it throughout `rustc_type_ir` instead of `TyEncodable`/`TyDecodable`. 3. Make `TyEncodable` and `TyDecodable` derives use `::rustc_middle::ty::codec::TyEncoder` (etc) for its generated paths, and move the `rustc_type_ir::codec` module back to `rustc_middle::ty::codec` :tada:. 4. Stop using `rustc_type_ir` in crates that aren't "fundamental" to the type system, namely middle/infer/trait-selection. This amounted mostly to changing imports from `use rustc_type_ir::...` to `use rustc_middle::ty::...`, but also this means that we can't glob import `TyKind::*` since the reexport into `rustc_middle::ty::TyKind` is a type alias. Instead, use the prefixed variants like `ty::Str` everywhere -- IMO this is a good change, since it makes it more regularized with most of the rest of the compiler. [^why]: `_NoContext` is the name for derive macros with no additional generic bounds and which do "perfect derive" by generating bounds based on field types. See `HashStable_NoContext`. I'm happy to cut out some of these changes into separate PRs to make landing it a bit easier, though I don't expect to have much trouble with bitrot. r? lcnr
💔 Test failed - checks-actions |
This comment has been minimized.
This comment has been minimized.
e4a6593
to
b88f85a
Compare
@bors r=lcnr |
☀️ Test successful - checks-actions |
Finished benchmarking commit (aa95b96): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 773.052s -> 771.649s (-0.18%) |
Use `rustc_type_ir` directly less in the codebase cc rust-lang#138449 This is a somewhat opinionated bundle of changes that will make working on rust-lang#138449 more easy, since it cuts out the bulk of the changes that would be necessitated by the lint. Namely: 1. Fold `rustc_middle::ty::fold` and `rustc_middle::ty::visit` into `rustc_middle::ty`. This is because we already reexport some parts of these modules into `rustc_middle::ty`, and there's really no benefit from namespacing away the rest of these modules's functionality given how important folding and visiting is to the type layer. 2. Rename `{Decodable,Encodable}_Generic` to `{Decodable,Encodable}_NoContext`[^why], change it to be "perfect derive" (`synstructure::AddBounds::Fields`), use it throughout `rustc_type_ir` instead of `TyEncodable`/`TyDecodable`. 3. Make `TyEncodable` and `TyDecodable` derives use `::rustc_middle::ty::codec::TyEncoder` (etc) for its generated paths, and move the `rustc_type_ir::codec` module back to `rustc_middle::ty::codec` :tada:. 4. Stop using `rustc_type_ir` in crates that aren't "fundamental" to the type system, namely middle/infer/trait-selection. This amounted mostly to changing imports from `use rustc_type_ir::...` to `use rustc_middle::ty::...`, but also this means that we can't glob import `TyKind::*` since the reexport into `rustc_middle::ty::TyKind` is a type alias. Instead, use the prefixed variants like `ty::Str` everywhere -- IMO this is a good change, since it makes it more regularized with most of the rest of the compiler. [^why]: `_NoContext` is the name for derive macros with no additional generic bounds and which do "perfect derive" by generating bounds based on field types. See `HashStable_NoContext`. I'm happy to cut out some of these changes into separate PRs to make landing it a bit easier, though I don't expect to have much trouble with bitrot. r? lcnr
cc #138449
This is a somewhat opinionated bundle of changes that will make working on #138449 more easy, since it cuts out the bulk of the changes that would be necessitated by the lint. Namely:
rustc_middle::ty::fold
andrustc_middle::ty::visit
intorustc_middle::ty
. This is because we already reexport some parts of these modules intorustc_middle::ty
, and there's really no benefit from namespacing away the rest of these modules's functionality given how important folding and visiting is to the type layer.{Decodable,Encodable}_Generic
to{Decodable,Encodable}_NoContext
1, change it to be "perfect derive" (synstructure::AddBounds::Fields
), use it throughoutrustc_type_ir
instead ofTyEncodable
/TyDecodable
.TyEncodable
andTyDecodable
derives use::rustc_middle::ty::codec::TyEncoder
(etc) for its generated paths, and move therustc_type_ir::codec
module back torustc_middle::ty::codec
🎉.rustc_type_ir
in crates that aren't "fundamental" to the type system, namely middle/infer/trait-selection. This amounted mostly to changing imports fromuse rustc_type_ir::...
touse rustc_middle::ty::...
, but also this means that we can't glob importTyKind::*
since the reexport intorustc_middle::ty::TyKind
is a type alias. Instead, use the prefixed variants likety::Str
everywhere -- IMO this is a good change, since it makes it more regularized with most of the rest of the compiler.I'm happy to cut out some of these changes into separate PRs to make landing it a bit easier, though I don't expect to have much trouble with bitrot.
r? lcnr
Footnotes
_NoContext
is the name for derive macros with no additional generic bounds and which do "perfect derive" by generating bounds based on field types. SeeHashStable_NoContext
. ↩