File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,14 +82,20 @@ fn project_discovery() -> anyhow::Result<DiscoverProject<'static>> {
8282 Ok ( DiscoverProject :: Finished { buildfile, project } )
8383}
8484
85+ fn write_discovery < W > ( mut writer : W , discovery : DiscoverProject ) -> std:: io:: Result < ( ) >
86+ where
87+ W : Write ,
88+ {
89+ serde_json:: to_writer ( & mut writer, & discovery) ?;
90+ // `rust-analyzer` reads messages line by line, so we must add a newline after each
91+ writeln ! ( writer, "" )
92+ }
93+
8594fn main ( ) -> anyhow:: Result < ( ) > {
8695 let log_format_fn = |fmt : & mut Formatter , rec : & Record | {
8796 let message = rec. args ( ) ;
8897 let discovery = DiscoverProject :: Progress { message } ;
89- serde_json:: to_writer ( & mut * fmt, & discovery) ?;
90- // `rust-analyzer` reads messages line by line
91- writeln ! ( fmt, "" ) ;
92- Ok ( ( ) )
98+ write_discovery ( fmt, discovery)
9399 } ;
94100
95101 // Treat logs as progress messages.
@@ -111,10 +117,7 @@ fn main() -> anyhow::Result<()> {
111117 } ,
112118 } ;
113119
114- serde_json:: to_writer ( io:: stdout ( ) , & discovery) ?;
115- // `rust-analyzer` reads messages line by line
116- println ! ( "" ) ;
117-
120+ write_discovery ( io:: stdout ( ) , discovery) ?;
118121 Ok ( ( ) )
119122}
120123
You can’t perform that action at this time.
0 commit comments