@@ -13,9 +13,7 @@ use rustc_errors::{pluralize, struct_span_err, Applicability};
1313use rustc_hir as hir;
1414use rustc_hir:: def_id:: LocalDefId ;
1515use 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 } ;
1917use rustc_hir:: { MethodKind , Target } ;
2018use rustc_session:: lint:: builtin:: {
2119 CONFLICTING_REPR_HINTS , INVALID_DOC_ATTRIBUTES , UNUSED_ATTRIBUTES ,
@@ -81,9 +79,6 @@ impl CheckAttrVisitor<'tcx> {
8179 sym:: doc => self . check_doc_attrs ( attr, hir_id, target, & mut specified_inline) ,
8280 sym:: no_link => self . check_no_link ( hir_id, & attr, span, target) ,
8381 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- }
8782 sym:: rustc_layout_scalar_valid_range_start
8883 | sym:: rustc_layout_scalar_valid_range_end => {
8984 self . check_rustc_layout_scalar_valid_range ( & attr, span, target)
@@ -948,79 +943,6 @@ impl CheckAttrVisitor<'tcx> {
948943 }
949944 }
950945
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-
1024946 fn check_rustc_layout_scalar_valid_range (
1025947 & self ,
1026948 attr : & Attribute ,
0 commit comments