Use extension trait derive
This commit is contained in:
parent
3250e95305
commit
9c25823bb4
29 changed files with 121 additions and 974 deletions
|
@ -23,20 +23,8 @@ use std::fmt;
|
|||
use std::num::NonZero;
|
||||
use std::ops::Bound;
|
||||
|
||||
pub trait IntegerExt {
|
||||
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>, signed: bool) -> Ty<'tcx>;
|
||||
fn from_int_ty<C: HasDataLayout>(cx: &C, ity: ty::IntTy) -> Integer;
|
||||
fn from_uint_ty<C: HasDataLayout>(cx: &C, uty: ty::UintTy) -> Integer;
|
||||
fn repr_discr<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
repr: &ReprOptions,
|
||||
min: i128,
|
||||
max: i128,
|
||||
) -> (Integer, bool);
|
||||
}
|
||||
|
||||
impl IntegerExt for Integer {
|
||||
#[extension]
|
||||
pub impl IntegerExt for Integer {
|
||||
#[inline]
|
||||
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>, signed: bool) -> Ty<'tcx> {
|
||||
match (*self, signed) {
|
||||
|
@ -123,12 +111,8 @@ impl IntegerExt for Integer {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait PrimitiveExt {
|
||||
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>;
|
||||
fn to_int_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx>;
|
||||
}
|
||||
|
||||
impl PrimitiveExt for Primitive {
|
||||
#[extension]
|
||||
pub impl PrimitiveExt for Primitive {
|
||||
#[inline]
|
||||
fn to_ty<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
|
||||
match *self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue