Add a b'x' byte literal of type u8.
This commit is contained in:
parent
2fd618e77a
commit
bccdba0296
16 changed files with 169 additions and 5 deletions
|
|
@ -506,6 +506,7 @@ pub fn lit_to_const(lit: &Lit) -> const_val {
|
|||
LitBinary(ref data) => {
|
||||
const_binary(Rc::new(data.iter().map(|x| *x).collect()))
|
||||
}
|
||||
LitByte(n) => const_uint(n as u64),
|
||||
LitChar(n) => const_uint(n as u64),
|
||||
LitInt(n, _) => const_int(n),
|
||||
LitUint(n, _) => const_uint(n),
|
||||
|
|
|
|||
|
|
@ -805,6 +805,7 @@ fn check_type_limits(cx: &Context, e: &ast::Expr) {
|
|||
} else { t };
|
||||
let (min, max) = uint_ty_range(uint_type);
|
||||
let lit_val: u64 = match lit.node {
|
||||
ast::LitByte(_v) => return, // _v is u8, within range by definition
|
||||
ast::LitInt(v, _) => v as u64,
|
||||
ast::LitUint(v, _) => v,
|
||||
ast::LitIntUnsuffixed(v) => v as u64,
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit)
|
|||
-> ValueRef {
|
||||
let _icx = push_ctxt("trans_lit");
|
||||
match lit.node {
|
||||
ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::TyU8), b as u64, false),
|
||||
ast::LitChar(i) => C_integral(Type::char(cx), i as u64, false),
|
||||
ast::LitInt(i, t) => C_integral(Type::int_from_ty(cx, t), i as u64, true),
|
||||
ast::LitUint(u, t) => C_integral(Type::uint_from_ty(cx, t), u, false),
|
||||
|
|
|
|||
|
|
@ -1715,6 +1715,7 @@ pub fn check_lit(fcx: &FnCtxt, lit: &ast::Lit) -> ty::t {
|
|||
ast::LitBinary(..) => {
|
||||
ty::mk_slice(tcx, ty::ReStatic, ty::mt{ ty: ty::mk_u8(), mutbl: ast::MutImmutable })
|
||||
}
|
||||
ast::LitByte(_) => ty::mk_u8(),
|
||||
ast::LitChar(_) => ty::mk_char(),
|
||||
ast::LitInt(_, t) => ty::mk_mach_int(t),
|
||||
ast::LitUint(_, t) => ty::mk_mach_uint(t),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue