@@ -355,31 +355,6 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
355
355
}
356
356
}
357
357
358
- #[ derive( Debug ) ]
359
- pub struct FnPtrCast ;
360
- impl < ' tcx > NonConstOp < ' tcx > for FnPtrCast {
361
- fn status_in_item ( & self , ccx : & ConstCx < ' _ , ' tcx > ) -> Status {
362
- if ccx. const_kind ( ) != hir:: ConstContext :: ConstFn {
363
- Status :: Allowed
364
- } else {
365
- Status :: Unstable ( sym:: const_fn_fn_ptr_basics)
366
- }
367
- }
368
-
369
- fn build_error (
370
- & self ,
371
- ccx : & ConstCx < ' _ , ' tcx > ,
372
- span : Span ,
373
- ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
374
- feature_err (
375
- & ccx. tcx . sess . parse_sess ,
376
- sym:: const_fn_fn_ptr_basics,
377
- span,
378
- & format ! ( "function pointer casts are not allowed in {}s" , ccx. const_kind( ) ) ,
379
- )
380
- }
381
- }
382
-
383
358
#[ derive( Debug ) ]
384
359
pub struct Generator ( pub hir:: GeneratorKind ) ;
385
360
impl < ' tcx > NonConstOp < ' tcx > for Generator {
@@ -820,167 +795,4 @@ pub mod ty {
820
795
)
821
796
}
822
797
}
823
-
824
- #[ derive( Debug ) ]
825
- pub struct FnPtr ( pub mir:: LocalKind ) ;
826
- impl < ' tcx > NonConstOp < ' tcx > for FnPtr {
827
- fn importance ( & self ) -> DiagnosticImportance {
828
- match self . 0 {
829
- mir:: LocalKind :: Var | mir:: LocalKind :: Temp => DiagnosticImportance :: Secondary ,
830
- mir:: LocalKind :: ReturnPointer | mir:: LocalKind :: Arg => {
831
- DiagnosticImportance :: Primary
832
- }
833
- }
834
- }
835
-
836
- fn status_in_item ( & self , ccx : & ConstCx < ' _ , ' tcx > ) -> Status {
837
- if ccx. const_kind ( ) != hir:: ConstContext :: ConstFn {
838
- Status :: Allowed
839
- } else {
840
- Status :: Unstable ( sym:: const_fn_fn_ptr_basics)
841
- }
842
- }
843
-
844
- fn build_error (
845
- & self ,
846
- ccx : & ConstCx < ' _ , ' tcx > ,
847
- span : Span ,
848
- ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
849
- feature_err (
850
- & ccx. tcx . sess . parse_sess ,
851
- sym:: const_fn_fn_ptr_basics,
852
- span,
853
- & format ! ( "function pointers cannot appear in {}s" , ccx. const_kind( ) ) ,
854
- )
855
- }
856
- }
857
-
858
- #[ derive( Debug ) ]
859
- pub struct ImplTrait ;
860
- impl < ' tcx > NonConstOp < ' tcx > for ImplTrait {
861
- fn status_in_item ( & self , _: & ConstCx < ' _ , ' _ > ) -> Status {
862
- Status :: Unstable ( sym:: const_impl_trait)
863
- }
864
-
865
- fn build_error (
866
- & self ,
867
- ccx : & ConstCx < ' _ , ' tcx > ,
868
- span : Span ,
869
- ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
870
- feature_err (
871
- & ccx. tcx . sess . parse_sess ,
872
- sym:: const_impl_trait,
873
- span,
874
- & format ! ( "`impl Trait` is not allowed in {}s" , ccx. const_kind( ) ) ,
875
- )
876
- }
877
- }
878
-
879
- #[ derive( Debug ) ]
880
- pub struct TraitBound ( pub mir:: LocalKind ) ;
881
- impl < ' tcx > NonConstOp < ' tcx > for TraitBound {
882
- fn importance ( & self ) -> DiagnosticImportance {
883
- match self . 0 {
884
- mir:: LocalKind :: Var | mir:: LocalKind :: Temp => DiagnosticImportance :: Secondary ,
885
- mir:: LocalKind :: ReturnPointer | mir:: LocalKind :: Arg => {
886
- DiagnosticImportance :: Primary
887
- }
888
- }
889
- }
890
-
891
- fn status_in_item ( & self , ccx : & ConstCx < ' _ , ' tcx > ) -> Status {
892
- if ccx. const_kind ( ) != hir:: ConstContext :: ConstFn {
893
- Status :: Allowed
894
- } else {
895
- Status :: Unstable ( sym:: const_fn_trait_bound)
896
- }
897
- }
898
-
899
- fn build_error (
900
- & self ,
901
- ccx : & ConstCx < ' _ , ' tcx > ,
902
- span : Span ,
903
- ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
904
- let mut err = feature_err (
905
- & ccx. tcx . sess . parse_sess ,
906
- sym:: const_fn_trait_bound,
907
- span,
908
- "trait bounds other than `Sized` on const fn parameters are unstable" ,
909
- ) ;
910
-
911
- match ccx. fn_sig ( ) {
912
- Some ( fn_sig) if !fn_sig. span . contains ( span) => {
913
- err. span_label ( fn_sig. span , "function declared as const here" ) ;
914
- }
915
- _ => { }
916
- }
917
-
918
- err
919
- }
920
- }
921
-
922
- #[ derive( Debug ) ]
923
- pub struct DynTrait ( pub mir:: LocalKind ) ;
924
- impl < ' tcx > NonConstOp < ' tcx > for DynTrait {
925
- fn importance ( & self ) -> DiagnosticImportance {
926
- match self . 0 {
927
- mir:: LocalKind :: Var | mir:: LocalKind :: Temp => DiagnosticImportance :: Secondary ,
928
- mir:: LocalKind :: ReturnPointer | mir:: LocalKind :: Arg => {
929
- DiagnosticImportance :: Primary
930
- }
931
- }
932
- }
933
-
934
- fn status_in_item ( & self , ccx : & ConstCx < ' _ , ' tcx > ) -> Status {
935
- if ccx. const_kind ( ) != hir:: ConstContext :: ConstFn {
936
- Status :: Allowed
937
- } else {
938
- Status :: Unstable ( sym:: const_fn_trait_bound)
939
- }
940
- }
941
-
942
- fn build_error (
943
- & self ,
944
- ccx : & ConstCx < ' _ , ' tcx > ,
945
- span : Span ,
946
- ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
947
- let mut err = feature_err (
948
- & ccx. tcx . sess . parse_sess ,
949
- sym:: const_fn_trait_bound,
950
- span,
951
- "trait objects in const fn are unstable" ,
952
- ) ;
953
-
954
- match ccx. fn_sig ( ) {
955
- Some ( fn_sig) if !fn_sig. span . contains ( span) => {
956
- err. span_label ( fn_sig. span , "function declared as const here" ) ;
957
- }
958
- _ => { }
959
- }
960
-
961
- err
962
- }
963
- }
964
-
965
- /// A trait bound with the `?const Trait` opt-out
966
- #[ derive( Debug ) ]
967
- pub struct TraitBoundNotConst ;
968
- impl < ' tcx > NonConstOp < ' tcx > for TraitBoundNotConst {
969
- fn status_in_item ( & self , _: & ConstCx < ' _ , ' tcx > ) -> Status {
970
- Status :: Unstable ( sym:: const_trait_bound_opt_out)
971
- }
972
-
973
- fn build_error (
974
- & self ,
975
- ccx : & ConstCx < ' _ , ' tcx > ,
976
- span : Span ,
977
- ) -> DiagnosticBuilder < ' tcx , ErrorGuaranteed > {
978
- feature_err (
979
- & ccx. tcx . sess . parse_sess ,
980
- sym:: const_trait_bound_opt_out,
981
- span,
982
- "`?const Trait` syntax is unstable" ,
983
- )
984
- }
985
- }
986
798
}
0 commit comments