Remove Ty prefix from Ty{Bool|Char|Int|Uint|Float|Str}
This commit is contained in:
parent
04fa5d3adb
commit
8a5dccde2a
@ -1672,12 +1672,12 @@ impl fmt::Debug for Ty {
|
||||
/// Not represented directly in the AST, referred to by name through a ty_path.
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||
pub enum PrimTy {
|
||||
TyInt(IntTy),
|
||||
TyUint(UintTy),
|
||||
TyFloat(FloatTy),
|
||||
TyStr,
|
||||
TyBool,
|
||||
TyChar,
|
||||
Int(IntTy),
|
||||
Uint(UintTy),
|
||||
Float(FloatTy),
|
||||
Str,
|
||||
Bool,
|
||||
Char,
|
||||
}
|
||||
|
||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||
|
@ -308,12 +308,12 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::Ty {
|
||||
}
|
||||
|
||||
impl_stable_hash_for!(enum hir::PrimTy {
|
||||
TyInt(int_ty),
|
||||
TyUint(uint_ty),
|
||||
TyFloat(float_ty),
|
||||
TyStr,
|
||||
TyBool,
|
||||
TyChar
|
||||
Int(int_ty),
|
||||
Uint(uint_ty),
|
||||
Float(float_ty),
|
||||
Str,
|
||||
Bool,
|
||||
Char
|
||||
});
|
||||
|
||||
impl_stable_hash_for!(struct hir::BareFnTy {
|
||||
|
@ -806,20 +806,20 @@ for ty::TyKind<'gcx>
|
||||
|
||||
mem::discriminant(self).hash_stable(hcx, hasher);
|
||||
match *self {
|
||||
TyBool |
|
||||
TyChar |
|
||||
TyStr |
|
||||
Bool |
|
||||
Char |
|
||||
Str |
|
||||
Error |
|
||||
Never => {
|
||||
// Nothing more to hash.
|
||||
}
|
||||
TyInt(int_ty) => {
|
||||
Int(int_ty) => {
|
||||
int_ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyUint(uint_ty) => {
|
||||
Uint(uint_ty) => {
|
||||
uint_ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
TyFloat(float_ty) => {
|
||||
Float(float_ty) => {
|
||||
float_ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
Adt(adt_def, substs) => {
|
||||
|
@ -265,13 +265,13 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
|
||||
ty::Closure(..)
|
||||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::TyBool
|
||||
| ty::TyChar
|
||||
| ty::TyInt(..)
|
||||
| ty::TyUint(..)
|
||||
| ty::TyFloat(..)
|
||||
| ty::Bool
|
||||
| ty::Char
|
||||
| ty::Int(..)
|
||||
| ty::Uint(..)
|
||||
| ty::Float(..)
|
||||
| ty::Adt(..)
|
||||
| ty::TyStr
|
||||
| ty::Str
|
||||
| ty::Error
|
||||
| ty::Array(..)
|
||||
| ty::Slice(..)
|
||||
|
@ -83,16 +83,16 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
|
||||
.map_err(|e| int_unification_error(a_is_expected, e))?;
|
||||
Ok(a)
|
||||
}
|
||||
(&ty::Infer(ty::IntVar(v_id)), &ty::TyInt(v)) => {
|
||||
(&ty::Infer(ty::IntVar(v_id)), &ty::Int(v)) => {
|
||||
self.unify_integral_variable(a_is_expected, v_id, IntType(v))
|
||||
}
|
||||
(&ty::TyInt(v), &ty::Infer(ty::IntVar(v_id))) => {
|
||||
(&ty::Int(v), &ty::Infer(ty::IntVar(v_id))) => {
|
||||
self.unify_integral_variable(!a_is_expected, v_id, IntType(v))
|
||||
}
|
||||
(&ty::Infer(ty::IntVar(v_id)), &ty::TyUint(v)) => {
|
||||
(&ty::Infer(ty::IntVar(v_id)), &ty::Uint(v)) => {
|
||||
self.unify_integral_variable(a_is_expected, v_id, UintType(v))
|
||||
}
|
||||
(&ty::TyUint(v), &ty::Infer(ty::IntVar(v_id))) => {
|
||||
(&ty::Uint(v), &ty::Infer(ty::IntVar(v_id))) => {
|
||||
self.unify_integral_variable(!a_is_expected, v_id, UintType(v))
|
||||
}
|
||||
|
||||
@ -104,10 +104,10 @@ impl<'infcx, 'gcx, 'tcx> InferCtxt<'infcx, 'gcx, 'tcx> {
|
||||
.map_err(|e| float_unification_error(relation.a_is_expected(), e))?;
|
||||
Ok(a)
|
||||
}
|
||||
(&ty::Infer(ty::FloatVar(v_id)), &ty::TyFloat(v)) => {
|
||||
(&ty::Infer(ty::FloatVar(v_id)), &ty::Float(v)) => {
|
||||
self.unify_float_variable(a_is_expected, v_id, v)
|
||||
}
|
||||
(&ty::TyFloat(v), &ty::Infer(ty::FloatVar(v_id))) => {
|
||||
(&ty::Float(v), &ty::Infer(ty::FloatVar(v_id))) => {
|
||||
self.unify_float_variable(!a_is_expected, v_id, v)
|
||||
}
|
||||
|
||||
|
@ -704,11 +704,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
fn equals<'tcx>(a: &Ty<'tcx>, b: &Ty<'tcx>) -> bool {
|
||||
match (&a.sty, &b.sty) {
|
||||
(a, b) if *a == *b => true,
|
||||
(&ty::TyInt(_), &ty::Infer(ty::InferTy::IntVar(_)))
|
||||
| (&ty::Infer(ty::InferTy::IntVar(_)), &ty::TyInt(_))
|
||||
(&ty::Int(_), &ty::Infer(ty::InferTy::IntVar(_)))
|
||||
| (&ty::Infer(ty::InferTy::IntVar(_)), &ty::Int(_))
|
||||
| (&ty::Infer(ty::InferTy::IntVar(_)), &ty::Infer(ty::InferTy::IntVar(_)))
|
||||
| (&ty::TyFloat(_), &ty::Infer(ty::InferTy::FloatVar(_)))
|
||||
| (&ty::Infer(ty::InferTy::FloatVar(_)), &ty::TyFloat(_))
|
||||
| (&ty::Float(_), &ty::Infer(ty::InferTy::FloatVar(_)))
|
||||
| (&ty::Infer(ty::InferTy::FloatVar(_)), &ty::Float(_))
|
||||
| (
|
||||
&ty::Infer(ty::InferTy::FloatVar(_)),
|
||||
&ty::Infer(ty::InferTy::FloatVar(_)),
|
||||
|
@ -175,13 +175,13 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
|
||||
bug!("encountered canonical ty during freshening"),
|
||||
|
||||
ty::Generator(..) |
|
||||
ty::TyBool |
|
||||
ty::TyChar |
|
||||
ty::TyInt(..) |
|
||||
ty::TyUint(..) |
|
||||
ty::TyFloat(..) |
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
ty::Int(..) |
|
||||
ty::Uint(..) |
|
||||
ty::Float(..) |
|
||||
ty::Adt(..) |
|
||||
ty::TyStr |
|
||||
ty::Str |
|
||||
ty::Error |
|
||||
ty::Array(..) |
|
||||
ty::Slice(..) |
|
||||
|
@ -2227,12 +2227,12 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const) -> fmt::Result {
|
||||
// print some primitives
|
||||
if let ConstValue::Scalar(Scalar::Bits { bits, .. }) = value {
|
||||
match ty.sty {
|
||||
TyBool if bits == 0 => return write!(f, "false"),
|
||||
TyBool if bits == 1 => return write!(f, "true"),
|
||||
TyFloat(ast::FloatTy::F32) => return write!(f, "{}f32", Single::from_bits(bits)),
|
||||
TyFloat(ast::FloatTy::F64) => return write!(f, "{}f64", Double::from_bits(bits)),
|
||||
TyUint(ui) => return write!(f, "{:?}{}", bits, ui),
|
||||
TyInt(i) => {
|
||||
Bool if bits == 0 => return write!(f, "false"),
|
||||
Bool if bits == 1 => return write!(f, "true"),
|
||||
Float(ast::FloatTy::F32) => return write!(f, "{}f32", Single::from_bits(bits)),
|
||||
Float(ast::FloatTy::F64) => return write!(f, "{}f64", Double::from_bits(bits)),
|
||||
Uint(ui) => return write!(f, "{:?}{}", bits, ui),
|
||||
Int(i) => {
|
||||
let bit_width = ty::tls::with(|tcx| {
|
||||
let ty = tcx.lift_to_global(&ty).unwrap();
|
||||
tcx.layout_of(ty::ParamEnv::empty().and(ty))
|
||||
@ -2243,7 +2243,7 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const) -> fmt::Result {
|
||||
let shift = 128 - bit_width;
|
||||
return write!(f, "{:?}{}", ((bits as i128) << shift) >> shift, i);
|
||||
}
|
||||
TyChar => return write!(f, "{:?}", ::std::char::from_u32(bits as u32).unwrap()),
|
||||
Char => return write!(f, "{:?}", ::std::char::from_u32(bits as u32).unwrap()),
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
@ -2255,7 +2255,7 @@ pub fn fmt_const_val(f: &mut impl Write, const_val: &ty::Const) -> fmt::Result {
|
||||
if let ConstValue::ScalarPair(ptr, len) = value {
|
||||
if let Scalar::Ptr(ptr) = ptr {
|
||||
if let ScalarMaybeUndef::Scalar(Scalar::Bits { bits: len, .. }) = len {
|
||||
if let Ref(_, &ty::TyS { sty: TyStr, .. }, _) = ty.sty {
|
||||
if let Ref(_, &ty::TyS { sty: Str, .. }, _) = ty.sty {
|
||||
return ty::tls::with(|tcx| {
|
||||
let alloc = tcx.alloc_map.lock().get(ptr.alloc_id);
|
||||
if let Some(interpret::AllocType::Memory(alloc)) = alloc {
|
||||
|
@ -441,12 +441,12 @@ fn ty_is_local_constructor(ty: Ty, in_crate: InCrate) -> bool {
|
||||
debug!("ty_is_local_constructor({:?})", ty);
|
||||
|
||||
match ty.sty {
|
||||
ty::TyBool |
|
||||
ty::TyChar |
|
||||
ty::TyInt(..) |
|
||||
ty::TyUint(..) |
|
||||
ty::TyFloat(..) |
|
||||
ty::TyStr |
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
ty::Int(..) |
|
||||
ty::Uint(..) |
|
||||
ty::Float(..) |
|
||||
ty::Str |
|
||||
ty::FnDef(..) |
|
||||
ty::FnPtr(_) |
|
||||
ty::Array(..) |
|
||||
|
@ -244,11 +244,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
/// if the type can be equated to any type.
|
||||
fn type_category<'tcx>(t: Ty<'tcx>) -> Option<u32> {
|
||||
match t.sty {
|
||||
ty::TyBool => Some(0),
|
||||
ty::TyChar => Some(1),
|
||||
ty::TyStr => Some(2),
|
||||
ty::TyInt(..) | ty::TyUint(..) | ty::Infer(ty::IntVar(..)) => Some(3),
|
||||
ty::TyFloat(..) | ty::Infer(ty::FloatVar(..)) => Some(4),
|
||||
ty::Bool => Some(0),
|
||||
ty::Char => Some(1),
|
||||
ty::Str => Some(2),
|
||||
ty::Int(..) | ty::Uint(..) | ty::Infer(ty::IntVar(..)) => Some(3),
|
||||
ty::Float(..) | ty::Infer(ty::FloatVar(..)) => Some(4),
|
||||
ty::Ref(..) | ty::RawPtr(..) => Some(5),
|
||||
ty::Array(..) | ty::Slice(..) => Some(6),
|
||||
ty::FnDef(..) | ty::FnPtr(..) => Some(7),
|
||||
|
@ -216,18 +216,18 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
|
||||
// execution.
|
||||
ty::Infer(ty::FreshIntTy(_))
|
||||
| ty::Infer(ty::FreshFloatTy(_))
|
||||
| ty::TyBool
|
||||
| ty::TyInt(_)
|
||||
| ty::TyUint(_)
|
||||
| ty::TyFloat(_)
|
||||
| ty::Bool
|
||||
| ty::Int(_)
|
||||
| ty::Uint(_)
|
||||
| ty::Float(_)
|
||||
| ty::Never
|
||||
| ty::FnDef(..)
|
||||
| ty::FnPtr(_)
|
||||
| ty::TyChar
|
||||
| ty::Char
|
||||
| ty::GeneratorWitness(..)
|
||||
| ty::RawPtr(_)
|
||||
| ty::Ref(..)
|
||||
| ty::TyStr
|
||||
| ty::Str
|
||||
| ty::Foreign(..)
|
||||
| ty::Error => true,
|
||||
|
||||
|
@ -2180,16 +2180,16 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||
|
||||
match self_ty.sty {
|
||||
ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) |
|
||||
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
|
||||
ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) |
|
||||
ty::FnDef(..) | ty::FnPtr(_) | ty::RawPtr(..) |
|
||||
ty::TyChar | ty::Ref(..) | ty::Generator(..) |
|
||||
ty::Char | ty::Ref(..) | ty::Generator(..) |
|
||||
ty::GeneratorWitness(..) | ty::Array(..) | ty::Closure(..) |
|
||||
ty::Never | ty::Error => {
|
||||
// safe for everything
|
||||
Where(ty::Binder::dummy(Vec::new()))
|
||||
}
|
||||
|
||||
ty::TyStr | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => None,
|
||||
ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) => None,
|
||||
|
||||
ty::Tuple(tys) => {
|
||||
Where(ty::Binder::bind(tys.last().into_iter().cloned().collect()))
|
||||
@ -2231,14 +2231,14 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||
Where(ty::Binder::dummy(Vec::new()))
|
||||
}
|
||||
|
||||
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
|
||||
ty::TyChar | ty::RawPtr(..) | ty::Never |
|
||||
ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) |
|
||||
ty::Char | ty::RawPtr(..) | ty::Never |
|
||||
ty::Ref(_, _, hir::MutImmutable) => {
|
||||
// Implementations provided in libcore
|
||||
None
|
||||
}
|
||||
|
||||
ty::Dynamic(..) | ty::TyStr | ty::Slice(..) |
|
||||
ty::Dynamic(..) | ty::Str | ty::Slice(..) |
|
||||
ty::Generator(..) | ty::GeneratorWitness(..) | ty::Foreign(..) |
|
||||
ty::Ref(_, _, hir::MutMutable) => {
|
||||
None
|
||||
@ -2300,18 +2300,18 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||
/// ```
|
||||
fn constituent_types_for_ty(&self, t: Ty<'tcx>) -> Vec<Ty<'tcx>> {
|
||||
match t.sty {
|
||||
ty::TyUint(_) |
|
||||
ty::TyInt(_) |
|
||||
ty::TyBool |
|
||||
ty::TyFloat(_) |
|
||||
ty::Uint(_) |
|
||||
ty::Int(_) |
|
||||
ty::Bool |
|
||||
ty::Float(_) |
|
||||
ty::FnDef(..) |
|
||||
ty::FnPtr(_) |
|
||||
ty::TyStr |
|
||||
ty::Str |
|
||||
ty::Error |
|
||||
ty::Infer(ty::IntVar(_)) |
|
||||
ty::Infer(ty::FloatVar(_)) |
|
||||
ty::Never |
|
||||
ty::TyChar => {
|
||||
ty::Char => {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
|
@ -60,13 +60,13 @@ pub enum CastKind {
|
||||
impl<'tcx> CastTy<'tcx> {
|
||||
pub fn from_ty(t: Ty<'tcx>) -> Option<CastTy<'tcx>> {
|
||||
match t.sty {
|
||||
ty::TyBool => Some(CastTy::Int(IntTy::Bool)),
|
||||
ty::TyChar => Some(CastTy::Int(IntTy::Char)),
|
||||
ty::TyInt(_) => Some(CastTy::Int(IntTy::I)),
|
||||
ty::Bool => Some(CastTy::Int(IntTy::Bool)),
|
||||
ty::Char => Some(CastTy::Int(IntTy::Char)),
|
||||
ty::Int(_) => Some(CastTy::Int(IntTy::I)),
|
||||
ty::Infer(ty::InferTy::IntVar(_)) => Some(CastTy::Int(IntTy::I)),
|
||||
ty::Infer(ty::InferTy::FloatVar(_)) => Some(CastTy::Float),
|
||||
ty::TyUint(u) => Some(CastTy::Int(IntTy::U(u))),
|
||||
ty::TyFloat(_) => Some(CastTy::Float),
|
||||
ty::Uint(u) => Some(CastTy::Int(IntTy::U(u))),
|
||||
ty::Float(_) => Some(CastTy::Float),
|
||||
ty::Adt(d,_) if d.is_enum() && d.is_payloadfree() =>
|
||||
Some(CastTy::Int(IntTy::CEnum)),
|
||||
ty::RawPtr(mt) => Some(CastTy::Ptr(mt)),
|
||||
|
@ -817,24 +817,24 @@ impl<'tcx> CommonTypes<'tcx> {
|
||||
&*r
|
||||
};
|
||||
CommonTypes {
|
||||
bool: mk(TyBool),
|
||||
char: mk(TyChar),
|
||||
bool: mk(Bool),
|
||||
char: mk(Char),
|
||||
never: mk(Never),
|
||||
err: mk(Error),
|
||||
isize: mk(TyInt(ast::IntTy::Isize)),
|
||||
i8: mk(TyInt(ast::IntTy::I8)),
|
||||
i16: mk(TyInt(ast::IntTy::I16)),
|
||||
i32: mk(TyInt(ast::IntTy::I32)),
|
||||
i64: mk(TyInt(ast::IntTy::I64)),
|
||||
i128: mk(TyInt(ast::IntTy::I128)),
|
||||
usize: mk(TyUint(ast::UintTy::Usize)),
|
||||
u8: mk(TyUint(ast::UintTy::U8)),
|
||||
u16: mk(TyUint(ast::UintTy::U16)),
|
||||
u32: mk(TyUint(ast::UintTy::U32)),
|
||||
u64: mk(TyUint(ast::UintTy::U64)),
|
||||
u128: mk(TyUint(ast::UintTy::U128)),
|
||||
f32: mk(TyFloat(ast::FloatTy::F32)),
|
||||
f64: mk(TyFloat(ast::FloatTy::F64)),
|
||||
isize: mk(Int(ast::IntTy::Isize)),
|
||||
i8: mk(Int(ast::IntTy::I8)),
|
||||
i16: mk(Int(ast::IntTy::I16)),
|
||||
i32: mk(Int(ast::IntTy::I32)),
|
||||
i64: mk(Int(ast::IntTy::I64)),
|
||||
i128: mk(Int(ast::IntTy::I128)),
|
||||
usize: mk(Uint(ast::UintTy::Usize)),
|
||||
u8: mk(Uint(ast::UintTy::U8)),
|
||||
u16: mk(Uint(ast::UintTy::U16)),
|
||||
u32: mk(Uint(ast::UintTy::U32)),
|
||||
u64: mk(Uint(ast::UintTy::U64)),
|
||||
u128: mk(Uint(ast::UintTy::U128)),
|
||||
f32: mk(Float(ast::FloatTy::F32)),
|
||||
f64: mk(Float(ast::FloatTy::F64)),
|
||||
|
||||
re_empty: mk_region(RegionKind::ReEmpty),
|
||||
re_static: mk_region(RegionKind::ReStatic),
|
||||
@ -2035,8 +2035,8 @@ macro_rules! sty_debug_print {
|
||||
|
||||
for &Interned(t) in tcx.interners.type_.borrow().iter() {
|
||||
let variant = match t.sty {
|
||||
ty::TyBool | ty::TyChar | ty::TyInt(..) | ty::TyUint(..) |
|
||||
ty::TyFloat(..) | ty::TyStr | ty::Never => continue,
|
||||
ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) |
|
||||
ty::Float(..) | ty::Str | ty::Never => continue,
|
||||
ty::Error => /* unimportant */ continue,
|
||||
$(ty::$variant(..) => &mut $variant,)*
|
||||
};
|
||||
@ -2374,7 +2374,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn mk_str(self) -> Ty<'tcx> {
|
||||
self.mk_ty(TyStr)
|
||||
self.mk_ty(Str)
|
||||
}
|
||||
|
||||
pub fn mk_static_str(self) -> Ty<'tcx> {
|
||||
@ -2466,7 +2466,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
pub fn mk_bool(self) -> Ty<'tcx> {
|
||||
self.mk_ty(TyBool)
|
||||
self.mk_ty(Bool)
|
||||
}
|
||||
|
||||
pub fn mk_fn_def(self, def_id: DefId,
|
||||
|
@ -175,8 +175,8 @@ impl<'tcx> fmt::Display for TypeError<'tcx> {
|
||||
impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
|
||||
pub fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> String {
|
||||
match self.sty {
|
||||
ty::TyBool | ty::TyChar | ty::TyInt(_) |
|
||||
ty::TyUint(_) | ty::TyFloat(_) | ty::TyStr | ty::Never => self.to_string(),
|
||||
ty::Bool | ty::Char | ty::Int(_) |
|
||||
ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => self.to_string(),
|
||||
ty::Tuple(ref tys) if tys.is_empty() => self.to_string(),
|
||||
|
||||
ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.item_path_str(def.did)),
|
||||
@ -251,7 +251,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
db.help("consider boxing your closure and/or using it as a trait object");
|
||||
}
|
||||
match (&values.found.sty, &values.expected.sty) { // Issue #53280
|
||||
(ty::Infer(ty::IntVar(_)), ty::TyFloat(_)) => {
|
||||
(ty::Infer(ty::IntVar(_)), ty::Float(_)) => {
|
||||
if let Ok(snippet) = self.sess.source_map().span_to_snippet(sp) {
|
||||
if snippet.chars().all(|c| c.is_digit(10) || c == '-' || c == '_') {
|
||||
db.span_suggestion_with_applicability(
|
||||
|
@ -68,13 +68,13 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
-> Option<SimplifiedType>
|
||||
{
|
||||
match ty.sty {
|
||||
ty::TyBool => Some(BoolSimplifiedType),
|
||||
ty::TyChar => Some(CharSimplifiedType),
|
||||
ty::TyInt(int_type) => Some(IntSimplifiedType(int_type)),
|
||||
ty::TyUint(uint_type) => Some(UintSimplifiedType(uint_type)),
|
||||
ty::TyFloat(float_type) => Some(FloatSimplifiedType(float_type)),
|
||||
ty::Bool => Some(BoolSimplifiedType),
|
||||
ty::Char => Some(CharSimplifiedType),
|
||||
ty::Int(int_type) => Some(IntSimplifiedType(int_type)),
|
||||
ty::Uint(uint_type) => Some(UintSimplifiedType(uint_type)),
|
||||
ty::Float(float_type) => Some(FloatSimplifiedType(float_type)),
|
||||
ty::Adt(def, _) => Some(AdtSimplifiedType(def.did)),
|
||||
ty::TyStr => Some(StrSimplifiedType),
|
||||
ty::Str => Some(StrSimplifiedType),
|
||||
ty::Array(..) | ty::Slice(_) => Some(ArraySimplifiedType),
|
||||
ty::RawPtr(_) => Some(PtrSimplifiedType),
|
||||
ty::Dynamic(ref trait_info, ..) => {
|
||||
|
@ -69,13 +69,13 @@ impl FlagComputation {
|
||||
|
||||
fn add_sty(&mut self, st: &ty::TyKind) {
|
||||
match st {
|
||||
&ty::TyBool |
|
||||
&ty::TyChar |
|
||||
&ty::TyInt(_) |
|
||||
&ty::TyFloat(_) |
|
||||
&ty::TyUint(_) |
|
||||
&ty::Bool |
|
||||
&ty::Char |
|
||||
&ty::Int(_) |
|
||||
&ty::Float(_) |
|
||||
&ty::Uint(_) |
|
||||
&ty::Never |
|
||||
&ty::TyStr |
|
||||
&ty::Str |
|
||||
&ty::Foreign(..) => {
|
||||
}
|
||||
|
||||
|
@ -309,12 +309,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
ty::Foreign(did) => self.push_item_path(buffer, did),
|
||||
|
||||
ty::TyBool |
|
||||
ty::TyChar |
|
||||
ty::TyInt(_) |
|
||||
ty::TyUint(_) |
|
||||
ty::TyFloat(_) |
|
||||
ty::TyStr => {
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
ty::Int(_) |
|
||||
ty::Uint(_) |
|
||||
ty::Float(_) |
|
||||
ty::Str => {
|
||||
buffer.push(&self_ty.to_string());
|
||||
}
|
||||
|
||||
@ -377,11 +377,11 @@ pub fn characteristic_def_id_of_type(ty: Ty) -> Option<DefId> {
|
||||
ty::Generator(def_id, _, _) |
|
||||
ty::Foreign(def_id) => Some(def_id),
|
||||
|
||||
ty::TyBool |
|
||||
ty::TyChar |
|
||||
ty::TyInt(_) |
|
||||
ty::TyUint(_) |
|
||||
ty::TyStr |
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
ty::Int(_) |
|
||||
ty::Uint(_) |
|
||||
ty::Str |
|
||||
ty::FnPtr(_) |
|
||||
ty::Projection(_) |
|
||||
ty::Param(_) |
|
||||
@ -390,7 +390,7 @@ pub fn characteristic_def_id_of_type(ty: Ty) -> Option<DefId> {
|
||||
ty::Error |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Never |
|
||||
ty::TyFloat(_) => None,
|
||||
ty::Float(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,25 +470,25 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
||||
|
||||
Ok(match ty.sty {
|
||||
// Basic scalars.
|
||||
ty::TyBool => {
|
||||
ty::Bool => {
|
||||
tcx.intern_layout(LayoutDetails::scalar(self, Scalar {
|
||||
value: Int(I8, false),
|
||||
valid_range: 0..=1
|
||||
}))
|
||||
}
|
||||
ty::TyChar => {
|
||||
ty::Char => {
|
||||
tcx.intern_layout(LayoutDetails::scalar(self, Scalar {
|
||||
value: Int(I32, false),
|
||||
valid_range: 0..=0x10FFFF
|
||||
}))
|
||||
}
|
||||
ty::TyInt(ity) => {
|
||||
ty::Int(ity) => {
|
||||
scalar(Int(Integer::from_attr(dl, attr::SignedInt(ity)), true))
|
||||
}
|
||||
ty::TyUint(ity) => {
|
||||
ty::Uint(ity) => {
|
||||
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
|
||||
}
|
||||
ty::TyFloat(fty) => scalar(Float(fty)),
|
||||
ty::Float(fty) => scalar(Float(fty)),
|
||||
ty::FnPtr(_) => {
|
||||
let mut ptr = scalar_unit(Pointer);
|
||||
ptr.valid_range = 1..=*ptr.valid_range.end();
|
||||
@ -524,7 +524,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
||||
ty::Foreign(..) => {
|
||||
return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr)));
|
||||
}
|
||||
ty::Slice(_) | ty::TyStr => {
|
||||
ty::Slice(_) | ty::Str => {
|
||||
scalar_unit(Int(dl.ptr_sized_integer(), false))
|
||||
}
|
||||
ty::Dynamic(..) => {
|
||||
@ -577,7 +577,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
||||
size: Size::ZERO
|
||||
})
|
||||
}
|
||||
ty::TyStr => {
|
||||
ty::Str => {
|
||||
tcx.intern_layout(LayoutDetails {
|
||||
variants: Variants::Single { index: 0 },
|
||||
fields: FieldPlacement::Array {
|
||||
@ -1582,11 +1582,11 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
||||
fn field(this: TyLayout<'tcx>, cx: C, i: usize) -> C::TyLayout {
|
||||
let tcx = cx.tcx();
|
||||
cx.layout_of(match this.ty.sty {
|
||||
ty::TyBool |
|
||||
ty::TyChar |
|
||||
ty::TyInt(_) |
|
||||
ty::TyUint(_) |
|
||||
ty::TyFloat(_) |
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
ty::Int(_) |
|
||||
ty::Uint(_) |
|
||||
ty::Float(_) |
|
||||
ty::FnPtr(_) |
|
||||
ty::Never |
|
||||
ty::FnDef(..) |
|
||||
@ -1620,7 +1620,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
||||
|
||||
match tcx.struct_tail(pointee).sty {
|
||||
ty::Slice(_) |
|
||||
ty::TyStr => tcx.types.usize,
|
||||
ty::Str => tcx.types.usize,
|
||||
ty::Dynamic(data, _) => {
|
||||
let trait_def_id = data.principal().unwrap().def_id();
|
||||
let num_fns: u64 = crate::traits::supertrait_def_ids(tcx, trait_def_id)
|
||||
@ -1648,7 +1648,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
||||
// Arrays and slices.
|
||||
ty::Array(element, _) |
|
||||
ty::Slice(element) => element,
|
||||
ty::TyStr => tcx.types.u8,
|
||||
ty::Str => tcx.types.u8,
|
||||
|
||||
// Tuples, generators and closures.
|
||||
ty::Closure(def_id, ref substs) => {
|
||||
|
@ -542,11 +542,11 @@ impl<'tcx> Hash for TyS<'tcx> {
|
||||
impl<'tcx> TyS<'tcx> {
|
||||
pub fn is_primitive_ty(&self) -> bool {
|
||||
match self.sty {
|
||||
TyKind::TyBool |
|
||||
TyKind::TyChar |
|
||||
TyKind::TyInt(_) |
|
||||
TyKind::TyUint(_) |
|
||||
TyKind::TyFloat(_) |
|
||||
TyKind::Bool |
|
||||
TyKind::Char |
|
||||
TyKind::Int(_) |
|
||||
TyKind::Uint(_) |
|
||||
TyKind::Float(_) |
|
||||
TyKind::Infer(InferTy::IntVar(_)) |
|
||||
TyKind::Infer(InferTy::FloatVar(_)) |
|
||||
TyKind::Infer(InferTy::FreshIntTy(_)) |
|
||||
@ -2230,13 +2230,13 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
||||
ty: Ty<'tcx>)
|
||||
-> Vec<Ty<'tcx>> {
|
||||
let result = match ty.sty {
|
||||
TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) |
|
||||
Bool | Char | Int(..) | Uint(..) | Float(..) |
|
||||
RawPtr(..) | Ref(..) | FnDef(..) | FnPtr(_) |
|
||||
Array(..) | Closure(..) | Generator(..) | Never => {
|
||||
vec![]
|
||||
}
|
||||
|
||||
TyStr |
|
||||
Str |
|
||||
Dynamic(..) |
|
||||
Slice(_) |
|
||||
Foreign(..) |
|
||||
|
@ -137,16 +137,16 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
// the type and then visits the types that are lexically
|
||||
// contained within. (The comments refer to relevant rules
|
||||
// from RFC1214.)
|
||||
ty::TyBool | // OutlivesScalar
|
||||
ty::TyChar | // OutlivesScalar
|
||||
ty::TyInt(..) | // OutlivesScalar
|
||||
ty::TyUint(..) | // OutlivesScalar
|
||||
ty::TyFloat(..) | // OutlivesScalar
|
||||
ty::Bool | // OutlivesScalar
|
||||
ty::Char | // OutlivesScalar
|
||||
ty::Int(..) | // OutlivesScalar
|
||||
ty::Uint(..) | // OutlivesScalar
|
||||
ty::Float(..) | // OutlivesScalar
|
||||
ty::Never | // ...
|
||||
ty::Adt(..) | // OutlivesNominalType
|
||||
ty::Anon(..) | // OutlivesNominalType (ish)
|
||||
ty::Foreign(..) | // OutlivesNominalType
|
||||
ty::TyStr | // OutlivesScalar (ish)
|
||||
ty::Str | // OutlivesScalar (ish)
|
||||
ty::Array(..) | // ...
|
||||
ty::Slice(..) | // ...
|
||||
ty::RawPtr(..) | // ...
|
||||
|
@ -376,12 +376,12 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R,
|
||||
}
|
||||
|
||||
(&ty::Never, _) |
|
||||
(&ty::TyChar, _) |
|
||||
(&ty::TyBool, _) |
|
||||
(&ty::TyInt(_), _) |
|
||||
(&ty::TyUint(_), _) |
|
||||
(&ty::TyFloat(_), _) |
|
||||
(&ty::TyStr, _)
|
||||
(&ty::Char, _) |
|
||||
(&ty::Bool, _) |
|
||||
(&ty::Int(_), _) |
|
||||
(&ty::Uint(_), _) |
|
||||
(&ty::Float(_), _) |
|
||||
(&ty::Str, _)
|
||||
if a == b =>
|
||||
{
|
||||
Ok(a)
|
||||
|
@ -860,8 +860,8 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
||||
ty::Closure(did, substs) => ty::Closure(did, substs.fold_with(folder)),
|
||||
ty::Projection(ref data) => ty::Projection(data.fold_with(folder)),
|
||||
ty::Anon(did, substs) => ty::Anon(did, substs.fold_with(folder)),
|
||||
ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) |
|
||||
ty::TyUint(_) | ty::TyFloat(_) | ty::Error | ty::Infer(_) |
|
||||
ty::Bool | ty::Char | ty::Str | ty::Int(_) |
|
||||
ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) |
|
||||
ty::Param(..) | ty::Never | ty::Foreign(..) => return self
|
||||
};
|
||||
|
||||
@ -895,8 +895,8 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
||||
ty::Closure(_did, ref substs) => substs.visit_with(visitor),
|
||||
ty::Projection(ref data) => data.visit_with(visitor),
|
||||
ty::Anon(_, ref substs) => substs.visit_with(visitor),
|
||||
ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) |
|
||||
ty::TyUint(_) | ty::TyFloat(_) | ty::Error | ty::Infer(_) |
|
||||
ty::Bool | ty::Char | ty::Str | ty::Int(_) |
|
||||
ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) |
|
||||
ty::Param(..) | ty::Never | ty::Foreign(..) => false,
|
||||
}
|
||||
}
|
||||
|
@ -84,20 +84,20 @@ impl BoundRegion {
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
|
||||
pub enum TyKind<'tcx> {
|
||||
/// The primitive boolean type. Written as `bool`.
|
||||
TyBool,
|
||||
Bool,
|
||||
|
||||
/// The primitive character type; holds a Unicode scalar value
|
||||
/// (a non-surrogate code point). Written as `char`.
|
||||
TyChar,
|
||||
Char,
|
||||
|
||||
/// A primitive signed integer type. For example, `i32`.
|
||||
TyInt(ast::IntTy),
|
||||
Int(ast::IntTy),
|
||||
|
||||
/// A primitive unsigned integer type. For example, `u32`.
|
||||
TyUint(ast::UintTy),
|
||||
Uint(ast::UintTy),
|
||||
|
||||
/// A primitive floating-point type. For example, `f64`.
|
||||
TyFloat(ast::FloatTy),
|
||||
Float(ast::FloatTy),
|
||||
|
||||
/// Structures, enumerations and unions.
|
||||
///
|
||||
@ -110,7 +110,7 @@ pub enum TyKind<'tcx> {
|
||||
Foreign(DefId),
|
||||
|
||||
/// The pointee of a string slice. Written as `str`.
|
||||
TyStr,
|
||||
Str,
|
||||
|
||||
/// An array with the given length. Written as `[T; n]`.
|
||||
Array(Ty<'tcx>, &'tcx ty::Const<'tcx>),
|
||||
@ -1483,7 +1483,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
|
||||
pub fn is_primitive(&self) -> bool {
|
||||
match self.sty {
|
||||
TyBool | TyChar | TyInt(_) | TyUint(_) | TyFloat(_) => true,
|
||||
Bool | Char | Int(_) | Uint(_) | Float(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -1510,7 +1510,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_bool(&self) -> bool { self.sty == TyBool }
|
||||
pub fn is_bool(&self) -> bool { self.sty == Bool }
|
||||
|
||||
pub fn is_param(&self, index: u32) -> bool {
|
||||
match self.sty {
|
||||
@ -1529,7 +1529,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
pub fn is_slice(&self) -> bool {
|
||||
match self.sty {
|
||||
RawPtr(TypeAndMut { ty, .. }) | Ref(_, ty, _) => match ty.sty {
|
||||
Slice(_) | TyStr => true,
|
||||
Slice(_) | Str => true,
|
||||
_ => false,
|
||||
},
|
||||
_ => false
|
||||
@ -1547,7 +1547,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
pub fn sequence_element_type(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {
|
||||
match self.sty {
|
||||
Array(ty, _) | Slice(ty) => ty,
|
||||
TyStr => tcx.mk_mach_uint(ast::UintTy::U8),
|
||||
Str => tcx.mk_mach_uint(ast::UintTy::U8),
|
||||
_ => bug!("sequence_element_type called on non-sequence value: {}", self),
|
||||
}
|
||||
}
|
||||
@ -1610,7 +1610,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
/// contents are abstract to rustc.)
|
||||
pub fn is_scalar(&self) -> bool {
|
||||
match self.sty {
|
||||
TyBool | TyChar | TyInt(_) | TyFloat(_) | TyUint(_) |
|
||||
Bool | Char | Int(_) | Float(_) | Uint(_) |
|
||||
Infer(IntVar(_)) | Infer(FloatVar(_)) |
|
||||
FnDef(..) | FnPtr(_) | RawPtr(_) => true,
|
||||
_ => false
|
||||
@ -1620,7 +1620,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
/// Returns true if this type is a floating point type and false otherwise.
|
||||
pub fn is_floating_point(&self) -> bool {
|
||||
match self.sty {
|
||||
TyFloat(_) |
|
||||
Float(_) |
|
||||
Infer(FloatVar(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
@ -1658,7 +1658,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
|
||||
pub fn is_integral(&self) -> bool {
|
||||
match self.sty {
|
||||
Infer(IntVar(_)) | TyInt(_) | TyUint(_) => true,
|
||||
Infer(IntVar(_)) | Int(_) | Uint(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
@ -1681,14 +1681,14 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
|
||||
pub fn is_char(&self) -> bool {
|
||||
match self.sty {
|
||||
TyChar => true,
|
||||
Char => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_fp(&self) -> bool {
|
||||
match self.sty {
|
||||
Infer(FloatVar(_)) | TyFloat(_) => true,
|
||||
Infer(FloatVar(_)) | Float(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
@ -1699,15 +1699,15 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
|
||||
pub fn is_signed(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInt(_) => true,
|
||||
Int(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_machine(&self) -> bool {
|
||||
match self.sty {
|
||||
TyInt(ast::IntTy::Isize) | TyUint(ast::UintTy::Usize) => false,
|
||||
TyInt(..) | TyUint(..) | TyFloat(..) => true,
|
||||
Int(ast::IntTy::Isize) | Uint(ast::UintTy::Usize) => false,
|
||||
Int(..) | Uint(..) | Float(..) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@ -1804,12 +1804,12 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
FnDef(..) |
|
||||
FnPtr(_) |
|
||||
GeneratorWitness(..) |
|
||||
TyBool |
|
||||
TyChar |
|
||||
TyInt(_) |
|
||||
TyUint(_) |
|
||||
TyFloat(_) |
|
||||
TyStr |
|
||||
Bool |
|
||||
Char |
|
||||
Int(_) |
|
||||
Uint(_) |
|
||||
Float(_) |
|
||||
Str |
|
||||
Array(..) |
|
||||
Slice(_) |
|
||||
RawPtr(_) |
|
||||
@ -1838,7 +1838,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
/// is complete, that type variable will be unified.
|
||||
pub fn to_opt_closure_kind(&self) -> Option<ty::ClosureKind> {
|
||||
match self.sty {
|
||||
TyInt(int_ty) => match int_ty {
|
||||
Int(int_ty) => match int_ty {
|
||||
ast::IntTy::I8 => Some(ty::ClosureKind::Fn),
|
||||
ast::IntTy::I16 => Some(ty::ClosureKind::FnMut),
|
||||
ast::IntTy::I32 => Some(ty::ClosureKind::FnOnce),
|
||||
@ -1860,14 +1860,14 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
pub fn is_trivially_sized(&self, tcx: TyCtxt<'_, '_, 'tcx>) -> bool {
|
||||
match self.sty {
|
||||
ty::Infer(ty::IntVar(_)) | ty::Infer(ty::FloatVar(_)) |
|
||||
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
|
||||
ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) |
|
||||
ty::FnDef(..) | ty::FnPtr(_) | ty::RawPtr(..) |
|
||||
ty::TyChar | ty::Ref(..) | ty::Generator(..) |
|
||||
ty::Char | ty::Ref(..) | ty::Generator(..) |
|
||||
ty::GeneratorWitness(..) | ty::Array(..) | ty::Closure(..) |
|
||||
ty::Never | ty::Error =>
|
||||
true,
|
||||
|
||||
ty::TyStr | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) =>
|
||||
ty::Str | ty::Slice(_) | ty::Dynamic(..) | ty::Foreign(..) =>
|
||||
false,
|
||||
|
||||
ty::Tuple(tys) =>
|
||||
|
@ -41,7 +41,7 @@ pub struct Discr<'tcx> {
|
||||
impl<'tcx> fmt::Display for Discr<'tcx> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self.ty.sty {
|
||||
ty::TyInt(ity) => {
|
||||
ty::Int(ity) => {
|
||||
let bits = ty::tls::with(|tcx| {
|
||||
Integer::from_attr(tcx, SignedInt(ity)).size().bits()
|
||||
});
|
||||
@ -62,8 +62,8 @@ impl<'tcx> Discr<'tcx> {
|
||||
}
|
||||
pub fn checked_add<'a, 'gcx>(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, n: u128) -> (Self, bool) {
|
||||
let (int, signed) = match self.ty.sty {
|
||||
TyInt(ity) => (Integer::from_attr(tcx, SignedInt(ity)), true),
|
||||
TyUint(uty) => (Integer::from_attr(tcx, UnsignedInt(uty)), false),
|
||||
Int(ity) => (Integer::from_attr(tcx, SignedInt(ity)), true),
|
||||
Uint(uty) => (Integer::from_attr(tcx, UnsignedInt(uty)), false),
|
||||
_ => bug!("non integer discriminant"),
|
||||
};
|
||||
|
||||
@ -193,8 +193,8 @@ impl<'tcx> ty::ParamEnv<'tcx> {
|
||||
let (adt, substs) = match self_type.sty {
|
||||
// These types used to have a builtin impl.
|
||||
// Now libcore provides that impl.
|
||||
ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) |
|
||||
ty::TyChar | ty::RawPtr(..) | ty::Never |
|
||||
ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Float(_) |
|
||||
ty::Char | ty::RawPtr(..) | ty::Never |
|
||||
ty::Ref(_, _, hir::MutImmutable) => return Ok(()),
|
||||
|
||||
ty::Adt(adt, substs) => (adt, substs),
|
||||
@ -925,9 +925,9 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
match ty.sty {
|
||||
// Fast-path for primitive types
|
||||
ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshFloatTy(_)) |
|
||||
ty::TyBool | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::Never |
|
||||
ty::FnDef(..) | ty::FnPtr(_) | ty::TyChar | ty::GeneratorWitness(..) |
|
||||
ty::RawPtr(_) | ty::Ref(..) | ty::TyStr => false,
|
||||
ty::Bool | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Never |
|
||||
ty::FnDef(..) | ty::FnPtr(_) | ty::Char | ty::GeneratorWitness(..) |
|
||||
ty::RawPtr(_) | ty::Ref(..) | ty::Str => false,
|
||||
|
||||
// Foreign types can never have destructors
|
||||
ty::Foreign(..) => false,
|
||||
|
@ -81,8 +81,8 @@ pub fn walk_shallow<'tcx>(ty: Ty<'tcx>) -> AccIntoIter<TypeWalkerArray<'tcx>> {
|
||||
// types as they are written).
|
||||
fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
|
||||
match parent_ty.sty {
|
||||
ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) |
|
||||
ty::TyStr | ty::Infer(_) | ty::Param(_) | ty::Never | ty::Error |
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) |
|
||||
ty::Str | ty::Infer(_) | ty::Param(_) | ty::Never | ty::Error |
|
||||
ty::Foreign(..) => {
|
||||
}
|
||||
ty::Array(ty, len) => {
|
||||
|
@ -248,13 +248,13 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
||||
let param_env = self.param_env;
|
||||
while let Some(ty) = subtys.next() {
|
||||
match ty.sty {
|
||||
ty::TyBool |
|
||||
ty::TyChar |
|
||||
ty::TyInt(..) |
|
||||
ty::TyUint(..) |
|
||||
ty::TyFloat(..) |
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
ty::Int(..) |
|
||||
ty::Uint(..) |
|
||||
ty::Float(..) |
|
||||
ty::Error |
|
||||
ty::TyStr |
|
||||
ty::Str |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Never |
|
||||
ty::Param(_) |
|
||||
|
@ -14,11 +14,11 @@ use mir::interpret::ConstValue;
|
||||
use middle::region::{self, BlockRemainder};
|
||||
use ty::subst::{self, Subst};
|
||||
use ty::{BrAnon, BrEnv, BrFresh, BrNamed};
|
||||
use ty::{TyBool, TyChar, Adt};
|
||||
use ty::{Error, TyStr, Array, Slice, TyFloat, FnDef, FnPtr};
|
||||
use ty::{Bool, Char, Adt};
|
||||
use ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr};
|
||||
use ty::{Param, RawPtr, Ref, Never, Tuple};
|
||||
use ty::{Closure, Generator, GeneratorWitness, Foreign, Projection, Anon};
|
||||
use ty::{Dynamic, TyInt, TyUint, Infer};
|
||||
use ty::{Dynamic, Int, Uint, Infer};
|
||||
use ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind};
|
||||
use util::nodemap::FxHashSet;
|
||||
|
||||
@ -1032,11 +1032,11 @@ define_print! {
|
||||
('tcx) ty::TyKind<'tcx>, (self, f, cx) {
|
||||
display {
|
||||
match *self {
|
||||
TyBool => write!(f, "bool"),
|
||||
TyChar => write!(f, "char"),
|
||||
TyInt(t) => write!(f, "{}", t.ty_to_string()),
|
||||
TyUint(t) => write!(f, "{}", t.ty_to_string()),
|
||||
TyFloat(t) => write!(f, "{}", t.ty_to_string()),
|
||||
Bool => write!(f, "bool"),
|
||||
Char => write!(f, "char"),
|
||||
Int(t) => write!(f, "{}", t.ty_to_string()),
|
||||
Uint(t) => write!(f, "{}", t.ty_to_string()),
|
||||
Float(t) => write!(f, "{}", t.ty_to_string()),
|
||||
RawPtr(ref tm) => {
|
||||
write!(f, "*{} ", match tm.mutbl {
|
||||
hir::MutMutable => "mut",
|
||||
@ -1154,7 +1154,7 @@ define_print! {
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
TyStr => write!(f, "str"),
|
||||
Str => write!(f, "str"),
|
||||
Generator(did, substs, movability) => ty::tls::with(|tcx| {
|
||||
let upvar_tys = substs.upvar_tys(did, tcx);
|
||||
let witness = substs.witness(did, tcx);
|
||||
|
@ -166,12 +166,12 @@ pub fn compare_simd_types(
|
||||
op: hir::BinOpKind
|
||||
) -> &'ll Value {
|
||||
let signed = match t.sty {
|
||||
ty::TyFloat(_) => {
|
||||
ty::Float(_) => {
|
||||
let cmp = bin_op_to_fcmp_predicate(op);
|
||||
return bx.sext(bx.fcmp(cmp, lhs, rhs), ret_ty);
|
||||
},
|
||||
ty::TyUint(_) => false,
|
||||
ty::TyInt(_) => true,
|
||||
ty::Uint(_) => false,
|
||||
ty::Int(_) => true,
|
||||
_ => bug!("compare_simd_types: invalid SIMD type"),
|
||||
};
|
||||
|
||||
|
@ -435,7 +435,7 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
|
||||
let tail = self.tcx.struct_tail(ty);
|
||||
match tail.sty {
|
||||
ty::Foreign(..) => false,
|
||||
ty::TyStr | ty::Slice(..) | ty::Dynamic(..) => true,
|
||||
ty::Str | ty::Slice(..) | ty::Dynamic(..) => true,
|
||||
_ => bug!("unexpected unsized tail: {:?}", tail.sty),
|
||||
}
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ pub fn type_metadata(
|
||||
ty::Slice(typ) => {
|
||||
Ok(vec_slice_metadata(cx, t, typ, unique_type_id, usage_site_span))
|
||||
}
|
||||
ty::TyStr => {
|
||||
ty::Str => {
|
||||
Ok(vec_slice_metadata(cx, t, cx.tcx.types.u8, unique_type_id, usage_site_span))
|
||||
}
|
||||
ty::Dynamic(..) => {
|
||||
@ -563,11 +563,11 @@ pub fn type_metadata(
|
||||
|
||||
let MetadataCreationResult { metadata, already_stored_in_typemap } = match t.sty {
|
||||
ty::Never |
|
||||
ty::TyBool |
|
||||
ty::TyChar |
|
||||
ty::TyInt(_) |
|
||||
ty::TyUint(_) |
|
||||
ty::TyFloat(_) => {
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
ty::Int(_) |
|
||||
ty::Uint(_) |
|
||||
ty::Float(_) => {
|
||||
MetadataCreationResult::new(basic_type_metadata(cx, t), false)
|
||||
}
|
||||
ty::Tuple(ref elements) if elements.is_empty() => {
|
||||
@ -577,7 +577,7 @@ pub fn type_metadata(
|
||||
ty::Slice(typ) => {
|
||||
fixed_vec_metadata(cx, unique_type_id, t, typ, usage_site_span)
|
||||
}
|
||||
ty::TyStr => {
|
||||
ty::Str => {
|
||||
fixed_vec_metadata(cx, unique_type_id, t, cx.tcx.types.i8, usage_site_span)
|
||||
}
|
||||
ty::Dynamic(..) => {
|
||||
@ -768,15 +768,15 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
||||
ty::Never => ("!", DW_ATE_unsigned),
|
||||
ty::Tuple(ref elements) if elements.is_empty() =>
|
||||
("()", DW_ATE_unsigned),
|
||||
ty::TyBool => ("bool", DW_ATE_boolean),
|
||||
ty::TyChar => ("char", DW_ATE_unsigned_char),
|
||||
ty::TyInt(int_ty) => {
|
||||
ty::Bool => ("bool", DW_ATE_boolean),
|
||||
ty::Char => ("char", DW_ATE_unsigned_char),
|
||||
ty::Int(int_ty) => {
|
||||
(int_ty.ty_to_string(), DW_ATE_signed)
|
||||
},
|
||||
ty::TyUint(uint_ty) => {
|
||||
ty::Uint(uint_ty) => {
|
||||
(uint_ty.ty_to_string(), DW_ATE_unsigned)
|
||||
},
|
||||
ty::TyFloat(float_ty) => {
|
||||
ty::Float(float_ty) => {
|
||||
(float_ty.ty_to_string(), DW_ATE_float)
|
||||
},
|
||||
_ => bug!("debuginfo::basic_type_metadata - t is invalid type")
|
||||
|
@ -41,13 +41,13 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
let cpp_like_names = cx.sess().target.target.options.is_like_msvc;
|
||||
|
||||
match t.sty {
|
||||
ty::TyBool => output.push_str("bool"),
|
||||
ty::TyChar => output.push_str("char"),
|
||||
ty::TyStr => output.push_str("str"),
|
||||
ty::Bool => output.push_str("bool"),
|
||||
ty::Char => output.push_str("char"),
|
||||
ty::Str => output.push_str("str"),
|
||||
ty::Never => output.push_str("!"),
|
||||
ty::TyInt(int_ty) => output.push_str(int_ty.ty_to_string()),
|
||||
ty::TyUint(uint_ty) => output.push_str(uint_ty.ty_to_string()),
|
||||
ty::TyFloat(float_ty) => output.push_str(float_ty.ty_to_string()),
|
||||
ty::Int(int_ty) => output.push_str(int_ty.ty_to_string()),
|
||||
ty::Uint(uint_ty) => output.push_str(uint_ty.ty_to_string()),
|
||||
ty::Float(float_ty) => output.push_str(float_ty.ty_to_string()),
|
||||
ty::Foreign(def_id) => push_item_name(cx, def_id, qualified, output),
|
||||
ty::Adt(def, substs) => {
|
||||
push_item_name(cx, def.did, qualified, output);
|
||||
|
@ -40,7 +40,7 @@ pub fn size_and_align_of_dst(bx: &Builder<'_, 'll, 'tcx>, t: Ty<'tcx>, info: Opt
|
||||
let vtable = info.unwrap();
|
||||
(meth::SIZE.get_usize(bx, vtable), meth::ALIGN.get_usize(bx, vtable))
|
||||
}
|
||||
ty::Slice(_) | ty::TyStr => {
|
||||
ty::Slice(_) | ty::Str => {
|
||||
let unit = t.sequence_element_type(bx.tcx());
|
||||
// The info in this case is the length of the str, so the size is that
|
||||
// times the unit size.
|
||||
|
@ -1149,7 +1149,7 @@ fn generic_simd_intrinsic(
|
||||
m_len, v_len
|
||||
);
|
||||
match m_elem_ty.sty {
|
||||
ty::TyInt(_) => {},
|
||||
ty::Int(_) => {},
|
||||
_ => {
|
||||
return_error!("mask element type is `{}`, expected `i_`", m_elem_ty);
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ fn generic_simd_intrinsic(
|
||||
}
|
||||
}
|
||||
let ety = match in_elem.sty {
|
||||
ty::TyFloat(f) if f.bit_width() == 32 => {
|
||||
ty::Float(f) if f.bit_width() == 32 => {
|
||||
if in_len < 2 || in_len > 16 {
|
||||
return_error!(
|
||||
"unsupported floating-point vector `{}` with length `{}` \
|
||||
@ -1200,7 +1200,7 @@ fn generic_simd_intrinsic(
|
||||
}
|
||||
"f32"
|
||||
},
|
||||
ty::TyFloat(f) if f.bit_width() == 64 => {
|
||||
ty::Float(f) if f.bit_width() == 64 => {
|
||||
if in_len < 2 || in_len > 8 {
|
||||
return_error!("unsupported floating-point vector `{}` with length `{}` \
|
||||
out-of-range [2, 8]",
|
||||
@ -1208,7 +1208,7 @@ fn generic_simd_intrinsic(
|
||||
}
|
||||
"f64"
|
||||
},
|
||||
ty::TyFloat(f) => {
|
||||
ty::Float(f) => {
|
||||
return_error!("unsupported element type `{}` of floating-point vector `{}`",
|
||||
f, in_ty);
|
||||
},
|
||||
@ -1288,9 +1288,9 @@ fn generic_simd_intrinsic(
|
||||
fn llvm_vector_str(elem_ty: ty::Ty, vec_len: usize, no_pointers: usize) -> String {
|
||||
let p0s: String = "p0".repeat(no_pointers);
|
||||
match elem_ty.sty {
|
||||
ty::TyInt(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()),
|
||||
ty::TyUint(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()),
|
||||
ty::TyFloat(v) => format!("v{}{}f{}", vec_len, p0s, v.bit_width()),
|
||||
ty::Int(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()),
|
||||
ty::Uint(v) => format!("v{}{}i{}", vec_len, p0s, v.bit_width().unwrap()),
|
||||
ty::Float(v) => format!("v{}{}f{}", vec_len, p0s, v.bit_width()),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
@ -1299,9 +1299,9 @@ fn generic_simd_intrinsic(
|
||||
mut no_pointers: usize) -> &'ll Type {
|
||||
// FIXME: use cx.layout_of(ty).llvm_type() ?
|
||||
let mut elem_ty = match elem_ty.sty {
|
||||
ty::TyInt(v) => Type::int_from_ty(cx, v),
|
||||
ty::TyUint(v) => Type::uint_from_ty(cx, v),
|
||||
ty::TyFloat(v) => Type::float_from_ty(cx, v),
|
||||
ty::Int(v) => Type::int_from_ty(cx, v),
|
||||
ty::Uint(v) => Type::uint_from_ty(cx, v),
|
||||
ty::Float(v) => Type::float_from_ty(cx, v),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
while no_pointers > 0 {
|
||||
@ -1376,7 +1376,7 @@ fn generic_simd_intrinsic(
|
||||
|
||||
// The element type of the third argument must be a signed integer type of any width:
|
||||
match arg_tys[2].simd_type(tcx).sty {
|
||||
ty::TyInt(_) => (),
|
||||
ty::Int(_) => (),
|
||||
_ => {
|
||||
require!(false, "expected element type `{}` of third argument `{}` \
|
||||
to be a signed integer type",
|
||||
@ -1473,7 +1473,7 @@ fn generic_simd_intrinsic(
|
||||
|
||||
// The element type of the third argument must be a signed integer type of any width:
|
||||
match arg_tys[2].simd_type(tcx).sty {
|
||||
ty::TyInt(_) => (),
|
||||
ty::Int(_) => (),
|
||||
_ => {
|
||||
require!(false, "expected element type `{}` of third argument `{}` \
|
||||
to be a signed integer type",
|
||||
@ -1522,7 +1522,7 @@ fn generic_simd_intrinsic(
|
||||
"expected return type `{}` (element of input `{}`), found `{}`",
|
||||
in_elem, in_ty, ret_ty);
|
||||
return match in_elem.sty {
|
||||
ty::TyInt(_) | ty::TyUint(_) => {
|
||||
ty::Int(_) | ty::Uint(_) => {
|
||||
let r = bx.$integer_reduce(args[0].immediate());
|
||||
if $ordered {
|
||||
// if overflow occurs, the result is the
|
||||
@ -1536,7 +1536,7 @@ fn generic_simd_intrinsic(
|
||||
Ok(bx.$integer_reduce(args[0].immediate()))
|
||||
}
|
||||
},
|
||||
ty::TyFloat(f) => {
|
||||
ty::Float(f) => {
|
||||
// ordered arithmetic reductions take an accumulator
|
||||
let acc = if $ordered {
|
||||
let acc = args[1].immediate();
|
||||
@ -1597,13 +1597,13 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
||||
"expected return type `{}` (element of input `{}`), found `{}`",
|
||||
in_elem, in_ty, ret_ty);
|
||||
return match in_elem.sty {
|
||||
ty::TyInt(_i) => {
|
||||
ty::Int(_i) => {
|
||||
Ok(bx.$int_red(args[0].immediate(), true))
|
||||
},
|
||||
ty::TyUint(_u) => {
|
||||
ty::Uint(_u) => {
|
||||
Ok(bx.$int_red(args[0].immediate(), false))
|
||||
},
|
||||
ty::TyFloat(_f) => {
|
||||
ty::Float(_f) => {
|
||||
Ok(bx.$float_red(args[0].immediate()))
|
||||
}
|
||||
_ => {
|
||||
@ -1632,7 +1632,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
||||
args[0].immediate()
|
||||
} else {
|
||||
match in_elem.sty {
|
||||
ty::TyInt(_) | ty::TyUint(_) => {},
|
||||
ty::Int(_) | ty::Uint(_) => {},
|
||||
_ => {
|
||||
return_error!("unsupported {} from `{}` with element `{}` to `{}`",
|
||||
$name, in_ty, in_elem, ret_ty)
|
||||
@ -1645,7 +1645,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
||||
bx.trunc(args[0].immediate(), i1xn)
|
||||
};
|
||||
return match in_elem.sty {
|
||||
ty::TyInt(_) | ty::TyUint(_) => {
|
||||
ty::Int(_) | ty::Uint(_) => {
|
||||
let r = bx.$red(input);
|
||||
Ok(
|
||||
if !$boolean {
|
||||
@ -1688,15 +1688,15 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
||||
let (in_style, in_width) = match in_elem.sty {
|
||||
// vectors of pointer-sized integers should've been
|
||||
// disallowed before here, so this unwrap is safe.
|
||||
ty::TyInt(i) => (Style::Int(true), i.bit_width().unwrap()),
|
||||
ty::TyUint(u) => (Style::Int(false), u.bit_width().unwrap()),
|
||||
ty::TyFloat(f) => (Style::Float, f.bit_width()),
|
||||
ty::Int(i) => (Style::Int(true), i.bit_width().unwrap()),
|
||||
ty::Uint(u) => (Style::Int(false), u.bit_width().unwrap()),
|
||||
ty::Float(f) => (Style::Float, f.bit_width()),
|
||||
_ => (Style::Unsupported, 0)
|
||||
};
|
||||
let (out_style, out_width) = match out_elem.sty {
|
||||
ty::TyInt(i) => (Style::Int(true), i.bit_width().unwrap()),
|
||||
ty::TyUint(u) => (Style::Int(false), u.bit_width().unwrap()),
|
||||
ty::TyFloat(f) => (Style::Float, f.bit_width()),
|
||||
ty::Int(i) => (Style::Int(true), i.bit_width().unwrap()),
|
||||
ty::Uint(u) => (Style::Int(false), u.bit_width().unwrap()),
|
||||
ty::Float(f) => (Style::Float, f.bit_width()),
|
||||
_ => (Style::Unsupported, 0)
|
||||
};
|
||||
|
||||
@ -1757,18 +1757,18 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
||||
}
|
||||
}
|
||||
arith! {
|
||||
simd_add: TyUint, TyInt => add, TyFloat => fadd;
|
||||
simd_sub: TyUint, TyInt => sub, TyFloat => fsub;
|
||||
simd_mul: TyUint, TyInt => mul, TyFloat => fmul;
|
||||
simd_div: TyUint => udiv, TyInt => sdiv, TyFloat => fdiv;
|
||||
simd_rem: TyUint => urem, TyInt => srem, TyFloat => frem;
|
||||
simd_shl: TyUint, TyInt => shl;
|
||||
simd_shr: TyUint => lshr, TyInt => ashr;
|
||||
simd_and: TyUint, TyInt => and;
|
||||
simd_or: TyUint, TyInt => or;
|
||||
simd_xor: TyUint, TyInt => xor;
|
||||
simd_fmax: TyFloat => maxnum;
|
||||
simd_fmin: TyFloat => minnum;
|
||||
simd_add: Uint, Int => add, Float => fadd;
|
||||
simd_sub: Uint, Int => sub, Float => fsub;
|
||||
simd_mul: Uint, Int => mul, Float => fmul;
|
||||
simd_div: Uint => udiv, Int => sdiv, Float => fdiv;
|
||||
simd_rem: Uint => urem, Int => srem, Float => frem;
|
||||
simd_shl: Uint, Int => shl;
|
||||
simd_shr: Uint => lshr, Int => ashr;
|
||||
simd_and: Uint, Int => and;
|
||||
simd_or: Uint, Int => or;
|
||||
simd_xor: Uint, Int => xor;
|
||||
simd_fmax: Float => maxnum;
|
||||
simd_fmin: Float => minnum;
|
||||
}
|
||||
span_bug!(span, "unknown SIMD intrinsic");
|
||||
}
|
||||
@ -1779,7 +1779,7 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
||||
// stuffs.
|
||||
fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> {
|
||||
match ty.sty {
|
||||
ty::TyInt(t) => Some((match t {
|
||||
ty::Int(t) => Some((match t {
|
||||
ast::IntTy::Isize => cx.tcx.sess.target.isize_ty.bit_width().unwrap() as u64,
|
||||
ast::IntTy::I8 => 8,
|
||||
ast::IntTy::I16 => 16,
|
||||
@ -1787,7 +1787,7 @@ fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> {
|
||||
ast::IntTy::I64 => 64,
|
||||
ast::IntTy::I128 => 128,
|
||||
}, true)),
|
||||
ty::TyUint(t) => Some((match t {
|
||||
ty::Uint(t) => Some((match t {
|
||||
ast::UintTy::Usize => cx.tcx.sess.target.usize_ty.bit_width().unwrap() as u64,
|
||||
ast::UintTy::U8 => 8,
|
||||
ast::UintTy::U16 => 16,
|
||||
@ -1803,7 +1803,7 @@ fn int_type_width_signed(ty: Ty, cx: &CodegenCx) -> Option<(u64, bool)> {
|
||||
// Returns None if the type is not a float
|
||||
fn float_type_width<'tcx>(sty: &ty::TyKind<'tcx>) -> Option<u64> {
|
||||
match *sty {
|
||||
ty::TyFloat(t) => Some(t.bit_width() as u64),
|
||||
ty::Float(t) => Some(t.bit_width() as u64),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ impl PlaceRef<'ll, 'tcx> {
|
||||
return simple();
|
||||
}
|
||||
_ if !field.is_unsized() => return simple(),
|
||||
ty::Slice(..) | ty::TyStr | ty::Foreign(..) => return simple(),
|
||||
ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(),
|
||||
ty::Adt(def, _) => {
|
||||
if def.repr.packed() {
|
||||
// FIXME(eddyb) generalize the adjustment when we
|
||||
|
@ -753,60 +753,60 @@ enum OverflowOp {
|
||||
fn get_overflow_intrinsic(oop: OverflowOp, bx: &Builder<'_, 'll, '_>, ty: Ty) -> &'ll Value {
|
||||
use syntax::ast::IntTy::*;
|
||||
use syntax::ast::UintTy::*;
|
||||
use rustc::ty::{TyInt, TyUint};
|
||||
use rustc::ty::{Int, Uint};
|
||||
|
||||
let tcx = bx.tcx();
|
||||
|
||||
let new_sty = match ty.sty {
|
||||
TyInt(Isize) => TyInt(tcx.sess.target.isize_ty),
|
||||
TyUint(Usize) => TyUint(tcx.sess.target.usize_ty),
|
||||
ref t @ TyUint(_) | ref t @ TyInt(_) => t.clone(),
|
||||
Int(Isize) => Int(tcx.sess.target.isize_ty),
|
||||
Uint(Usize) => Uint(tcx.sess.target.usize_ty),
|
||||
ref t @ Uint(_) | ref t @ Int(_) => t.clone(),
|
||||
_ => panic!("tried to get overflow intrinsic for op applied to non-int type")
|
||||
};
|
||||
|
||||
let name = match oop {
|
||||
OverflowOp::Add => match new_sty {
|
||||
TyInt(I8) => "llvm.sadd.with.overflow.i8",
|
||||
TyInt(I16) => "llvm.sadd.with.overflow.i16",
|
||||
TyInt(I32) => "llvm.sadd.with.overflow.i32",
|
||||
TyInt(I64) => "llvm.sadd.with.overflow.i64",
|
||||
TyInt(I128) => "llvm.sadd.with.overflow.i128",
|
||||
Int(I8) => "llvm.sadd.with.overflow.i8",
|
||||
Int(I16) => "llvm.sadd.with.overflow.i16",
|
||||
Int(I32) => "llvm.sadd.with.overflow.i32",
|
||||
Int(I64) => "llvm.sadd.with.overflow.i64",
|
||||
Int(I128) => "llvm.sadd.with.overflow.i128",
|
||||
|
||||
TyUint(U8) => "llvm.uadd.with.overflow.i8",
|
||||
TyUint(U16) => "llvm.uadd.with.overflow.i16",
|
||||
TyUint(U32) => "llvm.uadd.with.overflow.i32",
|
||||
TyUint(U64) => "llvm.uadd.with.overflow.i64",
|
||||
TyUint(U128) => "llvm.uadd.with.overflow.i128",
|
||||
Uint(U8) => "llvm.uadd.with.overflow.i8",
|
||||
Uint(U16) => "llvm.uadd.with.overflow.i16",
|
||||
Uint(U32) => "llvm.uadd.with.overflow.i32",
|
||||
Uint(U64) => "llvm.uadd.with.overflow.i64",
|
||||
Uint(U128) => "llvm.uadd.with.overflow.i128",
|
||||
|
||||
_ => unreachable!(),
|
||||
},
|
||||
OverflowOp::Sub => match new_sty {
|
||||
TyInt(I8) => "llvm.ssub.with.overflow.i8",
|
||||
TyInt(I16) => "llvm.ssub.with.overflow.i16",
|
||||
TyInt(I32) => "llvm.ssub.with.overflow.i32",
|
||||
TyInt(I64) => "llvm.ssub.with.overflow.i64",
|
||||
TyInt(I128) => "llvm.ssub.with.overflow.i128",
|
||||
Int(I8) => "llvm.ssub.with.overflow.i8",
|
||||
Int(I16) => "llvm.ssub.with.overflow.i16",
|
||||
Int(I32) => "llvm.ssub.with.overflow.i32",
|
||||
Int(I64) => "llvm.ssub.with.overflow.i64",
|
||||
Int(I128) => "llvm.ssub.with.overflow.i128",
|
||||
|
||||
TyUint(U8) => "llvm.usub.with.overflow.i8",
|
||||
TyUint(U16) => "llvm.usub.with.overflow.i16",
|
||||
TyUint(U32) => "llvm.usub.with.overflow.i32",
|
||||
TyUint(U64) => "llvm.usub.with.overflow.i64",
|
||||
TyUint(U128) => "llvm.usub.with.overflow.i128",
|
||||
Uint(U8) => "llvm.usub.with.overflow.i8",
|
||||
Uint(U16) => "llvm.usub.with.overflow.i16",
|
||||
Uint(U32) => "llvm.usub.with.overflow.i32",
|
||||
Uint(U64) => "llvm.usub.with.overflow.i64",
|
||||
Uint(U128) => "llvm.usub.with.overflow.i128",
|
||||
|
||||
_ => unreachable!(),
|
||||
},
|
||||
OverflowOp::Mul => match new_sty {
|
||||
TyInt(I8) => "llvm.smul.with.overflow.i8",
|
||||
TyInt(I16) => "llvm.smul.with.overflow.i16",
|
||||
TyInt(I32) => "llvm.smul.with.overflow.i32",
|
||||
TyInt(I64) => "llvm.smul.with.overflow.i64",
|
||||
TyInt(I128) => "llvm.smul.with.overflow.i128",
|
||||
Int(I8) => "llvm.smul.with.overflow.i8",
|
||||
Int(I16) => "llvm.smul.with.overflow.i16",
|
||||
Int(I32) => "llvm.smul.with.overflow.i32",
|
||||
Int(I64) => "llvm.smul.with.overflow.i64",
|
||||
Int(I128) => "llvm.smul.with.overflow.i128",
|
||||
|
||||
TyUint(U8) => "llvm.umul.with.overflow.i8",
|
||||
TyUint(U16) => "llvm.umul.with.overflow.i16",
|
||||
TyUint(U32) => "llvm.umul.with.overflow.i32",
|
||||
TyUint(U64) => "llvm.umul.with.overflow.i64",
|
||||
TyUint(U128) => "llvm.umul.with.overflow.i128",
|
||||
Uint(U8) => "llvm.umul.with.overflow.i8",
|
||||
Uint(U16) => "llvm.umul.with.overflow.i16",
|
||||
Uint(U32) => "llvm.umul.with.overflow.i32",
|
||||
Uint(U64) => "llvm.umul.with.overflow.i64",
|
||||
Uint(U128) => "llvm.umul.with.overflow.i128",
|
||||
|
||||
_ => unreachable!(),
|
||||
},
|
||||
|
@ -63,7 +63,7 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
||||
// in problematically distinct types due to HRTB and subtyping (see #47638).
|
||||
// ty::Dynamic(..) |
|
||||
ty::Foreign(..) |
|
||||
ty::TyStr => {
|
||||
ty::Str => {
|
||||
let mut name = String::with_capacity(32);
|
||||
let printer = DefPathBasedNames::new(cx.tcx, true, true);
|
||||
printer.push_type_name(layout.ty, &mut name);
|
||||
|
@ -84,7 +84,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
}
|
||||
hir::ExprKind::Lit(ref lit) => {
|
||||
match cx.tables.node_id_to_type(e.hir_id).sty {
|
||||
ty::TyInt(t) => {
|
||||
ty::Int(t) => {
|
||||
match lit.node {
|
||||
ast::LitKind::Int(v, ast::LitIntType::Signed(_)) |
|
||||
ast::LitKind::Int(v, ast::LitIntType::Unsuffixed) => {
|
||||
@ -104,7 +104,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
report_bin_hex_error(
|
||||
cx,
|
||||
e,
|
||||
ty::TyInt(t),
|
||||
ty::Int(t),
|
||||
repr_str,
|
||||
v,
|
||||
negative,
|
||||
@ -122,7 +122,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
_ => bug!(),
|
||||
};
|
||||
}
|
||||
ty::TyUint(t) => {
|
||||
ty::Uint(t) => {
|
||||
let uint_type = if let ast::UintTy::Usize = t {
|
||||
cx.sess().target.usize_ty
|
||||
} else {
|
||||
@ -139,7 +139,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
let parent_id = cx.tcx.hir.get_parent_node(e.id);
|
||||
if let hir_map::NodeExpr(parent_expr) = cx.tcx.hir.get(parent_id) {
|
||||
if let hir::ExprKind::Cast(..) = parent_expr.node {
|
||||
if let ty::TyChar = cx.tables.expr_ty(parent_expr).sty {
|
||||
if let ty::Char = cx.tables.expr_ty(parent_expr).sty {
|
||||
let mut err = cx.struct_span_lint(
|
||||
OVERFLOWING_LITERALS,
|
||||
parent_expr.span,
|
||||
@ -159,7 +159,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
report_bin_hex_error(
|
||||
cx,
|
||||
e,
|
||||
ty::TyUint(t),
|
||||
ty::Uint(t),
|
||||
repr_str,
|
||||
lit_val,
|
||||
false,
|
||||
@ -173,7 +173,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
);
|
||||
}
|
||||
}
|
||||
ty::TyFloat(t) => {
|
||||
ty::Float(t) => {
|
||||
let is_infinite = match lit.node {
|
||||
ast::LitKind::Float(v, _) |
|
||||
ast::LitKind::FloatUnsuffixed(v) => {
|
||||
@ -256,7 +256,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
// the comparison
|
||||
let norm_binop = if swap { rev_binop(binop) } else { binop };
|
||||
match cx.tables.node_id_to_type(expr.hir_id).sty {
|
||||
ty::TyInt(int_ty) => {
|
||||
ty::Int(int_ty) => {
|
||||
let (min, max) = int_ty_range(int_ty);
|
||||
let lit_val: i128 = match lit.node {
|
||||
hir::ExprKind::Lit(ref li) => {
|
||||
@ -270,7 +270,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
};
|
||||
is_valid(norm_binop, lit_val, min, max)
|
||||
}
|
||||
ty::TyUint(uint_ty) => {
|
||||
ty::Uint(uint_ty) => {
|
||||
let (min, max) :(u128, u128) = uint_ty_range(uint_ty);
|
||||
let lit_val: u128 = match lit.node {
|
||||
hir::ExprKind::Lit(ref li) => {
|
||||
@ -348,13 +348,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
}
|
||||
}
|
||||
match t {
|
||||
&ty::TyInt(i) => find_fit!(i, val, negative,
|
||||
&ty::Int(i) => find_fit!(i, val, negative,
|
||||
I8 => [U8] => [I16, I32, I64, I128],
|
||||
I16 => [U16] => [I32, I64, I128],
|
||||
I32 => [U32] => [I64, I128],
|
||||
I64 => [U64] => [I128],
|
||||
I128 => [U128] => []),
|
||||
&ty::TyUint(u) => find_fit!(u, val, negative,
|
||||
&ty::Uint(u) => find_fit!(u, val, negative,
|
||||
U8 => [U8, U16, U32, U64, U128] => [],
|
||||
U16 => [U16, U32, U64, U128] => [],
|
||||
U32 => [U32, U64, U128] => [],
|
||||
@ -373,13 +373,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
|
||||
negative: bool,
|
||||
) {
|
||||
let (t, actually) = match ty {
|
||||
ty::TyInt(t) => {
|
||||
ty::Int(t) => {
|
||||
let ity = attr::IntType::SignedInt(t);
|
||||
let bits = layout::Integer::from_attr(cx.tcx, ity).size().bits();
|
||||
let actually = (val << (128 - bits)) as i128 >> (128 - bits);
|
||||
(format!("{:?}", t), actually.to_string())
|
||||
}
|
||||
ty::TyUint(t) => {
|
||||
ty::Uint(t) => {
|
||||
let ity = attr::IntType::UnsignedInt(t);
|
||||
let bits = layout::Integer::from_attr(cx.tcx, ity).size().bits();
|
||||
let actually = (val << (128 - bits)) >> (128 - bits);
|
||||
@ -633,20 +633,20 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
ty::TyChar => FfiUnsafe {
|
||||
ty::Char => FfiUnsafe {
|
||||
ty: ty,
|
||||
reason: "the `char` type has no C equivalent",
|
||||
help: Some("consider using `u32` or `libc::wchar_t` instead"),
|
||||
},
|
||||
|
||||
ty::TyInt(ast::IntTy::I128) | ty::TyUint(ast::UintTy::U128) => FfiUnsafe {
|
||||
ty::Int(ast::IntTy::I128) | ty::Uint(ast::UintTy::U128) => FfiUnsafe {
|
||||
ty: ty,
|
||||
reason: "128-bit integers don't currently have a known stable ABI",
|
||||
help: None,
|
||||
},
|
||||
|
||||
// Primitive types with a stable representation.
|
||||
ty::TyBool | ty::TyInt(..) | ty::TyUint(..) | ty::TyFloat(..) | ty::Never => FfiSafe,
|
||||
ty::Bool | ty::Int(..) | ty::Uint(..) | ty::Float(..) | ty::Never => FfiSafe,
|
||||
|
||||
ty::Slice(_) => FfiUnsafe {
|
||||
ty: ty,
|
||||
@ -660,7 +660,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
help: None,
|
||||
},
|
||||
|
||||
ty::TyStr => FfiUnsafe {
|
||||
ty::Str => FfiUnsafe {
|
||||
ty: ty,
|
||||
reason: "string slices have no C equivalent",
|
||||
help: Some("consider using `*const u8` and a length instead"),
|
||||
|
@ -227,7 +227,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
TestKind::SwitchInt { switch_ty, ref options, indices: _ } => {
|
||||
let (ret, terminator) = if switch_ty.sty == ty::TyBool {
|
||||
let (ret, terminator) = if switch_ty.sty == ty::Bool {
|
||||
assert!(options.len() > 0 && options.len() <= 2);
|
||||
let (true_bb, false_bb) = (self.cfg.start_new_block(),
|
||||
self.cfg.start_new_block());
|
||||
|
@ -188,7 +188,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
LitKind::FloatUnsuffixed(n) => {
|
||||
let fty = match ty.sty {
|
||||
ty::TyFloat(fty) => fty,
|
||||
ty::Float(fty) => fty,
|
||||
_ => bug!()
|
||||
};
|
||||
parse_float(n, fty)
|
||||
|
@ -619,7 +619,7 @@ fn all_constructors<'a, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
|
||||
debug!("all_constructors({:?})", pcx.ty);
|
||||
let exhaustive_integer_patterns = cx.tcx.features().exhaustive_integer_patterns;
|
||||
let ctors = match pcx.ty.sty {
|
||||
ty::TyBool => {
|
||||
ty::Bool => {
|
||||
[true, false].iter().map(|&b| {
|
||||
ConstantValue(ty::Const::from_bool(cx.tcx, b))
|
||||
}).collect()
|
||||
|
@ -811,7 +811,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> {
|
||||
}).collect::<Vec<_>>()
|
||||
};
|
||||
let kind = match cv.ty.sty {
|
||||
ty::TyFloat(_) => {
|
||||
ty::Float(_) => {
|
||||
let id = self.tcx.hir.hir_to_node_id(id);
|
||||
self.tcx.lint_node(
|
||||
::rustc::lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
|
||||
@ -1073,17 +1073,17 @@ pub fn compare_const_vals<'a, 'tcx>(
|
||||
if let (Some(a), Some(b)) = (a.to_bits(tcx, ty), b.to_bits(tcx, ty)) {
|
||||
use ::rustc_apfloat::Float;
|
||||
return match ty.value.sty {
|
||||
ty::TyFloat(ast::FloatTy::F32) => {
|
||||
ty::Float(ast::FloatTy::F32) => {
|
||||
let l = ::rustc_apfloat::ieee::Single::from_bits(a);
|
||||
let r = ::rustc_apfloat::ieee::Single::from_bits(b);
|
||||
l.partial_cmp(&r)
|
||||
},
|
||||
ty::TyFloat(ast::FloatTy::F64) => {
|
||||
ty::Float(ast::FloatTy::F64) => {
|
||||
let l = ::rustc_apfloat::ieee::Double::from_bits(a);
|
||||
let r = ::rustc_apfloat::ieee::Double::from_bits(b);
|
||||
l.partial_cmp(&r)
|
||||
},
|
||||
ty::TyInt(_) => {
|
||||
ty::Int(_) => {
|
||||
let layout = tcx.layout_of(ty).ok()?;
|
||||
assert!(layout.abi.is_signed());
|
||||
let a = sign_extend(a, layout.size);
|
||||
@ -1095,7 +1095,7 @@ pub fn compare_const_vals<'a, 'tcx>(
|
||||
}
|
||||
|
||||
if let ty::Ref(_, rty, _) = ty.value.sty {
|
||||
if let ty::TyStr = rty.sty {
|
||||
if let ty::Str = rty.sty {
|
||||
match (a.val, b.val) {
|
||||
(
|
||||
ConstValue::ScalarPair(
|
||||
@ -1170,10 +1170,10 @@ fn lit_to_const<'a, 'tcx>(lit: &'tcx ast::LitKind,
|
||||
Unsigned(UintTy),
|
||||
}
|
||||
let ity = match ty.sty {
|
||||
ty::TyInt(IntTy::Isize) => Int::Signed(tcx.sess.target.isize_ty),
|
||||
ty::TyInt(other) => Int::Signed(other),
|
||||
ty::TyUint(UintTy::Usize) => Int::Unsigned(tcx.sess.target.usize_ty),
|
||||
ty::TyUint(other) => Int::Unsigned(other),
|
||||
ty::Int(IntTy::Isize) => Int::Signed(tcx.sess.target.isize_ty),
|
||||
ty::Int(other) => Int::Signed(other),
|
||||
ty::Uint(UintTy::Usize) => Int::Unsigned(tcx.sess.target.usize_ty),
|
||||
ty::Uint(other) => Int::Unsigned(other),
|
||||
ty::Error => { // Avoid ICE (#51963)
|
||||
return Err(LitToConstError::Propagated);
|
||||
}
|
||||
@ -1211,7 +1211,7 @@ fn lit_to_const<'a, 'tcx>(lit: &'tcx ast::LitKind,
|
||||
}
|
||||
LitKind::FloatUnsuffixed(n) => {
|
||||
let fty = match ty.sty {
|
||||
ty::TyFloat(fty) => fty,
|
||||
ty::Float(fty) => fty,
|
||||
_ => bug!()
|
||||
};
|
||||
parse_float(n, fty, neg).map_err(|_| LitToConstError::UnparseableFloat)?
|
||||
|
@ -152,7 +152,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
"Unexpected value of size {} before casting", size);
|
||||
|
||||
let res = match src_layout.ty.sty {
|
||||
TyFloat(fty) => self.cast_from_float(bits, fty, dest_layout.ty)?,
|
||||
Float(fty) => self.cast_from_float(bits, fty, dest_layout.ty)?,
|
||||
_ => self.cast_from_int(bits, src_layout, dest_layout)?,
|
||||
};
|
||||
|
||||
@ -186,7 +186,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
trace!("cast_from_int: {}, {}, {}", v, src_layout.ty, dest_layout.ty);
|
||||
use rustc::ty::TyKind::*;
|
||||
match dest_layout.ty.sty {
|
||||
TyInt(_) | TyUint(_) => {
|
||||
Int(_) | Uint(_) => {
|
||||
let v = self.truncate(v, dest_layout);
|
||||
Ok(Scalar::Bits {
|
||||
bits: v,
|
||||
@ -194,24 +194,24 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
})
|
||||
}
|
||||
|
||||
TyFloat(FloatTy::F32) if signed => Ok(Scalar::Bits {
|
||||
Float(FloatTy::F32) if signed => Ok(Scalar::Bits {
|
||||
bits: Single::from_i128(v as i128).value.to_bits(),
|
||||
size: 4,
|
||||
}),
|
||||
TyFloat(FloatTy::F64) if signed => Ok(Scalar::Bits {
|
||||
Float(FloatTy::F64) if signed => Ok(Scalar::Bits {
|
||||
bits: Double::from_i128(v as i128).value.to_bits(),
|
||||
size: 8,
|
||||
}),
|
||||
TyFloat(FloatTy::F32) => Ok(Scalar::Bits {
|
||||
Float(FloatTy::F32) => Ok(Scalar::Bits {
|
||||
bits: Single::from_u128(v).value.to_bits(),
|
||||
size: 4,
|
||||
}),
|
||||
TyFloat(FloatTy::F64) => Ok(Scalar::Bits {
|
||||
Float(FloatTy::F64) => Ok(Scalar::Bits {
|
||||
bits: Double::from_u128(v).value.to_bits(),
|
||||
size: 8,
|
||||
}),
|
||||
|
||||
TyChar => {
|
||||
Char => {
|
||||
assert_eq!(v as u8 as u128, v);
|
||||
Ok(Scalar::Bits { bits: v, size: 4 })
|
||||
},
|
||||
@ -234,7 +234,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
use rustc_apfloat::FloatConvert;
|
||||
match dest_ty.sty {
|
||||
// float -> uint
|
||||
TyUint(t) => {
|
||||
Uint(t) => {
|
||||
let width = t.bit_width().unwrap_or(self.memory.pointer_size().bits() as usize);
|
||||
let v = match fty {
|
||||
FloatTy::F32 => Single::from_bits(bits).to_u128(width).value,
|
||||
@ -247,7 +247,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
})
|
||||
},
|
||||
// float -> int
|
||||
TyInt(t) => {
|
||||
Int(t) => {
|
||||
let width = t.bit_width().unwrap_or(self.memory.pointer_size().bits() as usize);
|
||||
let v = match fty {
|
||||
FloatTy::F32 => Single::from_bits(bits).to_i128(width).value,
|
||||
@ -263,25 +263,25 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
})
|
||||
},
|
||||
// f64 -> f32
|
||||
TyFloat(FloatTy::F32) if fty == FloatTy::F64 => {
|
||||
Float(FloatTy::F32) if fty == FloatTy::F64 => {
|
||||
Ok(Scalar::Bits {
|
||||
bits: Single::to_bits(Double::from_bits(bits).convert(&mut false).value),
|
||||
size: 4,
|
||||
})
|
||||
},
|
||||
// f32 -> f64
|
||||
TyFloat(FloatTy::F64) if fty == FloatTy::F32 => {
|
||||
Float(FloatTy::F64) if fty == FloatTy::F32 => {
|
||||
Ok(Scalar::Bits {
|
||||
bits: Double::to_bits(Single::from_bits(bits).convert(&mut false).value),
|
||||
size: 8,
|
||||
})
|
||||
},
|
||||
// identity cast
|
||||
TyFloat(FloatTy:: F64) => Ok(Scalar::Bits {
|
||||
Float(FloatTy:: F64) => Ok(Scalar::Bits {
|
||||
bits,
|
||||
size: 8,
|
||||
}),
|
||||
TyFloat(FloatTy:: F32) => Ok(Scalar::Bits {
|
||||
Float(FloatTy:: F32) => Ok(Scalar::Bits {
|
||||
bits,
|
||||
size: 4,
|
||||
}),
|
||||
@ -294,9 +294,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
match ty.sty {
|
||||
// Casting to a reference or fn pointer is not permitted by rustc, no need to support it here.
|
||||
RawPtr(_) |
|
||||
TyInt(IntTy::Isize) |
|
||||
TyUint(UintTy::Usize) => Ok(ptr.into()),
|
||||
TyInt(_) | TyUint(_) => err!(ReadPointerAsBytes),
|
||||
Int(IntTy::Isize) |
|
||||
Uint(UintTy::Usize) => Ok(ptr.into()),
|
||||
Int(_) | Uint(_) => err!(ReadPointerAsBytes),
|
||||
_ => err!(Unimplemented(format!("ptr to {:?} cast", ty))),
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
}
|
||||
}
|
||||
|
||||
if let ty::TyFloat(fty) = left_layout.ty.sty {
|
||||
if let ty::Float(fty) = left_layout.ty.sty {
|
||||
macro_rules! float_math {
|
||||
($ty:path, $size:expr) => {{
|
||||
let l = <$ty>::from_bits(l);
|
||||
@ -267,12 +267,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
|
||||
|
||||
let result_bytes = match (un_op, &layout.ty.sty) {
|
||||
|
||||
(Not, ty::TyBool) => !val.to_bool()? as u128,
|
||||
(Not, ty::Bool) => !val.to_bool()? as u128,
|
||||
|
||||
(Not, _) => !bytes,
|
||||
|
||||
(Neg, ty::TyFloat(FloatTy::F32)) => Single::to_bits(-Single::from_bits(bytes)),
|
||||
(Neg, ty::TyFloat(FloatTy::F64)) => Double::to_bits(-Double::from_bits(bytes)),
|
||||
(Neg, ty::Float(FloatTy::F32)) => Single::to_bits(-Single::from_bits(bytes)),
|
||||
(Neg, ty::Float(FloatTy::F64)) => Double::to_bits(-Double::from_bits(bytes)),
|
||||
|
||||
(Neg, _) if bytes == (1 << (size.bits() - 1)) => return err!(OverflowNeg),
|
||||
(Neg, _) => (-(bytes as i128)) as u128,
|
||||
|
@ -839,7 +839,7 @@ fn find_vtable_types_for_unsizing<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
let tail = tcx.struct_tail(ty);
|
||||
match tail.sty {
|
||||
ty::Foreign(..) => false,
|
||||
ty::TyStr | ty::Slice(..) | ty::Dynamic(..) => true,
|
||||
ty::Str | ty::Slice(..) | ty::Dynamic(..) => true,
|
||||
_ => bug!("unexpected unsized tail: {:?}", tail.sty),
|
||||
}
|
||||
};
|
||||
|
@ -257,24 +257,24 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
|
||||
|
||||
pub fn push_type_name(&self, t: Ty<'tcx>, output: &mut String) {
|
||||
match t.sty {
|
||||
ty::TyBool => output.push_str("bool"),
|
||||
ty::TyChar => output.push_str("char"),
|
||||
ty::TyStr => output.push_str("str"),
|
||||
ty::Bool => output.push_str("bool"),
|
||||
ty::Char => output.push_str("char"),
|
||||
ty::Str => output.push_str("str"),
|
||||
ty::Never => output.push_str("!"),
|
||||
ty::TyInt(ast::IntTy::Isize) => output.push_str("isize"),
|
||||
ty::TyInt(ast::IntTy::I8) => output.push_str("i8"),
|
||||
ty::TyInt(ast::IntTy::I16) => output.push_str("i16"),
|
||||
ty::TyInt(ast::IntTy::I32) => output.push_str("i32"),
|
||||
ty::TyInt(ast::IntTy::I64) => output.push_str("i64"),
|
||||
ty::TyInt(ast::IntTy::I128) => output.push_str("i128"),
|
||||
ty::TyUint(ast::UintTy::Usize) => output.push_str("usize"),
|
||||
ty::TyUint(ast::UintTy::U8) => output.push_str("u8"),
|
||||
ty::TyUint(ast::UintTy::U16) => output.push_str("u16"),
|
||||
ty::TyUint(ast::UintTy::U32) => output.push_str("u32"),
|
||||
ty::TyUint(ast::UintTy::U64) => output.push_str("u64"),
|
||||
ty::TyUint(ast::UintTy::U128) => output.push_str("u128"),
|
||||
ty::TyFloat(ast::FloatTy::F32) => output.push_str("f32"),
|
||||
ty::TyFloat(ast::FloatTy::F64) => output.push_str("f64"),
|
||||
ty::Int(ast::IntTy::Isize) => output.push_str("isize"),
|
||||
ty::Int(ast::IntTy::I8) => output.push_str("i8"),
|
||||
ty::Int(ast::IntTy::I16) => output.push_str("i16"),
|
||||
ty::Int(ast::IntTy::I32) => output.push_str("i32"),
|
||||
ty::Int(ast::IntTy::I64) => output.push_str("i64"),
|
||||
ty::Int(ast::IntTy::I128) => output.push_str("i128"),
|
||||
ty::Uint(ast::UintTy::Usize) => output.push_str("usize"),
|
||||
ty::Uint(ast::UintTy::U8) => output.push_str("u8"),
|
||||
ty::Uint(ast::UintTy::U16) => output.push_str("u16"),
|
||||
ty::Uint(ast::UintTy::U32) => output.push_str("u32"),
|
||||
ty::Uint(ast::UintTy::U64) => output.push_str("u64"),
|
||||
ty::Uint(ast::UintTy::U128) => output.push_str("u128"),
|
||||
ty::Float(ast::FloatTy::F32) => output.push_str("f32"),
|
||||
ty::Float(ast::FloatTy::F64) => output.push_str("f64"),
|
||||
ty::Adt(adt_def, substs) => {
|
||||
self.push_def_path(adt_def.did, output);
|
||||
self.push_type_params(substs, iter::empty(), output);
|
||||
|
@ -190,8 +190,8 @@ impl RhsKind {
|
||||
|
||||
fn sign_of_128bit(ty: Ty) -> Option<bool> {
|
||||
match ty.sty {
|
||||
TyKind::TyInt(syntax::ast::IntTy::I128) => Some(true),
|
||||
TyKind::TyUint(syntax::ast::UintTy::U128) => Some(false),
|
||||
TyKind::Int(syntax::ast::IntTy::I128) => Some(true),
|
||||
TyKind::Uint(syntax::ast::UintTy::U128) => Some(false),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ use self::TypeParameters::*;
|
||||
use self::RibKind::*;
|
||||
|
||||
use rustc::hir::map::{Definitions, DefCollector};
|
||||
use rustc::hir::{self, PrimTy, TyBool, TyChar, TyFloat, TyInt, TyUint, TyStr};
|
||||
use rustc::hir::{self, PrimTy, Bool, Char, Float, Int, Uint, Str};
|
||||
use rustc::middle::cstore::CrateStore;
|
||||
use rustc::session::Session;
|
||||
use rustc::lint;
|
||||
@ -1280,23 +1280,23 @@ impl PrimitiveTypeTable {
|
||||
fn new() -> PrimitiveTypeTable {
|
||||
let mut table = PrimitiveTypeTable { primitive_types: FxHashMap() };
|
||||
|
||||
table.intern("bool", TyBool);
|
||||
table.intern("char", TyChar);
|
||||
table.intern("f32", TyFloat(FloatTy::F32));
|
||||
table.intern("f64", TyFloat(FloatTy::F64));
|
||||
table.intern("isize", TyInt(IntTy::Isize));
|
||||
table.intern("i8", TyInt(IntTy::I8));
|
||||
table.intern("i16", TyInt(IntTy::I16));
|
||||
table.intern("i32", TyInt(IntTy::I32));
|
||||
table.intern("i64", TyInt(IntTy::I64));
|
||||
table.intern("i128", TyInt(IntTy::I128));
|
||||
table.intern("str", TyStr);
|
||||
table.intern("usize", TyUint(UintTy::Usize));
|
||||
table.intern("u8", TyUint(UintTy::U8));
|
||||
table.intern("u16", TyUint(UintTy::U16));
|
||||
table.intern("u32", TyUint(UintTy::U32));
|
||||
table.intern("u64", TyUint(UintTy::U64));
|
||||
table.intern("u128", TyUint(UintTy::U128));
|
||||
table.intern("bool", Bool);
|
||||
table.intern("char", Char);
|
||||
table.intern("f32", Float(FloatTy::F32));
|
||||
table.intern("f64", Float(FloatTy::F64));
|
||||
table.intern("isize", Int(IntTy::Isize));
|
||||
table.intern("i8", Int(IntTy::I8));
|
||||
table.intern("i16", Int(IntTy::I16));
|
||||
table.intern("i32", Int(IntTy::I32));
|
||||
table.intern("i64", Int(IntTy::I64));
|
||||
table.intern("i128", Int(IntTy::I128));
|
||||
table.intern("str", Str);
|
||||
table.intern("usize", Uint(UintTy::Usize));
|
||||
table.intern("u8", Uint(UintTy::U8));
|
||||
table.intern("u16", Uint(UintTy::U16));
|
||||
table.intern("u32", Uint(UintTy::U32));
|
||||
table.intern("u64", Uint(UintTy::U64));
|
||||
table.intern("u128", Uint(UintTy::U128));
|
||||
table
|
||||
}
|
||||
|
||||
@ -3900,7 +3900,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> {
|
||||
}
|
||||
}
|
||||
// Add primitive types to the mix
|
||||
if filter_fn(Def::PrimTy(TyBool)) {
|
||||
if filter_fn(Def::PrimTy(Bool)) {
|
||||
names.extend(
|
||||
self.primitive_type_table.primitive_types.iter().map(|(name, _)| name)
|
||||
)
|
||||
|
@ -173,12 +173,12 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>(
|
||||
}
|
||||
|
||||
let result = match ty.sty {
|
||||
ty::TyBool
|
||||
| ty::TyChar
|
||||
| ty::TyInt(_)
|
||||
| ty::TyUint(_)
|
||||
| ty::TyFloat(_)
|
||||
| ty::TyStr
|
||||
ty::Bool
|
||||
| ty::Char
|
||||
| ty::Int(_)
|
||||
| ty::Uint(_)
|
||||
| ty::Float(_)
|
||||
| ty::Str
|
||||
| ty::Never
|
||||
| ty::Foreign(..)
|
||||
| ty::RawPtr(..)
|
||||
|
@ -1438,12 +1438,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {
|
||||
assert_eq!(opt_self_ty, None);
|
||||
self.prohibit_generics(&path.segments);
|
||||
match prim_ty {
|
||||
hir::TyBool => tcx.types.bool,
|
||||
hir::TyChar => tcx.types.char,
|
||||
hir::TyInt(it) => tcx.mk_mach_int(it),
|
||||
hir::TyUint(uit) => tcx.mk_mach_uint(uit),
|
||||
hir::TyFloat(ft) => tcx.mk_mach_float(ft),
|
||||
hir::TyStr => tcx.mk_str()
|
||||
hir::Bool => tcx.types.bool,
|
||||
hir::Char => tcx.types.char,
|
||||
hir::Int(it) => tcx.mk_mach_int(it),
|
||||
hir::Uint(uit) => tcx.mk_mach_uint(uit),
|
||||
hir::Float(ft) => tcx.mk_mach_float(ft),
|
||||
hir::Str => tcx.mk_str()
|
||||
}
|
||||
}
|
||||
Def::Err => {
|
||||
|
@ -103,7 +103,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
|
||||
Ok(match t.sty {
|
||||
ty::Slice(_) | ty::TyStr => Some(PointerKind::Length),
|
||||
ty::Slice(_) | ty::Str => Some(PointerKind::Length),
|
||||
ty::Dynamic(ref tty, ..) =>
|
||||
Some(PointerKind::Vtable(tty.principal().map(|p| p.def_id()))),
|
||||
ty::Adt(def, substs) if def.is_struct() => {
|
||||
@ -129,8 +129,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
// Insufficient type information.
|
||||
ty::Infer(_) => None,
|
||||
|
||||
ty::TyBool | ty::TyChar | ty::TyInt(..) | ty::TyUint(..) |
|
||||
ty::TyFloat(_) | ty::Array(..) | ty::GeneratorWitness(..) |
|
||||
ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) |
|
||||
ty::Float(_) | ty::Array(..) | ty::GeneratorWitness(..) |
|
||||
ty::RawPtr(_) | ty::Ref(..) | ty::FnDef(..) |
|
||||
ty::FnPtr(..) | ty::Closure(..) | ty::Generator(..) |
|
||||
ty::Adt(..) | ty::Never | ty::Error => {
|
||||
@ -477,9 +477,9 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
|
||||
(RPtr(p), Int(_)) |
|
||||
(RPtr(p), Float) => {
|
||||
match p.ty.sty {
|
||||
ty::TyKind::TyInt(_) |
|
||||
ty::TyKind::TyUint(_) |
|
||||
ty::TyKind::TyFloat(_) => {
|
||||
ty::TyKind::Int(_) |
|
||||
ty::TyKind::Uint(_) |
|
||||
ty::TyKind::Float(_) => {
|
||||
Err(CastError::NeedDeref)
|
||||
}
|
||||
ty::TyKind::Infer(t) => {
|
||||
|
@ -260,8 +260,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
|
||||
match (&expected.sty, &checked_ty.sty) {
|
||||
(&ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (&exp.sty, &check.sty) {
|
||||
(&ty::TyStr, &ty::Array(arr, _)) |
|
||||
(&ty::TyStr, &ty::Slice(arr)) if arr == self.tcx.types.u8 => {
|
||||
(&ty::Str, &ty::Array(arr, _)) |
|
||||
(&ty::Str, &ty::Slice(arr)) if arr == self.tcx.types.u8 => {
|
||||
if let hir::ExprKind::Lit(_) = expr.node {
|
||||
if let Ok(src) = cm.span_to_snippet(sp) {
|
||||
if src.starts_with("b\"") {
|
||||
@ -272,8 +272,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
}
|
||||
},
|
||||
(&ty::Array(arr, _), &ty::TyStr) |
|
||||
(&ty::Slice(arr), &ty::TyStr) if arr == self.tcx.types.u8 => {
|
||||
(&ty::Array(arr, _), &ty::Str) |
|
||||
(&ty::Slice(arr), &ty::Str) if arr == self.tcx.types.u8 => {
|
||||
if let hir::ExprKind::Lit(_) = expr.node {
|
||||
if let Ok(src) = cm.span_to_snippet(sp) {
|
||||
if src.starts_with("\"") {
|
||||
@ -418,7 +418,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
if needs_paren { ")" } else { "" });
|
||||
|
||||
match (&expected_ty.sty, &checked_ty.sty) {
|
||||
(&ty::TyInt(ref exp), &ty::TyInt(ref found)) => {
|
||||
(&ty::Int(ref exp), &ty::Int(ref found)) => {
|
||||
match (found.bit_width(), exp.bit_width()) {
|
||||
(Some(found), Some(exp)) if found > exp => {
|
||||
if can_cast {
|
||||
@ -444,7 +444,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
true
|
||||
}
|
||||
(&ty::TyUint(ref exp), &ty::TyUint(ref found)) => {
|
||||
(&ty::Uint(ref exp), &ty::Uint(ref found)) => {
|
||||
match (found.bit_width(), exp.bit_width()) {
|
||||
(Some(found), Some(exp)) if found > exp => {
|
||||
if can_cast {
|
||||
@ -470,7 +470,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
true
|
||||
}
|
||||
(&ty::TyInt(ref exp), &ty::TyUint(ref found)) => {
|
||||
(&ty::Int(ref exp), &ty::Uint(ref found)) => {
|
||||
if can_cast {
|
||||
match (found.bit_width(), exp.bit_width()) {
|
||||
(Some(found), Some(exp)) if found > exp - 1 => {
|
||||
@ -506,7 +506,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
true
|
||||
}
|
||||
(&ty::TyUint(ref exp), &ty::TyInt(ref found)) => {
|
||||
(&ty::Uint(ref exp), &ty::Int(ref found)) => {
|
||||
if can_cast {
|
||||
match (found.bit_width(), exp.bit_width()) {
|
||||
(Some(found), Some(exp)) if found - 1 > exp => {
|
||||
@ -542,7 +542,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
true
|
||||
}
|
||||
(&ty::TyFloat(ref exp), &ty::TyFloat(ref found)) => {
|
||||
(&ty::Float(ref exp), &ty::Float(ref found)) => {
|
||||
if found.bit_width() < exp.bit_width() {
|
||||
err.span_suggestion(expr.span,
|
||||
&format!("{} in a lossless way",
|
||||
@ -556,7 +556,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
true
|
||||
}
|
||||
(&ty::TyUint(_), &ty::TyFloat(_)) | (&ty::TyInt(_), &ty::TyFloat(_)) => {
|
||||
(&ty::Uint(_), &ty::Float(_)) | (&ty::Int(_), &ty::Float(_)) => {
|
||||
if can_cast {
|
||||
err.span_suggestion(expr.span,
|
||||
&format!("{}, rounding the float towards zero",
|
||||
@ -568,7 +568,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
true
|
||||
}
|
||||
(&ty::TyFloat(ref exp), &ty::TyUint(ref found)) => {
|
||||
(&ty::Float(ref exp), &ty::Uint(ref found)) => {
|
||||
// if `found` is `None` (meaning found is `usize`), don't suggest `.into()`
|
||||
if exp.bit_width() > found.bit_width().unwrap_or(256) {
|
||||
err.span_suggestion(expr.span,
|
||||
@ -586,7 +586,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
true
|
||||
}
|
||||
(&ty::TyFloat(ref exp), &ty::TyInt(ref found)) => {
|
||||
(&ty::Float(ref exp), &ty::Int(ref found)) => {
|
||||
// if `found` is `None` (meaning found is `isize`), don't suggest `.into()`
|
||||
if exp.bit_width() > found.bit_width().unwrap_or(256) {
|
||||
err.span_suggestion(expr.span,
|
||||
|
@ -468,24 +468,24 @@ fn match_intrinsic_type_to_type<'a, 'tcx>(
|
||||
},
|
||||
// (The width we pass to LLVM doesn't concern the type checker.)
|
||||
Integer(signed, bits, _llvm_width) => match (signed, bits, &t.sty) {
|
||||
(true, 8, &ty::TyInt(ast::IntTy::I8)) |
|
||||
(false, 8, &ty::TyUint(ast::UintTy::U8)) |
|
||||
(true, 16, &ty::TyInt(ast::IntTy::I16)) |
|
||||
(false, 16, &ty::TyUint(ast::UintTy::U16)) |
|
||||
(true, 32, &ty::TyInt(ast::IntTy::I32)) |
|
||||
(false, 32, &ty::TyUint(ast::UintTy::U32)) |
|
||||
(true, 64, &ty::TyInt(ast::IntTy::I64)) |
|
||||
(false, 64, &ty::TyUint(ast::UintTy::U64)) |
|
||||
(true, 128, &ty::TyInt(ast::IntTy::I128)) |
|
||||
(false, 128, &ty::TyUint(ast::UintTy::U128)) => {},
|
||||
(true, 8, &ty::Int(ast::IntTy::I8)) |
|
||||
(false, 8, &ty::Uint(ast::UintTy::U8)) |
|
||||
(true, 16, &ty::Int(ast::IntTy::I16)) |
|
||||
(false, 16, &ty::Uint(ast::UintTy::U16)) |
|
||||
(true, 32, &ty::Int(ast::IntTy::I32)) |
|
||||
(false, 32, &ty::Uint(ast::UintTy::U32)) |
|
||||
(true, 64, &ty::Int(ast::IntTy::I64)) |
|
||||
(false, 64, &ty::Uint(ast::UintTy::U64)) |
|
||||
(true, 128, &ty::Int(ast::IntTy::I128)) |
|
||||
(false, 128, &ty::Uint(ast::UintTy::U128)) => {},
|
||||
_ => simple_error(&format!("`{}`", t),
|
||||
&format!("`{}{n}`",
|
||||
if signed {"i"} else {"u"},
|
||||
n = bits)),
|
||||
},
|
||||
Float(bits) => match (bits, &t.sty) {
|
||||
(32, &ty::TyFloat(ast::FloatTy::F32)) |
|
||||
(64, &ty::TyFloat(ast::FloatTy::F64)) => {},
|
||||
(32, &ty::Float(ast::FloatTy::F32)) |
|
||||
(64, &ty::Float(ast::FloatTy::F64)) => {},
|
||||
_ => simple_error(&format!("`{}`", t),
|
||||
&format!("`f{n}`", n = bits)),
|
||||
},
|
||||
|
@ -465,11 +465,11 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||
ty::Param(p) => {
|
||||
self.assemble_inherent_candidates_from_param(self_ty, p);
|
||||
}
|
||||
ty::TyChar => {
|
||||
ty::Char => {
|
||||
let lang_def_id = lang_items.char_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyStr => {
|
||||
ty::Str => {
|
||||
let lang_def_id = lang_items.str_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
|
||||
@ -497,62 +497,62 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
|
||||
let lang_def_id = lang_items.mut_ptr_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I8) => {
|
||||
ty::Int(ast::IntTy::I8) => {
|
||||
let lang_def_id = lang_items.i8_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I16) => {
|
||||
ty::Int(ast::IntTy::I16) => {
|
||||
let lang_def_id = lang_items.i16_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I32) => {
|
||||
ty::Int(ast::IntTy::I32) => {
|
||||
let lang_def_id = lang_items.i32_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I64) => {
|
||||
ty::Int(ast::IntTy::I64) => {
|
||||
let lang_def_id = lang_items.i64_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I128) => {
|
||||
ty::Int(ast::IntTy::I128) => {
|
||||
let lang_def_id = lang_items.i128_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::Isize) => {
|
||||
ty::Int(ast::IntTy::Isize) => {
|
||||
let lang_def_id = lang_items.isize_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U8) => {
|
||||
ty::Uint(ast::UintTy::U8) => {
|
||||
let lang_def_id = lang_items.u8_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U16) => {
|
||||
ty::Uint(ast::UintTy::U16) => {
|
||||
let lang_def_id = lang_items.u16_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U32) => {
|
||||
ty::Uint(ast::UintTy::U32) => {
|
||||
let lang_def_id = lang_items.u32_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U64) => {
|
||||
ty::Uint(ast::UintTy::U64) => {
|
||||
let lang_def_id = lang_items.u64_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U128) => {
|
||||
ty::Uint(ast::UintTy::U128) => {
|
||||
let lang_def_id = lang_items.u128_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::Usize) => {
|
||||
ty::Uint(ast::UintTy::Usize) => {
|
||||
let lang_def_id = lang_items.usize_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyFloat(ast::FloatTy::F32) => {
|
||||
ty::Float(ast::FloatTy::F32) => {
|
||||
let lang_def_id = lang_items.f32_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
|
||||
let lang_def_id = lang_items.f32_runtime_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::TyFloat(ast::FloatTy::F64) => {
|
||||
ty::Float(ast::FloatTy::F64) => {
|
||||
let lang_def_id = lang_items.f64_impl();
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
|
||||
|
@ -311,7 +311,7 @@ impl<'a, 'gcx, 'tcx> Expectation<'tcx> {
|
||||
/// for examples of where this comes up,.
|
||||
fn rvalue_hint(fcx: &FnCtxt<'a, 'gcx, 'tcx>, ty: Ty<'tcx>) -> Expectation<'tcx> {
|
||||
match fcx.tcx.struct_tail(ty).sty {
|
||||
ty::Slice(_) | ty::TyStr | ty::Dynamic(..) => {
|
||||
ty::Slice(_) | ty::Str | ty::Dynamic(..) => {
|
||||
ExpectRvalueLikeUnsized(ty)
|
||||
}
|
||||
_ => ExpectHasType(ty)
|
||||
@ -2831,13 +2831,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
// in C but we just error out instead and require explicit casts.
|
||||
let arg_ty = self.structurally_resolved_type(arg.span, arg_ty);
|
||||
match arg_ty.sty {
|
||||
ty::TyFloat(ast::FloatTy::F32) => {
|
||||
ty::Float(ast::FloatTy::F32) => {
|
||||
variadic_error(tcx.sess, arg.span, arg_ty, "c_double");
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I8) | ty::TyInt(ast::IntTy::I16) | ty::TyBool => {
|
||||
ty::Int(ast::IntTy::I8) | ty::Int(ast::IntTy::I16) | ty::Bool => {
|
||||
variadic_error(tcx.sess, arg.span, arg_ty, "c_int");
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U8) | ty::TyUint(ast::UintTy::U16) => {
|
||||
ty::Uint(ast::UintTy::U8) | ty::Uint(ast::UintTy::U16) => {
|
||||
variadic_error(tcx.sess, arg.span, arg_ty, "c_uint");
|
||||
}
|
||||
ty::FnDef(..) => {
|
||||
@ -2876,8 +2876,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
|
||||
let opt_ty = expected.to_option(self).and_then(|ty| {
|
||||
match ty.sty {
|
||||
ty::TyInt(_) | ty::TyUint(_) => Some(ty),
|
||||
ty::TyChar => Some(tcx.types.u8),
|
||||
ty::Int(_) | ty::Uint(_) => Some(ty),
|
||||
ty::Char => Some(tcx.types.u8),
|
||||
ty::RawPtr(..) => Some(tcx.types.usize),
|
||||
ty::FnDef(..) | ty::FnPtr(_) => Some(tcx.types.usize),
|
||||
_ => None
|
||||
@ -2890,7 +2890,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
ast::LitKind::FloatUnsuffixed(_) => {
|
||||
let opt_ty = expected.to_option(self).and_then(|ty| {
|
||||
match ty.sty {
|
||||
ty::TyFloat(_) => Some(ty),
|
||||
ty::Float(_) => Some(ty),
|
||||
_ => None
|
||||
}
|
||||
});
|
||||
@ -3755,7 +3755,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
hir::UnNot => {
|
||||
let result = self.check_user_unop(expr, oprnd_t, unop);
|
||||
// If it's builtin, we can reuse the type, this helps inference.
|
||||
if !(oprnd_t.is_integral() || oprnd_t.sty == ty::TyBool) {
|
||||
if !(oprnd_t.is_integral() || oprnd_t.sty == ty::Bool) {
|
||||
oprnd_t = result;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
use super::{FnCtxt, Needs};
|
||||
use super::method::MethodCallee;
|
||||
use rustc::ty::{self, Ty, TypeFoldable};
|
||||
use rustc::ty::TyKind::{Ref, Adt, TyStr, TyUint, Never, Tuple, TyChar, Array};
|
||||
use rustc::ty::TyKind::{Ref, Adt, Str, Uint, Never, Tuple, Char, Array};
|
||||
use rustc::ty::adjustment::{Adjustment, Adjust, AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
|
||||
use rustc::infer::type_variable::TypeVariableOrigin;
|
||||
use errors;
|
||||
@ -430,7 +430,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
// to print the normal "implementation of `std::ops::Add` might be missing" note
|
||||
match (&lhs_ty.sty, &rhs_ty.sty) {
|
||||
(&Ref(_, l_ty, _), &Ref(_, r_ty, _))
|
||||
if l_ty.sty == TyStr && r_ty.sty == TyStr => {
|
||||
if l_ty.sty == Str && r_ty.sty == Str => {
|
||||
if !is_assign {
|
||||
err.span_label(expr.span,
|
||||
"`+` can't be used to concatenate two `&str` strings");
|
||||
@ -444,7 +444,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
true
|
||||
}
|
||||
(&Ref(_, l_ty, _), &Adt(..))
|
||||
if l_ty.sty == TyStr && &format!("{:?}", rhs_ty) == "std::string::String" => {
|
||||
if l_ty.sty == Str && &format!("{:?}", rhs_ty) == "std::string::String" => {
|
||||
err.span_label(expr.span,
|
||||
"`+` can't be used to concatenate a `&str` with a `String`");
|
||||
match (
|
||||
@ -489,11 +489,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
err.span_label(ex.span, format!("cannot apply unary \
|
||||
operator `{}`", op.as_str()));
|
||||
match actual.sty {
|
||||
TyUint(_) if op == hir::UnNeg => {
|
||||
Uint(_) if op == hir::UnNeg => {
|
||||
err.note("unsigned values cannot be negated");
|
||||
},
|
||||
TyStr | Never | TyChar | Tuple(_) | Array(_,_) => {},
|
||||
Ref(_, ref lty, _) if lty.sty == TyStr => {},
|
||||
Str | Never | Char | Tuple(_) | Array(_,_) => {},
|
||||
Ref(_, ref lty, _) if lty.sty == Str => {},
|
||||
_ => {
|
||||
let missing_trait = match op {
|
||||
hir::UnNeg => "std::ops::Neg",
|
||||
|
@ -916,7 +916,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> {
|
||||
let r_index_expr = ty::ReScope(region::Scope::Node(index_expr.hir_id.local_id));
|
||||
if let ty::Ref(r_ptr, r_ty, _) = indexed_ty.sty {
|
||||
match r_ty.sty {
|
||||
ty::Slice(_) | ty::TyStr => {
|
||||
ty::Slice(_) | ty::Str => {
|
||||
self.sub_regions(infer::IndexSlice(index_expr.span),
|
||||
self.tcx.mk_region(r_index_expr), r_ptr);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
ty::Dynamic(ref data, ..) if data.principal().is_some() => {
|
||||
self.check_def_id(item, data.principal().unwrap().def_id());
|
||||
}
|
||||
ty::TyChar => {
|
||||
ty::Char => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.char_impl(),
|
||||
None,
|
||||
@ -119,7 +119,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"char",
|
||||
item.span);
|
||||
}
|
||||
ty::TyStr => {
|
||||
ty::Str => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.str_impl(),
|
||||
lang_items.str_alloc_impl(),
|
||||
@ -159,7 +159,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"*mut T",
|
||||
item.span);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I8) => {
|
||||
ty::Int(ast::IntTy::I8) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.i8_impl(),
|
||||
None,
|
||||
@ -167,7 +167,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"i8",
|
||||
item.span);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I16) => {
|
||||
ty::Int(ast::IntTy::I16) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.i16_impl(),
|
||||
None,
|
||||
@ -175,7 +175,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"i16",
|
||||
item.span);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I32) => {
|
||||
ty::Int(ast::IntTy::I32) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.i32_impl(),
|
||||
None,
|
||||
@ -183,7 +183,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"i32",
|
||||
item.span);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I64) => {
|
||||
ty::Int(ast::IntTy::I64) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.i64_impl(),
|
||||
None,
|
||||
@ -191,7 +191,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"i64",
|
||||
item.span);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::I128) => {
|
||||
ty::Int(ast::IntTy::I128) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.i128_impl(),
|
||||
None,
|
||||
@ -199,7 +199,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"i128",
|
||||
item.span);
|
||||
}
|
||||
ty::TyInt(ast::IntTy::Isize) => {
|
||||
ty::Int(ast::IntTy::Isize) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.isize_impl(),
|
||||
None,
|
||||
@ -207,7 +207,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"isize",
|
||||
item.span);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U8) => {
|
||||
ty::Uint(ast::UintTy::U8) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.u8_impl(),
|
||||
None,
|
||||
@ -215,7 +215,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"u8",
|
||||
item.span);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U16) => {
|
||||
ty::Uint(ast::UintTy::U16) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.u16_impl(),
|
||||
None,
|
||||
@ -223,7 +223,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"u16",
|
||||
item.span);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U32) => {
|
||||
ty::Uint(ast::UintTy::U32) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.u32_impl(),
|
||||
None,
|
||||
@ -231,7 +231,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"u32",
|
||||
item.span);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U64) => {
|
||||
ty::Uint(ast::UintTy::U64) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.u64_impl(),
|
||||
None,
|
||||
@ -239,7 +239,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"u64",
|
||||
item.span);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::U128) => {
|
||||
ty::Uint(ast::UintTy::U128) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.u128_impl(),
|
||||
None,
|
||||
@ -247,7 +247,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"u128",
|
||||
item.span);
|
||||
}
|
||||
ty::TyUint(ast::UintTy::Usize) => {
|
||||
ty::Uint(ast::UintTy::Usize) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.usize_impl(),
|
||||
None,
|
||||
@ -255,7 +255,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"usize",
|
||||
item.span);
|
||||
}
|
||||
ty::TyFloat(ast::FloatTy::F32) => {
|
||||
ty::Float(ast::FloatTy::F32) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.f32_impl(),
|
||||
lang_items.f32_runtime_impl(),
|
||||
@ -263,7 +263,7 @@ impl<'a, 'tcx, 'v> ItemLikeVisitor<'v> for InherentCollect<'a, 'tcx> {
|
||||
"f32",
|
||||
item.span);
|
||||
}
|
||||
ty::TyFloat(ast::FloatTy::F64) => {
|
||||
ty::Float(ast::FloatTy::F64) => {
|
||||
self.check_primitive_impl(def_id,
|
||||
lang_items.f64_impl(),
|
||||
lang_items.f64_runtime_impl(),
|
||||
|
@ -261,8 +261,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
||||
variance);
|
||||
|
||||
match ty.sty {
|
||||
ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) |
|
||||
ty::TyStr | ty::Never | ty::Foreign(..) => {
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) |
|
||||
ty::Str | ty::Never | ty::Foreign(..) => {
|
||||
// leaf type -- noop
|
||||
}
|
||||
|
||||
|
@ -25,19 +25,19 @@ where F: Fn(& dyn Fn(DefId) -> Def) -> Vec<Item> {
|
||||
AdtKind::Enum => Def::Enum,
|
||||
AdtKind::Union => Def::Union,
|
||||
}),
|
||||
ty::TyInt(_) |
|
||||
ty::TyUint(_) |
|
||||
ty::TyFloat(_) |
|
||||
ty::TyStr |
|
||||
ty::TyBool |
|
||||
ty::TyChar => callback(&move |_: DefId| {
|
||||
ty::Int(_) |
|
||||
ty::Uint(_) |
|
||||
ty::Float(_) |
|
||||
ty::Str |
|
||||
ty::Bool |
|
||||
ty::Char => callback(&move |_: DefId| {
|
||||
match ty.sty {
|
||||
ty::TyInt(x) => Def::PrimTy(hir::TyInt(x)),
|
||||
ty::TyUint(x) => Def::PrimTy(hir::TyUint(x)),
|
||||
ty::TyFloat(x) => Def::PrimTy(hir::TyFloat(x)),
|
||||
ty::TyStr => Def::PrimTy(hir::TyStr),
|
||||
ty::TyBool => Def::PrimTy(hir::TyBool),
|
||||
ty::TyChar => Def::PrimTy(hir::TyChar),
|
||||
ty::Int(x) => Def::PrimTy(hir::Int(x)),
|
||||
ty::Uint(x) => Def::PrimTy(hir::Uint(x)),
|
||||
ty::Float(x) => Def::PrimTy(hir::Float(x)),
|
||||
ty::Str => Def::PrimTy(hir::Str),
|
||||
ty::Bool => Def::PrimTy(hir::Bool),
|
||||
ty::Char => Def::PrimTy(hir::Char),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}),
|
||||
|
@ -2546,12 +2546,12 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||
fn clean(&self, cx: &DocContext) -> Type {
|
||||
match self.sty {
|
||||
ty::Never => Never,
|
||||
ty::TyBool => Primitive(PrimitiveType::Bool),
|
||||
ty::TyChar => Primitive(PrimitiveType::Char),
|
||||
ty::TyInt(int_ty) => Primitive(int_ty.into()),
|
||||
ty::TyUint(uint_ty) => Primitive(uint_ty.into()),
|
||||
ty::TyFloat(float_ty) => Primitive(float_ty.into()),
|
||||
ty::TyStr => Primitive(PrimitiveType::Str),
|
||||
ty::Bool => Primitive(PrimitiveType::Bool),
|
||||
ty::Char => Primitive(PrimitiveType::Char),
|
||||
ty::Int(int_ty) => Primitive(int_ty.into()),
|
||||
ty::Uint(uint_ty) => Primitive(uint_ty.into()),
|
||||
ty::Float(float_ty) => Primitive(float_ty.into()),
|
||||
ty::Str => Primitive(PrimitiveType::Str),
|
||||
ty::Slice(ty) => Slice(box ty.clean(cx)),
|
||||
ty::Array(ty, n) => {
|
||||
let mut n = cx.tcx.lift(&n).expect("array lift failed");
|
||||
@ -3700,12 +3700,12 @@ fn resolve_type(cx: &DocContext,
|
||||
|
||||
let is_generic = match path.def {
|
||||
Def::PrimTy(p) => match p {
|
||||
hir::TyStr => return Primitive(PrimitiveType::Str),
|
||||
hir::TyBool => return Primitive(PrimitiveType::Bool),
|
||||
hir::TyChar => return Primitive(PrimitiveType::Char),
|
||||
hir::TyInt(int_ty) => return Primitive(int_ty.into()),
|
||||
hir::TyUint(uint_ty) => return Primitive(uint_ty.into()),
|
||||
hir::TyFloat(float_ty) => return Primitive(float_ty.into()),
|
||||
hir::Str => return Primitive(PrimitiveType::Str),
|
||||
hir::Bool => return Primitive(PrimitiveType::Bool),
|
||||
hir::Char => return Primitive(PrimitiveType::Char),
|
||||
hir::Int(int_ty) => return Primitive(int_ty.into()),
|
||||
hir::Uint(uint_ty) => return Primitive(uint_ty.into()),
|
||||
hir::Float(float_ty) => return Primitive(float_ty.into()),
|
||||
},
|
||||
Def::SelfTy(..) if path.segments.len() == 1 => {
|
||||
return Generic(keywords::SelfType.name().to_string());
|
||||
|
@ -567,23 +567,23 @@ fn handle_variant(cx: &DocContext, def: Def) -> Result<(Def, Option<String>), ()
|
||||
}
|
||||
|
||||
const PRIMITIVES: &[(&str, Def)] = &[
|
||||
("u8", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::U8))),
|
||||
("u16", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::U16))),
|
||||
("u32", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::U32))),
|
||||
("u64", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::U64))),
|
||||
("u128", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::U128))),
|
||||
("usize", Def::PrimTy(hir::PrimTy::TyUint(syntax::ast::UintTy::Usize))),
|
||||
("i8", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::I8))),
|
||||
("i16", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::I16))),
|
||||
("i32", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::I32))),
|
||||
("i64", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::I64))),
|
||||
("i128", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::I128))),
|
||||
("isize", Def::PrimTy(hir::PrimTy::TyInt(syntax::ast::IntTy::Isize))),
|
||||
("f32", Def::PrimTy(hir::PrimTy::TyFloat(syntax::ast::FloatTy::F32))),
|
||||
("f64", Def::PrimTy(hir::PrimTy::TyFloat(syntax::ast::FloatTy::F64))),
|
||||
("str", Def::PrimTy(hir::PrimTy::TyStr)),
|
||||
("bool", Def::PrimTy(hir::PrimTy::TyBool)),
|
||||
("char", Def::PrimTy(hir::PrimTy::TyChar)),
|
||||
("u8", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::U8))),
|
||||
("u16", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::U16))),
|
||||
("u32", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::U32))),
|
||||
("u64", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::U64))),
|
||||
("u128", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::U128))),
|
||||
("usize", Def::PrimTy(hir::PrimTy::Uint(syntax::ast::UintTy::Usize))),
|
||||
("i8", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::I8))),
|
||||
("i16", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::I16))),
|
||||
("i32", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::I32))),
|
||||
("i64", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::I64))),
|
||||
("i128", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::I128))),
|
||||
("isize", Def::PrimTy(hir::PrimTy::Int(syntax::ast::IntTy::Isize))),
|
||||
("f32", Def::PrimTy(hir::PrimTy::Float(syntax::ast::FloatTy::F32))),
|
||||
("f64", Def::PrimTy(hir::PrimTy::Float(syntax::ast::FloatTy::F64))),
|
||||
("str", Def::PrimTy(hir::PrimTy::Str)),
|
||||
("bool", Def::PrimTy(hir::PrimTy::Bool)),
|
||||
("char", Def::PrimTy(hir::PrimTy::Char)),
|
||||
];
|
||||
|
||||
fn is_primitive(path_str: &str, is_val: bool) -> Option<Def> {
|
||||
|
@ -32,22 +32,22 @@ pub mod testtypes {
|
||||
]
|
||||
}
|
||||
|
||||
// Tests TyBool
|
||||
// Tests Bool
|
||||
pub type FooBool = bool;
|
||||
|
||||
// Tests TyChar
|
||||
// Tests Char
|
||||
pub type FooChar = char;
|
||||
|
||||
// Tests TyInt (does not test all variants of IntTy)
|
||||
// Tests Int (does not test all variants of IntTy)
|
||||
pub type FooInt = isize;
|
||||
|
||||
// Tests TyUint (does not test all variants of UintTy)
|
||||
// Tests Uint (does not test all variants of UintTy)
|
||||
pub type FooUint = usize;
|
||||
|
||||
// Tests TyFloat (does not test all variants of FloatTy)
|
||||
// Tests Float (does not test all variants of FloatTy)
|
||||
pub type FooFloat = f64;
|
||||
|
||||
// Tests TyStr
|
||||
// Tests Str
|
||||
pub type FooStr = str;
|
||||
|
||||
// Tests Array
|
||||
|
@ -11,9 +11,9 @@
|
||||
// Original Levenshtein distance for both of this is 1. We improved accuracy with
|
||||
// additional case insensitive comparison.
|
||||
|
||||
struct TyUint {}
|
||||
struct Uint {}
|
||||
|
||||
struct TyInt {}
|
||||
struct Int {}
|
||||
|
||||
fn main() {
|
||||
TyUInt {};
|
||||
|
Loading…
Reference in New Issue
Block a user