@@ -364,6 +364,14 @@ impl Session {
364
364
pub fn struct_span_warn < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> DiagnosticBuilder < ' _ > {
365
365
self . diagnostic ( ) . struct_span_warn ( sp, msg)
366
366
}
367
+ pub fn struct_span_warn_with_code < S : Into < MultiSpan > > (
368
+ & self ,
369
+ sp : S ,
370
+ msg : & str ,
371
+ code : DiagnosticId ,
372
+ ) -> DiagnosticBuilder < ' _ > {
373
+ self . diagnostic ( ) . struct_span_warn_with_code ( sp, msg, code)
374
+ }
367
375
pub fn struct_warn ( & self , msg : & str ) -> DiagnosticBuilder < ' _ > {
368
376
self . diagnostic ( ) . struct_warn ( msg)
369
377
}
@@ -402,16 +410,37 @@ impl Session {
402
410
) -> DiagnosticBuilder < ' _ > {
403
411
self . diagnostic ( ) . struct_span_fatal_with_code ( sp, msg, code)
404
412
}
413
+ pub fn struct_fatal ( & self , msg : & str ) -> DiagnosticBuilder < ' _ > {
414
+ self . diagnostic ( ) . struct_fatal ( msg)
415
+ }
405
416
406
417
pub fn span_fatal < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> ! {
407
418
self . diagnostic ( ) . span_fatal ( sp, msg) . raise ( )
408
419
}
420
+ pub fn span_fatal_with_code < S : Into < MultiSpan > > (
421
+ & self ,
422
+ sp : S ,
423
+ msg : & str ,
424
+ code : DiagnosticId ,
425
+ ) -> ! {
426
+ self . diagnostic ( ) . span_fatal_with_code ( sp, msg, code) . raise ( )
427
+ }
409
428
pub fn fatal ( & self , msg : & str ) -> ! {
410
429
self . diagnostic ( ) . fatal ( msg) . raise ( )
411
430
}
431
+ pub fn span_err_or_warn < S : Into < MultiSpan > > ( & self , is_warning : bool , sp : S , msg : & str ) {
432
+ if is_warning {
433
+ self . span_warn ( sp, msg) ;
434
+ } else {
435
+ self . span_err ( sp, msg) ;
436
+ }
437
+ }
412
438
pub fn span_err < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
413
439
self . diagnostic ( ) . span_err ( sp, msg)
414
440
}
441
+ pub fn span_err_with_code < S : Into < MultiSpan > > ( & self , sp : S , msg : & str , code : DiagnosticId ) {
442
+ self . diagnostic ( ) . span_err_with_code ( sp, & msg, code)
443
+ }
415
444
pub fn err ( & self , msg : & str ) {
416
445
self . diagnostic ( ) . err ( msg)
417
446
}
@@ -451,9 +480,18 @@ impl Session {
451
480
pub fn span_warn < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
452
481
self . diagnostic ( ) . span_warn ( sp, msg)
453
482
}
483
+ pub fn span_warn_with_code < S : Into < MultiSpan > > ( & self , sp : S , msg : & str , code : DiagnosticId ) {
484
+ self . diagnostic ( ) . span_warn_with_code ( sp, msg, code)
485
+ }
454
486
pub fn warn ( & self , msg : & str ) {
455
487
self . diagnostic ( ) . warn ( msg)
456
488
}
489
+ pub fn opt_span_warn < S : Into < MultiSpan > > ( & self , opt_sp : Option < S > , msg : & str ) {
490
+ match opt_sp {
491
+ Some ( sp) => self . span_warn ( sp, msg) ,
492
+ None => self . warn ( msg) ,
493
+ }
494
+ }
457
495
/// Delay a span_bug() call until abort_if_errors()
458
496
#[ track_caller]
459
497
pub fn delay_span_bug < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
@@ -480,6 +518,9 @@ impl Session {
480
518
pub fn note_without_error ( & self , msg : & str ) {
481
519
self . diagnostic ( ) . note_without_error ( msg)
482
520
}
521
+ pub fn span_note_without_error < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
522
+ self . diagnostic ( ) . span_note_without_error ( sp, msg)
523
+ }
483
524
pub fn struct_note_without_error ( & self , msg : & str ) -> DiagnosticBuilder < ' _ > {
484
525
self . diagnostic ( ) . struct_note_without_error ( msg)
485
526
}
0 commit comments