Skip to content

Commit 479c4be

Browse files
committed
Rollup merge of rust-lang#33666 - xen0n:no-more-nest-levels, r=nikomatsakis
syntax_ext: format: nest_level's are no more Just noticed this while working on rust-lang#33642 and here's a quick fix, shouldn't touch anything else. It's some historic code indeed...
2 parents 9a5104d + 2ea6c70 commit 479c4be

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

src/libsyntax_ext/format.rs

+5-21
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ struct Context<'a, 'b:'a> {
6767

6868
name_positions: HashMap<String, usize>,
6969

70-
/// Updated as arguments are consumed or methods are entered
71-
nest_level: usize,
70+
/// Updated as arguments are consumed
7271
next_arg: usize,
7372
}
7473

@@ -164,9 +163,7 @@ impl<'a, 'b> Context<'a, 'b> {
164163
let pos = match arg.position {
165164
parse::ArgumentNext => {
166165
let i = self.next_arg;
167-
if self.check_positional_ok() {
168-
self.next_arg += 1;
169-
}
166+
self.next_arg += 1;
170167
Exact(i)
171168
}
172169
parse::ArgumentIs(i) => Exact(i),
@@ -189,25 +186,13 @@ impl<'a, 'b> Context<'a, 'b> {
189186
self.verify_arg_type(Named(s.to_string()), Unsigned);
190187
}
191188
parse::CountIsNextParam => {
192-
if self.check_positional_ok() {
193-
let next_arg = self.next_arg;
194-
self.verify_arg_type(Exact(next_arg), Unsigned);
195-
self.next_arg += 1;
196-
}
189+
let next_arg = self.next_arg;
190+
self.verify_arg_type(Exact(next_arg), Unsigned);
191+
self.next_arg += 1;
197192
}
198193
}
199194
}
200195

201-
fn check_positional_ok(&mut self) -> bool {
202-
if self.nest_level != 0 {
203-
self.ecx.span_err(self.fmtsp, "cannot use implicit positional \
204-
arguments nested inside methods");
205-
false
206-
} else {
207-
true
208-
}
209-
}
210-
211196
fn describe_num_args(&self) -> String {
212197
match self.args.len() {
213198
0 => "no arguments given".to_string(),
@@ -655,7 +640,6 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span,
655640
name_positions: HashMap::new(),
656641
name_types: HashMap::new(),
657642
name_ordering: name_ordering,
658-
nest_level: 0,
659643
next_arg: 0,
660644
literal: String::new(),
661645
pieces: Vec::new(),

0 commit comments

Comments
 (0)