Skip to content

Commit 6daf40e

Browse files
committed
Use trait aliases to shorten some code.
1 parent 04a3187 commit 6daf40e

File tree

4 files changed

+8
-44
lines changed

4 files changed

+8
-44
lines changed

compiler/rustc_codegen_ssa/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#![feature(negative_impls)]
1212
#![feature(rustdoc_internals)]
1313
#![feature(strict_provenance)]
14+
#![feature(trait_alias)]
1415
#![feature(try_blocks)]
1516
#![warn(unreachable_pub)]
1617
// tidy-alphabetical-end

compiler/rustc_codegen_ssa/src/traits/backend.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,11 @@ pub trait BackendTypes {
3636
type DIVariable: Copy;
3737
}
3838

39-
pub trait Backend<'tcx>:
40-
Sized
39+
pub trait Backend<'tcx> = Sized
4140
+ BackendTypes
4241
+ HasTyCtxt<'tcx>
4342
+ LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
44-
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>
45-
{
46-
}
47-
48-
impl<'tcx, T> Backend<'tcx> for T where
49-
Self: BackendTypes
50-
+ HasTyCtxt<'tcx>
51-
+ LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
52-
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>
53-
{
54-
}
43+
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>;
5544

5645
pub trait CodegenBackend {
5746
/// Locale resources for diagnostic messages - a string the content of the Fluent resource.

compiler/rustc_codegen_ssa/src/traits/mod.rs

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ pub use self::type_::{
5050
};
5151
pub use self::write::{ModuleBufferMethods, ThinBufferMethods, WriteBackendMethods};
5252

53-
pub trait CodegenObject: Copy + PartialEq + fmt::Debug {}
54-
impl<T: Copy + PartialEq + fmt::Debug> CodegenObject for T {}
53+
pub trait CodegenObject = Copy + PartialEq + fmt::Debug;
5554

56-
pub trait CodegenMethods<'tcx>:
57-
Backend<'tcx>
55+
pub trait CodegenMethods<'tcx> = Backend<'tcx>
5856
+ TypeMethods<'tcx>
5957
+ MiscMethods<'tcx>
6058
+ ConstMethods<'tcx>
@@ -64,24 +62,7 @@ pub trait CodegenMethods<'tcx>:
6462
+ PreDefineMethods<'tcx>
6563
+ HasParamEnv<'tcx>
6664
+ HasTyCtxt<'tcx>
67-
+ HasTargetSpec
68-
{
69-
}
70-
71-
impl<'tcx, T> CodegenMethods<'tcx> for T where
72-
Self: Backend<'tcx>
73-
+ TypeMethods<'tcx>
74-
+ MiscMethods<'tcx>
75-
+ ConstMethods<'tcx>
76-
+ StaticMethods
77-
+ DebugInfoMethods<'tcx>
78-
+ AsmMethods<'tcx>
79-
+ PreDefineMethods<'tcx>
80-
+ HasParamEnv<'tcx>
81-
+ HasTyCtxt<'tcx>
82-
+ HasTargetSpec
83-
{
84-
}
65+
+ HasTargetSpec;
8566

8667
pub trait HasCodegen<'tcx>:
8768
Backend<'tcx> + std::ops::Deref<Target = <Self as HasCodegen<'tcx>>::CodegenCx>

compiler/rustc_codegen_ssa/src/traits/type_.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,5 @@ pub trait ArgAbiMethods<'tcx>: HasCodegen<'tcx> {
172172
fn arg_memory_ty(&self, arg_abi: &ArgAbi<'tcx, Ty<'tcx>>) -> Self::Type;
173173
}
174174

175-
pub trait TypeMethods<'tcx>:
176-
DerivedTypeMethods<'tcx> + LayoutTypeMethods<'tcx> + TypeMembershipMethods<'tcx>
177-
{
178-
}
179-
180-
impl<'tcx, T> TypeMethods<'tcx> for T where
181-
Self: DerivedTypeMethods<'tcx> + LayoutTypeMethods<'tcx> + TypeMembershipMethods<'tcx>
182-
{
183-
}
175+
pub trait TypeMethods<'tcx> =
176+
DerivedTypeMethods<'tcx> + LayoutTypeMethods<'tcx> + TypeMembershipMethods<'tcx>;

0 commit comments

Comments
 (0)