diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-07-31 11:52:42 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-07-31 19:56:11 +1000 |
| commit | 1901dde97bdff7b6b308c41d751e826df4eb2016 (patch) | |
| tree | 402f2955610c02945f0b43464b5e307154735209 /compiler/rustc_middle/src | |
| parent | 606dcc0d2e54d260f67d8a91f8adaf797a4ed38a (diff) | |
| download | rust-1901dde97bdff7b6b308c41d751e826df4eb2016.tar.gz rust-1901dde97bdff7b6b308c41d751e826df4eb2016.zip | |
Deduplicate `IntTy`/`UintTy`/`FloatTy`.
There are identical definitions in `rustc_type_ir` and `rustc_ast`. This commit removes them and places a single definition in `rustc_ast_ir`. This requires adding `rust_span` as a dependency of `rustc_ast_ir`, but means a bunch of silly conversion functions can be removed. The one annoying wrinkle is that the old version had differences in their `Debug` impls, e.g. one printed `u32` while the other printed `U32`. Some compiler error messages rely on the former (yuk), and some clippy output depends on the latter. So the commit also changes clippy to not rely on `Debug` and just implement what it needs itself.
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index bb70c61cd14..4524fb5a097 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2198,59 +2198,6 @@ impl<'tcx> TyCtxt<'tcx> { } } -pub fn int_ty(ity: ast::IntTy) -> IntTy { - match ity { - ast::IntTy::Isize => IntTy::Isize, - ast::IntTy::I8 => IntTy::I8, - ast::IntTy::I16 => IntTy::I16, - ast::IntTy::I32 => IntTy::I32, - ast::IntTy::I64 => IntTy::I64, - ast::IntTy::I128 => IntTy::I128, - } -} - -pub fn uint_ty(uty: ast::UintTy) -> UintTy { - match uty { - ast::UintTy::Usize => UintTy::Usize, - ast::UintTy::U8 => UintTy::U8, - ast::UintTy::U16 => UintTy::U16, - ast::UintTy::U32 => UintTy::U32, - ast::UintTy::U64 => UintTy::U64, - ast::UintTy::U128 => UintTy::U128, - } -} - -pub fn float_ty(fty: ast::FloatTy) -> FloatTy { - match fty { - ast::FloatTy::F16 => FloatTy::F16, - ast::FloatTy::F32 => FloatTy::F32, - ast::FloatTy::F64 => FloatTy::F64, - ast::FloatTy::F128 => FloatTy::F128, - } -} - -pub fn ast_int_ty(ity: IntTy) -> ast::IntTy { - match ity { - IntTy::Isize => ast::IntTy::Isize, - IntTy::I8 => ast::IntTy::I8, - IntTy::I16 => ast::IntTy::I16, - IntTy::I32 => ast::IntTy::I32, - IntTy::I64 => ast::IntTy::I64, - IntTy::I128 => ast::IntTy::I128, - } -} - -pub fn ast_uint_ty(uty: UintTy) -> ast::UintTy { - match uty { - UintTy::Usize => ast::UintTy::Usize, - UintTy::U8 => ast::UintTy::U8, - UintTy::U16 => ast::UintTy::U16, - UintTy::U32 => ast::UintTy::U32, - UintTy::U64 => ast::UintTy::U64, - UintTy::U128 => ast::UintTy::U128, - } -} - pub fn provide(providers: &mut Providers) { closure::provide(providers); context::provide(providers); |
