mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Use ty::{IntTy,UintTy,FloatTy} in rustc
This commit is contained in:
parent
933bb18956
commit
50e1ae15e9
@ -83,7 +83,6 @@ mod vtable;
|
||||
mod prelude {
|
||||
pub(crate) use std::convert::{TryFrom, TryInto};
|
||||
|
||||
pub(crate) use rustc_ast::ast::{FloatTy, IntTy, UintTy};
|
||||
pub(crate) use rustc_span::Span;
|
||||
|
||||
pub(crate) use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
@ -91,7 +90,7 @@ mod prelude {
|
||||
pub(crate) use rustc_middle::mir::{self, *};
|
||||
pub(crate) use rustc_middle::ty::layout::{self, TyAndLayout};
|
||||
pub(crate) use rustc_middle::ty::{
|
||||
self, FnSig, Instance, InstanceDef, ParamEnv, Ty, TyCtxt, TypeAndMut, TypeFoldable,
|
||||
self, FloatTy, FnSig, Instance, InstanceDef, IntTy, ParamEnv, Ty, TyCtxt, TypeAndMut, TypeFoldable, UintTy,
|
||||
};
|
||||
pub(crate) use rustc_target::abi::{Abi, LayoutOf, Scalar, Size, VariantIdx};
|
||||
|
||||
|
@ -304,9 +304,8 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
|
||||
lhs: Self::Value,
|
||||
rhs: Self::Value,
|
||||
) -> (Self::Value, Self::Value) {
|
||||
use rustc_ast::IntTy::*;
|
||||
use rustc_ast::UintTy::*;
|
||||
use rustc_middle::ty::{Int, Uint};
|
||||
use rustc_middle::ty::{IntTy::*, UintTy::*};
|
||||
|
||||
let new_kind = match ty.kind() {
|
||||
Int(t @ Isize) => Int(t.normalize(self.tcx.sess.target.pointer_width)),
|
||||
|
@ -18,7 +18,6 @@ use crate::llvm::debuginfo::{
|
||||
};
|
||||
use crate::value::Value;
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_data_structures::const_cstr;
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
@ -830,37 +829,37 @@ trait MsvcBasicName {
|
||||
fn msvc_basic_name(self) -> &'static str;
|
||||
}
|
||||
|
||||
impl MsvcBasicName for ast::IntTy {
|
||||
impl MsvcBasicName for ty::IntTy {
|
||||
fn msvc_basic_name(self) -> &'static str {
|
||||
match self {
|
||||
ast::IntTy::Isize => "ptrdiff_t",
|
||||
ast::IntTy::I8 => "__int8",
|
||||
ast::IntTy::I16 => "__int16",
|
||||
ast::IntTy::I32 => "__int32",
|
||||
ast::IntTy::I64 => "__int64",
|
||||
ast::IntTy::I128 => "__int128",
|
||||
ty::IntTy::Isize => "ptrdiff_t",
|
||||
ty::IntTy::I8 => "__int8",
|
||||
ty::IntTy::I16 => "__int16",
|
||||
ty::IntTy::I32 => "__int32",
|
||||
ty::IntTy::I64 => "__int64",
|
||||
ty::IntTy::I128 => "__int128",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MsvcBasicName for ast::UintTy {
|
||||
impl MsvcBasicName for ty::UintTy {
|
||||
fn msvc_basic_name(self) -> &'static str {
|
||||
match self {
|
||||
ast::UintTy::Usize => "size_t",
|
||||
ast::UintTy::U8 => "unsigned __int8",
|
||||
ast::UintTy::U16 => "unsigned __int16",
|
||||
ast::UintTy::U32 => "unsigned __int32",
|
||||
ast::UintTy::U64 => "unsigned __int64",
|
||||
ast::UintTy::U128 => "unsigned __int128",
|
||||
ty::UintTy::Usize => "size_t",
|
||||
ty::UintTy::U8 => "unsigned __int8",
|
||||
ty::UintTy::U16 => "unsigned __int16",
|
||||
ty::UintTy::U32 => "unsigned __int32",
|
||||
ty::UintTy::U64 => "unsigned __int64",
|
||||
ty::UintTy::U128 => "unsigned __int128",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MsvcBasicName for ast::FloatTy {
|
||||
impl MsvcBasicName for ty::FloatTy {
|
||||
fn msvc_basic_name(self) -> &'static str {
|
||||
match self {
|
||||
ast::FloatTy::F32 => "float",
|
||||
ast::FloatTy::F64 => "double",
|
||||
ty::FloatTy::F32 => "float",
|
||||
ty::FloatTy::F64 => "double",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,12 @@ use crate::llvm;
|
||||
use crate::llvm::{Bool, False, True};
|
||||
use crate::type_of::LayoutLlvmExt;
|
||||
use crate::value::Value;
|
||||
use rustc_ast as ast;
|
||||
use rustc_codegen_ssa::common::TypeKind;
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_data_structures::small_c_str::SmallCStr;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::layout::TyAndLayout;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
|
||||
use rustc_target::abi::{AddressSpace, Align, Integer, Size};
|
||||
|
||||
@ -80,32 +79,32 @@ impl CodegenCx<'ll, 'tcx> {
|
||||
self.type_i8()
|
||||
}
|
||||
|
||||
crate fn type_int_from_ty(&self, t: ast::IntTy) -> &'ll Type {
|
||||
crate fn type_int_from_ty(&self, t: ty::IntTy) -> &'ll Type {
|
||||
match t {
|
||||
ast::IntTy::Isize => self.type_isize(),
|
||||
ast::IntTy::I8 => self.type_i8(),
|
||||
ast::IntTy::I16 => self.type_i16(),
|
||||
ast::IntTy::I32 => self.type_i32(),
|
||||
ast::IntTy::I64 => self.type_i64(),
|
||||
ast::IntTy::I128 => self.type_i128(),
|
||||
ty::IntTy::Isize => self.type_isize(),
|
||||
ty::IntTy::I8 => self.type_i8(),
|
||||
ty::IntTy::I16 => self.type_i16(),
|
||||
ty::IntTy::I32 => self.type_i32(),
|
||||
ty::IntTy::I64 => self.type_i64(),
|
||||
ty::IntTy::I128 => self.type_i128(),
|
||||
}
|
||||
}
|
||||
|
||||
crate fn type_uint_from_ty(&self, t: ast::UintTy) -> &'ll Type {
|
||||
crate fn type_uint_from_ty(&self, t: ty::UintTy) -> &'ll Type {
|
||||
match t {
|
||||
ast::UintTy::Usize => self.type_isize(),
|
||||
ast::UintTy::U8 => self.type_i8(),
|
||||
ast::UintTy::U16 => self.type_i16(),
|
||||
ast::UintTy::U32 => self.type_i32(),
|
||||
ast::UintTy::U64 => self.type_i64(),
|
||||
ast::UintTy::U128 => self.type_i128(),
|
||||
ty::UintTy::Usize => self.type_isize(),
|
||||
ty::UintTy::U8 => self.type_i8(),
|
||||
ty::UintTy::U16 => self.type_i16(),
|
||||
ty::UintTy::U32 => self.type_i32(),
|
||||
ty::UintTy::U64 => self.type_i64(),
|
||||
ty::UintTy::U128 => self.type_i128(),
|
||||
}
|
||||
}
|
||||
|
||||
crate fn type_float_from_ty(&self, t: ast::FloatTy) -> &'ll Type {
|
||||
crate fn type_float_from_ty(&self, t: ty::FloatTy) -> &'ll Type {
|
||||
match t {
|
||||
ast::FloatTy::F32 => self.type_f32(),
|
||||
ast::FloatTy::F64 => self.type_f64(),
|
||||
ty::FloatTy::F32 => self.type_f32(),
|
||||
ty::FloatTy::F64 => self.type_f64(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -875,20 +875,16 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
ty::Uint(_) => value.to_string(),
|
||||
ty::Int(int_ty) => {
|
||||
match int_ty.normalize(bx.tcx().sess.target.pointer_width) {
|
||||
ast::IntTy::I8 => (value as i8).to_string(),
|
||||
ast::IntTy::I16 => (value as i16).to_string(),
|
||||
ast::IntTy::I32 => (value as i32).to_string(),
|
||||
ast::IntTy::I64 => (value as i64).to_string(),
|
||||
ast::IntTy::I128 => (value as i128).to_string(),
|
||||
ast::IntTy::Isize => unreachable!(),
|
||||
ty::IntTy::I8 => (value as i8).to_string(),
|
||||
ty::IntTy::I16 => (value as i16).to_string(),
|
||||
ty::IntTy::I32 => (value as i32).to_string(),
|
||||
ty::IntTy::I64 => (value as i64).to_string(),
|
||||
ty::IntTy::I128 => (value as i128).to_string(),
|
||||
ty::IntTy::Isize => unreachable!(),
|
||||
}
|
||||
}
|
||||
ty::Float(ast::FloatTy::F32) => {
|
||||
f32::from_bits(value as u32).to_string()
|
||||
}
|
||||
ty::Float(ast::FloatTy::F64) => {
|
||||
f64::from_bits(value as u64).to_string()
|
||||
}
|
||||
ty::Float(ty::FloatTy::F32) => f32::from_bits(value as u32).to_string(),
|
||||
ty::Float(ty::FloatTy::F64) => f64::from_bits(value as u64).to_string(),
|
||||
_ => span_bug!(span, "asm const has bad type {}", ty),
|
||||
};
|
||||
InlineAsmOperandRef::Const { string }
|
||||
|
@ -34,7 +34,6 @@ use super::{InferCtxt, MiscVariable, TypeTrace};
|
||||
|
||||
use crate::traits::{Obligation, PredicateObligations};
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_data_structures::sso::SsoHashMap;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
@ -281,7 +280,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
|
||||
&self,
|
||||
vid_is_expected: bool,
|
||||
vid: ty::FloatVid,
|
||||
val: ast::FloatTy,
|
||||
val: ty::FloatTy,
|
||||
) -> RelateResult<'tcx, Ty<'tcx>> {
|
||||
self.inner
|
||||
.borrow_mut()
|
||||
|
@ -168,25 +168,25 @@ fn lint_overflowing_range_endpoint<'tcx>(
|
||||
|
||||
// For `isize` & `usize`, be conservative with the warnings, so that the
|
||||
// warnings are consistent between 32- and 64-bit platforms.
|
||||
fn int_ty_range(int_ty: ast::IntTy) -> (i128, i128) {
|
||||
fn int_ty_range(int_ty: ty::IntTy) -> (i128, i128) {
|
||||
match int_ty {
|
||||
ast::IntTy::Isize => (i64::MIN.into(), i64::MAX.into()),
|
||||
ast::IntTy::I8 => (i8::MIN.into(), i8::MAX.into()),
|
||||
ast::IntTy::I16 => (i16::MIN.into(), i16::MAX.into()),
|
||||
ast::IntTy::I32 => (i32::MIN.into(), i32::MAX.into()),
|
||||
ast::IntTy::I64 => (i64::MIN.into(), i64::MAX.into()),
|
||||
ast::IntTy::I128 => (i128::MIN, i128::MAX),
|
||||
ty::IntTy::Isize => (i64::MIN.into(), i64::MAX.into()),
|
||||
ty::IntTy::I8 => (i8::MIN.into(), i8::MAX.into()),
|
||||
ty::IntTy::I16 => (i16::MIN.into(), i16::MAX.into()),
|
||||
ty::IntTy::I32 => (i32::MIN.into(), i32::MAX.into()),
|
||||
ty::IntTy::I64 => (i64::MIN.into(), i64::MAX.into()),
|
||||
ty::IntTy::I128 => (i128::MIN, i128::MAX),
|
||||
}
|
||||
}
|
||||
|
||||
fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) {
|
||||
fn uint_ty_range(uint_ty: ty::UintTy) -> (u128, u128) {
|
||||
let max = match uint_ty {
|
||||
ast::UintTy::Usize => u64::MAX.into(),
|
||||
ast::UintTy::U8 => u8::MAX.into(),
|
||||
ast::UintTy::U16 => u16::MAX.into(),
|
||||
ast::UintTy::U32 => u32::MAX.into(),
|
||||
ast::UintTy::U64 => u64::MAX.into(),
|
||||
ast::UintTy::U128 => u128::MAX,
|
||||
ty::UintTy::Usize => u64::MAX.into(),
|
||||
ty::UintTy::U8 => u8::MAX.into(),
|
||||
ty::UintTy::U16 => u16::MAX.into(),
|
||||
ty::UintTy::U32 => u32::MAX.into(),
|
||||
ty::UintTy::U64 => u64::MAX.into(),
|
||||
ty::UintTy::U128 => u128::MAX,
|
||||
};
|
||||
(0, max)
|
||||
}
|
||||
@ -258,8 +258,8 @@ fn report_bin_hex_error(
|
||||
//
|
||||
// No suggestion for: `isize`, `usize`.
|
||||
fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option<&'static str> {
|
||||
use rustc_ast::IntTy::*;
|
||||
use rustc_ast::UintTy::*;
|
||||
use ty::IntTy::*;
|
||||
use ty::UintTy::*;
|
||||
macro_rules! find_fit {
|
||||
($ty:expr, $val:expr, $negative:expr,
|
||||
$($type:ident => [$($utypes:expr),*] => [$($itypes:expr),*]),+) => {
|
||||
@ -302,7 +302,7 @@ fn lint_int_literal<'tcx>(
|
||||
type_limits: &TypeLimits,
|
||||
e: &'tcx hir::Expr<'tcx>,
|
||||
lit: &hir::Lit,
|
||||
t: ast::IntTy,
|
||||
t: ty::IntTy,
|
||||
v: u128,
|
||||
) {
|
||||
let int_type = t.normalize(cx.sess().target.pointer_width);
|
||||
@ -314,7 +314,14 @@ fn lint_int_literal<'tcx>(
|
||||
// avoiding use of -min to prevent overflow/panic
|
||||
if (negative && v > max + 1) || (!negative && v > max) {
|
||||
if let Some(repr_str) = get_bin_hex_repr(cx, lit) {
|
||||
report_bin_hex_error(cx, e, attr::IntType::SignedInt(t), repr_str, v, negative);
|
||||
report_bin_hex_error(
|
||||
cx,
|
||||
e,
|
||||
attr::IntType::SignedInt(ty::ast_int_ty(t)),
|
||||
repr_str,
|
||||
v,
|
||||
negative,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -351,7 +358,7 @@ fn lint_uint_literal<'tcx>(
|
||||
cx: &LateContext<'tcx>,
|
||||
e: &'tcx hir::Expr<'tcx>,
|
||||
lit: &hir::Lit,
|
||||
t: ast::UintTy,
|
||||
t: ty::UintTy,
|
||||
) {
|
||||
let uint_type = t.normalize(cx.sess().target.pointer_width);
|
||||
let (min, max) = uint_ty_range(uint_type);
|
||||
@ -391,7 +398,14 @@ fn lint_uint_literal<'tcx>(
|
||||
}
|
||||
}
|
||||
if let Some(repr_str) = get_bin_hex_repr(cx, lit) {
|
||||
report_bin_hex_error(cx, e, attr::IntType::UnsignedInt(t), repr_str, lit_val, false);
|
||||
report_bin_hex_error(
|
||||
cx,
|
||||
e,
|
||||
attr::IntType::UnsignedInt(ty::ast_uint_ty(t)),
|
||||
repr_str,
|
||||
lit_val,
|
||||
false,
|
||||
);
|
||||
return;
|
||||
}
|
||||
cx.struct_span_lint(OVERFLOWING_LITERALS, e.span, |lint| {
|
||||
@ -430,8 +444,8 @@ fn lint_literal<'tcx>(
|
||||
ty::Float(t) => {
|
||||
let is_infinite = match lit.node {
|
||||
ast::LitKind::Float(v, _) => match t {
|
||||
ast::FloatTy::F32 => v.as_str().parse().map(f32::is_infinite),
|
||||
ast::FloatTy::F64 => v.as_str().parse().map(f64::is_infinite),
|
||||
ty::FloatTy::F32 => v.as_str().parse().map(f32::is_infinite),
|
||||
ty::FloatTy::F64 => v.as_str().parse().map(f64::is_infinite),
|
||||
},
|
||||
_ => bug!(),
|
||||
};
|
||||
@ -984,7 +998,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
help: Some("consider using `u32` or `libc::wchar_t` instead".into()),
|
||||
},
|
||||
|
||||
ty::Int(ast::IntTy::I128) | ty::Uint(ast::UintTy::U128) => FfiUnsafe {
|
||||
ty::Int(ty::IntTy::I128) | ty::Uint(ty::UintTy::U128) => FfiUnsafe {
|
||||
ty,
|
||||
reason: "128-bit integers don't currently have a known stable ABI".into(),
|
||||
help: None,
|
||||
|
@ -2,13 +2,11 @@ use std::convert::TryFrom;
|
||||
|
||||
use rustc_apfloat::ieee::{Double, Single};
|
||||
use rustc_apfloat::{Float, FloatConvert};
|
||||
use rustc_ast::FloatTy;
|
||||
use rustc_attr as attr;
|
||||
use rustc_middle::mir::interpret::{InterpResult, PointerArithmetic, Scalar};
|
||||
use rustc_middle::mir::CastKind;
|
||||
use rustc_middle::ty::adjustment::PointerCast;
|
||||
use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Ty, TypeAndMut};
|
||||
use rustc_middle::ty::{self, FloatTy, Ty, TypeAndMut};
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_target::abi::{Integer, LayoutOf, Variants};
|
||||
|
||||
@ -203,8 +201,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
match *cast_ty.kind() {
|
||||
Int(_) | Uint(_) | RawPtr(_) => {
|
||||
let size = match *cast_ty.kind() {
|
||||
Int(t) => Integer::from_attr(self, attr::IntType::SignedInt(t)).size(),
|
||||
Uint(t) => Integer::from_attr(self, attr::IntType::UnsignedInt(t)).size(),
|
||||
Int(t) => Integer::from_int_ty(self, t).size(),
|
||||
Uint(t) => Integer::from_uint_ty(self, t).size(),
|
||||
RawPtr(_) => self.pointer_size(),
|
||||
_ => bug!(),
|
||||
};
|
||||
@ -235,7 +233,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
match *dest_ty.kind() {
|
||||
// float -> uint
|
||||
Uint(t) => {
|
||||
let size = Integer::from_attr(self, attr::IntType::UnsignedInt(t)).size();
|
||||
let size = Integer::from_uint_ty(self, t).size();
|
||||
// `to_u128` is a saturating cast, which is what we need
|
||||
// (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_apfloat/trait.Float.html#method.to_i128_r).
|
||||
let v = f.to_u128(size.bits_usize()).value;
|
||||
@ -244,7 +242,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
}
|
||||
// float -> int
|
||||
Int(t) => {
|
||||
let size = Integer::from_attr(self, attr::IntType::SignedInt(t)).size();
|
||||
let size = Integer::from_int_ty(self, t).size();
|
||||
// `to_i128` is a saturating cast, which is what we need
|
||||
// (https://doc.rust-lang.org/nightly/nightly-rustc/rustc_apfloat/trait.Float.html#method.to_i128_r).
|
||||
let v = f.to_i128(size.bits_usize()).value;
|
||||
|
@ -1,10 +1,9 @@
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use rustc_apfloat::Float;
|
||||
use rustc_ast::FloatTy;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::mir::interpret::{InterpResult, Scalar};
|
||||
use rustc_middle::ty::{self, layout::TyAndLayout, Ty};
|
||||
use rustc_middle::ty::{self, layout::TyAndLayout, FloatTy, Ty};
|
||||
use rustc_target::abi::LayoutOf;
|
||||
|
||||
use super::{ImmTy, Immediate, InterpCx, Machine, PlaceTy};
|
||||
|
@ -15,7 +15,6 @@
|
||||
use crate::build::matches::{Ascription, Binding, Candidate, MatchPair};
|
||||
use crate::build::Builder;
|
||||
use crate::thir::{self, *};
|
||||
use rustc_attr::{SignedInt, UnsignedInt};
|
||||
use rustc_hir::RangeEnd;
|
||||
use rustc_middle::mir::Place;
|
||||
use rustc_middle::ty;
|
||||
@ -203,13 +202,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
(Some(('\u{0000}' as u128, '\u{10FFFF}' as u128, Size::from_bits(32))), 0)
|
||||
}
|
||||
ty::Int(ity) => {
|
||||
let size = Integer::from_attr(&tcx, SignedInt(ity)).size();
|
||||
let size = Integer::from_int_ty(&tcx, ity).size();
|
||||
let max = size.truncate(u128::MAX);
|
||||
let bias = 1u128 << (size.bits() - 1);
|
||||
(Some((0, max, size)), bias)
|
||||
}
|
||||
ty::Uint(uty) => {
|
||||
let size = Integer::from_attr(&tcx, UnsignedInt(uty)).size();
|
||||
let size = Integer::from_uint_ty(&tcx, uty).size();
|
||||
let max = size.truncate(u128::MAX);
|
||||
(Some((0, max, size)), 0)
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ crate fn lit_to_const<'tcx>(
|
||||
let id = tcx.allocate_bytes(data);
|
||||
ConstValue::Scalar(Scalar::Ptr(id.into()))
|
||||
}
|
||||
(ast::LitKind::Byte(n), ty::Uint(ast::UintTy::U8)) => {
|
||||
(ast::LitKind::Byte(n), ty::Uint(ty::UintTy::U8)) => {
|
||||
ConstValue::Scalar(Scalar::from_uint(*n, Size::from_bytes(1)))
|
||||
}
|
||||
(ast::LitKind::Int(n, _), ty::Uint(_)) | (ast::LitKind::Int(n, _), ty::Int(_)) => {
|
||||
@ -56,11 +56,11 @@ crate fn lit_to_const<'tcx>(
|
||||
Ok(ty::Const::from_value(tcx, lit, ty))
|
||||
}
|
||||
|
||||
fn parse_float<'tcx>(num: Symbol, fty: ast::FloatTy, neg: bool) -> Result<ConstValue<'tcx>, ()> {
|
||||
fn parse_float<'tcx>(num: Symbol, fty: ty::FloatTy, neg: bool) -> Result<ConstValue<'tcx>, ()> {
|
||||
let num = num.as_str();
|
||||
use rustc_apfloat::ieee::{Double, Single};
|
||||
let scalar = match fty {
|
||||
ast::FloatTy::F32 => {
|
||||
ty::FloatTy::F32 => {
|
||||
num.parse::<f32>().map_err(|_| ())?;
|
||||
let mut f = num.parse::<Single>().unwrap_or_else(|e| {
|
||||
panic!("apfloat::ieee::Single failed to parse `{}`: {:?}", num, e)
|
||||
@ -70,7 +70,7 @@ fn parse_float<'tcx>(num: Symbol, fty: ast::FloatTy, neg: bool) -> Result<ConstV
|
||||
}
|
||||
Scalar::from_f32(f)
|
||||
}
|
||||
ast::FloatTy::F64 => {
|
||||
ty::FloatTy::F64 => {
|
||||
num.parse::<f64>().map_err(|_| ())?;
|
||||
let mut f = num.parse::<Double>().unwrap_or_else(|e| {
|
||||
panic!("apfloat::ieee::Double failed to parse `{}`: {:?}", num, e)
|
||||
|
@ -52,7 +52,6 @@ use super::{FieldPat, Pat, PatKind, PatRange};
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_index::vec::Idx;
|
||||
|
||||
use rustc_attr::{SignedInt, UnsignedInt};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{HirId, RangeEnd};
|
||||
use rustc_middle::mir::interpret::ConstValue;
|
||||
@ -103,10 +102,10 @@ impl IntRange {
|
||||
ty::Bool => Some((Size::from_bytes(1), 0)),
|
||||
ty::Char => Some((Size::from_bytes(4), 0)),
|
||||
ty::Int(ity) => {
|
||||
let size = Integer::from_attr(&tcx, SignedInt(ity)).size();
|
||||
let size = Integer::from_int_ty(&tcx, ity).size();
|
||||
Some((size, 1u128 << (size.bits() as u128 - 1)))
|
||||
}
|
||||
ty::Uint(uty) => Some((Integer::from_attr(&tcx, UnsignedInt(uty)).size(), 0)),
|
||||
ty::Uint(uty) => Some((Integer::from_uint_ty(&tcx, uty).size(), 0)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@ -167,7 +166,7 @@ impl IntRange {
|
||||
fn signed_bias(tcx: TyCtxt<'_>, ty: Ty<'_>) -> u128 {
|
||||
match *ty.kind() {
|
||||
ty::Int(ity) => {
|
||||
let bits = Integer::from_attr(&tcx, SignedInt(ity)).size().bits() as u128;
|
||||
let bits = Integer::from_int_ty(&tcx, ity).size().bits() as u128;
|
||||
1u128 << (bits - 1)
|
||||
}
|
||||
_ => 0,
|
||||
@ -959,13 +958,13 @@ impl<'tcx> SplitWildcard<'tcx> {
|
||||
smallvec![NonExhaustive]
|
||||
}
|
||||
&ty::Int(ity) => {
|
||||
let bits = Integer::from_attr(&cx.tcx, SignedInt(ity)).size().bits() as u128;
|
||||
let bits = Integer::from_int_ty(&cx.tcx, ity).size().bits() as u128;
|
||||
let min = 1u128 << (bits - 1);
|
||||
let max = min - 1;
|
||||
smallvec![make_range(min, max)]
|
||||
}
|
||||
&ty::Uint(uty) => {
|
||||
let size = Integer::from_attr(&cx.tcx, UnsignedInt(uty)).size();
|
||||
let size = Integer::from_uint_ty(&cx.tcx, uty).size();
|
||||
let max = size.truncate(u128::MAX);
|
||||
smallvec![make_range(0, max)]
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ pub(crate) use self::check_match::check_match;
|
||||
|
||||
use crate::thir::util::UserAnnotatedTyHelpers;
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
|
||||
@ -1069,20 +1068,19 @@ crate fn compare_const_vals<'tcx>(
|
||||
if let (Some(a), Some(b)) = (a_bits, b_bits) {
|
||||
use rustc_apfloat::Float;
|
||||
return match *ty.kind() {
|
||||
ty::Float(ast::FloatTy::F32) => {
|
||||
ty::Float(ty::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::Float(ast::FloatTy::F64) => {
|
||||
ty::Float(ty::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::Int(ity) => {
|
||||
use rustc_attr::SignedInt;
|
||||
use rustc_middle::ty::layout::IntegerExt;
|
||||
let size = rustc_target::abi::Integer::from_attr(&tcx, SignedInt(ity)).size();
|
||||
let size = rustc_target::abi::Integer::from_int_ty(&tcx, ity).size();
|
||||
let a = size.sign_extend(a);
|
||||
let b = size.sign_extend(b);
|
||||
Some((a as i128).cmp(&(b as i128)))
|
||||
|
@ -1,4 +1,4 @@
|
||||
use rustc_ast::{FloatTy, InlineAsmTemplatePiece, IntTy, UintTy};
|
||||
use rustc_ast::InlineAsmTemplatePiece;
|
||||
use rustc_errors::struct_span_err;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
@ -7,7 +7,7 @@ use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::ty::layout::{LayoutError, SizeSkeleton};
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, UintTy};
|
||||
use rustc_session::lint;
|
||||
use rustc_span::{sym, Span, Symbol, DUMMY_SP};
|
||||
use rustc_target::abi::{Pointer, VariantIdx};
|
||||
|
@ -1,4 +1,3 @@
|
||||
use rustc_ast::{FloatTy, IntTy, UintTy};
|
||||
use rustc_data_structures::base_n;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir as hir;
|
||||
@ -6,7 +5,7 @@ use rustc_hir::def_id::{CrateNum, DefId};
|
||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||
use rustc_middle::ty::print::{Print, Printer};
|
||||
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst};
|
||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_middle::ty::{self, FloatTy, Instance, IntTy, Ty, TyCtxt, TypeFoldable, UintTy};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
use std::fmt::Write;
|
||||
|
@ -346,26 +346,26 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
||||
(ty::Char, Scalar(Char)) => true,
|
||||
(ty::Int(ty1), Scalar(Int(ty2))) => matches!(
|
||||
(ty1, ty2),
|
||||
(ast::IntTy::Isize, chalk_ir::IntTy::Isize)
|
||||
| (ast::IntTy::I8, chalk_ir::IntTy::I8)
|
||||
| (ast::IntTy::I16, chalk_ir::IntTy::I16)
|
||||
| (ast::IntTy::I32, chalk_ir::IntTy::I32)
|
||||
| (ast::IntTy::I64, chalk_ir::IntTy::I64)
|
||||
| (ast::IntTy::I128, chalk_ir::IntTy::I128)
|
||||
(ty::IntTy::Isize, chalk_ir::IntTy::Isize)
|
||||
| (ty::IntTy::I8, chalk_ir::IntTy::I8)
|
||||
| (ty::IntTy::I16, chalk_ir::IntTy::I16)
|
||||
| (ty::IntTy::I32, chalk_ir::IntTy::I32)
|
||||
| (ty::IntTy::I64, chalk_ir::IntTy::I64)
|
||||
| (ty::IntTy::I128, chalk_ir::IntTy::I128)
|
||||
),
|
||||
(ty::Uint(ty1), Scalar(Uint(ty2))) => matches!(
|
||||
(ty1, ty2),
|
||||
(ast::UintTy::Usize, chalk_ir::UintTy::Usize)
|
||||
| (ast::UintTy::U8, chalk_ir::UintTy::U8)
|
||||
| (ast::UintTy::U16, chalk_ir::UintTy::U16)
|
||||
| (ast::UintTy::U32, chalk_ir::UintTy::U32)
|
||||
| (ast::UintTy::U64, chalk_ir::UintTy::U64)
|
||||
| (ast::UintTy::U128, chalk_ir::UintTy::U128)
|
||||
(ty::UintTy::Usize, chalk_ir::UintTy::Usize)
|
||||
| (ty::UintTy::U8, chalk_ir::UintTy::U8)
|
||||
| (ty::UintTy::U16, chalk_ir::UintTy::U16)
|
||||
| (ty::UintTy::U32, chalk_ir::UintTy::U32)
|
||||
| (ty::UintTy::U64, chalk_ir::UintTy::U64)
|
||||
| (ty::UintTy::U128, chalk_ir::UintTy::U128)
|
||||
),
|
||||
(ty::Float(ty1), Scalar(Float(ty2))) => matches!(
|
||||
(ty1, ty2),
|
||||
(ast::FloatTy::F32, chalk_ir::FloatTy::F32)
|
||||
| (ast::FloatTy::F64, chalk_ir::FloatTy::F64)
|
||||
(ty::FloatTy::F32, chalk_ir::FloatTy::F32)
|
||||
| (ty::FloatTy::F64, chalk_ir::FloatTy::F64)
|
||||
),
|
||||
(&ty::Tuple(substs), Tuple(len, _)) => substs.len() == *len,
|
||||
(&ty::Array(..), Array(..)) => true,
|
||||
|
@ -233,8 +233,6 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::AliasEq<RustInterner<'tcx>>>
|
||||
|
||||
impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::Ty<RustInterner<'tcx>> {
|
||||
use rustc_ast as ast;
|
||||
|
||||
let int = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Int(i));
|
||||
let uint = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Uint(i));
|
||||
let float = |f| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Float(f));
|
||||
@ -243,24 +241,24 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
||||
ty::Bool => chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Bool),
|
||||
ty::Char => chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Char),
|
||||
ty::Int(ty) => match ty {
|
||||
ast::IntTy::Isize => int(chalk_ir::IntTy::Isize),
|
||||
ast::IntTy::I8 => int(chalk_ir::IntTy::I8),
|
||||
ast::IntTy::I16 => int(chalk_ir::IntTy::I16),
|
||||
ast::IntTy::I32 => int(chalk_ir::IntTy::I32),
|
||||
ast::IntTy::I64 => int(chalk_ir::IntTy::I64),
|
||||
ast::IntTy::I128 => int(chalk_ir::IntTy::I128),
|
||||
ty::IntTy::Isize => int(chalk_ir::IntTy::Isize),
|
||||
ty::IntTy::I8 => int(chalk_ir::IntTy::I8),
|
||||
ty::IntTy::I16 => int(chalk_ir::IntTy::I16),
|
||||
ty::IntTy::I32 => int(chalk_ir::IntTy::I32),
|
||||
ty::IntTy::I64 => int(chalk_ir::IntTy::I64),
|
||||
ty::IntTy::I128 => int(chalk_ir::IntTy::I128),
|
||||
},
|
||||
ty::Uint(ty) => match ty {
|
||||
ast::UintTy::Usize => uint(chalk_ir::UintTy::Usize),
|
||||
ast::UintTy::U8 => uint(chalk_ir::UintTy::U8),
|
||||
ast::UintTy::U16 => uint(chalk_ir::UintTy::U16),
|
||||
ast::UintTy::U32 => uint(chalk_ir::UintTy::U32),
|
||||
ast::UintTy::U64 => uint(chalk_ir::UintTy::U64),
|
||||
ast::UintTy::U128 => uint(chalk_ir::UintTy::U128),
|
||||
ty::UintTy::Usize => uint(chalk_ir::UintTy::Usize),
|
||||
ty::UintTy::U8 => uint(chalk_ir::UintTy::U8),
|
||||
ty::UintTy::U16 => uint(chalk_ir::UintTy::U16),
|
||||
ty::UintTy::U32 => uint(chalk_ir::UintTy::U32),
|
||||
ty::UintTy::U64 => uint(chalk_ir::UintTy::U64),
|
||||
ty::UintTy::U128 => uint(chalk_ir::UintTy::U128),
|
||||
},
|
||||
ty::Float(ty) => match ty {
|
||||
ast::FloatTy::F32 => float(chalk_ir::FloatTy::F32),
|
||||
ast::FloatTy::F64 => float(chalk_ir::FloatTy::F64),
|
||||
ty::FloatTy::F32 => float(chalk_ir::FloatTy::F32),
|
||||
ty::FloatTy::F64 => float(chalk_ir::FloatTy::F64),
|
||||
},
|
||||
ty::Adt(def, substs) => {
|
||||
chalk_ir::TyKind::Adt(chalk_ir::AdtId(def), substs.lower_into(interner))
|
||||
@ -347,24 +345,24 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
||||
chalk_ir::Scalar::Bool => ty::Bool,
|
||||
chalk_ir::Scalar::Char => ty::Char,
|
||||
chalk_ir::Scalar::Int(int_ty) => match int_ty {
|
||||
chalk_ir::IntTy::Isize => ty::Int(ast::IntTy::Isize),
|
||||
chalk_ir::IntTy::I8 => ty::Int(ast::IntTy::I8),
|
||||
chalk_ir::IntTy::I16 => ty::Int(ast::IntTy::I16),
|
||||
chalk_ir::IntTy::I32 => ty::Int(ast::IntTy::I32),
|
||||
chalk_ir::IntTy::I64 => ty::Int(ast::IntTy::I64),
|
||||
chalk_ir::IntTy::I128 => ty::Int(ast::IntTy::I128),
|
||||
chalk_ir::IntTy::Isize => ty::Int(ty::IntTy::Isize),
|
||||
chalk_ir::IntTy::I8 => ty::Int(ty::IntTy::I8),
|
||||
chalk_ir::IntTy::I16 => ty::Int(ty::IntTy::I16),
|
||||
chalk_ir::IntTy::I32 => ty::Int(ty::IntTy::I32),
|
||||
chalk_ir::IntTy::I64 => ty::Int(ty::IntTy::I64),
|
||||
chalk_ir::IntTy::I128 => ty::Int(ty::IntTy::I128),
|
||||
},
|
||||
chalk_ir::Scalar::Uint(int_ty) => match int_ty {
|
||||
chalk_ir::UintTy::Usize => ty::Uint(ast::UintTy::Usize),
|
||||
chalk_ir::UintTy::U8 => ty::Uint(ast::UintTy::U8),
|
||||
chalk_ir::UintTy::U16 => ty::Uint(ast::UintTy::U16),
|
||||
chalk_ir::UintTy::U32 => ty::Uint(ast::UintTy::U32),
|
||||
chalk_ir::UintTy::U64 => ty::Uint(ast::UintTy::U64),
|
||||
chalk_ir::UintTy::U128 => ty::Uint(ast::UintTy::U128),
|
||||
chalk_ir::UintTy::Usize => ty::Uint(ty::UintTy::Usize),
|
||||
chalk_ir::UintTy::U8 => ty::Uint(ty::UintTy::U8),
|
||||
chalk_ir::UintTy::U16 => ty::Uint(ty::UintTy::U16),
|
||||
chalk_ir::UintTy::U32 => ty::Uint(ty::UintTy::U32),
|
||||
chalk_ir::UintTy::U64 => ty::Uint(ty::UintTy::U64),
|
||||
chalk_ir::UintTy::U128 => ty::Uint(ty::UintTy::U128),
|
||||
},
|
||||
chalk_ir::Scalar::Float(float_ty) => match float_ty {
|
||||
chalk_ir::FloatTy::F32 => ty::Float(ast::FloatTy::F32),
|
||||
chalk_ir::FloatTy::F64 => ty::Float(ast::FloatTy::F64),
|
||||
chalk_ir::FloatTy::F32 => ty::Float(ty::FloatTy::F32),
|
||||
chalk_ir::FloatTy::F64 => ty::Float(ty::FloatTy::F64),
|
||||
},
|
||||
},
|
||||
TyKind::Array(ty, c) => {
|
||||
|
@ -2059,9 +2059,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
||||
match prim_ty {
|
||||
hir::PrimTy::Bool => tcx.types.bool,
|
||||
hir::PrimTy::Char => tcx.types.char,
|
||||
hir::PrimTy::Int(it) => tcx.mk_mach_int(it),
|
||||
hir::PrimTy::Uint(uit) => tcx.mk_mach_uint(uit),
|
||||
hir::PrimTy::Float(ft) => tcx.mk_mach_float(ft),
|
||||
hir::PrimTy::Int(it) => tcx.mk_mach_int(ty::int_ty(it)),
|
||||
hir::PrimTy::Uint(uit) => tcx.mk_mach_uint(ty::uint_ty(uit)),
|
||||
hir::PrimTy::Float(ft) => tcx.mk_mach_float(ty::float_ty(ft)),
|
||||
hir::PrimTy::Str => tcx.types.str_,
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ use super::FnCtxt;
|
||||
|
||||
use crate::hir::def_id::DefId;
|
||||
use crate::type_error_struct;
|
||||
use rustc_ast as ast;
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
@ -660,7 +659,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
(_, Int(Bool)) => Err(CastError::CastToBool),
|
||||
|
||||
// * -> Char
|
||||
(Int(U(ast::UintTy::U8)), Int(Char)) => Ok(CastKind::U8CharCast), // u8-char-cast
|
||||
(Int(U(ty::UintTy::U8)), Int(Char)) => Ok(CastKind::U8CharCast), // u8-char-cast
|
||||
(_, Int(Char)) => Err(CastError::CastToChar),
|
||||
|
||||
// prim -> float,ptr
|
||||
|
@ -373,13 +373,13 @@ impl<'a, 'tcx> FnCtxt<'a, '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.kind() {
|
||||
ty::Float(ast::FloatTy::F32) => {
|
||||
ty::Float(ty::FloatTy::F32) => {
|
||||
variadic_error(tcx.sess, arg.span, arg_ty, "c_double");
|
||||
}
|
||||
ty::Int(ast::IntTy::I8 | ast::IntTy::I16) | ty::Bool => {
|
||||
ty::Int(ty::IntTy::I8 | ty::IntTy::I16) | ty::Bool => {
|
||||
variadic_error(tcx.sess, arg.span, arg_ty, "c_int");
|
||||
}
|
||||
ty::Uint(ast::UintTy::U8 | ast::UintTy::U16) => {
|
||||
ty::Uint(ty::UintTy::U8 | ty::UintTy::U16) => {
|
||||
variadic_error(tcx.sess, arg.span, arg_ty, "c_uint");
|
||||
}
|
||||
ty::FnDef(..) => {
|
||||
@ -408,8 +408,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
}
|
||||
ast::LitKind::Byte(_) => tcx.types.u8,
|
||||
ast::LitKind::Char(_) => tcx.types.char,
|
||||
ast::LitKind::Int(_, ast::LitIntType::Signed(t)) => tcx.mk_mach_int(t),
|
||||
ast::LitKind::Int(_, ast::LitIntType::Unsigned(t)) => tcx.mk_mach_uint(t),
|
||||
ast::LitKind::Int(_, ast::LitIntType::Signed(t)) => tcx.mk_mach_int(ty::int_ty(t)),
|
||||
ast::LitKind::Int(_, ast::LitIntType::Unsigned(t)) => tcx.mk_mach_uint(ty::uint_ty(t)),
|
||||
ast::LitKind::Int(_, ast::LitIntType::Unsuffixed) => {
|
||||
let opt_ty = expected.to_option(self).and_then(|ty| match ty.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => Some(ty),
|
||||
@ -420,7 +420,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
});
|
||||
opt_ty.unwrap_or_else(|| self.next_int_var())
|
||||
}
|
||||
ast::LitKind::Float(_, ast::LitFloatType::Suffixed(t)) => tcx.mk_mach_float(t),
|
||||
ast::LitKind::Float(_, ast::LitFloatType::Suffixed(t)) => {
|
||||
tcx.mk_mach_float(ty::float_ty(t))
|
||||
}
|
||||
ast::LitKind::Float(_, ast::LitFloatType::Unsuffixed) => {
|
||||
let opt_ty = expected.to_option(self).and_then(|ty| match ty.kind() {
|
||||
ty::Float(_) => Some(ty),
|
||||
|
@ -8,7 +8,6 @@ use crate::errors::MethodCallOnUnknownType;
|
||||
use crate::hir::def::DefKind;
|
||||
use crate::hir::def_id::DefId;
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_hir as hir;
|
||||
@ -662,30 +661,30 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
||||
}
|
||||
ty::Int(i) => {
|
||||
let lang_def_id = match i {
|
||||
ast::IntTy::I8 => lang_items.i8_impl(),
|
||||
ast::IntTy::I16 => lang_items.i16_impl(),
|
||||
ast::IntTy::I32 => lang_items.i32_impl(),
|
||||
ast::IntTy::I64 => lang_items.i64_impl(),
|
||||
ast::IntTy::I128 => lang_items.i128_impl(),
|
||||
ast::IntTy::Isize => lang_items.isize_impl(),
|
||||
ty::IntTy::I8 => lang_items.i8_impl(),
|
||||
ty::IntTy::I16 => lang_items.i16_impl(),
|
||||
ty::IntTy::I32 => lang_items.i32_impl(),
|
||||
ty::IntTy::I64 => lang_items.i64_impl(),
|
||||
ty::IntTy::I128 => lang_items.i128_impl(),
|
||||
ty::IntTy::Isize => lang_items.isize_impl(),
|
||||
};
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::Uint(i) => {
|
||||
let lang_def_id = match i {
|
||||
ast::UintTy::U8 => lang_items.u8_impl(),
|
||||
ast::UintTy::U16 => lang_items.u16_impl(),
|
||||
ast::UintTy::U32 => lang_items.u32_impl(),
|
||||
ast::UintTy::U64 => lang_items.u64_impl(),
|
||||
ast::UintTy::U128 => lang_items.u128_impl(),
|
||||
ast::UintTy::Usize => lang_items.usize_impl(),
|
||||
ty::UintTy::U8 => lang_items.u8_impl(),
|
||||
ty::UintTy::U16 => lang_items.u16_impl(),
|
||||
ty::UintTy::U32 => lang_items.u32_impl(),
|
||||
ty::UintTy::U64 => lang_items.u64_impl(),
|
||||
ty::UintTy::U128 => lang_items.u128_impl(),
|
||||
ty::UintTy::Usize => lang_items.usize_impl(),
|
||||
};
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id);
|
||||
}
|
||||
ty::Float(f) => {
|
||||
let (lang_def_id1, lang_def_id2) = match f {
|
||||
ast::FloatTy::F32 => (lang_items.f32_impl(), lang_items.f32_runtime_impl()),
|
||||
ast::FloatTy::F64 => (lang_items.f64_impl(), lang_items.f64_runtime_impl()),
|
||||
ty::FloatTy::F32 => (lang_items.f32_impl(), lang_items.f32_runtime_impl()),
|
||||
ty::FloatTy::F64 => (lang_items.f64_impl(), lang_items.f64_runtime_impl()),
|
||||
};
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id1);
|
||||
self.assemble_inherent_impl_for_primitive(lang_def_id2);
|
||||
|
@ -13,7 +13,6 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
||||
use rustc_hir::itemlikevisit::ItemLikeVisitor;
|
||||
use rustc_middle::ty::{self, CrateInherentImpls, TyCtxt};
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_span::Span;
|
||||
|
||||
/// On-demand query: yields a map containing all types mapped to their inherent impls.
|
||||
@ -178,7 +177,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Int(ast::IntTy::I8) => {
|
||||
ty::Int(ty::IntTy::I8) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.i8_impl(),
|
||||
@ -189,7 +188,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Int(ast::IntTy::I16) => {
|
||||
ty::Int(ty::IntTy::I16) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.i16_impl(),
|
||||
@ -200,7 +199,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Int(ast::IntTy::I32) => {
|
||||
ty::Int(ty::IntTy::I32) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.i32_impl(),
|
||||
@ -211,7 +210,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Int(ast::IntTy::I64) => {
|
||||
ty::Int(ty::IntTy::I64) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.i64_impl(),
|
||||
@ -222,7 +221,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Int(ast::IntTy::I128) => {
|
||||
ty::Int(ty::IntTy::I128) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.i128_impl(),
|
||||
@ -233,7 +232,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Int(ast::IntTy::Isize) => {
|
||||
ty::Int(ty::IntTy::Isize) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.isize_impl(),
|
||||
@ -244,7 +243,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Uint(ast::UintTy::U8) => {
|
||||
ty::Uint(ty::UintTy::U8) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.u8_impl(),
|
||||
@ -255,7 +254,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Uint(ast::UintTy::U16) => {
|
||||
ty::Uint(ty::UintTy::U16) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.u16_impl(),
|
||||
@ -266,7 +265,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Uint(ast::UintTy::U32) => {
|
||||
ty::Uint(ty::UintTy::U32) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.u32_impl(),
|
||||
@ -277,7 +276,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Uint(ast::UintTy::U64) => {
|
||||
ty::Uint(ty::UintTy::U64) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.u64_impl(),
|
||||
@ -288,7 +287,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Uint(ast::UintTy::U128) => {
|
||||
ty::Uint(ty::UintTy::U128) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.u128_impl(),
|
||||
@ -299,7 +298,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Uint(ast::UintTy::Usize) => {
|
||||
ty::Uint(ty::UintTy::Usize) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.usize_impl(),
|
||||
@ -310,7 +309,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Float(ast::FloatTy::F32) => {
|
||||
ty::Float(ty::FloatTy::F32) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.f32_impl(),
|
||||
@ -321,7 +320,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
|
||||
assoc_items,
|
||||
);
|
||||
}
|
||||
ty::Float(ast::FloatTy::F64) => {
|
||||
ty::Float(ty::FloatTy::F64) => {
|
||||
self.check_primitive_impl(
|
||||
def_id,
|
||||
lang_items.f64_impl(),
|
||||
|
Loading…
Reference in New Issue
Block a user