@@ -38,6 +38,7 @@ use crate::check::wfcheck::{
3838 check_associated_item, check_trait_item, check_type_defn, check_variances_for_type_defn,
3939 check_where_clauses, enter_wf_checking_ctxt,
4040} ;
41+ use crate :: diagnostics;
4142
4243fn add_abi_diag_help < T : EmissionGuarantee > ( abi : ExternAbi , diag : & mut Diag < ' _ , T > ) {
4344 if let ExternAbi :: Cdecl { unwind } = abi {
@@ -95,7 +96,7 @@ pub fn check_custom_abi(tcx: TyCtxt<'_>, def_id: LocalDefId, fn_sig: FnSig<'_>,
9596 if fn_sig. abi ( ) == ExternAbi :: Custom {
9697 // Function definitions that use `extern "custom"` must be naked functions.
9798 if !find_attr ! ( tcx, def_id, Naked ( _) ) {
98- tcx. dcx ( ) . emit_err ( crate :: errors :: AbiCustomClothedFunction {
99+ tcx. dcx ( ) . emit_err ( crate :: diagnostics :: AbiCustomClothedFunction {
99100 span : fn_sig_span,
100101 naked_span : tcx. def_span ( def_id) . shrink_to_lo ( ) ,
101102 } ) ;
@@ -181,9 +182,9 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
181182 Some ( Node :: Field ( field) ) => ( field. span , field. ty . span ) ,
182183 _ => unreachable ! ( "mir field has to correspond to hir field" ) ,
183184 } ;
184- tcx. dcx ( ) . emit_err ( errors :: InvalidUnionField {
185+ tcx. dcx ( ) . emit_err ( diagnostics :: InvalidUnionField {
185186 field_span,
186- sugg : errors :: InvalidUnionFieldSuggestion {
187+ sugg : diagnostics :: InvalidUnionFieldSuggestion {
187188 lo : ty_span. shrink_to_lo ( ) ,
188189 hi : ty_span. shrink_to_hi ( ) ,
189190 } ,
@@ -217,7 +218,7 @@ fn check_static_inhabited(tcx: TyCtxt<'_>, def_id: LocalDefId) {
217218 if matches ! ( tcx. def_kind( def_id) , DefKind :: Static { .. }
218219 if tcx. def_kind( tcx. local_parent( def_id) ) == DefKind :: ForeignMod ) =>
219220 {
220- tcx. dcx ( ) . emit_err ( errors :: TooLargeStatic { span } ) ;
221+ tcx. dcx ( ) . emit_err ( diagnostics :: TooLargeStatic { span } ) ;
221222 return ;
222223 }
223224 // SIMD types with invalid layout (e.g., zero-length) should emit an error
@@ -599,7 +600,7 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
599600 }
600601 hir:: PreciseCapturingArg :: Lifetime ( & hir:: Lifetime { hir_id, ident, .. } ) => {
601602 if let Some ( prev_non_lifetime_param) = prev_non_lifetime_param {
602- tcx. dcx ( ) . emit_err ( errors :: LifetimesMustBeFirst {
603+ tcx. dcx ( ) . emit_err ( diagnostics :: LifetimesMustBeFirst {
603604 lifetime_span : ident. span ,
604605 name : ident. name ,
605606 other_span : prev_non_lifetime_param. span ,
@@ -611,7 +612,7 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
611612
612613 let ident = ident. normalize_to_macros_2_0 ( ) ;
613614 if let Some ( span) = seen_params. insert ( ident, ident. span ) {
614- tcx. dcx ( ) . emit_err ( errors :: DuplicatePreciseCapture {
615+ tcx. dcx ( ) . emit_err ( diagnostics :: DuplicatePreciseCapture {
615616 name : ident. name ,
616617 first_span : span,
617618 second_span : ident. span ,
@@ -675,14 +676,14 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
675676 . map_opaque_lifetime_to_parent_lifetime ( param. def_id . expect_local ( ) )
676677 . opt_param_def_id ( tcx, tcx. parent ( opaque_def_id. to_def_id ( ) ) )
677678 {
678- tcx. dcx ( ) . emit_err ( errors :: LifetimeNotCaptured {
679+ tcx. dcx ( ) . emit_err ( diagnostics :: LifetimeNotCaptured {
679680 opaque_span,
680681 use_span,
681682 param_span : tcx. def_span ( def_id) ,
682683 } ) ;
683684 } else {
684685 if tcx. def_kind ( tcx. parent ( param. def_id ) ) == DefKind :: Trait {
685- tcx. dcx ( ) . emit_err ( errors :: LifetimeImplicitlyCaptured {
686+ tcx. dcx ( ) . emit_err ( diagnostics :: LifetimeImplicitlyCaptured {
686687 opaque_span,
687688 param_span : tcx. def_span ( param. def_id ) ,
688689 } ) ;
@@ -691,7 +692,7 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
691692 // have not duplicated the lifetime but captured the original.
692693 // The "effective" `use_span` will be the span of the opaque itself,
693694 // and the param span will be the def span of the param.
694- tcx. dcx ( ) . emit_err ( errors :: LifetimeNotCaptured {
695+ tcx. dcx ( ) . emit_err ( diagnostics :: LifetimeNotCaptured {
695696 opaque_span,
696697 use_span : opaque_span,
697698 param_span : use_span,
@@ -704,13 +705,13 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
704705 ty:: GenericParamDefKind :: Type { .. } => {
705706 if matches ! ( tcx. def_kind( param. def_id) , DefKind :: Trait | DefKind :: TraitAlias ) {
706707 // FIXME(precise_capturing): Structured suggestion for this would be useful
707- tcx. dcx ( ) . emit_err ( errors :: SelfTyNotCaptured {
708+ tcx. dcx ( ) . emit_err ( diagnostics :: SelfTyNotCaptured {
708709 trait_span : tcx. def_span ( param. def_id ) ,
709710 opaque_span : tcx. def_span ( opaque_def_id) ,
710711 } ) ;
711712 } else {
712713 // FIXME(precise_capturing): Structured suggestion for this would be useful
713- tcx. dcx ( ) . emit_err ( errors :: ParamNotCaptured {
714+ tcx. dcx ( ) . emit_err ( diagnostics :: ParamNotCaptured {
714715 param_span : tcx. def_span ( param. def_id ) ,
715716 opaque_span : tcx. def_span ( opaque_def_id) ,
716717 kind : "type" ,
@@ -719,7 +720,7 @@ fn check_opaque_precise_captures<'tcx>(tcx: TyCtxt<'tcx>, opaque_def_id: LocalDe
719720 }
720721 ty:: GenericParamDefKind :: Const { .. } => {
721722 // FIXME(precise_capturing): Structured suggestion for this would be useful
722- tcx. dcx ( ) . emit_err ( errors :: ParamNotCaptured {
723+ tcx. dcx ( ) . emit_err ( diagnostics :: ParamNotCaptured {
723724 param_span : tcx. def_span ( param. def_id ) ,
724725 opaque_span : tcx. def_span ( opaque_def_id) ,
725726 kind : "const" ,
@@ -755,7 +756,7 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
755756 ty:: Adt ( adt_def, args) => !is_enum_of_nonnullable_ptr ( tcx, * adt_def, * args) ,
756757 _ => true ,
757758 } {
758- tcx. dcx ( ) . emit_err ( errors :: LinkageType { span : tcx. def_span ( def_id) } ) ;
759+ tcx. dcx ( ) . emit_err ( diagnostics :: LinkageType { span : tcx. def_span ( def_id) } ) ;
759760 }
760761 }
761762}
@@ -1238,8 +1239,8 @@ pub(super) fn check_specialization_validity<'tcx>(
12381239 let ident = tcx. item_ident ( impl_item) ;
12391240
12401241 let err = match tcx. span_of_impl ( parent_impl) {
1241- Ok ( sp) => errors :: ImplNotMarkedDefault :: Ok { span, ident, ok_label : sp } ,
1242- Err ( cname) => errors :: ImplNotMarkedDefault :: Err { span, ident, cname } ,
1242+ Ok ( sp) => diagnostics :: ImplNotMarkedDefault :: Ok { span, ident, ok_label : sp } ,
1243+ Err ( cname) => diagnostics :: ImplNotMarkedDefault :: Err { span, ident, cname } ,
12431244 } ;
12441245
12451246 tcx. dcx ( ) . emit_err ( err) ;
@@ -1255,7 +1256,7 @@ fn check_overriding_final_trait_item<'tcx>(
12551256 impl_item : ty:: AssocItem ,
12561257) {
12571258 if trait_item. defaultness ( tcx) . is_final ( ) {
1258- tcx. dcx ( ) . emit_err ( errors :: OverridingFinalTraitFunction {
1259+ tcx. dcx ( ) . emit_err ( diagnostics :: OverridingFinalTraitFunction {
12591260 impl_span : tcx. def_span ( impl_item. def_id ) ,
12601261 trait_span : tcx. def_span ( trait_item. def_id ) ,
12611262 ident : tcx. item_ident ( impl_item. def_id ) ,
@@ -1330,7 +1331,7 @@ fn check_impl_items_against_trait<'tcx>(
13301331 rustc_lint_defs:: builtin:: DEAD_CODE ,
13311332 tcx. local_def_id_to_hir_id ( ty_impl_item. def_id . expect_local ( ) ) ,
13321333 tcx. def_span ( ty_impl_item. def_id ) ,
1333- errors :: UselessImplItem ,
1334+ diagnostics :: UselessImplItem ,
13341335 )
13351336 }
13361337
@@ -1638,7 +1639,7 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
16381639 // over-aligned field to an aligned location before running its destructor, which would
16391640 // move a structurally pinned field out from under a `Pin<&mut _>` that was handed out.
16401641 if def. is_pin_project ( ) {
1641- tcx. dcx ( ) . emit_err ( errors :: PinV2OnPacked {
1642+ tcx. dcx ( ) . emit_err ( diagnostics :: PinV2OnPacked {
16421643 span : sp,
16431644 pin_v2_span : find_attr ! ( tcx, def. did( ) , PinV2 ( span) => * span) ,
16441645 adt_name : tcx. item_name ( def. did ( ) ) ,
@@ -2119,11 +2120,11 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
21192120 || ( * bounded_params) . get ( & param. index ) . is_some_and ( |& & pred_sp| pred_sp != span) ;
21202121 let const_param_help = !has_explicit_bounds;
21212122
2122- let mut diag = tcx. dcx ( ) . create_err ( errors :: UnusedGenericParameter {
2123+ let mut diag = tcx. dcx ( ) . create_err ( diagnostics :: UnusedGenericParameter {
21232124 span,
21242125 param_name,
21252126 param_def_kind : tcx. def_descr ( param. def_id ) ,
2126- help : errors :: UnusedGenericParameterHelp :: TyAlias { param_name } ,
2127+ help : diagnostics :: UnusedGenericParameterHelp :: TyAlias { param_name } ,
21272128 usage_spans : vec ! [ ] ,
21282129 const_param_help,
21292130 } ) ;
0 commit comments