Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aa95b96

Browse files
committedMar 15, 2025
Auto merge of rust-lang#138464 - compiler-errors:less-type-ir, r=lcnr
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
2 parents adea7cb + b88f85a commit aa95b96

File tree

160 files changed

+748
-695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+748
-695
lines changed
 

‎compiler/rustc_codegen_ssa/src/errors.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ use rustc_errors::{
1212
Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, IntoDiagArg, Level,
1313
};
1414
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
15-
use rustc_middle::ty::Ty;
1615
use rustc_middle::ty::layout::LayoutError;
16+
use rustc_middle::ty::{FloatTy, Ty};
1717
use rustc_span::{Span, Symbol};
18-
use rustc_type_ir::FloatTy;
1918

2019
use crate::assert_module_sources::CguReuse;
2120
use crate::back::command::Command;

‎compiler/rustc_codegen_ssa/src/mir/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
4343
mir::Const::Ty(_, c) => match c.kind() {
4444
// A constant that came from a const generic but was then used as an argument to
4545
// old-style simd_shuffle (passing as argument instead of as a generic param).
46-
rustc_type_ir::ConstKind::Value(cv) => return Ok(Ok(cv.valtree)),
46+
ty::ConstKind::Value(cv) => return Ok(Ok(cv.valtree)),
4747
other => span_bug!(constant.span, "{other:#?}"),
4848
},
4949
// We should never encounter `Const::Val` unless MIR opts (like const prop) evaluate

‎compiler/rustc_const_eval/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ rustc_session = { path = "../rustc_session" }
2323
rustc_span = { path = "../rustc_span" }
2424
rustc_target = { path = "../rustc_target" }
2525
rustc_trait_selection = { path = "../rustc_trait_selection" }
26-
rustc_type_ir = { path = "../rustc_type_ir" }
2726
tracing = "0.1"
2827
# tidy-alphabetical-end
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.