]> git.lizzy.rs Git - rust.git/blobdiff - src/checkstyle.rs
Merge pull request #3472 from devinalvaro/add-print-current-config
[rust.git] / src / checkstyle.rs
index 7f6e650ad220295e9539484d5b4c28f88b42de54..169a3741be46860d8de5d02a5f9ecbe87b7c862e 100644 (file)
@@ -1,43 +1,26 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
 use std::io::{self, Write};
 use std::path::Path;
 
-use config::WriteMode;
-use rustfmt_diff::{DiffLine, Mismatch};
+use crate::rustfmt_diff::{DiffLine, Mismatch};
 
-pub fn output_header<T>(out: &mut T, mode: WriteMode) -> Result<(), io::Error>
-where
-    T: Write,
-{
-    if mode == WriteMode::Checkstyle {
-        let mut xml_heading = String::new();
-        xml_heading.push_str("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
-        xml_heading.push_str("\n");
-        xml_heading.push_str("<checkstyle version=\"4.3\">");
-        write!(out, "{}", xml_heading)?;
-    }
-    Ok(())
+/// The checkstyle header - should be emitted before the output of Rustfmt.
+///
+/// Note that emitting checkstyle output is not stable and may removed in a
+/// future version of Rustfmt.
+pub fn header() -> String {
+    let mut xml_heading = String::new();
+    xml_heading.push_str("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+    xml_heading.push_str("\n");
+    xml_heading.push_str("<checkstyle version=\"4.3\">");
+    xml_heading
 }
 
-pub fn output_footer<T>(out: &mut T, mode: WriteMode) -> Result<(), io::Error>
-where
-    T: Write,
-{
-    if mode == WriteMode::Checkstyle {
-        let mut xml_tail = String::new();
-        xml_tail.push_str("</checkstyle>\n");
-        write!(out, "{}", xml_tail)?;
-    }
-    Ok(())
+/// The checkstyle footer - should be emitted after the output of Rustfmt.
+///
+/// Note that emitting checkstyle output is not stable and may removed in a
+/// future version of Rustfmt.
+pub fn footer() -> String {
+    "</checkstyle>\n".to_owned()
 }
 
 pub fn output_checkstyle_file<T>(