Skip to content

Commit e0ffa7c

Browse files
Inline State::new_from_input in pprust
This function took too many arguments and are simple on the inside; inlining them makes complexity go down. hir::print's copy is unfortunately used from librustc_driver so inlining it is not as straightforward.
1 parent e0db2e6 commit e0ffa7c

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

src/libsyntax/print/pprust.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ pub fn print_crate<'a>(cm: &'a SourceMap,
105105
ann: &'a dyn PpAnn,
106106
is_expanded: bool) -> String {
107107
let mut out = String::new();
108-
let mut s = State::new_from_input(cm, sess, filename, input, &mut out, ann, is_expanded);
108+
let mut s = State {
109+
s: pp::mk_printer(&mut out),
110+
comments: Some(Comments::new(cm, sess, filename, input)),
111+
ann,
112+
is_expanded,
113+
};
109114

110115
if is_expanded && std_inject::injected_crate_name().is_some() {
111116
// We need to print `#![no_std]` (and its feature gate) so that
@@ -132,23 +137,6 @@ pub fn print_crate<'a>(cm: &'a SourceMap,
132137
out
133138
}
134139

135-
impl<'a> State<'a> {
136-
pub fn new_from_input(cm: &'a SourceMap,
137-
sess: &ParseSess,
138-
filename: FileName,
139-
input: String,
140-
out: &'a mut String,
141-
ann: &'a dyn PpAnn,
142-
is_expanded: bool) -> State<'a> {
143-
State {
144-
s: pp::mk_printer(out),
145-
comments: Some(Comments::new(cm, sess, filename, input)),
146-
ann,
147-
is_expanded,
148-
}
149-
}
150-
}
151-
152140
pub fn to_string<F>(f: F) -> String where
153141
F: FnOnce(&mut State<'_>),
154142
{

0 commit comments

Comments
 (0)