rollup merge of #21340: pshc/libsyntax-no-more-ints
Collaboration with @rylev!
I didn't change `int` in the [quasi-quoter](99ae1a30f3/src/libsyntax/ext/quote.rs (L328)), because I'm not sure if there will be adverse effects.
Addresses #21095.
This commit is contained in:
commit
0c981875e4
46 changed files with 488 additions and 488 deletions
|
|
@ -548,7 +548,7 @@ pub struct ExtCtxt<'a> {
|
|||
pub exported_macros: Vec<ast::MacroDef>,
|
||||
|
||||
pub syntax_env: SyntaxEnv,
|
||||
pub recursion_count: uint,
|
||||
pub recursion_count: usize,
|
||||
}
|
||||
|
||||
impl<'a> ExtCtxt<'a> {
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub trait AstBuilder {
|
|||
fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr>;
|
||||
fn expr_field_access(&self, span: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr>;
|
||||
fn expr_tup_field_access(&self, sp: Span, expr: P<ast::Expr>,
|
||||
idx: uint) -> P<ast::Expr>;
|
||||
idx: usize) -> P<ast::Expr>;
|
||||
fn expr_call(&self, span: Span, expr: P<ast::Expr>, args: Vec<P<ast::Expr>>) -> P<ast::Expr>;
|
||||
fn expr_call_ident(&self, span: Span, id: ast::Ident, args: Vec<P<ast::Expr>>) -> P<ast::Expr>;
|
||||
fn expr_call_global(&self, sp: Span, fn_path: Vec<ast::Ident>,
|
||||
|
|
@ -134,8 +134,8 @@ pub trait AstBuilder {
|
|||
|
||||
fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P<ast::Expr>;
|
||||
|
||||
fn expr_uint(&self, span: Span, i: uint) -> P<ast::Expr>;
|
||||
fn expr_int(&self, sp: Span, i: int) -> P<ast::Expr>;
|
||||
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr>;
|
||||
fn expr_int(&self, sp: Span, i: isize) -> P<ast::Expr>;
|
||||
fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr>;
|
||||
fn expr_bool(&self, sp: Span, value: bool) -> P<ast::Expr>;
|
||||
|
||||
|
|
@ -579,7 +579,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
fn expr_field_access(&self, sp: Span, expr: P<ast::Expr>, ident: ast::Ident) -> P<ast::Expr> {
|
||||
let field_name = token::get_ident(ident);
|
||||
let field_span = Span {
|
||||
lo: sp.lo - Pos::from_uint(field_name.get().len()),
|
||||
lo: sp.lo - Pos::from_usize(field_name.get().len()),
|
||||
hi: sp.hi,
|
||||
expn_id: sp.expn_id,
|
||||
};
|
||||
|
|
@ -587,9 +587,9 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let id = Spanned { node: ident, span: field_span };
|
||||
self.expr(sp, ast::ExprField(expr, id))
|
||||
}
|
||||
fn expr_tup_field_access(&self, sp: Span, expr: P<ast::Expr>, idx: uint) -> P<ast::Expr> {
|
||||
fn expr_tup_field_access(&self, sp: Span, expr: P<ast::Expr>, idx: usize) -> P<ast::Expr> {
|
||||
let field_span = Span {
|
||||
lo: sp.lo - Pos::from_uint(idx.to_string().len()),
|
||||
lo: sp.lo - Pos::from_usize(idx.to_string().len()),
|
||||
hi: sp.hi,
|
||||
expn_id: sp.expn_id,
|
||||
};
|
||||
|
|
@ -641,10 +641,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P<ast::Expr> {
|
||||
self.expr(sp, ast::ExprLit(P(respan(sp, lit))))
|
||||
}
|
||||
fn expr_uint(&self, span: Span, i: uint) -> P<ast::Expr> {
|
||||
fn expr_usize(&self, span: Span, i: usize) -> P<ast::Expr> {
|
||||
self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs(false))))
|
||||
}
|
||||
fn expr_int(&self, sp: Span, i: int) -> P<ast::Expr> {
|
||||
fn expr_int(&self, sp: Span, i: isize) -> P<ast::Expr> {
|
||||
self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs(false),
|
||||
ast::Sign::new(i))))
|
||||
}
|
||||
|
|
@ -710,7 +710,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
let loc = self.codemap().lookup_char_pos(span.lo);
|
||||
let expr_file = self.expr_str(span,
|
||||
token::intern_and_get_ident(&loc.file.name[]));
|
||||
let expr_line = self.expr_uint(span, loc.line);
|
||||
let expr_line = self.expr_usize(span, loc.line);
|
||||
let expr_file_line_tuple = self.expr_tuple(span, vec!(expr_file, expr_line));
|
||||
let expr_file_line_ptr = self.expr_addr_of(span, expr_file_line_tuple);
|
||||
self.expr_call_global(
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
cx.expr_try(span,
|
||||
cx.expr_method_call(span, blkdecoder.clone(), read_struct_field,
|
||||
vec!(cx.expr_str(span, name),
|
||||
cx.expr_uint(span, field),
|
||||
cx.expr_usize(span, field),
|
||||
exprdecode.clone())))
|
||||
});
|
||||
let result = cx.expr_ok(trait_span, result);
|
||||
|
|
@ -123,7 +123,7 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
cx.ident_of("read_struct"),
|
||||
vec!(
|
||||
cx.expr_str(trait_span, token::get_ident(substr.type_ident)),
|
||||
cx.expr_uint(trait_span, nfields),
|
||||
cx.expr_usize(trait_span, nfields),
|
||||
cx.lambda_expr_1(trait_span, result, blkarg)
|
||||
))
|
||||
}
|
||||
|
|
@ -143,14 +143,14 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
path,
|
||||
parts,
|
||||
|cx, span, _, field| {
|
||||
let idx = cx.expr_uint(span, field);
|
||||
let idx = cx.expr_usize(span, field);
|
||||
cx.expr_try(span,
|
||||
cx.expr_method_call(span, blkdecoder.clone(), rvariant_arg,
|
||||
vec!(idx, exprdecode.clone())))
|
||||
});
|
||||
|
||||
arms.push(cx.arm(v_span,
|
||||
vec!(cx.pat_lit(v_span, cx.expr_uint(v_span, i))),
|
||||
vec!(cx.pat_lit(v_span, cx.expr_usize(v_span, i))),
|
||||
decoded));
|
||||
}
|
||||
|
||||
|
|
@ -179,14 +179,14 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
|
||||
/// Create a decoder for a single enum variant/struct:
|
||||
/// - `outer_pat_path` is the path to this enum variant/struct
|
||||
/// - `getarg` should retrieve the `uint`-th field with name `@str`.
|
||||
/// - `getarg` should retrieve the `usize`-th field with name `@str`.
|
||||
fn decode_static_fields<F>(cx: &mut ExtCtxt,
|
||||
trait_span: Span,
|
||||
outer_pat_path: ast::Path,
|
||||
fields: &StaticFields,
|
||||
mut getarg: F)
|
||||
-> P<Expr> where
|
||||
F: FnMut(&mut ExtCtxt, Span, InternedString, uint) -> P<Expr>,
|
||||
F: FnMut(&mut ExtCtxt, Span, InternedString, usize) -> P<Expr>,
|
||||
{
|
||||
match *fields {
|
||||
Unnamed(ref fields) => {
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur
|
|||
StaticEnum(..) => {
|
||||
cx.span_err(trait_span, "`Default` cannot be derived for enums, only structs");
|
||||
// let compilation continue
|
||||
cx.expr_uint(trait_span, 0)
|
||||
cx.expr_usize(trait_span, 0)
|
||||
}
|
||||
_ => cx.span_bug(trait_span, "Non-static method in `derive(Default)`")
|
||||
};
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
//!
|
||||
//! ```ignore
|
||||
//! #[derive(Encodable, Decodable)]
|
||||
//! struct Node { id: uint }
|
||||
//! struct Node { id: usize }
|
||||
//! ```
|
||||
//!
|
||||
//! would generate two implementations like:
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
//! s.emit_struct("Node", 1, |this| {
|
||||
//! this.emit_struct_field("id", 0, |this| {
|
||||
//! Encodable::encode(&self.id, this)
|
||||
//! /* this.emit_uint(self.id) can also be used */
|
||||
//! /* this.emit_usize(self.id) can also be used */
|
||||
//! })
|
||||
//! })
|
||||
//! }
|
||||
|
|
@ -192,7 +192,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
let call = cx.expr_method_call(span, blkencoder.clone(),
|
||||
emit_struct_field,
|
||||
vec!(cx.expr_str(span, name),
|
||||
cx.expr_uint(span, i),
|
||||
cx.expr_usize(span, i),
|
||||
lambda));
|
||||
|
||||
// last call doesn't need a try!
|
||||
|
|
@ -218,7 +218,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
cx.ident_of("emit_struct"),
|
||||
vec!(
|
||||
cx.expr_str(trait_span, token::get_ident(substr.type_ident)),
|
||||
cx.expr_uint(trait_span, fields.len()),
|
||||
cx.expr_usize(trait_span, fields.len()),
|
||||
blk
|
||||
))
|
||||
}
|
||||
|
|
@ -239,7 +239,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
let lambda = cx.lambda_expr_1(span, enc, blkarg);
|
||||
let call = cx.expr_method_call(span, blkencoder.clone(),
|
||||
emit_variant_arg,
|
||||
vec!(cx.expr_uint(span, i),
|
||||
vec!(cx.expr_usize(span, i),
|
||||
lambda));
|
||||
let call = if i != last {
|
||||
cx.expr_try(span, call)
|
||||
|
|
@ -262,8 +262,8 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
|
|||
let call = cx.expr_method_call(trait_span, blkencoder,
|
||||
cx.ident_of("emit_enum_variant"),
|
||||
vec!(name,
|
||||
cx.expr_uint(trait_span, idx),
|
||||
cx.expr_uint(trait_span, fields.len()),
|
||||
cx.expr_usize(trait_span, idx),
|
||||
cx.expr_usize(trait_span, fields.len()),
|
||||
blk));
|
||||
let blk = cx.lambda_expr_1(trait_span, call, blkarg);
|
||||
let ret = cx.expr_method_call(trait_span,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
//! arguments:
|
||||
//!
|
||||
//! - `Struct`, when `Self` is a struct (including tuple structs, e.g
|
||||
//! `struct T(int, char)`).
|
||||
//! `struct T(i32, char)`).
|
||||
//! - `EnumMatching`, when `Self` is an enum and all the arguments are the
|
||||
//! same variant of the enum (e.g. `Some(1)`, `Some(3)` and `Some(4)`)
|
||||
//! - `EnumNonMatchingCollapsed` when `Self` is an enum and the arguments
|
||||
|
|
@ -54,17 +54,17 @@
|
|||
//! following snippet
|
||||
//!
|
||||
//! ```rust
|
||||
//! struct A { x : int }
|
||||
//! struct A { x : i32 }
|
||||
//!
|
||||
//! struct B(int);
|
||||
//! struct B(i32);
|
||||
//!
|
||||
//! enum C {
|
||||
//! C0(int),
|
||||
//! C1 { x: int }
|
||||
//! C0(i32),
|
||||
//! C1 { x: i32 }
|
||||
//! }
|
||||
//! ```
|
||||
//!
|
||||
//! The `int`s in `B` and `C0` don't have an identifier, so the
|
||||
//! The `i32`s in `B` and `C0` don't have an identifier, so the
|
||||
//! `Option<ident>`s would be `None` for them.
|
||||
//!
|
||||
//! In the static cases, the structure is summarised, either into the just
|
||||
|
|
@ -90,8 +90,8 @@
|
|||
//! trait PartialEq {
|
||||
//! fn eq(&self, other: &Self);
|
||||
//! }
|
||||
//! impl PartialEq for int {
|
||||
//! fn eq(&self, other: &int) -> bool {
|
||||
//! impl PartialEq for i32 {
|
||||
//! fn eq(&self, other: &i32) -> bool {
|
||||
//! *self == *other
|
||||
//! }
|
||||
//! }
|
||||
|
|
@ -117,7 +117,7 @@
|
|||
//!
|
||||
//! ```{.text}
|
||||
//! Struct(vec![FieldInfo {
|
||||
//! span: <span of `int`>,
|
||||
//! span: <span of `i32`>,
|
||||
//! name: None,
|
||||
//! self_: <expr for &a>
|
||||
//! other: vec![<expr for &b>]
|
||||
|
|
@ -132,7 +132,7 @@
|
|||
//! ```{.text}
|
||||
//! EnumMatching(0, <ast::Variant for C0>,
|
||||
//! vec![FieldInfo {
|
||||
//! span: <span of int>
|
||||
//! span: <span of i32>
|
||||
//! name: None,
|
||||
//! self_: <expr for &a>,
|
||||
//! other: vec![<expr for &b>]
|
||||
|
|
@ -179,7 +179,7 @@
|
|||
//! StaticStruct(<ast::StructDef of B>, Unnamed(vec![<span of x>]))
|
||||
//!
|
||||
//! StaticEnum(<ast::EnumDef of C>,
|
||||
//! vec![(<ident of C0>, <span of C0>, Unnamed(vec![<span of int>])),
|
||||
//! vec![(<ident of C0>, <span of C0>, Unnamed(vec![<span of i32>])),
|
||||
//! (<ident of C1>, <span of C1>, Named(vec![(<ident of x>, <span of x>)]))])
|
||||
//! ```
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ pub enum SubstructureFields<'a> {
|
|||
/// Matching variants of the enum: variant index, ast::Variant,
|
||||
/// fields: the field name is only non-`None` in the case of a struct
|
||||
/// variant.
|
||||
EnumMatching(uint, &'a ast::Variant, Vec<FieldInfo>),
|
||||
EnumMatching(usize, &'a ast::Variant, Vec<FieldInfo>),
|
||||
|
||||
/// Non-matching variants of the enum, but with all state hidden from
|
||||
/// the consequent code. The first component holds `Ident`s for all of
|
||||
|
|
@ -719,7 +719,7 @@ impl<'a> MethodDef<'a> {
|
|||
|
||||
/// ```
|
||||
/// #[derive(PartialEq)]
|
||||
/// struct A { x: int, y: int }
|
||||
/// struct A { x: i32, y: i32 }
|
||||
///
|
||||
/// // equivalent to:
|
||||
/// impl PartialEq for A {
|
||||
|
|
@ -748,7 +748,7 @@ impl<'a> MethodDef<'a> {
|
|||
let mut raw_fields = Vec::new(); // ~[[fields of self],
|
||||
// [fields of next Self arg], [etc]]
|
||||
let mut patterns = Vec::new();
|
||||
for i in range(0u, self_args.len()) {
|
||||
for i in range(0us, self_args.len()) {
|
||||
let struct_path= cx.path(DUMMY_SP, vec!( type_ident ));
|
||||
let (pat, ident_expr) =
|
||||
trait_.create_struct_pattern(cx,
|
||||
|
|
@ -825,7 +825,7 @@ impl<'a> MethodDef<'a> {
|
|||
/// #[derive(PartialEq)]
|
||||
/// enum A {
|
||||
/// A1,
|
||||
/// A2(int)
|
||||
/// A2(i32)
|
||||
/// }
|
||||
///
|
||||
/// // is equivalent to
|
||||
|
|
@ -837,8 +837,8 @@ impl<'a> MethodDef<'a> {
|
|||
/// (&A2(ref __self_0),
|
||||
/// &A2(ref __arg_1_0)) => (*__self_0).eq(&(*__arg_1_0)),
|
||||
/// _ => {
|
||||
/// let __self_vi = match *self { A1(..) => 0u, A2(..) => 1u };
|
||||
/// let __arg_1_vi = match *__arg_1 { A1(..) => 0u, A2(..) => 1u };
|
||||
/// let __self_vi = match *self { A1(..) => 0us, A2(..) => 1us };
|
||||
/// let __arg_1_vi = match *__arg_1 { A1(..) => 0us, A2(..) => 1us };
|
||||
/// false
|
||||
/// }
|
||||
/// }
|
||||
|
|
@ -882,8 +882,8 @@ impl<'a> MethodDef<'a> {
|
|||
/// (Variant2, Variant2, Variant2) => ... // delegate Matching on Variant2
|
||||
/// ...
|
||||
/// _ => {
|
||||
/// let __this_vi = match this { Variant1 => 0u, Variant2 => 1u, ... };
|
||||
/// let __that_vi = match that { Variant1 => 0u, Variant2 => 1u, ... };
|
||||
/// let __this_vi = match this { Variant1 => 0us, Variant2 => 1us, ... };
|
||||
/// let __that_vi = match that { Variant1 => 0us, Variant2 => 1us, ... };
|
||||
/// ... // catch-all remainder can inspect above variant index values.
|
||||
/// }
|
||||
/// }
|
||||
|
|
@ -915,7 +915,7 @@ impl<'a> MethodDef<'a> {
|
|||
.collect::<Vec<ast::Ident>>();
|
||||
|
||||
// The `vi_idents` will be bound, solely in the catch-all, to
|
||||
// a series of let statements mapping each self_arg to a uint
|
||||
// a series of let statements mapping each self_arg to a usize
|
||||
// corresponding to its variant index.
|
||||
let vi_idents: Vec<ast::Ident> = self_arg_names.iter()
|
||||
.map(|name| { let vi_suffix = format!("{}_vi", &name[]);
|
||||
|
|
@ -1039,19 +1039,19 @@ impl<'a> MethodDef<'a> {
|
|||
}).collect();
|
||||
|
||||
// Build a series of let statements mapping each self_arg
|
||||
// to a uint corresponding to its variant index.
|
||||
// to a usize corresponding to its variant index.
|
||||
// i.e. for `enum E<T> { A, B(1), C(T, T) }`, and a deriving
|
||||
// with three Self args, builds three statements:
|
||||
//
|
||||
// ```
|
||||
// let __self0_vi = match self {
|
||||
// A => 0u, B(..) => 1u, C(..) => 2u
|
||||
// A => 0us, B(..) => 1us, C(..) => 2us
|
||||
// };
|
||||
// let __self1_vi = match __arg1 {
|
||||
// A => 0u, B(..) => 1u, C(..) => 2u
|
||||
// A => 0us, B(..) => 1us, C(..) => 2us
|
||||
// };
|
||||
// let __self2_vi = match __arg2 {
|
||||
// A => 0u, B(..) => 1u, C(..) => 2u
|
||||
// A => 0us, B(..) => 1us, C(..) => 2us
|
||||
// };
|
||||
// ```
|
||||
let mut index_let_stmts: Vec<P<ast::Stmt>> = Vec::new();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ pub enum PtrTy<'a> {
|
|||
Raw(ast::Mutability),
|
||||
}
|
||||
|
||||
/// A path, e.g. `::std::option::Option::<int>` (global). Has support
|
||||
/// A path, e.g. `::std::option::Option::<i32>` (global). Has support
|
||||
/// for type parameters and a lifetime.
|
||||
#[derive(Clone)]
|
||||
pub struct Path<'a> {
|
||||
|
|
@ -91,7 +91,7 @@ pub enum Ty<'a> {
|
|||
/// &/Box/ Ty
|
||||
Ptr(Box<Ty<'a>>, PtrTy<'a>),
|
||||
/// mod::mod::Type<[lifetime], [Params...]>, including a plain type
|
||||
/// parameter, and things like `int`
|
||||
/// parameter, and things like `i32`
|
||||
Literal(Path<'a>),
|
||||
/// includes unit
|
||||
Tuple(Vec<Ty<'a>> )
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
|
|||
// iteration function.
|
||||
let discriminant = match variant.node.disr_expr {
|
||||
Some(ref d) => d.clone(),
|
||||
None => cx.expr_uint(trait_span, index)
|
||||
None => cx.expr_usize(trait_span, index)
|
||||
};
|
||||
|
||||
stmts.push(call_hash(trait_span, discriminant));
|
||||
|
|
|
|||
|
|
@ -80,10 +80,10 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
|
|||
if variants.is_empty() {
|
||||
cx.span_err(trait_span, "`Rand` cannot be derived for enums with no variants");
|
||||
// let compilation continue
|
||||
return cx.expr_uint(trait_span, 0);
|
||||
return cx.expr_usize(trait_span, 0);
|
||||
}
|
||||
|
||||
let variant_count = cx.expr_uint(trait_span, variants.len());
|
||||
let variant_count = cx.expr_usize(trait_span, variants.len());
|
||||
|
||||
let rand_name = cx.path_all(trait_span,
|
||||
true,
|
||||
|
|
@ -115,7 +115,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
|
|||
variant_count);
|
||||
|
||||
let mut arms = variants.iter().enumerate().map(|(i, &(ident, v_span, ref summary))| {
|
||||
let i_expr = cx.expr_uint(v_span, i);
|
||||
let i_expr = cx.expr_usize(v_span, i);
|
||||
let pat = cx.pat_lit(v_span, i_expr);
|
||||
|
||||
let path = cx.path(v_span, vec![substr.type_ident, ident]);
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
|||
let e = match os::getenv(var.get()) {
|
||||
None => {
|
||||
cx.span_err(sp, msg.get());
|
||||
cx.expr_uint(sp, 0)
|
||||
cx.expr_usize(sp, 0)
|
||||
}
|
||||
Some(s) => cx.expr_str(sp, token::intern_and_get_ident(&s[]))
|
||||
};
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac, span: codemap::Span,
|
|||
// in this file.
|
||||
// Token-tree macros:
|
||||
MacInvocTT(pth, tts, _) => {
|
||||
if pth.segments.len() > 1u {
|
||||
if pth.segments.len() > 1us {
|
||||
fld.cx.span_err(pth.span,
|
||||
"expected macro name without module \
|
||||
separators");
|
||||
|
|
@ -844,7 +844,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
|
|||
},
|
||||
_ => unreachable!()
|
||||
};
|
||||
if pth.segments.len() > 1u {
|
||||
if pth.segments.len() > 1us {
|
||||
fld.cx.span_err(pth.span, "expected macro name without module separators");
|
||||
return DummyResult::raw_pat(span);
|
||||
}
|
||||
|
|
@ -1311,7 +1311,7 @@ fn new_span(cx: &ExtCtxt, sp: Span) -> Span {
|
|||
pub struct ExpansionConfig {
|
||||
pub crate_name: String,
|
||||
pub enable_quotes: bool,
|
||||
pub recursion_limit: uint,
|
||||
pub recursion_limit: usize,
|
||||
}
|
||||
|
||||
impl ExpansionConfig {
|
||||
|
|
@ -1507,7 +1507,7 @@ mod test {
|
|||
#[should_fail]
|
||||
#[test] fn macros_cant_escape_fns_test () {
|
||||
let src = "fn bogus() {macro_rules! z (() => (3+4));}\
|
||||
fn inty() -> int { z!() }".to_string();
|
||||
fn inty() -> i32 { z!() }".to_string();
|
||||
let sess = parse::new_parse_sess();
|
||||
let crate_ast = parse::parse_crate_from_source_str(
|
||||
"<test>".to_string(),
|
||||
|
|
@ -1521,7 +1521,7 @@ mod test {
|
|||
#[should_fail]
|
||||
#[test] fn macros_cant_escape_mods_test () {
|
||||
let src = "mod foo {macro_rules! z (() => (3+4));}\
|
||||
fn inty() -> int { z!() }".to_string();
|
||||
fn inty() -> i32 { z!() }".to_string();
|
||||
let sess = parse::new_parse_sess();
|
||||
let crate_ast = parse::parse_crate_from_source_str(
|
||||
"<test>".to_string(),
|
||||
|
|
@ -1533,7 +1533,7 @@ mod test {
|
|||
// macro_use modules should allow macros to escape
|
||||
#[test] fn macros_can_escape_flattened_mods_test () {
|
||||
let src = "#[macro_use] mod foo {macro_rules! z (() => (3+4));}\
|
||||
fn inty() -> int { z!() }".to_string();
|
||||
fn inty() -> i32 { z!() }".to_string();
|
||||
let sess = parse::new_parse_sess();
|
||||
let crate_ast = parse::parse_crate_from_source_str(
|
||||
"<test>".to_string(),
|
||||
|
|
@ -1564,8 +1564,8 @@ mod test {
|
|||
// should be able to use a bound identifier as a literal in a macro definition:
|
||||
#[test] fn self_macro_parsing(){
|
||||
expand_crate_str(
|
||||
"macro_rules! foo ((zz) => (287u;));
|
||||
fn f(zz : int) {foo!(zz);}".to_string()
|
||||
"macro_rules! foo ((zz) => (287;));
|
||||
fn f(zz: i32) {foo!(zz);}".to_string()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -1595,29 +1595,29 @@ mod test {
|
|||
// in principle, you might want to control this boolean on a per-varref basis,
|
||||
// but that would make things even harder to understand, and might not be
|
||||
// necessary for thorough testing.
|
||||
type RenamingTest = (&'static str, Vec<Vec<uint>>, bool);
|
||||
type RenamingTest = (&'static str, Vec<Vec<usize>>, bool);
|
||||
|
||||
#[test]
|
||||
fn automatic_renaming () {
|
||||
let tests: Vec<RenamingTest> =
|
||||
vec!(// b & c should get new names throughout, in the expr too:
|
||||
("fn a() -> int { let b = 13; let c = b; b+c }",
|
||||
("fn a() -> i32 { let b = 13; let c = b; b+c }",
|
||||
vec!(vec!(0,1),vec!(2)), false),
|
||||
// both x's should be renamed (how is this causing a bug?)
|
||||
("fn main () {let x: int = 13;x;}",
|
||||
("fn main () {let x: i32 = 13;x;}",
|
||||
vec!(vec!(0)), false),
|
||||
// the use of b after the + should be renamed, the other one not:
|
||||
("macro_rules! f (($x:ident) => (b + $x)); fn a() -> int { let b = 13; f!(b)}",
|
||||
("macro_rules! f (($x:ident) => (b + $x)); fn a() -> i32 { let b = 13; f!(b)}",
|
||||
vec!(vec!(1)), false),
|
||||
// the b before the plus should not be renamed (requires marks)
|
||||
("macro_rules! f (($x:ident) => ({let b=9; ($x + b)})); fn a() -> int { f!(b)}",
|
||||
("macro_rules! f (($x:ident) => ({let b=9; ($x + b)})); fn a() -> i32 { f!(b)}",
|
||||
vec!(vec!(1)), false),
|
||||
// the marks going in and out of letty should cancel, allowing that $x to
|
||||
// capture the one following the semicolon.
|
||||
// this was an awesome test case, and caught a *lot* of bugs.
|
||||
("macro_rules! letty(($x:ident) => (let $x = 15;));
|
||||
macro_rules! user(($x:ident) => ({letty!($x); $x}));
|
||||
fn main() -> int {user!(z)}",
|
||||
fn main() -> i32 {user!(z)}",
|
||||
vec!(vec!(0)), false)
|
||||
);
|
||||
for (idx,s) in tests.iter().enumerate() {
|
||||
|
|
@ -1680,13 +1680,13 @@ mod test {
|
|||
// can't write this test case until we have macro-generating macros.
|
||||
|
||||
// method arg hygiene
|
||||
// method expands to fn get_x(&self_0, x_1:int) {self_0 + self_2 + x_3 + x_1}
|
||||
// method expands to fn get_x(&self_0, x_1: i32) {self_0 + self_2 + x_3 + x_1}
|
||||
#[test] fn method_arg_hygiene(){
|
||||
run_renaming_test(
|
||||
&("macro_rules! inject_x (()=>(x));
|
||||
macro_rules! inject_self (()=>(self));
|
||||
struct A;
|
||||
impl A{fn get_x(&self, x: int) {self + inject_self!() + inject_x!() + x;} }",
|
||||
impl A{fn get_x(&self, x: i32) {self + inject_self!() + inject_x!() + x;} }",
|
||||
vec!(vec!(0),vec!(3)),
|
||||
true),
|
||||
0)
|
||||
|
|
@ -1706,21 +1706,21 @@ mod test {
|
|||
}
|
||||
|
||||
// item fn hygiene
|
||||
// expands to fn q(x_1:int){fn g(x_2:int){x_2 + x_1};}
|
||||
// expands to fn q(x_1: i32){fn g(x_2: i32){x_2 + x_1};}
|
||||
#[test] fn issue_9383(){
|
||||
run_renaming_test(
|
||||
&("macro_rules! bad_macro (($ex:expr) => (fn g(x:int){ x + $ex }));
|
||||
fn q(x:int) { bad_macro!(x); }",
|
||||
&("macro_rules! bad_macro (($ex:expr) => (fn g(x: i32){ x + $ex }));
|
||||
fn q(x: i32) { bad_macro!(x); }",
|
||||
vec!(vec!(1),vec!(0)),true),
|
||||
0)
|
||||
}
|
||||
|
||||
// closure arg hygiene (ExprClosure)
|
||||
// expands to fn f(){(|x_1 : int| {(x_2 + x_1)})(3);}
|
||||
// expands to fn f(){(|x_1 : i32| {(x_2 + x_1)})(3);}
|
||||
#[test] fn closure_arg_hygiene(){
|
||||
run_renaming_test(
|
||||
&("macro_rules! inject_x (()=>(x));
|
||||
fn f(){(|x : int| {(inject_x!() + x)})(3);}",
|
||||
fn f(){(|x : i32| {(inject_x!() + x)})(3);}",
|
||||
vec!(vec!(1)),
|
||||
true),
|
||||
0)
|
||||
|
|
@ -1729,7 +1729,7 @@ mod test {
|
|||
// macro_rules in method position. Sadly, unimplemented.
|
||||
#[test] fn macro_in_method_posn(){
|
||||
expand_crate_str(
|
||||
"macro_rules! my_method (() => (fn thirteen(&self) -> int {13}));
|
||||
"macro_rules! my_method (() => (fn thirteen(&self) -> i32 {13}));
|
||||
struct A;
|
||||
impl A{ my_method!(); }
|
||||
fn f(){A.thirteen;}".to_string());
|
||||
|
|
@ -1749,7 +1749,7 @@ mod test {
|
|||
}
|
||||
|
||||
// run one of the renaming tests
|
||||
fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
|
||||
fn run_renaming_test(t: &RenamingTest, test_idx: usize) {
|
||||
let invalid_name = token::special_idents::invalid.name;
|
||||
let (teststr, bound_connections, bound_ident_check) = match *t {
|
||||
(ref str,ref conns, bic) => (str.to_string(), conns.clone(), bic)
|
||||
|
|
@ -1876,7 +1876,7 @@ foo_module!();
|
|||
// it's the name of a 0-ary variant, and that 'i' appears twice in succession.
|
||||
#[test]
|
||||
fn crate_bindings_test(){
|
||||
let the_crate = string_to_crate("fn main (a : int) -> int {|b| {
|
||||
let the_crate = string_to_crate("fn main (a: i32) -> i32 {|b| {
|
||||
match 34 {None => 3, Some(i) | i => j, Foo{k:z,l:y} => \"banana\"}} }".to_string());
|
||||
let idents = crate_bindings(&the_crate);
|
||||
assert_eq!(idents, strs_to_idents(vec!("a","b","None","i","i","z","y")));
|
||||
|
|
@ -1885,10 +1885,10 @@ foo_module!();
|
|||
// test the IdentRenamer directly
|
||||
#[test]
|
||||
fn ident_renamer_test () {
|
||||
let the_crate = string_to_crate("fn f(x : int){let x = x; x}".to_string());
|
||||
let the_crate = string_to_crate("fn f(x: i32){let x = x; x}".to_string());
|
||||
let f_ident = token::str_to_ident("f");
|
||||
let x_ident = token::str_to_ident("x");
|
||||
let int_ident = token::str_to_ident("int");
|
||||
let int_ident = token::str_to_ident("i32");
|
||||
let renames = vec!((x_ident,Name(16)));
|
||||
let mut renamer = IdentRenamer{renames: &renames};
|
||||
let renamed_crate = renamer.fold_crate(the_crate);
|
||||
|
|
@ -1900,10 +1900,10 @@ foo_module!();
|
|||
// test the PatIdentRenamer; only PatIdents get renamed
|
||||
#[test]
|
||||
fn pat_ident_renamer_test () {
|
||||
let the_crate = string_to_crate("fn f(x : int){let x = x; x}".to_string());
|
||||
let the_crate = string_to_crate("fn f(x: i32){let x = x; x}".to_string());
|
||||
let f_ident = token::str_to_ident("f");
|
||||
let x_ident = token::str_to_ident("x");
|
||||
let int_ident = token::str_to_ident("int");
|
||||
let int_ident = token::str_to_ident("i32");
|
||||
let renames = vec!((x_ident,Name(16)));
|
||||
let mut renamer = PatIdentRenamer{renames: &renames};
|
||||
let renamed_crate = renamer.fold_crate(the_crate);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ enum ArgumentType {
|
|||
}
|
||||
|
||||
enum Position {
|
||||
Exact(uint),
|
||||
Exact(usize),
|
||||
Named(String),
|
||||
}
|
||||
|
||||
|
|
@ -61,11 +61,11 @@ struct Context<'a, 'b:'a> {
|
|||
/// Stays `true` if all formatting parameters are default (as in "{}{}").
|
||||
all_pieces_simple: bool,
|
||||
|
||||
name_positions: HashMap<String, uint>,
|
||||
name_positions: HashMap<String, usize>,
|
||||
|
||||
/// Updated as arguments are consumed or methods are entered
|
||||
nest_level: uint,
|
||||
next_arg: uint,
|
||||
nest_level: usize,
|
||||
next_arg: usize,
|
||||
}
|
||||
|
||||
/// Parses the arguments from the given list of tokens, returning None
|
||||
|
|
@ -326,11 +326,11 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
match c {
|
||||
parse::CountIs(i) => {
|
||||
self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "CountIs"),
|
||||
vec!(self.ecx.expr_uint(sp, i)))
|
||||
vec!(self.ecx.expr_usize(sp, i)))
|
||||
}
|
||||
parse::CountIsParam(i) => {
|
||||
self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "CountIsParam"),
|
||||
vec!(self.ecx.expr_uint(sp, i)))
|
||||
vec!(self.ecx.expr_usize(sp, i)))
|
||||
}
|
||||
parse::CountImplied => {
|
||||
let path = self.ecx.path_global(sp, Context::rtpath(self.ecx,
|
||||
|
|
@ -349,7 +349,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
};
|
||||
let i = i + self.args.len();
|
||||
self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "CountIsParam"),
|
||||
vec!(self.ecx.expr_uint(sp, i)))
|
||||
vec!(self.ecx.expr_usize(sp, i)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -382,7 +382,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
}
|
||||
parse::ArgumentIs(i) => {
|
||||
self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "ArgumentIs"),
|
||||
vec!(self.ecx.expr_uint(sp, i)))
|
||||
vec!(self.ecx.expr_usize(sp, i)))
|
||||
}
|
||||
// Named arguments are converted to positional arguments at
|
||||
// the end of the list of arguments
|
||||
|
|
@ -393,7 +393,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
};
|
||||
let i = i + self.args.len();
|
||||
self.ecx.expr_call_global(sp, Context::rtpath(self.ecx, "ArgumentIs"),
|
||||
vec!(self.ecx.expr_uint(sp, i)))
|
||||
vec!(self.ecx.expr_usize(sp, i)))
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -432,7 +432,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
|||
}
|
||||
};
|
||||
let align = self.ecx.expr_path(align);
|
||||
let flags = self.ecx.expr_uint(sp, arg.format.flags);
|
||||
let flags = self.ecx.expr_usize(sp, arg.format.flags);
|
||||
let prec = self.trans_count(arg.format.precision);
|
||||
let width = self.trans_count(arg.format.width);
|
||||
let path = self.ecx.path_global(sp, Context::rtpath(self.ecx, "FormatSpec"));
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ fn resolve_internal(id: Ident,
|
|||
}
|
||||
|
||||
let resolved = {
|
||||
let result = (*table.table.borrow())[id.ctxt as uint];
|
||||
let result = (*table.table.borrow())[id.ctxt as usize];
|
||||
match result {
|
||||
EmptyCtxt => id.name,
|
||||
// ignore marks here:
|
||||
|
|
@ -231,7 +231,7 @@ fn marksof_internal(ctxt: SyntaxContext,
|
|||
let mut result = Vec::new();
|
||||
let mut loopvar = ctxt;
|
||||
loop {
|
||||
let table_entry = (*table.table.borrow())[loopvar as uint];
|
||||
let table_entry = (*table.table.borrow())[loopvar as usize];
|
||||
match table_entry {
|
||||
EmptyCtxt => {
|
||||
return result;
|
||||
|
|
@ -258,7 +258,7 @@ fn marksof_internal(ctxt: SyntaxContext,
|
|||
/// FAILS when outside is not a mark.
|
||||
pub fn outer_mark(ctxt: SyntaxContext) -> Mrk {
|
||||
with_sctable(|sctable| {
|
||||
match (*sctable.table.borrow())[ctxt as uint] {
|
||||
match (*sctable.table.borrow())[ctxt as usize] {
|
||||
Mark(mrk, _) => mrk,
|
||||
_ => panic!("can't retrieve outer mark when outside is not a mark")
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ mod tests {
|
|||
let mut result = Vec::new();
|
||||
loop {
|
||||
let table = table.table.borrow();
|
||||
match (*table)[sc as uint] {
|
||||
match (*table)[sc as usize] {
|
||||
EmptyCtxt => {return result;},
|
||||
Mark(mrk,tail) => {
|
||||
result.push(M(mrk));
|
||||
|
|
@ -398,7 +398,7 @@ mod tests {
|
|||
assert_eq! (marksof_internal (ans, stopname,&t), vec!(16));}
|
||||
// rename where stop doesn't match:
|
||||
{ let chain = vec!(M(9),
|
||||
R(id(name1.uint() as u32,
|
||||
R(id(name1.usize() as u32,
|
||||
apply_mark_internal (4, EMPTY_CTXT,&mut t)),
|
||||
Name(100101102)),
|
||||
M(14));
|
||||
|
|
@ -407,7 +407,7 @@ mod tests {
|
|||
// rename where stop does match
|
||||
{ let name1sc = apply_mark_internal(4, EMPTY_CTXT, &mut t);
|
||||
let chain = vec!(M(9),
|
||||
R(id(name1.uint() as u32, name1sc),
|
||||
R(id(name1.usize() as u32, name1sc),
|
||||
stopname),
|
||||
M(14));
|
||||
let ans = unfold_test_sc(chain,EMPTY_CTXT,&mut t);
|
||||
|
|
|
|||
|
|
@ -588,7 +588,7 @@ fn mk_token(cx: &ExtCtxt, sp: Span, tok: &token::Token) -> P<ast::Expr> {
|
|||
}
|
||||
|
||||
token::Literal(token::StrRaw(ident, n), suf) => {
|
||||
return mk_lit!("StrRaw", suf, mk_name(cx, sp, ident.ident()), cx.expr_uint(sp, n))
|
||||
return mk_lit!("StrRaw", suf, mk_name(cx, sp, ident.ident()), cx.expr_usize(sp, n))
|
||||
}
|
||||
|
||||
token::Ident(ident, style) => {
|
||||
|
|
@ -716,7 +716,7 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
|||
// try removing it when enough of them are gone.
|
||||
|
||||
let mut p = cx.new_parser_from_tts(tts);
|
||||
p.quote_depth += 1u;
|
||||
p.quote_depth += 1us;
|
||||
|
||||
let cx_expr = p.parse_expr();
|
||||
if !p.eat(&token::Comma) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ pub fn expand_line(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
|||
let topmost = cx.original_span_in_file();
|
||||
let loc = cx.codemap().lookup_char_pos(topmost.lo);
|
||||
|
||||
base::MacExpr::new(cx.expr_uint(topmost, loc.line))
|
||||
base::MacExpr::new(cx.expr_usize(topmost, loc.line))
|
||||
}
|
||||
|
||||
/* column!(): expands to the current column number */
|
||||
|
|
@ -45,7 +45,7 @@ pub fn expand_column(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
|||
|
||||
let topmost = cx.original_span_in_file();
|
||||
let loc = cx.codemap().lookup_char_pos(topmost.lo);
|
||||
base::MacExpr::new(cx.expr_uint(topmost, loc.col.to_uint()))
|
||||
base::MacExpr::new(cx.expr_usize(topmost, loc.col.to_usize()))
|
||||
}
|
||||
|
||||
/// file!(): expands to the current filename */
|
||||
|
|
|
|||
|
|
@ -110,14 +110,14 @@ enum TokenTreeOrTokenTreeVec {
|
|||
}
|
||||
|
||||
impl TokenTreeOrTokenTreeVec {
|
||||
fn len(&self) -> uint {
|
||||
fn len(&self) -> usize {
|
||||
match self {
|
||||
&TtSeq(ref v) => v.len(),
|
||||
&Tt(ref tt) => tt.len(),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_tt(&self, index: uint) -> TokenTree {
|
||||
fn get_tt(&self, index: usize) -> TokenTree {
|
||||
match self {
|
||||
&TtSeq(ref v) => v[index].clone(),
|
||||
&Tt(ref tt) => tt.get_tt(index),
|
||||
|
|
@ -129,7 +129,7 @@ impl TokenTreeOrTokenTreeVec {
|
|||
#[derive(Clone)]
|
||||
struct MatcherTtFrame {
|
||||
elts: TokenTreeOrTokenTreeVec,
|
||||
idx: uint,
|
||||
idx: usize,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
@ -137,16 +137,16 @@ pub struct MatcherPos {
|
|||
stack: Vec<MatcherTtFrame>,
|
||||
top_elts: TokenTreeOrTokenTreeVec,
|
||||
sep: Option<Token>,
|
||||
idx: uint,
|
||||
idx: usize,
|
||||
up: Option<Box<MatcherPos>>,
|
||||
matches: Vec<Vec<Rc<NamedMatch>>>,
|
||||
match_lo: uint,
|
||||
match_cur: uint,
|
||||
match_hi: uint,
|
||||
match_lo: usize,
|
||||
match_cur: usize,
|
||||
match_hi: usize,
|
||||
sp_lo: BytePos,
|
||||
}
|
||||
|
||||
pub fn count_names(ms: &[TokenTree]) -> uint {
|
||||
pub fn count_names(ms: &[TokenTree]) -> usize {
|
||||
ms.iter().fold(0, |count, elt| {
|
||||
count + match elt {
|
||||
&TtSequence(_, ref seq) => {
|
||||
|
|
@ -171,11 +171,11 @@ pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: ByteP
|
|||
stack: vec![],
|
||||
top_elts: TtSeq(ms),
|
||||
sep: sep,
|
||||
idx: 0u,
|
||||
idx: 0us,
|
||||
up: None,
|
||||
matches: matches,
|
||||
match_lo: 0u,
|
||||
match_cur: 0u,
|
||||
match_lo: 0us,
|
||||
match_cur: 0us,
|
||||
match_hi: match_idx_hi,
|
||||
sp_lo: lo
|
||||
}
|
||||
|
|
@ -206,7 +206,7 @@ pub enum NamedMatch {
|
|||
pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>])
|
||||
-> HashMap<Ident, Rc<NamedMatch>> {
|
||||
fn n_rec(p_s: &ParseSess, m: &TokenTree, res: &[Rc<NamedMatch>],
|
||||
ret_val: &mut HashMap<Ident, Rc<NamedMatch>>, idx: &mut uint) {
|
||||
ret_val: &mut HashMap<Ident, Rc<NamedMatch>>, idx: &mut usize) {
|
||||
match m {
|
||||
&TtSequence(_, ref seq) => {
|
||||
for next_m in seq.tts.iter() {
|
||||
|
|
@ -238,7 +238,7 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>])
|
|||
}
|
||||
}
|
||||
let mut ret_val = HashMap::new();
|
||||
let mut idx = 0u;
|
||||
let mut idx = 0us;
|
||||
for m in ms.iter() { n_rec(p_s, m, res, &mut ret_val, &mut idx) }
|
||||
ret_val
|
||||
}
|
||||
|
|
@ -383,7 +383,7 @@ pub fn parse(sess: &ParseSess,
|
|||
if seq.op == ast::ZeroOrMore {
|
||||
let mut new_ei = ei.clone();
|
||||
new_ei.match_cur += seq.num_captures;
|
||||
new_ei.idx += 1u;
|
||||
new_ei.idx += 1us;
|
||||
//we specifically matched zero repeats.
|
||||
for idx in range(ei.match_cur, ei.match_cur + seq.num_captures) {
|
||||
(&mut new_ei.matches[idx]).push(Rc::new(MatchedSeq(vec![], sp)));
|
||||
|
|
@ -398,7 +398,7 @@ pub fn parse(sess: &ParseSess,
|
|||
cur_eis.push(box MatcherPos {
|
||||
stack: vec![],
|
||||
sep: seq.separator.clone(),
|
||||
idx: 0u,
|
||||
idx: 0us,
|
||||
matches: matches,
|
||||
match_lo: ei_t.match_cur,
|
||||
match_cur: ei_t.match_cur,
|
||||
|
|
@ -442,20 +442,20 @@ pub fn parse(sess: &ParseSess,
|
|||
|
||||
/* error messages here could be improved with links to orig. rules */
|
||||
if token_name_eq(&tok, &token::Eof) {
|
||||
if eof_eis.len() == 1u {
|
||||
if eof_eis.len() == 1us {
|
||||
let mut v = Vec::new();
|
||||
for dv in (&mut eof_eis[0]).matches.iter_mut() {
|
||||
v.push(dv.pop().unwrap());
|
||||
}
|
||||
return Success(nameize(sess, ms, &v[]));
|
||||
} else if eof_eis.len() > 1u {
|
||||
} else if eof_eis.len() > 1us {
|
||||
return Error(sp, "ambiguity: multiple successful parses".to_string());
|
||||
} else {
|
||||
return Failure(sp, "unexpected end of macro invocation".to_string());
|
||||
}
|
||||
} else {
|
||||
if (bb_eis.len() > 0u && next_eis.len() > 0u)
|
||||
|| bb_eis.len() > 1u {
|
||||
if (bb_eis.len() > 0us && next_eis.len() > 0us)
|
||||
|| bb_eis.len() > 1us {
|
||||
let nts = bb_eis.iter().map(|ei| {
|
||||
match ei.top_elts.get_tt(ei.idx) {
|
||||
TtToken(_, MatchNt(bind, name, _, _)) => {
|
||||
|
|
@ -469,12 +469,12 @@ pub fn parse(sess: &ParseSess,
|
|||
"local ambiguity: multiple parsing options: \
|
||||
built-in NTs {} or {} other options.",
|
||||
nts, next_eis.len()).to_string());
|
||||
} else if bb_eis.len() == 0u && next_eis.len() == 0u {
|
||||
} else if bb_eis.len() == 0us && next_eis.len() == 0us {
|
||||
return Failure(sp, format!("no rules expected the token `{}`",
|
||||
pprust::token_to_string(&tok)).to_string());
|
||||
} else if next_eis.len() > 0u {
|
||||
} else if next_eis.len() > 0us {
|
||||
/* Now process the next token */
|
||||
while next_eis.len() > 0u {
|
||||
while next_eis.len() > 0us {
|
||||
cur_eis.push(next_eis.pop().unwrap());
|
||||
}
|
||||
rdr.next_token();
|
||||
|
|
@ -488,7 +488,7 @@ pub fn parse(sess: &ParseSess,
|
|||
let match_cur = ei.match_cur;
|
||||
(&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal(
|
||||
parse_nt(&mut rust_parser, name_string.get()))));
|
||||
ei.idx += 1u;
|
||||
ei.idx += 1us;
|
||||
ei.match_cur += 1;
|
||||
}
|
||||
_ => panic!()
|
||||
|
|
@ -501,16 +501,16 @@ pub fn parse(sess: &ParseSess,
|
|||
}
|
||||
}
|
||||
|
||||
assert!(cur_eis.len() > 0u);
|
||||
assert!(cur_eis.len() > 0us);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal {
|
||||
match name {
|
||||
"tt" => {
|
||||
p.quote_depth += 1u; //but in theory, non-quoted tts might be useful
|
||||
p.quote_depth += 1us; //but in theory, non-quoted tts might be useful
|
||||
let res = token::NtTT(P(p.parse_token_tree()));
|
||||
p.quote_depth -= 1u;
|
||||
p.quote_depth -= 1us;
|
||||
return res;
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use std::collections::HashMap;
|
|||
#[derive(Clone)]
|
||||
struct TtFrame {
|
||||
forest: TokenTree,
|
||||
idx: uint,
|
||||
idx: usize,
|
||||
dotdotdoted: bool,
|
||||
sep: Option<Token>,
|
||||
}
|
||||
|
|
@ -43,8 +43,8 @@ pub struct TtReader<'a> {
|
|||
|
||||
// Some => return imported_from as the next token
|
||||
crate_name_next: Option<Span>,
|
||||
repeat_idx: Vec<uint>,
|
||||
repeat_len: Vec<uint>,
|
||||
repeat_idx: Vec<usize>,
|
||||
repeat_len: Vec<usize>,
|
||||
/* cached: */
|
||||
pub cur_tok: Token,
|
||||
pub cur_span: Span,
|
||||
|
|
@ -124,7 +124,7 @@ fn lookup_cur_matched(r: &TtReader, name: Ident) -> Option<Rc<NamedMatch>> {
|
|||
#[derive(Clone)]
|
||||
enum LockstepIterSize {
|
||||
LisUnconstrained,
|
||||
LisConstraint(uint, Ident),
|
||||
LisConstraint(usize, Ident),
|
||||
LisContradiction(String),
|
||||
}
|
||||
|
||||
|
|
@ -223,7 +223,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
|
|||
r.repeat_len.pop();
|
||||
}
|
||||
} else { /* repeat */
|
||||
*r.repeat_idx.last_mut().unwrap() += 1u;
|
||||
*r.repeat_idx.last_mut().unwrap() += 1us;
|
||||
r.stack.last_mut().unwrap().idx = 0;
|
||||
match r.stack.last().unwrap().sep.clone() {
|
||||
Some(tk) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue