@@ -364,6 +364,14 @@ impl Session {
364364 pub fn struct_span_warn < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> DiagnosticBuilder < ' _ > {
365365 self . diagnostic ( ) . struct_span_warn ( sp, msg)
366366 }
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+ }
367375 pub fn struct_warn ( & self , msg : & str ) -> DiagnosticBuilder < ' _ > {
368376 self . diagnostic ( ) . struct_warn ( msg)
369377 }
@@ -402,16 +410,37 @@ impl Session {
402410 ) -> DiagnosticBuilder < ' _ > {
403411 self . diagnostic ( ) . struct_span_fatal_with_code ( sp, msg, code)
404412 }
413+ pub fn struct_fatal ( & self , msg : & str ) -> DiagnosticBuilder < ' _ > {
414+ self . diagnostic ( ) . struct_fatal ( msg)
415+ }
405416
406417 pub fn span_fatal < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) -> ! {
407418 self . diagnostic ( ) . span_fatal ( sp, msg) . raise ( )
408419 }
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+ }
409428 pub fn fatal ( & self , msg : & str ) -> ! {
410429 self . diagnostic ( ) . fatal ( msg) . raise ( )
411430 }
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+ }
412438 pub fn span_err < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
413439 self . diagnostic ( ) . span_err ( sp, msg)
414440 }
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+ }
415444 pub fn err ( & self , msg : & str ) {
416445 self . diagnostic ( ) . err ( msg)
417446 }
@@ -451,9 +480,18 @@ impl Session {
451480 pub fn span_warn < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
452481 self . diagnostic ( ) . span_warn ( sp, msg)
453482 }
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+ }
454486 pub fn warn ( & self , msg : & str ) {
455487 self . diagnostic ( ) . warn ( msg)
456488 }
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+ }
457495 /// Delay a span_bug() call until abort_if_errors()
458496 #[ track_caller]
459497 pub fn delay_span_bug < S : Into < MultiSpan > > ( & self , sp : S , msg : & str ) {
@@ -480,6 +518,9 @@ impl Session {
480518 pub fn note_without_error ( & self , msg : & str ) {
481519 self . diagnostic ( ) . note_without_error ( msg)
482520 }
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+ }
483524 pub fn struct_note_without_error ( & self , msg : & str ) -> DiagnosticBuilder < ' _ > {
484525 self . diagnostic ( ) . struct_note_without_error ( msg)
485526 }
0 commit comments