@@ -73,13 +73,7 @@ pub(crate) fn process_json(line: String, error_format: ErrorFormat) -> LineOutpu
73
73
)
74
74
} ) ;
75
75
match parsed. try_into ( ) {
76
- Ok ( RustcMessage :: Message ( msg) ) => match error_format {
77
- // If the output should be json, we just forward the messages as-is
78
- // using `line`.
79
- ErrorFormat :: Json => LineOutput :: Message ( line) ,
80
- // Otherwise we return the rendered field.
81
- _ => LineOutput :: Message ( msg) ,
82
- } ,
76
+ Ok ( RustcMessage :: Message ( rendered) ) => output_based_on_error_format ( line, rendered, error_format) ,
83
77
_ => LineOutput :: Skip ,
84
78
}
85
79
}
@@ -89,6 +83,7 @@ pub(crate) fn process_json(line: String, error_format: ErrorFormat) -> LineOutpu
89
83
/// so the compiler can be terminated.
90
84
/// This is used to implement pipelining in rules_rust, please see
91
85
/// https://internals.rust-lang.org/t/evaluating-pipelined-rustc-compilation/10199
86
+ /// TODO pass a function to handle the emit event and merge with process_json
92
87
pub ( crate ) fn stop_on_rmeta_completion (
93
88
line : String ,
94
89
error_format : ErrorFormat ,
@@ -105,13 +100,21 @@ pub(crate) fn stop_on_rmeta_completion(
105
100
* kill = true ;
106
101
LineOutput :: Terminate
107
102
}
108
- Ok ( RustcMessage :: Message ( msg) ) => match error_format {
109
- // If the output should be json, we just forward the messages as-is
110
- // using `line`.
111
- ErrorFormat :: Json => LineOutput :: Message ( line) ,
112
- // Otherwise we return the rendered field.
113
- _ => LineOutput :: Message ( msg) ,
114
- } ,
103
+ Ok ( RustcMessage :: Message ( rendered) ) => output_based_on_error_format ( line, rendered, error_format) ,
115
104
_ => LineOutput :: Skip ,
116
105
}
117
106
}
107
+
108
+ fn output_based_on_error_format (
109
+ line : String ,
110
+ rendered : String ,
111
+ error_format : ErrorFormat ,
112
+ ) -> LineOutput {
113
+ match error_format {
114
+ // If the output should be json, we just forward the messages as-is
115
+ // using `line`.
116
+ ErrorFormat :: Json => LineOutput :: Message ( line) ,
117
+ // Otherwise we return the rendered field.
118
+ ErrorFormat :: Rendered => LineOutput :: Message ( rendered) ,
119
+ }
120
+ }
0 commit comments