@@ -781,9 +781,9 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
781
781
0 => return AutoDiffAttrs :: inactive ( ) ,
782
782
1 => attrs. get ( 0 ) . unwrap ( ) ,
783
783
_ => {
784
- tcx. sess
784
+ tcx. dcx ( )
785
785
. struct_span_err ( attrs[ 1 ] . span , msg_once)
786
- . span_label ( attrs [ 1 ] . span , "more than one" )
786
+ . with_note ( "more than one" )
787
787
. emit ( ) ;
788
788
return AutoDiffAttrs :: inactive ( ) ;
789
789
}
@@ -797,19 +797,19 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
797
797
}
798
798
799
799
let [ mode, input_activities @ .., ret_activity] = & list[ ..] else {
800
- tcx. sess
800
+ tcx. dcx ( )
801
801
. struct_span_err ( attr. span , msg_once)
802
- . span_label ( attr . span , "Implementation bug in autodiff_attrs. Please report this!" )
802
+ . with_note ( "Implementation bug in autodiff_attrs. Please report this!" )
803
803
. emit ( ) ;
804
804
return AutoDiffAttrs :: inactive ( ) ;
805
805
} ;
806
806
let mode = if let NestedMetaItem :: MetaItem ( MetaItem { path : ref p1, .. } ) = mode {
807
807
p1. segments . first ( ) . unwrap ( ) . ident
808
808
} else {
809
809
let msg = "autodiff attribute must contain autodiff mode" ;
810
- tcx. sess
810
+ tcx. dcx ( )
811
811
. struct_span_err ( attr. span , msg)
812
- . span_label ( attr . span , "empty argument list" )
812
+ . with_note ( "empty argument list" )
813
813
. emit ( ) ;
814
814
return AutoDiffAttrs :: inactive ( ) ;
815
815
} ;
@@ -822,9 +822,9 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
822
822
"ForwardFirst" => DiffMode :: ForwardFirst ,
823
823
"ReverseFirst" => DiffMode :: ReverseFirst ,
824
824
_ => {
825
- tcx. sess
825
+ tcx. dcx ( )
826
826
. struct_span_err ( attr. span , msg_mode)
827
- . span_label ( attr . span , "invalid mode" )
827
+ . with_note ( "invalid mode" )
828
828
. emit ( ) ;
829
829
return AutoDiffAttrs :: inactive ( ) ;
830
830
}
@@ -835,9 +835,9 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
835
835
p1. segments . first ( ) . unwrap ( ) . ident
836
836
} else {
837
837
let msg = "autodiff attribute must contain the return activity" ;
838
- tcx. sess
838
+ tcx. dcx ( )
839
839
. struct_span_err ( attr. span , msg)
840
- . span_label ( attr . span , "missing return activity" )
840
+ . with_note ( "missing return activity" )
841
841
. emit ( ) ;
842
842
return AutoDiffAttrs :: inactive ( ) ;
843
843
} ;
@@ -847,9 +847,9 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
847
847
let ret_activity = match DiffActivity :: from_str ( ret_symbol. as_str ( ) ) {
848
848
Ok ( x) => x,
849
849
Err ( _) => {
850
- tcx. sess
850
+ tcx. dcx ( )
851
851
. struct_span_err ( attr. span , msg_unknown_ret_activity)
852
- . span_label ( attr . span , "invalid return activity" )
852
+ . with_note ( "invalid return activity" )
853
853
. emit ( ) ;
854
854
return AutoDiffAttrs :: inactive ( ) ;
855
855
}
@@ -862,19 +862,19 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
862
862
let arg_symbol = if let NestedMetaItem :: MetaItem ( MetaItem { path : ref p2, .. } ) = arg {
863
863
p2. segments . first ( ) . unwrap ( ) . ident
864
864
} else {
865
- tcx. sess
865
+ tcx. dcx ( )
866
866
. struct_span_err ( attr. span , msg_arg_activity)
867
- . span_label ( attr . span , "Implementation bug, please report this!" )
867
+ . with_note ( "Implementation bug, please report this!" )
868
868
. emit ( ) ;
869
869
return AutoDiffAttrs :: inactive ( ) ;
870
870
} ;
871
871
872
872
match DiffActivity :: from_str ( arg_symbol. as_str ( ) ) {
873
873
Ok ( arg_activity) => arg_activities. push ( arg_activity) ,
874
874
Err ( _) => {
875
- tcx. sess
875
+ tcx. dcx ( )
876
876
. struct_span_err ( attr. span , msg_unknown_ret_activity)
877
- . span_label ( attr . span , "invalid input activity" )
877
+ . with_note ( "invalid input activity" )
878
878
. emit ( ) ;
879
879
return AutoDiffAttrs :: inactive ( ) ;
880
880
}
@@ -889,9 +889,9 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
889
889
msg = format ! ( "Invalid return activity {} for {} mode" , ret_activity, mode) ;
890
890
}
891
891
if msg != "" . to_string ( ) {
892
- tcx. sess
892
+ tcx. dcx ( )
893
893
. struct_span_err ( attr. span , msg)
894
- . span_label ( attr . span , "invalid activity" )
894
+ . with_note ( "invalid activity" )
895
895
. emit ( ) ;
896
896
return AutoDiffAttrs :: inactive ( ) ;
897
897
}
0 commit comments