@@ -35,7 +35,7 @@ pub fn generate_asts(
35
35
SourceType :: SourceFile ( source_file) => {
36
36
let root_package = build_state. get_package ( & build_state. root_config_name ) . unwrap ( ) ;
37
37
38
- let ( ast_path , iast_path , dirty) = if source_file. implementation . parse_dirty
38
+ let ( ast_result , iast_result , dirty) = if source_file. implementation . parse_dirty
39
39
|| source_file
40
40
. interface
41
41
. as_ref ( )
@@ -80,18 +80,18 @@ pub fn generate_asts(
80
80
)
81
81
} ;
82
82
83
- ( module_name. to_owned ( ) , ast_path , iast_path , dirty)
83
+ ( module_name. to_owned ( ) , ast_result , iast_result , dirty)
84
84
}
85
85
}
86
86
} )
87
87
. collect :: < Vec < (
88
88
String ,
89
- Result < ( String , Option < String > ) , String > ,
90
- Result < Option < ( String , Option < String > ) > , String > ,
89
+ Result < ( String , Option < helpers :: StdErr > ) , String > ,
90
+ Result < Option < ( String , Option < helpers :: StdErr > ) > , String > ,
91
91
bool ,
92
92
) > > ( )
93
93
. into_iter ( )
94
- . for_each ( |( module_name, ast_path , iast_path , is_dirty) | {
94
+ . for_each ( |( module_name, ast_result , iast_result , is_dirty) | {
95
95
if let Some ( module) = build_state. modules . get_mut ( & module_name) {
96
96
// if the module is dirty, mark it also compile_dirty
97
97
// do NOT set to false if the module is not parse_dirty, it needs to keep
@@ -104,57 +104,77 @@ pub fn generate_asts(
104
104
. get ( & module. package_name )
105
105
. expect ( "Package not found" ) ;
106
106
if let SourceType :: SourceFile ( ref mut source_file) = module. source_type {
107
- match ast_path {
108
- // supress warnings in non-pinned deps
109
- Ok ( ( _path, Some ( err) ) ) if package. is_pinned_dep => {
107
+ // We get Err(x) when there is a parse error. When it's Ok(_, Some(
108
+ // stderr_warnings )), the outputs are warnings
109
+ match ast_result {
110
+ // In case of a pinned (internal) dependency, we want to keep on
111
+ // propagating the warning with every compile. So we mark it as dirty for
112
+ // the next round
113
+ Ok ( ( _path, Some ( stderr_warnings) ) ) if package. is_pinned_dep => {
110
114
source_file. implementation . parse_state = ParseState :: Warning ;
111
115
source_file. implementation . parse_dirty = true ;
112
116
if let Some ( interface) = source_file. interface . as_mut ( ) {
113
117
interface. parse_dirty = false ;
114
118
}
115
- logs:: append ( package, & err ) ;
116
- stderr. push_str ( & err ) ;
119
+ logs:: append ( package, & stderr_warnings ) ;
120
+ stderr. push_str ( & stderr_warnings ) ;
117
121
}
118
- Ok ( ( _path, None ) ) => {
122
+ Ok ( ( _path, Some ( _) ) ) | Ok ( ( _path, None ) ) => {
123
+ // If we do have stderr_warnings here, the file is not a pinned
124
+ // dependency (so some external dep). We can ignore those
119
125
source_file. implementation . parse_state = ParseState :: Success ;
120
126
source_file. implementation . parse_dirty = false ;
121
127
if let Some ( interface) = source_file. interface . as_mut ( ) {
122
128
interface. parse_dirty = false ;
123
129
}
124
130
}
125
131
Err ( err) => {
132
+ // Some compilation error
126
133
source_file. implementation . parse_state = ParseState :: ParseError ;
127
134
source_file. implementation . parse_dirty = true ;
128
135
logs:: append ( package, & err) ;
129
136
has_failure = true ;
130
137
stderr. push_str ( & err) ;
131
138
}
132
- _ => ( ) ,
133
139
} ;
134
- }
135
140
136
- match ( iast_path, module. source_type . to_owned ( ) ) {
137
- ( Ok ( Some ( ( _path, Some ( err) ) ) ) , SourceType :: SourceFile ( ref mut source_file) )
138
- if package. is_pinned_dep =>
139
- {
140
- // supress warnings in non-pinned deps
141
- if let Some ( interface) = source_file. interface . as_mut ( ) {
142
- interface. parse_state = ParseState :: Warning ;
143
- interface. parse_dirty = true ;
141
+ // We get Err(x) when there is a parse error. When it's Ok(_, Some(( _path,
142
+ // stderr_warnings ))), the outputs are warnings
143
+ match iast_result {
144
+ // In case of a pinned (internal) dependency, we want to keep on
145
+ // propagating the warning with every compile. So we mark it as dirty for
146
+ // the next round
147
+ Ok ( Some ( ( _path, Some ( stderr_warnings) ) ) ) if package. is_pinned_dep => {
148
+ if let Some ( interface) = source_file. interface . as_mut ( ) {
149
+ interface. parse_state = ParseState :: Warning ;
150
+ interface. parse_dirty = true ;
151
+ }
152
+ logs:: append ( package, & stderr_warnings) ;
153
+ stderr. push_str ( & stderr_warnings) ;
144
154
}
145
- logs:: append ( package, & err) ;
146
- stderr. push_str ( & err) ;
147
- }
148
- ( Err ( err) , SourceType :: SourceFile ( ref mut source_file) ) => {
149
- if let Some ( interface) = source_file. interface . as_mut ( ) {
150
- interface. parse_state = ParseState :: ParseError ;
151
- interface. parse_dirty = true ;
155
+ Ok ( Some ( ( _, None ) ) ) | Ok ( Some ( ( _, Some ( _) ) ) ) => {
156
+ // If we do have stderr_warnings here, the file is not a pinned
157
+ // dependency (so some external dep). We can ignore those
158
+ if let Some ( interface) = source_file. interface . as_mut ( ) {
159
+ interface. parse_state = ParseState :: Success ;
160
+ interface. parse_dirty = false ;
161
+ }
162
+ }
163
+ Err ( err) => {
164
+ // Some compilation error
165
+ if let Some ( interface) = source_file. interface . as_mut ( ) {
166
+ interface. parse_state = ParseState :: ParseError ;
167
+ interface. parse_dirty = true ;
168
+ }
169
+ logs:: append ( package, & err) ;
170
+ has_failure = true ;
171
+ stderr. push_str ( & err) ;
172
+ }
173
+ Ok ( None ) => {
174
+ // The file had no interface file associated
175
+ ( )
152
176
}
153
- logs:: append ( package, & err) ;
154
- has_failure = true ;
155
- stderr. push_str ( & err) ;
156
177
}
157
- _ => ( ) ,
158
178
} ;
159
179
}
160
180
} ) ;
@@ -263,7 +283,7 @@ fn generate_ast(
263
283
version : & str ,
264
284
bsc_path : & str ,
265
285
workspace_root : & Option < String > ,
266
- ) -> Result < ( String , Option < String > ) , String > {
286
+ ) -> Result < ( String , Option < helpers :: StdErr > ) , String > {
267
287
let file_path = PathBuf :: from ( & package. path ) . join ( filename) ;
268
288
let contents = helpers:: read_file ( & file_path) . expect ( "Error reading file" ) ;
269
289
0 commit comments