@@ -23,7 +23,7 @@ use rustc_trait_selection::traits::SelectionContext;
2323use tracing:: debug;
2424
2525use super :: ConstCx ;
26- use crate :: errors ;
26+ use crate :: diagnostics ;
2727
2828#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
2929pub enum Status {
@@ -71,7 +71,7 @@ pub trait NonConstOp<'tcx>: std::fmt::Debug {
7171pub ( crate ) struct FnCallIndirect ;
7272impl < ' tcx > NonConstOp < ' tcx > for FnCallIndirect {
7373 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
74- ccx. dcx ( ) . create_err ( errors :: UnallowedFnPointerCall { span, kind : ccx. const_kind ( ) } )
74+ ccx. dcx ( ) . create_err ( diagnostics :: UnallowedFnPointerCall { span, kind : ccx. const_kind ( ) } )
7575 }
7676}
7777
@@ -90,7 +90,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallCVariadic {
9090
9191 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
9292 ccx. tcx . sess . create_feature_err (
93- errors :: NonConstCVariadicCall { span, kind : ccx. const_kind ( ) } ,
93+ diagnostics :: NonConstCVariadicCall { span, kind : ccx. const_kind ( ) } ,
9494 sym:: const_c_variadic,
9595 )
9696 }
@@ -192,7 +192,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
192192 // FIXME(const_trait_impl) revisit this
193193 if !tcx. is_const_trait_impl ( data. impl_def_id ) {
194194 let span = tcx. def_span ( data. impl_def_id ) ;
195- err. subdiagnostic ( errors :: NonConstImplNote { span } ) ;
195+ err. subdiagnostic ( diagnostics :: NonConstImplNote { span } ) ;
196196 }
197197 }
198198 }
@@ -235,7 +235,7 @@ fn build_error_for_const_call<'tcx>(
235235 CallKind :: Normal { desugaring : Some ( ( kind, self_ty) ) , .. } => {
236236 macro_rules! error {
237237 ( $err: ident) => {
238- tcx. dcx( ) . create_err( errors :: $err {
238+ tcx. dcx( ) . create_err( diagnostics :: $err {
239239 span,
240240 ty: self_ty,
241241 kind: ccx. const_kind( ) ,
@@ -273,14 +273,14 @@ fn build_error_for_const_call<'tcx>(
273273 span_bug ! ( span, "calling const FnDef errored when it shouldn't" ) ;
274274 }
275275
276- Some ( errors :: NonConstClosureNote :: FnDef { span } )
276+ Some ( diagnostics :: NonConstClosureNote :: FnDef { span } )
277277 }
278- FnPtr ( ..) => Some ( errors :: NonConstClosureNote :: FnPtr { kind } ) ,
279- Closure ( ..) => Some ( errors :: NonConstClosureNote :: Closure { kind } ) ,
278+ FnPtr ( ..) => Some ( diagnostics :: NonConstClosureNote :: FnPtr { kind } ) ,
279+ Closure ( ..) => Some ( diagnostics :: NonConstClosureNote :: Closure { kind } ) ,
280280 _ => None ,
281281 } ;
282282
283- let mut err = tcx. dcx ( ) . create_err ( errors :: NonConstClosure {
283+ let mut err = tcx. dcx ( ) . create_err ( diagnostics :: NonConstClosure {
284284 span,
285285 kind : ccx. const_kind ( ) ,
286286 note,
@@ -292,7 +292,7 @@ fn build_error_for_const_call<'tcx>(
292292 }
293293 CallKind :: Operator { trait_id, self_ty, .. } => {
294294 let mut err = if let CallSource :: MatchCmp = call_source {
295- tcx. dcx ( ) . create_err ( errors :: NonConstMatchEq {
295+ tcx. dcx ( ) . create_err ( diagnostics :: NonConstMatchEq {
296296 span,
297297 kind : ccx. const_kind ( ) ,
298298 ty : self_ty,
@@ -323,7 +323,7 @@ fn build_error_for_const_call<'tcx>(
323323 {
324324 let rhs_pos = span. lo ( ) + BytePos :: from_usize ( eq_idx + 2 + rhs_idx) ;
325325 let rhs_span = span. with_lo ( rhs_pos) . with_hi ( rhs_pos) ;
326- sugg = Some ( errors :: ConsiderDereferencing {
326+ sugg = Some ( diagnostics :: ConsiderDereferencing {
327327 deref,
328328 span : span. shrink_to_lo ( ) ,
329329 rhs_span,
@@ -333,7 +333,7 @@ fn build_error_for_const_call<'tcx>(
333333 _ => { }
334334 }
335335 }
336- tcx. dcx ( ) . create_err ( errors :: NonConstOperator {
336+ tcx. dcx ( ) . create_err ( diagnostics :: NonConstOperator {
337337 span,
338338 kind : ccx. const_kind ( ) ,
339339 sugg,
@@ -354,7 +354,7 @@ fn build_error_for_const_call<'tcx>(
354354 None
355355 } ;
356356
357- let mut err = tcx. dcx ( ) . create_err ( errors :: NonConstDerefCoercion {
357+ let mut err = tcx. dcx ( ) . create_err ( diagnostics :: NonConstDerefCoercion {
358358 span,
359359 ty : self_ty,
360360 kind : ccx. const_kind ( ) ,
@@ -367,15 +367,15 @@ fn build_error_for_const_call<'tcx>(
367367 err
368368 }
369369 _ if tcx. opt_parent ( callee) == tcx. get_diagnostic_item ( sym:: FmtArgumentsNew ) => {
370- ccx. dcx ( ) . create_err ( errors :: NonConstFmtMacroCall {
370+ ccx. dcx ( ) . create_err ( diagnostics :: NonConstFmtMacroCall {
371371 span,
372372 kind : ccx. const_kind ( ) ,
373373 non_or_conditionally,
374374 } )
375375 }
376376 _ => {
377377 let def_descr = ccx. tcx . def_descr ( callee) ;
378- let mut err = ccx. dcx ( ) . create_err ( errors :: NonConstFnCall {
378+ let mut err = ccx. dcx ( ) . create_err ( diagnostics :: NonConstFnCall {
379379 span,
380380 def_descr,
381381 def_path_str : ccx. tcx . def_path_str_with_args ( callee, args) ,
@@ -471,12 +471,12 @@ impl<'tcx> NonConstOp<'tcx> for CallUnstable {
471471 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
472472 assert ! ( !self . feature_enabled) ;
473473 let mut err = if self . is_function_call {
474- ccx. dcx ( ) . create_err ( errors :: UnstableConstFn {
474+ ccx. dcx ( ) . create_err ( diagnostics :: UnstableConstFn {
475475 span,
476476 def_path : ccx. tcx . def_path_str ( self . def_id ) ,
477477 } )
478478 } else {
479- ccx. dcx ( ) . create_err ( errors :: UnstableConstTrait {
479+ ccx. dcx ( ) . create_err ( diagnostics :: UnstableConstTrait {
480480 span,
481481 def_path : ccx. tcx . def_path_str ( self . def_id ) ,
482482 } )
@@ -494,7 +494,7 @@ pub(crate) struct IntrinsicNonConst {
494494
495495impl < ' tcx > NonConstOp < ' tcx > for IntrinsicNonConst {
496496 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
497- ccx. dcx ( ) . create_err ( errors :: NonConstIntrinsic {
497+ ccx. dcx ( ) . create_err ( diagnostics :: NonConstIntrinsic {
498498 span,
499499 name : self . name ,
500500 kind : ccx. const_kind ( ) ,
@@ -523,7 +523,7 @@ impl<'tcx> NonConstOp<'tcx> for IntrinsicUnstable {
523523 }
524524
525525 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
526- ccx. dcx ( ) . create_err ( errors :: UnstableIntrinsic {
526+ ccx. dcx ( ) . create_err ( diagnostics :: UnstableIntrinsic {
527527 span,
528528 name : self . name ,
529529 feature : self . feature ,
@@ -556,9 +556,11 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine {
556556 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
557557 let msg = format ! ( "{} are not allowed in {}s" , self . 0 . to_plural_string( ) , ccx. const_kind( ) ) ;
558558 if let Status :: Unstable { gate, .. } = self . status_in_item ( ccx) {
559- ccx. tcx . sess . create_feature_err ( errors:: UnallowedOpInConstContext { span, msg } , gate)
559+ ccx. tcx
560+ . sess
561+ . create_feature_err ( diagnostics:: UnallowedOpInConstContext { span, msg } , gate)
560562 } else {
561- ccx. dcx ( ) . create_err ( errors :: UnallowedOpInConstContext { span, msg } )
563+ ccx. dcx ( ) . create_err ( diagnostics :: UnallowedOpInConstContext { span, msg } )
562564 }
563565 }
564566}
@@ -567,7 +569,7 @@ impl<'tcx> NonConstOp<'tcx> for Coroutine {
567569pub ( crate ) struct InlineAsm ;
568570impl < ' tcx > NonConstOp < ' tcx > for InlineAsm {
569571 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
570- ccx. dcx ( ) . create_err ( errors :: UnallowedInlineAsm { span, kind : ccx. const_kind ( ) } )
572+ ccx. dcx ( ) . create_err ( diagnostics :: UnallowedInlineAsm { span, kind : ccx. const_kind ( ) } )
571573 }
572574}
573575
@@ -593,15 +595,15 @@ impl<'tcx> NonConstOp<'tcx> for LiveDrop<'tcx> {
593595
594596 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
595597 if self . needs_non_const_drop {
596- ccx. dcx ( ) . create_err ( errors :: LiveDrop {
598+ ccx. dcx ( ) . create_err ( diagnostics :: LiveDrop {
597599 span,
598600 dropped_ty : self . dropped_ty ,
599601 kind : ccx. const_kind ( ) ,
600602 dropped_at : self . dropped_at ,
601603 } )
602604 } else {
603605 ccx. tcx . sess . create_feature_err (
604- errors :: LiveDrop {
606+ diagnostics :: LiveDrop {
605607 span,
606608 dropped_ty : self . dropped_ty ,
607609 kind : ccx. const_kind ( ) ,
@@ -625,7 +627,8 @@ impl<'tcx> NonConstOp<'tcx> for EscapingCellBorrow {
625627 DiagImportance :: Secondary
626628 }
627629 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
628- ccx. dcx ( ) . create_err ( errors:: InteriorMutableBorrowEscaping { span, kind : ccx. const_kind ( ) } )
630+ ccx. dcx ( )
631+ . create_err ( diagnostics:: InteriorMutableBorrowEscaping { span, kind : ccx. const_kind ( ) } )
629632 }
630633}
631634
@@ -647,7 +650,7 @@ impl<'tcx> NonConstOp<'tcx> for EscapingMutBorrow {
647650 }
648651
649652 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
650- ccx. dcx ( ) . create_err ( errors :: MutableBorrowEscaping { span, kind : ccx. const_kind ( ) } )
653+ ccx. dcx ( ) . create_err ( diagnostics :: MutableBorrowEscaping { span, kind : ccx. const_kind ( ) } )
651654 }
652655}
653656
@@ -656,7 +659,7 @@ impl<'tcx> NonConstOp<'tcx> for EscapingMutBorrow {
656659pub ( crate ) struct PanicNonStr ;
657660impl < ' tcx > NonConstOp < ' tcx > for PanicNonStr {
658661 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
659- ccx. dcx ( ) . create_err ( errors :: PanicNonStrErr { span } )
662+ ccx. dcx ( ) . create_err ( diagnostics :: PanicNonStrErr { span } )
660663 }
661664}
662665
@@ -668,7 +671,7 @@ pub(crate) struct RawPtrComparison;
668671impl < ' tcx > NonConstOp < ' tcx > for RawPtrComparison {
669672 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
670673 // FIXME(const_trait_impl): revert to span_bug?
671- ccx. dcx ( ) . create_err ( errors :: RawPtrComparisonErr { span } )
674+ ccx. dcx ( ) . create_err ( diagnostics :: RawPtrComparisonErr { span } )
672675 }
673676}
674677
@@ -679,7 +682,7 @@ impl<'tcx> NonConstOp<'tcx> for RawPtrComparison {
679682pub ( crate ) struct RawPtrToIntCast ;
680683impl < ' tcx > NonConstOp < ' tcx > for RawPtrToIntCast {
681684 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
682- ccx. dcx ( ) . create_err ( errors :: RawPtrToIntErr { span } )
685+ ccx. dcx ( ) . create_err ( diagnostics :: RawPtrToIntErr { span } )
683686 }
684687}
685688
@@ -688,6 +691,6 @@ impl<'tcx> NonConstOp<'tcx> for RawPtrToIntCast {
688691pub ( crate ) struct ThreadLocalAccess ;
689692impl < ' tcx > NonConstOp < ' tcx > for ThreadLocalAccess {
690693 fn build_error ( & self , ccx : & ConstCx < ' _ , ' tcx > , span : Span ) -> Diag < ' tcx > {
691- ccx. dcx ( ) . create_err ( errors :: ThreadLocalAccessErr { span } )
694+ ccx. dcx ( ) . create_err ( diagnostics :: ThreadLocalAccessErr { span } )
692695 }
693696}
0 commit comments