@@ -64,14 +64,10 @@ pub struct Session {
64
64
pub crate_metadata : RefCell < Vec < String > > ,
65
65
pub features : RefCell < feature_gate:: Features > ,
66
66
67
- pub delayed_span_bug : RefCell < Option < ( codemap:: Span , String ) > > ,
68
-
69
67
/// The maximum recursion limit for potentially infinitely recursive
70
68
/// operations such as auto-dereference and monomorphization.
71
69
pub recursion_limit : Cell < usize > ,
72
70
73
- pub can_print_warnings : bool ,
74
-
75
71
/// The metadata::creader module may inject an allocator dependency if it
76
72
/// didn't already find one, and this tracks what was injected.
77
73
pub injected_allocator : Cell < Option < ast:: CrateNum > > ,
@@ -85,21 +81,12 @@ pub struct Session {
85
81
86
82
impl Session {
87
83
pub fn span_fatal ( & self , sp : Span , msg : & str ) -> ! {
88
- if self . opts . treat_err_as_bug {
89
- self . span_bug ( sp, msg) ;
90
- }
91
84
panic ! ( self . diagnostic( ) . span_fatal( sp, msg) )
92
85
}
93
86
pub fn span_fatal_with_code ( & self , sp : Span , msg : & str , code : & str ) -> ! {
94
- if self . opts . treat_err_as_bug {
95
- self . span_bug ( sp, msg) ;
96
- }
97
87
panic ! ( self . diagnostic( ) . span_fatal_with_code( sp, msg, code) )
98
88
}
99
89
pub fn fatal ( & self , msg : & str ) -> ! {
100
- if self . opts . treat_err_as_bug {
101
- self . bug ( msg) ;
102
- }
103
90
panic ! ( self . diagnostic( ) . fatal( msg) )
104
91
}
105
92
pub fn span_err_or_warn ( & self , is_warning : bool , sp : Span , msg : & str ) {
@@ -110,9 +97,6 @@ impl Session {
110
97
}
111
98
}
112
99
pub fn span_err ( & self , sp : Span , msg : & str ) {
113
- if self . opts . treat_err_as_bug {
114
- self . span_bug ( sp, msg) ;
115
- }
116
100
match split_msg_into_multilines ( msg) {
117
101
Some ( msg) => self . diagnostic ( ) . span_err ( sp, & msg[ ..] ) ,
118
102
None => self . diagnostic ( ) . span_err ( sp, msg)
@@ -126,18 +110,12 @@ impl Session {
126
110
See RFC 1214 for details.") ) ;
127
111
}
128
112
pub fn span_err_with_code ( & self , sp : Span , msg : & str , code : & str ) {
129
- if self . opts . treat_err_as_bug {
130
- self . span_bug ( sp, msg) ;
131
- }
132
113
match split_msg_into_multilines ( msg) {
133
114
Some ( msg) => self . diagnostic ( ) . span_err_with_code ( sp, & msg[ ..] , code) ,
134
115
None => self . diagnostic ( ) . span_err_with_code ( sp, msg, code)
135
116
}
136
117
}
137
118
pub fn err ( & self , msg : & str ) {
138
- if self . opts . treat_err_as_bug {
139
- self . bug ( msg) ;
140
- }
141
119
self . diagnostic ( ) . err ( msg)
142
120
}
143
121
pub fn err_count ( & self ) -> usize {
@@ -148,14 +126,6 @@ impl Session {
148
126
}
149
127
pub fn abort_if_errors ( & self ) {
150
128
self . diagnostic ( ) . abort_if_errors ( ) ;
151
-
152
- let delayed_bug = self . delayed_span_bug . borrow ( ) ;
153
- match * delayed_bug {
154
- Some ( ( span, ref errmsg) ) => {
155
- self . diagnostic ( ) . span_bug ( span, errmsg) ;
156
- } ,
157
- _ => { }
158
- }
159
129
}
160
130
pub fn abort_if_new_errors < F > ( & self , mut f : F )
161
131
where F : FnMut ( )
@@ -167,19 +137,13 @@ impl Session {
167
137
}
168
138
}
169
139
pub fn span_warn ( & self , sp : Span , msg : & str ) {
170
- if self . can_print_warnings {
171
- self . diagnostic ( ) . span_warn ( sp, msg)
172
- }
140
+ self . diagnostic ( ) . span_warn ( sp, msg)
173
141
}
174
142
pub fn span_warn_with_code ( & self , sp : Span , msg : & str , code : & str ) {
175
- if self . can_print_warnings {
176
- self . diagnostic ( ) . span_warn_with_code ( sp, msg, code)
177
- }
143
+ self . diagnostic ( ) . span_warn_with_code ( sp, msg, code)
178
144
}
179
145
pub fn warn ( & self , msg : & str ) {
180
- if self . can_print_warnings {
181
- self . diagnostic ( ) . warn ( msg)
182
- }
146
+ self . diagnostic ( ) . warn ( msg)
183
147
}
184
148
pub fn opt_span_warn ( & self , opt_sp : Option < Span > , msg : & str ) {
185
149
match opt_sp {
@@ -223,8 +187,7 @@ impl Session {
223
187
}
224
188
/// Delay a span_bug() call until abort_if_errors()
225
189
pub fn delay_span_bug ( & self , sp : Span , msg : & str ) {
226
- let mut delayed = self . delayed_span_bug . borrow_mut ( ) ;
227
- * delayed = Some ( ( sp, msg. to_string ( ) ) ) ;
190
+ self . diagnostic ( ) . delay_span_bug ( sp, msg)
228
191
}
229
192
pub fn span_bug ( & self , sp : Span , msg : & str ) -> ! {
230
193
self . diagnostic ( ) . span_bug ( sp, msg)
@@ -270,8 +233,7 @@ impl Session {
270
233
// This exists to help with refactoring to eliminate impossible
271
234
// cases later on
272
235
pub fn impossible_case ( & self , sp : Span , msg : & str ) -> ! {
273
- self . span_bug ( sp,
274
- & format ! ( "impossible case reached: {}" , msg) ) ;
236
+ self . span_bug ( sp, & format ! ( "impossible case reached: {}" , msg) ) ;
275
237
}
276
238
pub fn verbose ( & self ) -> bool { self . opts . debugging_opts . verbose }
277
239
pub fn time_passes ( & self ) -> bool { self . opts . debugging_opts . time_passes }
@@ -414,10 +376,15 @@ pub fn build_session(sopts: config::Options,
414
376
. map ( |& ( _, ref level) | * level != lint:: Allow )
415
377
. last ( )
416
378
. unwrap_or ( true ) ;
379
+ let treat_err_as_bug = sopts. treat_err_as_bug ;
417
380
418
381
let codemap = Rc :: new ( codemap:: CodeMap :: new ( ) ) ;
419
382
let diagnostic_handler =
420
- errors:: Handler :: new ( sopts. color , Some ( registry) , can_print_warnings, codemap. clone ( ) ) ;
383
+ errors:: Handler :: new ( sopts. color ,
384
+ Some ( registry) ,
385
+ can_print_warnings,
386
+ treat_err_as_bug,
387
+ codemap. clone ( ) ) ;
421
388
422
389
build_session_ ( sopts, local_crate_source_file, diagnostic_handler, codemap, cstore)
423
390
}
@@ -450,13 +417,6 @@ pub fn build_session_(sopts: config::Options,
450
417
}
451
418
) ;
452
419
453
- let can_print_warnings = sopts. lint_opts
454
- . iter ( )
455
- . filter ( |& & ( ref key, _) | * key == "warnings" )
456
- . map ( |& ( _, ref level) | * level != lint:: Allow )
457
- . last ( )
458
- . unwrap_or ( true ) ;
459
-
460
420
let sess = Session {
461
421
target : target_cfg,
462
422
host : host,
@@ -477,10 +437,8 @@ pub fn build_session_(sopts: config::Options,
477
437
crate_types : RefCell :: new ( Vec :: new ( ) ) ,
478
438
dependency_formats : RefCell :: new ( FnvHashMap ( ) ) ,
479
439
crate_metadata : RefCell :: new ( Vec :: new ( ) ) ,
480
- delayed_span_bug : RefCell :: new ( None ) ,
481
440
features : RefCell :: new ( feature_gate:: Features :: new ( ) ) ,
482
441
recursion_limit : Cell :: new ( 64 ) ,
483
- can_print_warnings : can_print_warnings,
484
442
next_node_id : Cell :: new ( 1 ) ,
485
443
injected_allocator : Cell :: new ( None ) ,
486
444
available_macros : RefCell :: new ( HashSet :: new ( ) ) ,
@@ -489,13 +447,6 @@ pub fn build_session_(sopts: config::Options,
489
447
sess
490
448
}
491
449
492
- // Seems out of place, but it uses session, so I'm putting it here
493
- pub fn expect < T , M > ( sess : & Session , opt : Option < T > , msg : M ) -> T where
494
- M : FnOnce ( ) -> String ,
495
- {
496
- errors:: expect ( sess. diagnostic ( ) , opt, msg)
497
- }
498
-
499
450
pub fn early_error ( color : errors:: ColorConfig , msg : & str ) -> ! {
500
451
let mut emitter = BasicEmitter :: stderr ( color) ;
501
452
emitter. emit ( None , msg, None , errors:: Level :: Fatal ) ;
0 commit comments