@@ -3,7 +3,7 @@ use crate::load::{FileSourceLoader, SourceLoader, Sources};
3
3
use crate :: query:: { Build , BuildEntry , Query } ;
4
4
use crate :: shared:: { Consts , Gen } ;
5
5
use crate :: worker:: { LoadFileKind , Task , Worker } ;
6
- use crate :: { Error , Errors , Options , Spanned as _, Storage , Warnings } ;
6
+ use crate :: { Diagnostics , Error , Options , Spanned as _, Storage } ;
7
7
use runestick:: { Context , Location , Source , Span } ;
8
8
use std:: rc:: Rc ;
9
9
use std:: sync:: Arc ;
@@ -26,8 +26,7 @@ pub fn compile(
26
26
context : & Context ,
27
27
sources : & mut Sources ,
28
28
unit : & UnitBuilder ,
29
- errors : & mut Errors ,
30
- warnings : & mut Warnings ,
29
+ diagnostics : & mut Diagnostics ,
31
30
) -> Result < ( ) , ( ) > {
32
31
let visitor = Rc :: new ( NoopCompileVisitor :: new ( ) ) ;
33
32
let source_loader = Rc :: new ( FileSourceLoader :: new ( ) ) ;
@@ -36,8 +35,7 @@ pub fn compile(
36
35
context,
37
36
sources,
38
37
unit,
39
- errors,
40
- warnings,
38
+ diagnostics,
41
39
& Default :: default ( ) ,
42
40
visitor,
43
41
source_loader,
@@ -51,8 +49,7 @@ pub fn compile_with_options(
51
49
context : & Context ,
52
50
sources : & mut Sources ,
53
51
unit : & UnitBuilder ,
54
- errors : & mut Errors ,
55
- warnings : & mut Warnings ,
52
+ diagnostics : & mut Diagnostics ,
56
53
options : & Options ,
57
54
visitor : Rc < dyn CompileVisitor > ,
58
55
source_loader : Rc < dyn SourceLoader > ,
@@ -71,8 +68,7 @@ pub fn compile_with_options(
71
68
options,
72
69
unit. clone ( ) ,
73
70
consts,
74
- errors,
75
- warnings,
71
+ diagnostics,
76
72
visitor. clone ( ) ,
77
73
source_loader,
78
74
storage. clone ( ) ,
@@ -84,7 +80,7 @@ pub fn compile_with_options(
84
80
let mod_item = match worker. query . insert_root_mod ( source_id, Span :: empty ( ) ) {
85
81
Ok ( result) => result,
86
82
Err ( error) => {
87
- errors . push ( Error :: new ( source_id, error) ) ;
83
+ diagnostics . error ( Error :: new ( source_id, error) ) ;
88
84
return Err ( ( ) ) ;
89
85
}
90
86
} ;
@@ -98,7 +94,7 @@ pub fn compile_with_options(
98
94
99
95
worker. run ( ) ;
100
96
101
- if !worker. errors . is_empty ( ) {
97
+ if !worker. diagnostics . errors ( ) . is_empty ( ) {
102
98
return Err ( ( ) ) ;
103
99
}
104
100
@@ -112,13 +108,13 @@ pub fn compile_with_options(
112
108
options,
113
109
storage : & storage,
114
110
unit,
115
- warnings : worker. warnings ,
111
+ diagnostics : worker. diagnostics ,
116
112
consts : & worker. consts ,
117
113
query : & mut worker. query ,
118
114
} ;
119
115
120
116
if let Err ( error) = task. compile ( entry) {
121
- worker. errors . push ( Error :: new ( source_id, error) ) ;
117
+ worker. diagnostics . error ( Error :: new ( source_id, error) ) ;
122
118
}
123
119
}
124
120
@@ -127,13 +123,13 @@ pub fn compile_with_options(
127
123
Ok ( false ) => break ,
128
124
Err ( ( source_id, error) ) => {
129
125
worker
130
- . errors
131
- . push ( Error :: new ( source_id, CompileError :: from ( error) ) ) ;
126
+ . diagnostics
127
+ . error ( Error :: new ( source_id, CompileError :: from ( error) ) ) ;
132
128
}
133
129
}
134
130
}
135
131
136
- if !worker. errors . is_empty ( ) {
132
+ if !worker. diagnostics . errors ( ) . is_empty ( ) {
137
133
return Err ( ( ) ) ;
138
134
}
139
135
@@ -146,7 +142,7 @@ struct CompileBuildEntry<'a> {
146
142
options : & ' a Options ,
147
143
storage : & ' a Storage ,
148
144
unit : & ' a UnitBuilder ,
149
- warnings : & ' a mut Warnings ,
145
+ diagnostics : & ' a mut Diagnostics ,
150
146
consts : & ' a Consts ,
151
147
query : & ' a mut Query ,
152
148
}
@@ -173,7 +169,7 @@ impl CompileBuildEntry<'_> {
173
169
contexts : vec ! [ span] ,
174
170
loops : self :: v1:: Loops :: new ( ) ,
175
171
options : self . options ,
176
- warnings : self . warnings ,
172
+ diagnostics : self . diagnostics ,
177
173
}
178
174
}
179
175
@@ -201,7 +197,7 @@ impl CompileBuildEntry<'_> {
201
197
f. ast . assemble_fn ( & mut c, false ) ?;
202
198
203
199
if used. is_unused ( ) {
204
- self . warnings . not_used ( location. source_id , span, None ) ;
200
+ self . diagnostics . not_used ( location. source_id , span, None ) ;
205
201
} else {
206
202
self . unit . new_function (
207
203
location,
@@ -232,7 +228,7 @@ impl CompileBuildEntry<'_> {
232
228
f. ast . assemble_fn ( & mut c, true ) ?;
233
229
234
230
if used. is_unused ( ) {
235
- c. warnings . not_used ( location. source_id , span, None ) ;
231
+ c. diagnostics . not_used ( location. source_id , span, None ) ;
236
232
} else {
237
233
self . unit . new_instance_function (
238
234
location,
@@ -257,7 +253,8 @@ impl CompileBuildEntry<'_> {
257
253
closure. ast . assemble_closure ( & mut c, & closure. captures ) ?;
258
254
259
255
if used. is_unused ( ) {
260
- c. warnings . not_used ( location. source_id , location. span , None ) ;
256
+ c. diagnostics
257
+ . not_used ( location. source_id , location. span , None ) ;
261
258
} else {
262
259
self . unit . new_function (
263
260
location,
@@ -279,7 +276,7 @@ impl CompileBuildEntry<'_> {
279
276
b. ast . assemble_closure ( & mut c, & b. captures ) ?;
280
277
281
278
if used. is_unused ( ) {
282
- self . warnings
279
+ self . diagnostics
283
280
. not_used ( location. source_id , location. span , None ) ;
284
281
} else {
285
282
self . unit . new_function (
@@ -293,7 +290,7 @@ impl CompileBuildEntry<'_> {
293
290
}
294
291
}
295
292
Build :: Unused => {
296
- self . warnings
293
+ self . diagnostics
297
294
. not_used ( location. source_id , location. span , None ) ;
298
295
}
299
296
Build :: Import ( import) => {
@@ -303,7 +300,7 @@ impl CompileBuildEntry<'_> {
303
300
. import ( location. span , & item. module , & item. item , used) ?;
304
301
305
302
if used. is_unused ( ) {
306
- self . warnings
303
+ self . diagnostics
307
304
. not_used ( location. source_id , location. span , None ) ;
308
305
}
309
306
0 commit comments