@@ -37,7 +37,7 @@ use rustc_span::symbol::{sym, Ident};
3737use rustc_span:: { ErrorGuaranteed , FileName , LocalExpnId , Span } ;
3838
3939use smallvec:: SmallVec ;
40- use std:: ops:: Deref ;
40+ use std:: ops:: { Deref , DerefMut } ;
4141use std:: path:: PathBuf ;
4242use std:: rc:: Rc ;
4343use std:: { iter, mem} ;
@@ -699,7 +699,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
699699 }
700700 _ => unreachable ! ( ) ,
701701 } ,
702- InvocationKind :: Attr { attr, pos, mut item, derives } => match ext {
702+ InvocationKind :: Attr { mut attr, pos, mut item, derives } => match ext {
703703 SyntaxExtensionKind :: Attr ( expander) => {
704704 self . gate_proc_macro_input ( & item) ;
705705 self . gate_proc_macro_attr_item ( span, & item) ;
@@ -742,7 +742,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
742742 }
743743 }
744744 SyntaxExtensionKind :: LegacyAttr ( expander) => {
745- match validate_attr:: parse_meta ( & self . cx . sess . psess , & attr) {
745+ match validate_attr:: parse_meta ( & self . cx . sess . psess , & mut attr) {
746746 Ok ( meta) => {
747747 let items = match expander. expand ( self . cx , span, & meta, item, false ) {
748748 ExpandResult :: Ready ( items) => items,
@@ -1079,7 +1079,7 @@ enum AddSemicolon {
10791079/// of functionality used by `InvocationCollector`.
10801080trait InvocationCollectorNode : HasAttrs + HasNodeId + Sized {
10811081 type OutputTy = SmallVec < [ Self ; 1 ] > ;
1082- type AttrsTy : Deref < Target = [ ast:: Attribute ] > = ast:: AttrVec ;
1082+ type AttrsTy : Deref < Target = [ ast:: Attribute ] > + DerefMut = ast:: AttrVec ;
10831083 type ItemKind = ItemKind ;
10841084 const KIND : AstFragmentKind ;
10851085 fn to_annotatable ( self ) -> Annotatable ;
@@ -1873,9 +1873,9 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
18731873 // Detect use of feature-gated or invalid attributes on macro invocations
18741874 // since they will not be detected after macro expansion.
18751875 #[ allow( rustc:: untranslatable_diagnostic) ] // FIXME: make this translatable
1876- fn check_attributes ( & self , attrs : & [ ast:: Attribute ] , call : & ast:: MacCall ) {
1876+ fn check_attributes ( & self , attrs : & mut [ ast:: Attribute ] , call : & ast:: MacCall ) {
18771877 let features = self . cx . ecfg . features ;
1878- let mut attrs = attrs. iter ( ) . peekable ( ) ;
1878+ let mut attrs = attrs. iter_mut ( ) . peekable ( ) ;
18791879 let mut span: Option < Span > = None ;
18801880 while let Some ( attr) = attrs. next ( ) {
18811881 rustc_ast_passes:: feature_gate:: check_attribute ( attr, self . cx . sess , features) ;
@@ -1918,10 +1918,10 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
19181918 fn expand_cfg_true (
19191919 & mut self ,
19201920 node : & mut impl HasAttrs ,
1921- attr : ast:: Attribute ,
1921+ mut attr : ast:: Attribute ,
19221922 pos : usize ,
19231923 ) -> ( bool , Option < ast:: MetaItem > ) {
1924- let ( res, meta_item) = self . cfg ( ) . cfg_true ( & attr) ;
1924+ let ( res, meta_item) = self . cfg ( ) . cfg_true ( & mut attr) ;
19251925 if res {
19261926 // FIXME: `cfg(TRUE)` attributes do not currently remove themselves during expansion,
19271927 // and some tools like rustdoc and clippy rely on that. Find a way to remove them
@@ -1978,8 +1978,8 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
19781978 }
19791979 } ,
19801980 None if node. is_mac_call ( ) => {
1981- let ( mac, attrs, add_semicolon) = node. take_mac_call ( ) ;
1982- self . check_attributes ( & attrs, & mac) ;
1981+ let ( mac, mut attrs, add_semicolon) = node. take_mac_call ( ) ;
1982+ self . check_attributes ( & mut attrs, & mac) ;
19831983 let mut res = self . collect_bang ( mac, Node :: KIND ) . make_ast :: < Node > ( ) ;
19841984 Node :: post_flat_map_node_collect_bang ( & mut res, add_semicolon) ;
19851985 res
@@ -2058,8 +2058,8 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
20582058 None if node. is_mac_call ( ) => {
20592059 visit_clobber ( node, |node| {
20602060 // Do not clobber unless it's actually a macro (uncommon case).
2061- let ( mac, attrs, _) = node. take_mac_call ( ) ;
2062- self . check_attributes ( & attrs, & mac) ;
2061+ let ( mac, mut attrs, _) = node. take_mac_call ( ) ;
2062+ self . check_attributes ( & mut attrs, & mac) ;
20632063 self . collect_bang ( mac, Node :: KIND ) . make_ast :: < Node > ( )
20642064 } )
20652065 }
0 commit comments