syntax: use distinct FloatTy from rustc_target.
We also sever syntax's dependency on rustc_target as a result. This should slightly improve pipe-lining. Moreover, some cleanup is done in related code.
This commit is contained in:
parent
bffc3d8073
commit
55f76cdb2f
19 changed files with 123 additions and 158 deletions
|
@ -3762,7 +3762,6 @@ dependencies = [
|
||||||
"rustc",
|
"rustc",
|
||||||
"rustc_codegen_utils",
|
"rustc_codegen_utils",
|
||||||
"rustc_data_structures",
|
"rustc_data_structures",
|
||||||
"rustc_target",
|
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"syntax",
|
"syntax",
|
||||||
"syntax_pos",
|
"syntax_pos",
|
||||||
|
@ -4362,7 +4361,6 @@ dependencies = [
|
||||||
"rustc_errors",
|
"rustc_errors",
|
||||||
"rustc_index",
|
"rustc_index",
|
||||||
"rustc_lexer",
|
"rustc_lexer",
|
||||||
"rustc_target",
|
|
||||||
"scoped-tls",
|
"scoped-tls",
|
||||||
"serialize",
|
"serialize",
|
||||||
"smallvec 1.0.0",
|
"smallvec 1.0.0",
|
||||||
|
@ -4380,7 +4378,6 @@ dependencies = [
|
||||||
"rustc_errors",
|
"rustc_errors",
|
||||||
"rustc_index",
|
"rustc_index",
|
||||||
"rustc_lexer",
|
"rustc_lexer",
|
||||||
"rustc_target",
|
|
||||||
"scoped-tls",
|
"scoped-tls",
|
||||||
"serialize",
|
"serialize",
|
||||||
"smallvec 1.0.0",
|
"smallvec 1.0.0",
|
||||||
|
|
|
@ -124,7 +124,6 @@ for ::syntax::attr::StabilityLevel {
|
||||||
|
|
||||||
impl_stable_hash_for!(struct ::syntax::attr::RustcDeprecation { since, reason, suggestion });
|
impl_stable_hash_for!(struct ::syntax::attr::RustcDeprecation { since, reason, suggestion });
|
||||||
|
|
||||||
|
|
||||||
impl_stable_hash_for!(enum ::syntax::attr::IntType {
|
impl_stable_hash_for!(enum ::syntax::attr::IntType {
|
||||||
SignedInt(int_ty),
|
SignedInt(int_ty),
|
||||||
UnsignedInt(uint_ty)
|
UnsignedInt(uint_ty)
|
||||||
|
@ -136,6 +135,11 @@ impl_stable_hash_for!(enum ::syntax::ast::LitIntType {
|
||||||
Unsuffixed
|
Unsuffixed
|
||||||
});
|
});
|
||||||
|
|
||||||
|
impl_stable_hash_for!(enum ::syntax::ast::LitFloatType {
|
||||||
|
Suffixed(float_ty),
|
||||||
|
Unsuffixed
|
||||||
|
});
|
||||||
|
|
||||||
impl_stable_hash_for!(struct ::syntax::ast::Lit {
|
impl_stable_hash_for!(struct ::syntax::ast::Lit {
|
||||||
kind,
|
kind,
|
||||||
token,
|
token,
|
||||||
|
@ -148,8 +152,7 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind {
|
||||||
Byte(value),
|
Byte(value),
|
||||||
Char(value),
|
Char(value),
|
||||||
Int(value, lit_int_type),
|
Int(value, lit_int_type),
|
||||||
Float(value, float_ty),
|
Float(value, lit_float_type),
|
||||||
FloatUnsuffixed(value),
|
|
||||||
Bool(value),
|
Bool(value),
|
||||||
Err(value)
|
Err(value)
|
||||||
});
|
});
|
||||||
|
@ -159,6 +162,7 @@ impl_stable_hash_for_spanned!(::syntax::ast::LitKind);
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
|
impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 });
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
|
impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 });
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
|
impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 });
|
||||||
|
impl_stable_hash_for!(enum ::rustc_target::abi::FloatTy { F32, F64 });
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
|
impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal });
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
|
impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst });
|
||||||
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });
|
impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final });
|
||||||
|
|
|
@ -538,7 +538,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
|
||||||
ty::Uint(ity) => {
|
ty::Uint(ity) => {
|
||||||
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
|
scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false))
|
||||||
}
|
}
|
||||||
ty::Float(fty) => scalar(Float(fty)),
|
ty::Float(fty) => scalar(Float(match fty {
|
||||||
|
ast::FloatTy::F32 => FloatTy::F32,
|
||||||
|
ast::FloatTy::F64 => FloatTy::F64,
|
||||||
|
})),
|
||||||
ty::FnPtr(_) => {
|
ty::FnPtr(_) => {
|
||||||
let mut ptr = scalar_unit(Pointer);
|
let mut ptr = scalar_unit(Pointer);
|
||||||
ptr.valid_range = 1..=*ptr.valid_range.end();
|
ptr.valid_range = 1..=*ptr.valid_range.end();
|
||||||
|
|
|
@ -12,7 +12,6 @@ use rustc::ty::{self, Const, Instance, Ty, TyCtxt};
|
||||||
use rustc::{bug, hir};
|
use rustc::{bug, hir};
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use syntax::ast;
|
|
||||||
|
|
||||||
/// Same as `unique_type_name()` but with the result pushed onto the given
|
/// Same as `unique_type_name()` but with the result pushed onto the given
|
||||||
/// `output` parameter.
|
/// `output` parameter.
|
||||||
|
@ -39,20 +38,9 @@ impl DefPathBasedNames<'tcx> {
|
||||||
ty::Char => output.push_str("char"),
|
ty::Char => output.push_str("char"),
|
||||||
ty::Str => output.push_str("str"),
|
ty::Str => output.push_str("str"),
|
||||||
ty::Never => output.push_str("!"),
|
ty::Never => output.push_str("!"),
|
||||||
ty::Int(ast::IntTy::Isize) => output.push_str("isize"),
|
ty::Int(ty) => output.push_str(ty.name_str()),
|
||||||
ty::Int(ast::IntTy::I8) => output.push_str("i8"),
|
ty::Uint(ty) => output.push_str(ty.name_str()),
|
||||||
ty::Int(ast::IntTy::I16) => output.push_str("i16"),
|
ty::Float(ty) => output.push_str(ty.name_str()),
|
||||||
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) => {
|
ty::Adt(adt_def, substs) => {
|
||||||
self.push_def_path(adt_def.did, output);
|
self.push_def_path(adt_def.did, output);
|
||||||
self.push_generic_params(substs, iter::empty(), output, debug);
|
self.push_generic_params(substs, iter::empty(), output, debug);
|
||||||
|
|
|
@ -466,9 +466,9 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
match ty.kind {
|
match ty.kind {
|
||||||
ty::Bool => p!(write("bool")),
|
ty::Bool => p!(write("bool")),
|
||||||
ty::Char => p!(write("char")),
|
ty::Char => p!(write("char")),
|
||||||
ty::Int(t) => p!(write("{}", t.ty_to_string())),
|
ty::Int(t) => p!(write("{}", t.name_str())),
|
||||||
ty::Uint(t) => p!(write("{}", t.ty_to_string())),
|
ty::Uint(t) => p!(write("{}", t.name_str())),
|
||||||
ty::Float(t) => p!(write("{}", t.ty_to_string())),
|
ty::Float(t) => p!(write("{}", t.name_str())),
|
||||||
ty::RawPtr(ref tm) => {
|
ty::RawPtr(ref tm) => {
|
||||||
p!(write("*{} ", match tm.mutbl {
|
p!(write("*{} ", match tm.mutbl {
|
||||||
hir::MutMutable => "mut",
|
hir::MutMutable => "mut",
|
||||||
|
@ -895,10 +895,11 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
let bit_size = Integer::from_attr(&self.tcx(), UnsignedInt(*ui)).size();
|
let bit_size = Integer::from_attr(&self.tcx(), UnsignedInt(*ui)).size();
|
||||||
let max = truncate(u128::max_value(), bit_size);
|
let max = truncate(u128::max_value(), bit_size);
|
||||||
|
|
||||||
|
let ui_str = ui.name_str();
|
||||||
if data == max {
|
if data == max {
|
||||||
p!(write("std::{}::MAX", ui))
|
p!(write("std::{}::MAX", ui_str))
|
||||||
} else {
|
} else {
|
||||||
p!(write("{}{}", data, ui))
|
p!(write("{}{}", data, ui_str))
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Int(i)) => {
|
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Int(i)) => {
|
||||||
|
@ -911,10 +912,11 @@ pub trait PrettyPrinter<'tcx>:
|
||||||
let size = self.tcx().layout_of(ty::ParamEnv::empty().and(ty))
|
let size = self.tcx().layout_of(ty::ParamEnv::empty().and(ty))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.size;
|
.size;
|
||||||
|
let i_str = i.name_str();
|
||||||
match data {
|
match data {
|
||||||
d if d == min => p!(write("std::{}::MIN", i)),
|
d if d == min => p!(write("std::{}::MIN", i_str)),
|
||||||
d if d == max => p!(write("std::{}::MAX", i)),
|
d if d == max => p!(write("std::{}::MAX", i_str)),
|
||||||
_ => p!(write("{}{}", sign_extend(data, size) as i128, i))
|
_ => p!(write("{}{}", sign_extend(data, size) as i128, i_str))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Char) =>
|
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Char) =>
|
||||||
|
|
|
@ -843,13 +843,13 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
|
||||||
ty::Bool => ("bool", DW_ATE_boolean),
|
ty::Bool => ("bool", DW_ATE_boolean),
|
||||||
ty::Char => ("char", DW_ATE_unsigned_char),
|
ty::Char => ("char", DW_ATE_unsigned_char),
|
||||||
ty::Int(int_ty) => {
|
ty::Int(int_ty) => {
|
||||||
(int_ty.ty_to_string(), DW_ATE_signed)
|
(int_ty.name_str(), DW_ATE_signed)
|
||||||
},
|
},
|
||||||
ty::Uint(uint_ty) => {
|
ty::Uint(uint_ty) => {
|
||||||
(uint_ty.ty_to_string(), DW_ATE_unsigned)
|
(uint_ty.name_str(), DW_ATE_unsigned)
|
||||||
},
|
},
|
||||||
ty::Float(float_ty) => {
|
ty::Float(float_ty) => {
|
||||||
(float_ty.ty_to_string(), DW_ATE_float)
|
(float_ty.name_str(), DW_ATE_float)
|
||||||
},
|
},
|
||||||
_ => bug!("debuginfo::basic_type_metadata - t is invalid type")
|
_ => bug!("debuginfo::basic_type_metadata - t is invalid type")
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,8 +18,8 @@ use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Primitive};
|
||||||
use rustc::mir::interpret::GlobalId;
|
use rustc::mir::interpret::GlobalId;
|
||||||
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
|
use rustc_codegen_ssa::common::{IntPredicate, TypeKind};
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use syntax::ast::{self, FloatTy};
|
use rustc_target::abi::{FloatTy, HasDataLayout};
|
||||||
use rustc_target::abi::HasDataLayout;
|
use syntax::ast;
|
||||||
|
|
||||||
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
|
use rustc_codegen_ssa::common::span_invalid_monomorphization_error;
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
|
@ -1335,7 +1335,7 @@ fn generic_simd_intrinsic(
|
||||||
},
|
},
|
||||||
ty::Float(f) => {
|
ty::Float(f) => {
|
||||||
return_error!("unsupported element type `{}` of floating-point vector `{}`",
|
return_error!("unsupported element type `{}` of floating-point vector `{}`",
|
||||||
f, in_ty);
|
f.name_str(), in_ty);
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
return_error!("`{}` is not a floating-point type", in_ty);
|
return_error!("`{}` is not a floating-point type", in_ty);
|
||||||
|
|
|
@ -37,9 +37,9 @@ pub fn push_debuginfo_type_name<'tcx>(
|
||||||
ty::Char => output.push_str("char"),
|
ty::Char => output.push_str("char"),
|
||||||
ty::Str => output.push_str("str"),
|
ty::Str => output.push_str("str"),
|
||||||
ty::Never => output.push_str("!"),
|
ty::Never => output.push_str("!"),
|
||||||
ty::Int(int_ty) => output.push_str(int_ty.ty_to_string()),
|
ty::Int(int_ty) => output.push_str(int_ty.name_str()),
|
||||||
ty::Uint(uint_ty) => output.push_str(uint_ty.ty_to_string()),
|
ty::Uint(uint_ty) => output.push_str(uint_ty.name_str()),
|
||||||
ty::Float(float_ty) => output.push_str(float_ty.ty_to_string()),
|
ty::Float(float_ty) => output.push_str(float_ty.name_str()),
|
||||||
ty::Foreign(def_id) => push_item_name(tcx, def_id, qualified, output),
|
ty::Foreign(def_id) => push_item_name(tcx, def_id, qualified, output),
|
||||||
ty::Adt(def, substs) => {
|
ty::Adt(def, substs) => {
|
||||||
push_item_name(tcx, def.did, qualified, output);
|
push_item_name(tcx, def.did, qualified, output);
|
||||||
|
|
|
@ -27,7 +27,6 @@ rustc_codegen_utils = { path = "../librustc_codegen_utils" }
|
||||||
rustc_metadata = { path = "../librustc_metadata" }
|
rustc_metadata = { path = "../librustc_metadata" }
|
||||||
rustc_mir = { path = "../librustc_mir" }
|
rustc_mir = { path = "../librustc_mir" }
|
||||||
rustc_passes = { path = "../librustc_passes" }
|
rustc_passes = { path = "../librustc_passes" }
|
||||||
rustc_target = { path = "../librustc_target" }
|
|
||||||
rustc_typeck = { path = "../librustc_typeck" }
|
rustc_typeck = { path = "../librustc_typeck" }
|
||||||
rustc_lint = { path = "../librustc_lint" }
|
rustc_lint = { path = "../librustc_lint" }
|
||||||
rustc_errors = { path = "../librustc_errors" }
|
rustc_errors = { path = "../librustc_errors" }
|
||||||
|
@ -36,3 +35,6 @@ rustc_privacy = { path = "../librustc_privacy" }
|
||||||
rustc_resolve = { path = "../librustc_resolve" }
|
rustc_resolve = { path = "../librustc_resolve" }
|
||||||
tempfile = "3.0.5"
|
tempfile = "3.0.5"
|
||||||
once_cell = "1"
|
once_cell = "1"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
rustc_target = { path = "../librustc_target" }
|
||||||
|
|
|
@ -68,7 +68,7 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>(
|
||||||
max: u128,
|
max: u128,
|
||||||
expr: &'tcx hir::Expr,
|
expr: &'tcx hir::Expr,
|
||||||
parent_expr: &'tcx hir::Expr,
|
parent_expr: &'tcx hir::Expr,
|
||||||
ty: impl std::fmt::Debug,
|
ty: &str,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// We only want to handle exclusive (`..`) ranges,
|
// We only want to handle exclusive (`..`) ranges,
|
||||||
// which are represented as `ExprKind::Struct`.
|
// which are represented as `ExprKind::Struct`.
|
||||||
|
@ -83,15 +83,15 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>(
|
||||||
let mut err = cx.struct_span_lint(
|
let mut err = cx.struct_span_lint(
|
||||||
OVERFLOWING_LITERALS,
|
OVERFLOWING_LITERALS,
|
||||||
parent_expr.span,
|
parent_expr.span,
|
||||||
&format!("range endpoint is out of range for `{:?}`", ty),
|
&format!("range endpoint is out of range for `{}`", ty),
|
||||||
);
|
);
|
||||||
if let Ok(start) = cx.sess().source_map().span_to_snippet(eps[0].span) {
|
if let Ok(start) = cx.sess().source_map().span_to_snippet(eps[0].span) {
|
||||||
use ast::{LitKind, LitIntType};
|
use ast::{LitKind, LitIntType};
|
||||||
// We need to preserve the literal's suffix,
|
// We need to preserve the literal's suffix,
|
||||||
// as it may determine typing information.
|
// as it may determine typing information.
|
||||||
let suffix = match lit.node {
|
let suffix = match lit.node {
|
||||||
LitKind::Int(_, LitIntType::Signed(s)) => format!("{}", s),
|
LitKind::Int(_, LitIntType::Signed(s)) => format!("{}", s.name_str()),
|
||||||
LitKind::Int(_, LitIntType::Unsigned(s)) => format!("{}", s),
|
LitKind::Int(_, LitIntType::Unsigned(s)) => format!("{}", s.name_str()),
|
||||||
LitKind::Int(_, LitIntType::Unsuffixed) => "".to_owned(),
|
LitKind::Int(_, LitIntType::Unsuffixed) => "".to_owned(),
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
|
@ -161,11 +161,11 @@ fn report_bin_hex_error(
|
||||||
let (t, actually) = match ty {
|
let (t, actually) = match ty {
|
||||||
attr::IntType::SignedInt(t) => {
|
attr::IntType::SignedInt(t) => {
|
||||||
let actually = sign_extend(val, size) as i128;
|
let actually = sign_extend(val, size) as i128;
|
||||||
(format!("{:?}", t), actually.to_string())
|
(t.name_str(), actually.to_string())
|
||||||
}
|
}
|
||||||
attr::IntType::UnsignedInt(t) => {
|
attr::IntType::UnsignedInt(t) => {
|
||||||
let actually = truncate(val, size);
|
let actually = truncate(val, size);
|
||||||
(format!("{:?}", t), actually.to_string())
|
(t.name_str(), actually.to_string())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let mut err = cx.struct_span_lint(
|
let mut err = cx.struct_span_lint(
|
||||||
|
@ -204,7 +204,7 @@ fn report_bin_hex_error(
|
||||||
// - `uX` => `uY`
|
// - `uX` => `uY`
|
||||||
//
|
//
|
||||||
// No suggestion for: `isize`, `usize`.
|
// No suggestion for: `isize`, `usize`.
|
||||||
fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option<String> {
|
fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option<&'static str> {
|
||||||
use syntax::ast::IntTy::*;
|
use syntax::ast::IntTy::*;
|
||||||
use syntax::ast::UintTy::*;
|
use syntax::ast::UintTy::*;
|
||||||
macro_rules! find_fit {
|
macro_rules! find_fit {
|
||||||
|
@ -215,10 +215,10 @@ fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option<String> {
|
||||||
match $ty {
|
match $ty {
|
||||||
$($type => {
|
$($type => {
|
||||||
$(if !negative && val <= uint_ty_range($utypes).1 {
|
$(if !negative && val <= uint_ty_range($utypes).1 {
|
||||||
return Some(format!("{:?}", $utypes))
|
return Some($utypes.name_str())
|
||||||
})*
|
})*
|
||||||
$(if val <= int_ty_range($itypes).1 as u128 + _neg {
|
$(if val <= int_ty_range($itypes).1 as u128 + _neg {
|
||||||
return Some(format!("{:?}", $itypes))
|
return Some($itypes.name_str())
|
||||||
})*
|
})*
|
||||||
None
|
None
|
||||||
},)+
|
},)+
|
||||||
|
@ -281,7 +281,7 @@ fn lint_int_literal<'a, 'tcx>(
|
||||||
if let Node::Expr(par_e) = cx.tcx.hir().get(par_id) {
|
if let Node::Expr(par_e) = cx.tcx.hir().get(par_id) {
|
||||||
if let hir::ExprKind::Struct(..) = par_e.kind {
|
if let hir::ExprKind::Struct(..) = par_e.kind {
|
||||||
if is_range_literal(cx.sess(), par_e)
|
if is_range_literal(cx.sess(), par_e)
|
||||||
&& lint_overflowing_range_endpoint(cx, lit, v, max, e, par_e, t)
|
&& lint_overflowing_range_endpoint(cx, lit, v, max, e, par_e, t.name_str())
|
||||||
{
|
{
|
||||||
// The overflowing literal lint was overridden.
|
// The overflowing literal lint was overridden.
|
||||||
return;
|
return;
|
||||||
|
@ -292,7 +292,7 @@ fn lint_int_literal<'a, 'tcx>(
|
||||||
cx.span_lint(
|
cx.span_lint(
|
||||||
OVERFLOWING_LITERALS,
|
OVERFLOWING_LITERALS,
|
||||||
e.span,
|
e.span,
|
||||||
&format!("literal out of range for `{:?}`", t),
|
&format!("literal out of range for `{}`", t.name_str()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -338,6 +338,7 @@ fn lint_uint_literal<'a, 'tcx>(
|
||||||
}
|
}
|
||||||
hir::ExprKind::Struct(..)
|
hir::ExprKind::Struct(..)
|
||||||
if is_range_literal(cx.sess(), par_e) => {
|
if is_range_literal(cx.sess(), par_e) => {
|
||||||
|
let t = t.name_str();
|
||||||
if lint_overflowing_range_endpoint(cx, lit, lit_val, max, e, par_e, t) {
|
if lint_overflowing_range_endpoint(cx, lit, lit_val, max, e, par_e, t) {
|
||||||
// The overflowing literal lint was overridden.
|
// The overflowing literal lint was overridden.
|
||||||
return;
|
return;
|
||||||
|
@ -353,7 +354,7 @@ fn lint_uint_literal<'a, 'tcx>(
|
||||||
cx.span_lint(
|
cx.span_lint(
|
||||||
OVERFLOWING_LITERALS,
|
OVERFLOWING_LITERALS,
|
||||||
e.span,
|
e.span,
|
||||||
&format!("literal out of range for `{:?}`", t),
|
&format!("literal out of range for `{}`", t.name_str()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -379,8 +380,7 @@ fn lint_literal<'a, 'tcx>(
|
||||||
}
|
}
|
||||||
ty::Float(t) => {
|
ty::Float(t) => {
|
||||||
let is_infinite = match lit.node {
|
let is_infinite = match lit.node {
|
||||||
ast::LitKind::Float(v, _) |
|
ast::LitKind::Float(v, _) => {
|
||||||
ast::LitKind::FloatUnsuffixed(v) => {
|
|
||||||
match t {
|
match t {
|
||||||
ast::FloatTy::F32 => v.as_str().parse().map(f32::is_infinite),
|
ast::FloatTy::F32 => v.as_str().parse().map(f32::is_infinite),
|
||||||
ast::FloatTy::F64 => v.as_str().parse().map(f64::is_infinite),
|
ast::FloatTy::F64 => v.as_str().parse().map(f64::is_infinite),
|
||||||
|
@ -389,9 +389,11 @@ fn lint_literal<'a, 'tcx>(
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
if is_infinite == Ok(true) {
|
if is_infinite == Ok(true) {
|
||||||
cx.span_lint(OVERFLOWING_LITERALS,
|
cx.span_lint(
|
||||||
e.span,
|
OVERFLOWING_LITERALS,
|
||||||
&format!("literal out of range for `{:?}`", t));
|
e.span,
|
||||||
|
&format!("literal out of range for `{}`", t.name_str()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -45,10 +45,7 @@ crate fn lit_to_const<'tcx>(
|
||||||
trunc(n as u128)?
|
trunc(n as u128)?
|
||||||
},
|
},
|
||||||
LitKind::Int(n, _) => trunc(n)?,
|
LitKind::Int(n, _) => trunc(n)?,
|
||||||
LitKind::Float(n, fty) => {
|
LitKind::Float(n, _) => {
|
||||||
parse_float(n, fty, neg).map_err(|_| LitToConstError::UnparseableFloat)?
|
|
||||||
}
|
|
||||||
LitKind::FloatUnsuffixed(n) => {
|
|
||||||
let fty = match ty.kind {
|
let fty = match ty.kind {
|
||||||
ty::Float(fty) => fty,
|
ty::Float(fty) => fty,
|
||||||
_ => bug!()
|
_ => bug!()
|
||||||
|
|
|
@ -13,7 +13,6 @@ log = "0.4"
|
||||||
rustc = { path = "../librustc" }
|
rustc = { path = "../librustc" }
|
||||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||||
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
|
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
|
||||||
rustc_target = { path = "../librustc_target" }
|
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
syntax = { path = "../libsyntax" }
|
syntax = { path = "../libsyntax" }
|
||||||
syntax_pos = { path = "../libsyntax_pos" }
|
syntax_pos = { path = "../libsyntax_pos" }
|
||||||
|
|
|
@ -3,11 +3,9 @@ pub use Primitive::*;
|
||||||
|
|
||||||
use crate::spec::Target;
|
use crate::spec::Target;
|
||||||
|
|
||||||
use std::fmt;
|
|
||||||
use std::ops::{Add, Deref, Sub, Mul, AddAssign, Range, RangeInclusive};
|
use std::ops::{Add, Deref, Sub, Mul, AddAssign, Range, RangeInclusive};
|
||||||
|
|
||||||
use rustc_index::vec::{Idx, IndexVec};
|
use rustc_index::vec::{Idx, IndexVec};
|
||||||
use syntax_pos::symbol::{sym, Symbol};
|
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
pub mod call;
|
pub mod call;
|
||||||
|
@ -534,49 +532,13 @@ impl Integer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy,
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy,
|
||||||
PartialOrd, Ord)]
|
PartialOrd, Ord, Debug)]
|
||||||
pub enum FloatTy {
|
pub enum FloatTy {
|
||||||
F32,
|
F32,
|
||||||
F64,
|
F64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for FloatTy {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
fmt::Display::fmt(self, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for FloatTy {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
write!(f, "{}", self.ty_to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FloatTy {
|
|
||||||
pub fn ty_to_string(self) -> &'static str {
|
|
||||||
match self {
|
|
||||||
FloatTy::F32 => "f32",
|
|
||||||
FloatTy::F64 => "f64",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn to_symbol(self) -> Symbol {
|
|
||||||
match self {
|
|
||||||
FloatTy::F32 => sym::f32,
|
|
||||||
FloatTy::F64 => sym::f64,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn bit_width(self) -> usize {
|
|
||||||
match self {
|
|
||||||
FloatTy::F32 => 32,
|
|
||||||
FloatTy::F64 => 64,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Fundamental unit of memory access and layout.
|
/// Fundamental unit of memory access and layout.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
pub enum Primitive {
|
pub enum Primitive {
|
||||||
|
|
|
@ -3660,8 +3660,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
});
|
});
|
||||||
opt_ty.unwrap_or_else(|| self.next_int_var())
|
opt_ty.unwrap_or_else(|| self.next_int_var())
|
||||||
}
|
}
|
||||||
ast::LitKind::Float(_, t) => tcx.mk_mach_float(t),
|
ast::LitKind::Float(_, ast::LitFloatType::Suffixed(t)) => tcx.mk_mach_float(t),
|
||||||
ast::LitKind::FloatUnsuffixed(_) => {
|
ast::LitKind::Float(_, ast::LitFloatType::Unsuffixed) => {
|
||||||
let opt_ty = expected.to_option(self).and_then(|ty| {
|
let opt_ty = expected.to_option(self).and_then(|ty| {
|
||||||
match ty.kind {
|
match ty.kind {
|
||||||
ty::Float(_) => Some(ty),
|
ty::Float(_) => Some(ty),
|
||||||
|
|
|
@ -20,5 +20,4 @@ errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||||
rustc_index = { path = "../librustc_index" }
|
rustc_index = { path = "../librustc_index" }
|
||||||
rustc_lexer = { path = "../librustc_lexer" }
|
rustc_lexer = { path = "../librustc_lexer" }
|
||||||
rustc_target = { path = "../librustc_target" }
|
|
||||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||||
|
|
|
@ -22,7 +22,6 @@ pub use GenericArgs::*;
|
||||||
pub use UnsafeSource::*;
|
pub use UnsafeSource::*;
|
||||||
pub use crate::util::parser::ExprPrecedence;
|
pub use crate::util::parser::ExprPrecedence;
|
||||||
|
|
||||||
pub use rustc_target::abi::FloatTy;
|
|
||||||
pub use syntax_pos::symbol::{Ident, Symbol as Name};
|
pub use syntax_pos::symbol::{Ident, Symbol as Name};
|
||||||
|
|
||||||
use crate::parse::token::{self, DelimToken};
|
use crate::parse::token::{self, DelimToken};
|
||||||
|
@ -1400,7 +1399,7 @@ pub struct Lit {
|
||||||
|
|
||||||
// Clippy uses Hash and PartialEq
|
// Clippy uses Hash and PartialEq
|
||||||
/// Type of the integer literal based on provided suffix.
|
/// Type of the integer literal based on provided suffix.
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq)]
|
#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)]
|
||||||
pub enum LitIntType {
|
pub enum LitIntType {
|
||||||
/// e.g. `42_i32`.
|
/// e.g. `42_i32`.
|
||||||
Signed(IntTy),
|
Signed(IntTy),
|
||||||
|
@ -1410,6 +1409,15 @@ pub enum LitIntType {
|
||||||
Unsuffixed,
|
Unsuffixed,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Type of the float literal based on provided suffix.
|
||||||
|
#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)]
|
||||||
|
pub enum LitFloatType {
|
||||||
|
/// A float literal with a suffix (`1f32` or `1E10f32`).
|
||||||
|
Suffixed(FloatTy),
|
||||||
|
/// A float literal without a suffix (`1.0 or 1.0E10`).
|
||||||
|
Unsuffixed,
|
||||||
|
}
|
||||||
|
|
||||||
/// Literal kind.
|
/// Literal kind.
|
||||||
///
|
///
|
||||||
/// E.g., `"foo"`, `42`, `12.34`, or `bool`.
|
/// E.g., `"foo"`, `42`, `12.34`, or `bool`.
|
||||||
|
@ -1427,9 +1435,7 @@ pub enum LitKind {
|
||||||
/// An integer literal (`1`).
|
/// An integer literal (`1`).
|
||||||
Int(u128, LitIntType),
|
Int(u128, LitIntType),
|
||||||
/// A float literal (`1f64` or `1E10f64`).
|
/// A float literal (`1f64` or `1E10f64`).
|
||||||
Float(Symbol, FloatTy),
|
Float(Symbol, LitFloatType),
|
||||||
/// A float literal without a suffix (`1.0 or 1.0E10`).
|
|
||||||
FloatUnsuffixed(Symbol),
|
|
||||||
/// A boolean literal.
|
/// A boolean literal.
|
||||||
Bool(bool),
|
Bool(bool),
|
||||||
/// Placeholder for a literal that wasn't well-formed in some way.
|
/// Placeholder for a literal that wasn't well-formed in some way.
|
||||||
|
@ -1456,7 +1462,7 @@ impl LitKind {
|
||||||
/// Returns `true` if this is a numeric literal.
|
/// Returns `true` if this is a numeric literal.
|
||||||
pub fn is_numeric(&self) -> bool {
|
pub fn is_numeric(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
LitKind::Int(..) | LitKind::Float(..) | LitKind::FloatUnsuffixed(..) => true,
|
LitKind::Int(..) | LitKind::Float(..) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1473,14 +1479,14 @@ impl LitKind {
|
||||||
// suffixed variants
|
// suffixed variants
|
||||||
LitKind::Int(_, LitIntType::Signed(..))
|
LitKind::Int(_, LitIntType::Signed(..))
|
||||||
| LitKind::Int(_, LitIntType::Unsigned(..))
|
| LitKind::Int(_, LitIntType::Unsigned(..))
|
||||||
| LitKind::Float(..) => true,
|
| LitKind::Float(_, LitFloatType::Suffixed(..)) => true,
|
||||||
// unsuffixed variants
|
// unsuffixed variants
|
||||||
LitKind::Str(..)
|
LitKind::Str(..)
|
||||||
| LitKind::ByteStr(..)
|
| LitKind::ByteStr(..)
|
||||||
| LitKind::Byte(..)
|
| LitKind::Byte(..)
|
||||||
| LitKind::Char(..)
|
| LitKind::Char(..)
|
||||||
| LitKind::Int(_, LitIntType::Unsuffixed)
|
| LitKind::Int(_, LitIntType::Unsuffixed)
|
||||||
| LitKind::FloatUnsuffixed(..)
|
| LitKind::Float(_, LitFloatType::Unsuffixed)
|
||||||
| LitKind::Bool(..)
|
| LitKind::Bool(..)
|
||||||
| LitKind::Err(..) => false,
|
| LitKind::Err(..) => false,
|
||||||
}
|
}
|
||||||
|
@ -1552,7 +1558,36 @@ pub enum ImplItemKind {
|
||||||
Macro(Mac),
|
Macro(Mac),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)]
|
||||||
|
pub enum FloatTy {
|
||||||
|
F32,
|
||||||
|
F64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FloatTy {
|
||||||
|
pub fn name_str(self) -> &'static str {
|
||||||
|
match self {
|
||||||
|
FloatTy::F32 => "f32",
|
||||||
|
FloatTy::F64 => "f64",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn name(self) -> Symbol {
|
||||||
|
match self {
|
||||||
|
FloatTy::F32 => sym::f32,
|
||||||
|
FloatTy::F64 => sym::f64,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn bit_width(self) -> usize {
|
||||||
|
match self {
|
||||||
|
FloatTy::F32 => 32,
|
||||||
|
FloatTy::F64 => 64,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)]
|
||||||
pub enum IntTy {
|
pub enum IntTy {
|
||||||
Isize,
|
Isize,
|
||||||
I8,
|
I8,
|
||||||
|
@ -1562,20 +1597,8 @@ pub enum IntTy {
|
||||||
I128,
|
I128,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for IntTy {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
fmt::Display::fmt(self, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for IntTy {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
write!(f, "{}", self.ty_to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl IntTy {
|
impl IntTy {
|
||||||
pub fn ty_to_string(&self) -> &'static str {
|
pub fn name_str(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
IntTy::Isize => "isize",
|
IntTy::Isize => "isize",
|
||||||
IntTy::I8 => "i8",
|
IntTy::I8 => "i8",
|
||||||
|
@ -1586,7 +1609,7 @@ impl IntTy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_symbol(&self) -> Symbol {
|
pub fn name(&self) -> Symbol {
|
||||||
match *self {
|
match *self {
|
||||||
IntTy::Isize => sym::isize,
|
IntTy::Isize => sym::isize,
|
||||||
IntTy::I8 => sym::i8,
|
IntTy::I8 => sym::i8,
|
||||||
|
@ -1601,7 +1624,7 @@ impl IntTy {
|
||||||
// Cast to a `u128` so we can correctly print `INT128_MIN`. All integral types
|
// Cast to a `u128` so we can correctly print `INT128_MIN`. All integral types
|
||||||
// are parsed as `u128`, so we wouldn't want to print an extra negative
|
// are parsed as `u128`, so we wouldn't want to print an extra negative
|
||||||
// sign.
|
// sign.
|
||||||
format!("{}{}", val as u128, self.ty_to_string())
|
format!("{}{}", val as u128, self.name_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bit_width(&self) -> Option<usize> {
|
pub fn bit_width(&self) -> Option<usize> {
|
||||||
|
@ -1616,7 +1639,7 @@ impl IntTy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy, Debug)]
|
||||||
pub enum UintTy {
|
pub enum UintTy {
|
||||||
Usize,
|
Usize,
|
||||||
U8,
|
U8,
|
||||||
|
@ -1627,7 +1650,7 @@ pub enum UintTy {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UintTy {
|
impl UintTy {
|
||||||
pub fn ty_to_string(&self) -> &'static str {
|
pub fn name_str(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
UintTy::Usize => "usize",
|
UintTy::Usize => "usize",
|
||||||
UintTy::U8 => "u8",
|
UintTy::U8 => "u8",
|
||||||
|
@ -1638,7 +1661,7 @@ impl UintTy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_symbol(&self) -> Symbol {
|
pub fn name(&self) -> Symbol {
|
||||||
match *self {
|
match *self {
|
||||||
UintTy::Usize => sym::usize,
|
UintTy::Usize => sym::usize,
|
||||||
UintTy::U8 => sym::u8,
|
UintTy::U8 => sym::u8,
|
||||||
|
@ -1650,7 +1673,7 @@ impl UintTy {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn val_to_string(&self, val: u128) -> String {
|
pub fn val_to_string(&self, val: u128) -> String {
|
||||||
format!("{}{}", val, self.ty_to_string())
|
format!("{}{}", val, self.name_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bit_width(&self) -> Option<usize> {
|
pub fn bit_width(&self) -> Option<usize> {
|
||||||
|
@ -1665,18 +1688,6 @@ impl UintTy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for UintTy {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
fmt::Display::fmt(self, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for UintTy {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
write!(f, "{}", self.ty_to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A constraint on an associated type (e.g., `A = Bar` in `Foo<A = Bar>` or
|
/// A constraint on an associated type (e.g., `A = Bar` in `Foo<A = Bar>` or
|
||||||
/// `A: TraitA + TraitB` in `Foo<A: TraitA + TraitB>`).
|
/// `A: TraitA + TraitB` in `Foo<A: TraitA + TraitB>`).
|
||||||
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
|
||||||
|
|
|
@ -157,17 +157,18 @@ impl LitKind {
|
||||||
}
|
}
|
||||||
LitKind::Int(n, ty) => {
|
LitKind::Int(n, ty) => {
|
||||||
let suffix = match ty {
|
let suffix = match ty {
|
||||||
ast::LitIntType::Unsigned(ty) => Some(ty.to_symbol()),
|
ast::LitIntType::Unsigned(ty) => Some(ty.name()),
|
||||||
ast::LitIntType::Signed(ty) => Some(ty.to_symbol()),
|
ast::LitIntType::Signed(ty) => Some(ty.name()),
|
||||||
ast::LitIntType::Unsuffixed => None,
|
ast::LitIntType::Unsuffixed => None,
|
||||||
};
|
};
|
||||||
(token::Integer, sym::integer(n), suffix)
|
(token::Integer, sym::integer(n), suffix)
|
||||||
}
|
}
|
||||||
LitKind::Float(symbol, ty) => {
|
LitKind::Float(symbol, ty) => {
|
||||||
(token::Float, symbol, Some(ty.to_symbol()))
|
let suffix = match ty {
|
||||||
}
|
ast::LitFloatType::Suffixed(ty) => Some(ty.name()),
|
||||||
LitKind::FloatUnsuffixed(symbol) => {
|
ast::LitFloatType::Unsuffixed => None,
|
||||||
(token::Float, symbol, None)
|
};
|
||||||
|
(token::Float, symbol, suffix)
|
||||||
}
|
}
|
||||||
LitKind::Bool(value) => {
|
LitKind::Bool(value) => {
|
||||||
let symbol = if value { kw::True } else { kw::False };
|
let symbol = if value { kw::True } else { kw::False };
|
||||||
|
@ -244,12 +245,12 @@ fn filtered_float_lit(symbol: Symbol, suffix: Option<Symbol>, base: u32)
|
||||||
return Err(LitError::NonDecimalFloat(base));
|
return Err(LitError::NonDecimalFloat(base));
|
||||||
}
|
}
|
||||||
Ok(match suffix {
|
Ok(match suffix {
|
||||||
Some(suf) => match suf {
|
Some(suf) => LitKind::Float(symbol, ast::LitFloatType::Suffixed(match suf {
|
||||||
sym::f32 => LitKind::Float(symbol, ast::FloatTy::F32),
|
sym::f32 => ast::FloatTy::F32,
|
||||||
sym::f64 => LitKind::Float(symbol, ast::FloatTy::F64),
|
sym::f64 => ast::FloatTy::F64,
|
||||||
_ => return Err(LitError::InvalidFloatSuffix),
|
_ => return Err(LitError::InvalidFloatSuffix),
|
||||||
}
|
})),
|
||||||
None => LitKind::FloatUnsuffixed(symbol)
|
None => LitKind::Float(symbol, ast::LitFloatType::Unsuffixed)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,5 @@ errors = { path = "../librustc_errors", package = "rustc_errors" }
|
||||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||||
rustc_index = { path = "../librustc_index" }
|
rustc_index = { path = "../librustc_index" }
|
||||||
rustc_lexer = { path = "../librustc_lexer" }
|
rustc_lexer = { path = "../librustc_lexer" }
|
||||||
rustc_target = { path = "../librustc_target" }
|
|
||||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||||
syntax = { path = "../libsyntax" }
|
syntax = { path = "../libsyntax" }
|
||||||
|
|
|
@ -21,8 +21,7 @@ pub fn expand_concat(
|
||||||
match e.kind {
|
match e.kind {
|
||||||
ast::ExprKind::Lit(ref lit) => match lit.kind {
|
ast::ExprKind::Lit(ref lit) => match lit.kind {
|
||||||
ast::LitKind::Str(ref s, _)
|
ast::LitKind::Str(ref s, _)
|
||||||
| ast::LitKind::Float(ref s, _)
|
| ast::LitKind::Float(ref s, _) => {
|
||||||
| ast::LitKind::FloatUnsuffixed(ref s) => {
|
|
||||||
accumulator.push_str(&s.as_str());
|
accumulator.push_str(&s.as_str());
|
||||||
}
|
}
|
||||||
ast::LitKind::Char(c) => {
|
ast::LitKind::Char(c) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue