Skip to content

Commit

Permalink
Drop args from Formatter
Browse files Browse the repository at this point in the history
These are no longer used by Formatter methods.
  • Loading branch information
Mark-Simulacrum committed Jan 20, 2020
1 parent 4919b96 commit 9ae32c9
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/libcore/fmt/mod.rs
Expand Up @@ -233,7 +233,6 @@ pub struct Formatter<'a> {
precision: Option<usize>,

buf: &'a mut (dyn Write + 'a),
args: &'a [ArgumentV1<'a>],
}

// NB. Argument is essentially an optimized partially applied formatting function,
Expand Down Expand Up @@ -1041,7 +1040,6 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
buf: output,
align: rt::v1::Alignment::Unknown,
fill: ' ',
args: args.args,
};

let mut idx = 0;
Expand All @@ -1060,7 +1058,7 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
// a string piece.
for (arg, piece) in fmt.iter().zip(args.pieces.iter()) {
formatter.buf.write_str(*piece)?;
run(&mut formatter, arg)?;
run(&mut formatter, arg, &args.args)?;
idx += 1;
}
}
Expand All @@ -1074,25 +1072,24 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
Ok(())
}

fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument) -> Result {
// Fill in the format parameters into the formatter
fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument, args: &[ArgumentV1<'_>]) -> Result {
fmt.fill = arg.format.fill;
fmt.align = arg.format.align;
fmt.flags = arg.format.flags;
fmt.width = getcount(&fmt.args, &arg.format.width);
fmt.precision = getcount(&fmt.args, &arg.format.precision);
fmt.width = getcount(args, &arg.format.width);
fmt.precision = getcount(args, &arg.format.precision);

// Extract the correct argument
let value = {
#[cfg(bootstrap)]
{
match arg.position {
rt::v1::Position::At(i) => fmt.args[i],
rt::v1::Position::At(i) => args[i],
}
}
#[cfg(not(bootstrap))]
{
fmt.args[arg.position]
args[arg.position]
}
};

Expand Down Expand Up @@ -1145,10 +1142,6 @@ impl<'a> Formatter<'a> {
align: self.align,
width: self.width,
precision: self.precision,

// These only exist in the struct for the `run` method,
// which won’t be used together with this method.
args: self.args,
}
}

Expand Down

0 comments on commit 9ae32c9

Please sign in to comment.