about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-07-05 18:32:04 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2019-07-10 07:12:28 -0400
commite0ffa7c3d2115b9a1d22b6a5de288aa696abf50f (patch)
treefd5c77bd6b3416bb7ffdc1e43eeb4d20eac1b277 /src/libsyntax/print
parente0db2e606cdb242db1466ae51129c9a6b81560fe (diff)
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.
Diffstat (limited to 'src/libsyntax/print')
-rw-r--r--src/libsyntax/print/pprust.rs24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 555276234f7..43714d3015b 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -105,7 +105,12 @@ pub fn print_crate<'a>(cm: &'a SourceMap,
                        ann: &'a dyn PpAnn,
                        is_expanded: bool) -> String {
     let mut out = String::new();
-    let mut s = State::new_from_input(cm, sess, filename, input, &mut out, ann, is_expanded);
+    let mut s = State {
+        s: pp::mk_printer(&mut out),
+        comments: Some(Comments::new(cm, sess, filename, input)),
+        ann,
+        is_expanded,
+    };
 
     if is_expanded && std_inject::injected_crate_name().is_some() {
         // We need to print `#![no_std]` (and its feature gate) so that
@@ -132,23 +137,6 @@ pub fn print_crate<'a>(cm: &'a SourceMap,
     out
 }
 
-impl<'a> State<'a> {
-    pub fn new_from_input(cm: &'a SourceMap,
-                          sess: &ParseSess,
-                          filename: FileName,
-                          input: String,
-                          out: &'a mut String,
-                          ann: &'a dyn PpAnn,
-                          is_expanded: bool) -> State<'a> {
-        State {
-            s: pp::mk_printer(out),
-            comments: Some(Comments::new(cm, sess, filename, input)),
-            ann,
-            is_expanded,
-        }
-    }
-}
-
 pub fn to_string<F>(f: F) -> String where
     F: FnOnce(&mut State<'_>),
 {