@@ -13,9 +13,7 @@ use rustc_errors::{pluralize, struct_span_err, Applicability};
13
13
use rustc_hir as hir;
14
14
use rustc_hir:: def_id:: LocalDefId ;
15
15
use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
16
- use rustc_hir:: {
17
- self , FnSig , ForeignItem , ForeignItemKind , HirId , Item , ItemKind , TraitItem , CRATE_HIR_ID ,
18
- } ;
16
+ use rustc_hir:: { self , FnSig , ForeignItem , HirId , Item , ItemKind , TraitItem , CRATE_HIR_ID } ;
19
17
use rustc_hir:: { MethodKind , Target } ;
20
18
use rustc_session:: lint:: builtin:: {
21
19
CONFLICTING_REPR_HINTS , INVALID_DOC_ATTRIBUTES , UNUSED_ATTRIBUTES ,
@@ -81,9 +79,6 @@ impl CheckAttrVisitor<'tcx> {
81
79
sym:: doc => self . check_doc_attrs ( attr, hir_id, target, & mut specified_inline) ,
82
80
sym:: no_link => self . check_no_link ( hir_id, & attr, span, target) ,
83
81
sym:: export_name => self . check_export_name ( hir_id, & attr, span, target) ,
84
- sym:: rustc_args_required_const => {
85
- self . check_rustc_args_required_const ( & attr, span, target, item)
86
- }
87
82
sym:: rustc_layout_scalar_valid_range_start
88
83
| sym:: rustc_layout_scalar_valid_range_end => {
89
84
self . check_rustc_layout_scalar_valid_range ( & attr, span, target)
@@ -948,79 +943,6 @@ impl CheckAttrVisitor<'tcx> {
948
943
}
949
944
}
950
945
951
- /// Checks if `#[rustc_args_required_const]` is applied to a function and has a valid argument.
952
- fn check_rustc_args_required_const (
953
- & self ,
954
- attr : & Attribute ,
955
- span : & Span ,
956
- target : Target ,
957
- item : Option < ItemLike < ' _ > > ,
958
- ) -> bool {
959
- let is_function = matches ! ( target, Target :: Fn | Target :: Method ( ..) | Target :: ForeignFn ) ;
960
- if !is_function {
961
- self . tcx
962
- . sess
963
- . struct_span_err ( attr. span , "attribute should be applied to a function" )
964
- . span_label ( * span, "not a function" )
965
- . emit ( ) ;
966
- return false ;
967
- }
968
-
969
- let list = match attr. meta_item_list ( ) {
970
- // The attribute form is validated on AST.
971
- None => return false ,
972
- Some ( it) => it,
973
- } ;
974
-
975
- let mut invalid_args = vec ! [ ] ;
976
- for meta in list {
977
- if let Some ( LitKind :: Int ( val, _) ) = meta. literal ( ) . map ( |lit| & lit. kind ) {
978
- if let Some ( ItemLike :: Item ( Item {
979
- kind : ItemKind :: Fn ( FnSig { decl, .. } , ..) ,
980
- ..
981
- } ) )
982
- | Some ( ItemLike :: ForeignItem ( ForeignItem {
983
- kind : ForeignItemKind :: Fn ( decl, ..) ,
984
- ..
985
- } ) ) = item
986
- {
987
- let arg_count = decl. inputs . len ( ) as u128 ;
988
- if * val >= arg_count {
989
- let span = meta. span ( ) ;
990
- self . tcx
991
- . sess
992
- . struct_span_err ( span, "index exceeds number of arguments" )
993
- . span_label (
994
- span,
995
- format ! (
996
- "there {} only {} argument{}" ,
997
- if arg_count != 1 { "are" } else { "is" } ,
998
- arg_count,
999
- pluralize!( arg_count)
1000
- ) ,
1001
- )
1002
- . emit ( ) ;
1003
- return false ;
1004
- }
1005
- } else {
1006
- bug ! ( "should be a function item" ) ;
1007
- }
1008
- } else {
1009
- invalid_args. push ( meta. span ( ) ) ;
1010
- }
1011
- }
1012
-
1013
- if !invalid_args. is_empty ( ) {
1014
- self . tcx
1015
- . sess
1016
- . struct_span_err ( invalid_args, "arguments should be non-negative integers" )
1017
- . emit ( ) ;
1018
- false
1019
- } else {
1020
- true
1021
- }
1022
- }
1023
-
1024
946
fn check_rustc_layout_scalar_valid_range (
1025
947
& self ,
1026
948
attr : & Attribute ,
0 commit comments