Skip to content

Commit 700c518

Browse files
committed
Modify parser to require isize/usize suffixes.
1 parent dfc5c0f commit 700c518

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/libsyntax/parse/mod.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,14 +701,12 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
701701
if let Some(suf) = suffix {
702702
if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
703703
ty = match suf {
704-
"i" => ast::SignedIntLit(ast::TyIs(true), ast::Plus),
705-
"is" => ast::SignedIntLit(ast::TyIs(false), ast::Plus),
704+
"isize" => ast::SignedIntLit(ast::TyIs(false), ast::Plus),
706705
"i8" => ast::SignedIntLit(ast::TyI8, ast::Plus),
707706
"i16" => ast::SignedIntLit(ast::TyI16, ast::Plus),
708707
"i32" => ast::SignedIntLit(ast::TyI32, ast::Plus),
709708
"i64" => ast::SignedIntLit(ast::TyI64, ast::Plus),
710-
"u" => ast::UnsignedIntLit(ast::TyUs(true)),
711-
"us" => ast::UnsignedIntLit(ast::TyUs(false)),
709+
"usize" => ast::UnsignedIntLit(ast::TyUs(false)),
712710
"u8" => ast::UnsignedIntLit(ast::TyU8),
713711
"u16" => ast::UnsignedIntLit(ast::TyU16),
714712
"u32" => ast::UnsignedIntLit(ast::TyU32),
@@ -722,6 +720,17 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
722720
&suf[1..]));
723721
} else {
724722
sd.span_err(sp, &*format!("illegal suffix `{}` for numeric literal", suf));
723+
724+
if suf == "i" || suf == "is" {
725+
sd.span_help(sp, "per RFC 544/573, the suffix \
726+
for `isize` literals is now `isize`");
727+
} else if suf == "u" || suf == "us" {
728+
sd.span_help(sp, "per RFC 544/573, the suffix \
729+
for `usize` literals is now `usize`");
730+
} else {
731+
sd.span_help(sp, "the suffix must be one of the integral types \
732+
(`u32`, `isize`, etc)");
733+
}
725734
}
726735

727736
ty

0 commit comments

Comments
 (0)