@@ -15,8 +15,7 @@ use proc_macro2::TokenStream;
15
15
use quote:: quote;
16
16
use std:: {
17
17
collections:: { HashMap , HashSet } ,
18
- fs:: File ,
19
- io:: Read ,
18
+ fs:: read_to_string,
20
19
path:: { Path , PathBuf } ,
21
20
} ;
22
21
use syn:: { parse_macro_input, Ident , LitStr } ;
@@ -95,22 +94,15 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
95
94
96
95
// As this macro also outputs an `include_str!` for this file, the macro will always be
97
96
// re-executed when the file changes.
98
- let mut resource_file = match File :: open ( absolute_ftl_path) {
99
- Ok ( resource_file ) => resource_file ,
97
+ let resource_contents = match read_to_string ( absolute_ftl_path) {
98
+ Ok ( resource_contents ) => resource_contents ,
100
99
Err ( e) => {
101
100
Diagnostic :: spanned ( resource_span, Level :: Error , "could not open Fluent resource" )
102
101
. note ( e. to_string ( ) )
103
102
. emit ( ) ;
104
103
return failed ( & crate_name) ;
105
104
}
106
105
} ;
107
- let mut resource_contents = String :: new ( ) ;
108
- if let Err ( e) = resource_file. read_to_string ( & mut resource_contents) {
109
- Diagnostic :: spanned ( resource_span, Level :: Error , "could not read Fluent resource" )
110
- . note ( e. to_string ( ) )
111
- . emit ( ) ;
112
- return failed ( & crate_name) ;
113
- }
114
106
let mut bad = false ;
115
107
for esc in [ "\\ n" , "\\ \" " , "\\ '" ] {
116
108
for _ in resource_contents. matches ( esc) {
0 commit comments