We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 65d201f + 4d34bfd commit 3dfda16Copy full SHA for 3dfda16
src/libproc_macro/quote.rs
@@ -163,9 +163,9 @@ impl<'a> Quote for &'a str {
163
}
164
165
166
-impl Quote for usize {
+impl Quote for u16 {
167
fn quote(self) -> TokenStream {
168
- TokenTree::from(Literal::usize_unsuffixed(self)).into()
+ TokenTree::from(Literal::u16_unsuffixed(self)).into()
169
170
171
@@ -197,7 +197,7 @@ macro_rules! literals {
197
($($i:ident),*; $($raw:ident),*) => {
198
pub enum LiteralKind {
199
$($i,)*
200
- $($raw(usize),)*
+ $($raw(u16),)*
201
202
203
impl LiteralKind {
src/libsyntax/ast.rs
@@ -1255,8 +1255,8 @@ pub enum StrStyle {
1255
Cooked,
1256
/// A raw string, like `r##"foo"##`
1257
///
1258
- /// The uint is the number of `#` symbols used
1259
- Raw(usize)
+ /// The value is the number of `#` symbols used.
+ Raw(u16)
1260
1261
1262
/// A literal
src/libsyntax/ext/build.rs
@@ -139,6 +139,7 @@ pub trait AstBuilder {
139
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr>;
140
fn expr_isize(&self, sp: Span, i: isize) -> P<ast::Expr>;
141
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr>;
142
+ fn expr_u16(&self, sp: Span, u: u16) -> P<ast::Expr>;
143
fn expr_u32(&self, sp: Span, u: u32) -> P<ast::Expr>;
144
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr>;
145
@@ -708,6 +709,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
708
709
self.expr_lit(sp, ast::LitKind::Int(u as u128,
710
ast::LitIntType::Unsigned(ast::UintTy::U32)))
711
712
+ fn expr_u16(&self, sp: Span, u: u16) -> P<ast::Expr> {
713
+ self.expr_lit(sp, ast::LitKind::Int(u as u128,
714
+ ast::LitIntType::Unsigned(ast::UintTy::U16)))
715
+ }
716
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> {
717
self.expr_lit(sp, ast::LitKind::Int(u as u128, ast::LitIntType::Unsigned(ast::UintTy::U8)))
718
src/libsyntax/ext/quote.rs
@@ -623,7 +623,7 @@ fn expr_mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
623
($name: expr, $suffix: expr, $content: expr $(, $count: expr)*) => {{
624
let name = mk_name(cx, sp, ast::Ident::with_empty_ctxt($content));
625
let inner = cx.expr_call(sp, mk_token_path(cx, sp, $name), vec![
626
- name $(, cx.expr_usize(sp, $count))*
+ name $(, cx.expr_u16(sp, $count))*
627
]);
628
let suffix = match $suffix {
629
Some(name) => cx.expr_some(sp, mk_name(cx, sp, ast::Ident::with_empty_ctxt(name))),
src/libsyntax/parse/lexer/mod.rs
@@ -133,12 +133,12 @@ impl<'a> StringReader<'a> {
133
Ok(ret_val)
134
135
136
- fn fail_unterminated_raw_string(&self, pos: BytePos, hash_count: usize) {
+ fn fail_unterminated_raw_string(&self, pos: BytePos, hash_count: u16) {
137
let mut err = self.struct_span_fatal(pos, pos, "unterminated raw string");
138
err.span_label(self.mk_sp(pos, pos), "unterminated raw string");
if hash_count > 0 {
err.note(&format!("this raw string should be terminated with `\"{}`",
- "#".repeat(hash_count)));
+ "#".repeat(hash_count as usize)));
err.emit();
FatalError.raise();
@@ -1439,7 +1439,7 @@ impl<'a> StringReader<'a> {
1439
'r' => {
1440
let start_bpos = self.pos;
1441
self.bump();
1442
- let mut hash_count = 0;
+ let mut hash_count: u16 = 0;
1443
while self.ch_is('#') {
1444
1445
hash_count += 1;
src/libsyntax/parse/token.rs
@@ -72,9 +72,9 @@ pub enum Lit {
72
Integer(ast::Name),
73
Float(ast::Name),
74
Str_(ast::Name),
75
- StrRaw(ast::Name, usize), /* raw str delimited by n hash symbols */
+ StrRaw(ast::Name, u16), /* raw str delimited by n hash symbols */
76
ByteStr(ast::Name),
77
- ByteStrRaw(ast::Name, usize), /* raw byte str delimited by n hash symbols */
+ ByteStrRaw(ast::Name, u16), /* raw byte str delimited by n hash symbols */
78
79
80
impl Lit {
src/libsyntax/print/pprust.rs
@@ -234,11 +234,11 @@ pub fn token_to_string(tok: &Token) -> String {
234
token::Integer(c) => c.to_string(),
235
token::Str_(s) => format!("\"{}\"", s),
236
token::StrRaw(s, n) => format!("r{delim}\"{string}\"{delim}",
237
- delim=repeat("#", n),
+ delim=repeat("#", n as usize),
238
string=s),
239
token::ByteStr(v) => format!("b\"{}\"", v),
240
token::ByteStrRaw(s, n) => format!("br{delim}\"{string}\"{delim}",
241
242
243
};
244
@@ -660,7 +660,7 @@ pub trait PrintState<'a> {
660
661
ast::StrStyle::Raw(n) => {
662
(format!("r{delim}\"{string}\"{delim}",
663
664
string=st))
665
666
0 commit comments