diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-09-11 17:07:49 +1200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-09-19 15:11:00 +1200 |
| commit | ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7 (patch) | |
| tree | 9ea529bfee7d62b85288d37b0e2bbcdd1c866e0d /src/libsyntax/ext/format.rs | |
| parent | af3889f6979647b9bd2dc5f5132d80e3e5b405a5 (diff) | |
| download | rust-ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7.tar.gz rust-ce0907e46e8e1aa23ee39f69e4f628f68bfbb0d7.zip | |
Add enum variants to the type namespace
Change to resolve and update compiler and libs for uses. [breaking-change] Enum variants are now in both the value and type namespaces. This means that if you have a variant with the same name as a type in scope in a module, you will get a name clash and thus an error. The solution is to either rename the type or the variant.
Diffstat (limited to 'src/libsyntax/ext/format.rs')
| -rw-r--r-- | src/libsyntax/ext/format.rs | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 26586684309..b760c893a10 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -19,17 +19,18 @@ use parse::token; use ptr::P; use std::collections::HashMap; +use std::string; #[deriving(PartialEq)] enum ArgumentType { - Known(String), + Known(string::String), Unsigned, String, } enum Position { Exact(uint), - Named(String), + Named(string::String), } struct Context<'a, 'b:'a> { @@ -44,12 +45,12 @@ struct Context<'a, 'b:'a> { /// Note that we keep a side-array of the ordering of the named arguments /// found to be sure that we can translate them in the same order that they /// were declared in. - names: HashMap<String, P<ast::Expr>>, - name_types: HashMap<String, ArgumentType>, - name_ordering: Vec<String>, + names: HashMap<string::String, P<ast::Expr>>, + name_types: HashMap<string::String, ArgumentType>, + name_ordering: Vec<string::String>, /// The latest consecutive literal strings, or empty if there weren't any. - literal: String, + literal: string::String, /// Collection of the compiled `rt::Argument` structures pieces: Vec<P<ast::Expr>>, @@ -58,7 +59,7 @@ 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::String, uint>, method_statics: Vec<P<ast::Item>>, /// Updated as arguments are consumed or methods are entered @@ -81,10 +82,10 @@ pub enum Invocation { /// named arguments)) fn parse_args(ecx: &mut ExtCtxt, sp: Span, allow_method: bool, tts: &[ast::TokenTree]) - -> (Invocation, Option<(P<ast::Expr>, Vec<P<ast::Expr>>, Vec<String>, - HashMap<String, P<ast::Expr>>)>) { + -> (Invocation, Option<(P<ast::Expr>, Vec<P<ast::Expr>>, Vec<string::String>, + HashMap<string::String, P<ast::Expr>>)>) { let mut args = Vec::new(); - let mut names = HashMap::<String, P<ast::Expr>>::new(); + let mut names = HashMap::<string::String, P<ast::Expr>>::new(); let mut order = Vec::new(); let mut p = ecx.new_parser_from_tts(tts); @@ -167,7 +168,7 @@ impl<'a, 'b> Context<'a, 'b> { fn verify_piece(&mut self, p: &parse::Piece) { match *p { parse::String(..) => {} - parse::Argument(ref arg) => { + parse::NextArgument(ref arg) => { // width/precision first, if they have implicit positional // parameters it makes more sense to consume them first. self.verify_count(arg.format.width); @@ -222,7 +223,7 @@ impl<'a, 'b> Context<'a, 'b> { } } - fn describe_num_args(&self) -> String { + fn describe_num_args(&self) -> string::String { match self.args.len() { 0 => "no arguments given".to_string(), 1 => "there is 1 argument".to_string(), @@ -391,7 +392,7 @@ impl<'a, 'b> Context<'a, 'b> { self.literal.push_str(s); None } - parse::Argument(ref arg) => { + parse::NextArgument(ref arg) => { // Translate the position let pos = match arg.position { // These two have a direct mapping @@ -747,8 +748,8 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, invocation: Invocation, efmt: P<ast::Expr>, args: Vec<P<ast::Expr>>, - name_ordering: Vec<String>, - names: HashMap<String, P<ast::Expr>>) + name_ordering: Vec<string::String>, + names: HashMap<string::String, P<ast::Expr>>) -> P<ast::Expr> { let arg_types = Vec::from_fn(args.len(), |_| None); let mut cx = Context { @@ -761,7 +762,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, name_ordering: name_ordering, nest_level: 0, next_arg: 0, - literal: String::new(), + literal: string::String::new(), pieces: Vec::new(), str_pieces: Vec::new(), all_pieces_simple: true, |
