From 067284b2917561f5bff1db4c521347d897dcaf3b Mon Sep 17 00:00:00 2001 From: Wang Xuerui Date: Mon, 16 May 2016 16:59:27 +0800 Subject: [PATCH 1/2] syntax_ext: format: nest_level's are no more `nest_level` is long dead since cac7a2053aba7be214d5e58e13867089638a8f50 (PR #14831), so is `check_positional_ok()`. Let's bid them farewell. --- src/libsyntax_ext/format.rs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 6c61d6b914c56..7d57614fd7982 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -68,7 +68,6 @@ struct Context<'a, 'b:'a> { name_positions: HashMap, /// Updated as arguments are consumed or methods are entered - nest_level: usize, next_arg: usize, } @@ -164,9 +163,7 @@ impl<'a, 'b> Context<'a, 'b> { let pos = match arg.position { parse::ArgumentNext => { let i = self.next_arg; - if self.check_positional_ok() { - self.next_arg += 1; - } + self.next_arg += 1; Exact(i) } parse::ArgumentIs(i) => Exact(i), @@ -189,25 +186,13 @@ impl<'a, 'b> Context<'a, 'b> { self.verify_arg_type(Named(s.to_string()), Unsigned); } parse::CountIsNextParam => { - if self.check_positional_ok() { - let next_arg = self.next_arg; - self.verify_arg_type(Exact(next_arg), Unsigned); - self.next_arg += 1; - } + let next_arg = self.next_arg; + self.verify_arg_type(Exact(next_arg), Unsigned); + self.next_arg += 1; } } } - fn check_positional_ok(&mut self) -> bool { - if self.nest_level != 0 { - self.ecx.span_err(self.fmtsp, "cannot use implicit positional \ - arguments nested inside methods"); - false - } else { - true - } - } - fn describe_num_args(&self) -> String { match self.args.len() { 0 => "no arguments given".to_string(), @@ -655,7 +640,6 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, name_positions: HashMap::new(), name_types: HashMap::new(), name_ordering: name_ordering, - nest_level: 0, next_arg: 0, literal: String::new(), pieces: Vec::new(), From 2ea6c70a1ad43ae8af0e108ddcee4fc06ea9c77c Mon Sep 17 00:00:00 2001 From: Wang Xuerui Date: Mon, 16 May 2016 17:16:32 +0800 Subject: [PATCH 2/2] syntax_ext: format: remove reference to methods in comment --- src/libsyntax_ext/format.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 7d57614fd7982..abfa65580646d 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -67,7 +67,7 @@ struct Context<'a, 'b:'a> { name_positions: HashMap, - /// Updated as arguments are consumed or methods are entered + /// Updated as arguments are consumed next_arg: usize, }