Skip to content

Commit 9ae32c9

Browse files
Drop args from Formatter
These are no longer used by Formatter methods.
1 parent 4919b96 commit 9ae32c9

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/libcore/fmt/mod.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ pub struct Formatter<'a> {
233233
precision: Option<usize>,
234234

235235
buf: &'a mut (dyn Write + 'a),
236-
args: &'a [ArgumentV1<'a>],
237236
}
238237

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

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

1077-
fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument) -> Result {
1078-
// Fill in the format parameters into the formatter
1075+
fn run(fmt: &mut Formatter<'_>, arg: &rt::v1::Argument, args: &[ArgumentV1<'_>]) -> Result {
10791076
fmt.fill = arg.format.fill;
10801077
fmt.align = arg.format.align;
10811078
fmt.flags = arg.format.flags;
1082-
fmt.width = getcount(&fmt.args, &arg.format.width);
1083-
fmt.precision = getcount(&fmt.args, &arg.format.precision);
1079+
fmt.width = getcount(args, &arg.format.width);
1080+
fmt.precision = getcount(args, &arg.format.precision);
10841081

10851082
// Extract the correct argument
10861083
let value = {
10871084
#[cfg(bootstrap)]
10881085
{
10891086
match arg.position {
1090-
rt::v1::Position::At(i) => fmt.args[i],
1087+
rt::v1::Position::At(i) => args[i],
10911088
}
10921089
}
10931090
#[cfg(not(bootstrap))]
10941091
{
1095-
fmt.args[arg.position]
1092+
args[arg.position]
10961093
}
10971094
};
10981095

@@ -1145,10 +1142,6 @@ impl<'a> Formatter<'a> {
11451142
align: self.align,
11461143
width: self.width,
11471144
precision: self.precision,
1148-
1149-
// These only exist in the struct for the `run` method,
1150-
// which won’t be used together with this method.
1151-
args: self.args,
11521145
}
11531146
}
11541147

0 commit comments

Comments
 (0)