@@ -843,12 +843,28 @@ pub(crate) fn get_publish(
843843    } 
844844} 
845845
846+ // Only those relevant to classifying an item as external / not external 
847+ // (external_body is relevant because it means anything on the inside of the item should 
848+ // be external) 
849+ #[ derive( Debug ) ]  
850+ pub ( crate )  struct  ExternalAttrs  { 
851+     pub ( crate )  external :  bool , 
852+     pub ( crate )  external_body :  bool , 
853+     pub ( crate )  external_fn_specification :  bool , 
854+     pub ( crate )  external_type_specification :  bool , 
855+     pub ( crate )  external_trait_specification :  bool , 
856+     pub ( crate )  sets_mode :  bool , 
857+     pub ( crate )  verify :  bool , 
858+     pub ( crate )  verus_macro :  bool , 
859+     pub ( crate )  size_of_global :  bool , 
860+     pub ( crate )  any_other_verus_specific_attribute :  bool , 
861+     pub ( crate )  internal_get_field_many_variants :  bool , 
862+ } 
863+ 
846864#[ derive( Debug ) ]  
847865pub ( crate )  struct  VerifierAttrs  { 
848866    pub ( crate )  verus_macro :  bool , 
849867    pub ( crate )  external_body :  bool , 
850-     pub ( crate )  external :  bool , 
851-     pub ( crate )  verify :  bool , 
852868    pub ( crate )  opaque :  bool , 
853869    pub ( crate )  publish :  Option < bool > , 
854870    pub ( crate )  opaque_outside_module :  bool , 
@@ -896,20 +912,6 @@ pub(crate) struct VerifierAttrs {
896912    pub ( crate )  type_invariant_fn :  bool , 
897913} 
898914
899- impl  VerifierAttrs  { 
900-     pub ( crate )  fn  is_external ( & self ,  cmd_line_args :  & crate :: config:: Args )  -> bool  { 
901-         self . external 
902-             || !( cmd_line_args. no_external_by_default 
903-                 || self . verus_macro 
904-                 || self . external_body 
905-                 || self . external_fn_specification 
906-                 || self . external_type_specification 
907-                 || self . external_trait_specification . is_some ( ) 
908-                 || self . verify 
909-                 || self . sets_mode ) 
910-     } 
911- } 
912- 
913915// Check for the `get_field_many_variants` attribute 
914916// Skips additional checks that are meant to be applied only during the 'main' processing 
915917// of an item. 
@@ -946,16 +948,55 @@ pub(crate) fn is_sealed(
946948    Ok ( false ) 
947949} 
948950
951+ /// Get the attributes needed to determine if the item is external. 
952+ pub ( crate )  fn  get_external_attrs ( 
953+     attrs :  & [ Attribute ] , 
954+     diagnostics :  Option < & mut  Vec < VirErrAs > > , 
955+ )  -> Result < ExternalAttrs ,  VirErr >  { 
956+     let  mut  es = ExternalAttrs  { 
957+         external_body :  false , 
958+         external_fn_specification :  false , 
959+         external_type_specification :  false , 
960+         external_trait_specification :  false , 
961+         external :  false , 
962+         verify :  false , 
963+         sets_mode :  false , 
964+         verus_macro :  false , 
965+         size_of_global :  false , 
966+         any_other_verus_specific_attribute :  false , 
967+         internal_get_field_many_variants :  false , 
968+     } ; 
969+ 
970+     for  attr in  parse_attrs ( attrs,  diagnostics) ? { 
971+         match  attr { 
972+             Attr :: ExternalBody  => es. external_body  = true , 
973+             Attr :: ExternalFnSpecification  => es. external_fn_specification  = true , 
974+             Attr :: ExternalTypeSpecification  => es. external_type_specification  = true , 
975+             Attr :: ExternalTraitSpecification ( _)  => es. external_trait_specification  = true , 
976+             Attr :: External  => es. external  = true , 
977+             Attr :: Verify  => es. verify  = true , 
978+             Attr :: Mode ( _)  => es. sets_mode  = true , 
979+             Attr :: VerusMacro  => es. verus_macro  = true , 
980+             Attr :: SizeOfGlobal  => es. size_of_global  = true , 
981+             Attr :: InternalGetFieldManyVariants  => es. internal_get_field_many_variants  = true , 
982+             Attr :: Trusted  => { } 
983+             Attr :: UnsupportedRustcAttr ( ..)  => { } 
984+             _ => { 
985+                 es. any_other_verus_specific_attribute  = true ; 
986+             } 
987+         } 
988+     } 
989+ 
990+     return  Ok ( es) ; 
991+ } 
992+ 
949993pub ( crate )  fn  get_verifier_attrs ( 
950994    attrs :  & [ Attribute ] , 
951995    diagnostics :  Option < & mut  Vec < VirErrAs > > , 
952-     cmd_line_args :  Option < & crate :: config:: Args > , 
953996)  -> Result < VerifierAttrs ,  VirErr >  { 
954997    let  mut  vs = VerifierAttrs  { 
955998        verus_macro :  false , 
956999        external_body :  false , 
957-         external :  false , 
958-         verify :  false , 
9591000        opaque :  false , 
9601001        publish :  None , 
9611002        opaque_outside_module :  false , 
@@ -1006,8 +1047,6 @@ pub(crate) fn get_verifier_attrs(
10061047        match  attr { 
10071048            Attr :: VerusMacro  => vs. verus_macro  = true , 
10081049            Attr :: ExternalBody  => vs. external_body  = true , 
1009-             Attr :: External  => vs. external  = true , 
1010-             Attr :: Verify  => vs. verify  = true , 
10111050            Attr :: ExternalFnSpecification  => vs. external_fn_specification  = true , 
10121051            Attr :: ExternalTypeSpecification  => vs. external_type_specification  = true , 
10131052            Attr :: ExternalTraitSpecification ( assoc)  => { 
@@ -1072,24 +1111,8 @@ pub(crate) fn get_verifier_attrs(
10721111            _ => { } 
10731112        } 
10741113    } 
1075-     if  attrs. len ( )  > 0  { 
1076-         let  span = attrs[ 0 ] . span ; 
1077-         let  mismatches = vec ! [ 
1078-             ( "inside verus macro" ,  "`verify`" ,  vs. verus_macro,  vs. verify) , 
1079-             ( "`external`" ,  "`verify`" ,  vs. external,  vs. verify) , 
1080-             ( "`external_body`" ,  "`verify`" ,  vs. external_body,  vs. verify) , 
1081-             ( "`external_body`" ,  "`external`" ,  vs. external_body,  vs. external) , 
1082-         ] ; 
1083-         for  ( msg1,  msg2,  flag1,  flag2)  in  mismatches { 
1084-             if  flag1 && flag2 { 
1085-                 return  err_span ( span,  format ! ( "item cannot be both {msg1} and {msg2}" , ) ) ; 
1086-             } 
1087-         } 
1088-     } 
10891114    if  let  Some ( ( rustc_attr,  span) )  = unsupported_rustc_attr { 
1090-         if  cmd_line_args. is_none ( )  || !vs. is_external ( cmd_line_args. unwrap ( ) )  { 
1091-             return  err_span ( span,  format ! ( "The attribute `{rustc_attr:}` is not supported" ) ) ; 
1092-         } 
1115+         return  err_span ( span,  format ! ( "The attribute `{rustc_attr:}` is not supported" ) ) ; 
10931116    } 
10941117    Ok ( vs) 
10951118} 
0 commit comments