@@ -37,7 +37,7 @@ use rustc_span::symbol::{sym, Ident};
37
37
use rustc_span:: { ErrorGuaranteed , FileName , LocalExpnId , Span } ;
38
38
39
39
use smallvec:: SmallVec ;
40
- use std:: ops:: Deref ;
40
+ use std:: ops:: { Deref , DerefMut } ;
41
41
use std:: path:: PathBuf ;
42
42
use std:: rc:: Rc ;
43
43
use std:: { iter, mem} ;
@@ -699,7 +699,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
699
699
}
700
700
_ => unreachable ! ( ) ,
701
701
} ,
702
- InvocationKind :: Attr { attr, pos, mut item, derives } => match ext {
702
+ InvocationKind :: Attr { mut attr, pos, mut item, derives } => match ext {
703
703
SyntaxExtensionKind :: Attr ( expander) => {
704
704
self . gate_proc_macro_input ( & item) ;
705
705
self . gate_proc_macro_attr_item ( span, & item) ;
@@ -742,7 +742,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
742
742
}
743
743
}
744
744
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) {
746
746
Ok ( meta) => {
747
747
let items = match expander. expand ( self . cx , span, & meta, item, false ) {
748
748
ExpandResult :: Ready ( items) => items,
@@ -1079,7 +1079,7 @@ enum AddSemicolon {
1079
1079
/// of functionality used by `InvocationCollector`.
1080
1080
trait InvocationCollectorNode : HasAttrs + HasNodeId + Sized {
1081
1081
type OutputTy = SmallVec < [ Self ; 1 ] > ;
1082
- type AttrsTy : Deref < Target = [ ast:: Attribute ] > = ast:: AttrVec ;
1082
+ type AttrsTy : Deref < Target = [ ast:: Attribute ] > + DerefMut = ast:: AttrVec ;
1083
1083
type ItemKind = ItemKind ;
1084
1084
const KIND : AstFragmentKind ;
1085
1085
fn to_annotatable ( self ) -> Annotatable ;
@@ -1873,9 +1873,9 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1873
1873
// Detect use of feature-gated or invalid attributes on macro invocations
1874
1874
// since they will not be detected after macro expansion.
1875
1875
#[ 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 ) {
1877
1877
let features = self . cx . ecfg . features ;
1878
- let mut attrs = attrs. iter ( ) . peekable ( ) ;
1878
+ let mut attrs = attrs. iter_mut ( ) . peekable ( ) ;
1879
1879
let mut span: Option < Span > = None ;
1880
1880
while let Some ( attr) = attrs. next ( ) {
1881
1881
rustc_ast_passes:: feature_gate:: check_attribute ( attr, self . cx . sess , features) ;
@@ -1918,10 +1918,10 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1918
1918
fn expand_cfg_true (
1919
1919
& mut self ,
1920
1920
node : & mut impl HasAttrs ,
1921
- attr : ast:: Attribute ,
1921
+ mut attr : ast:: Attribute ,
1922
1922
pos : usize ,
1923
1923
) -> ( 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) ;
1925
1925
if res {
1926
1926
// FIXME: `cfg(TRUE)` attributes do not currently remove themselves during expansion,
1927
1927
// 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> {
1978
1978
}
1979
1979
} ,
1980
1980
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) ;
1983
1983
let mut res = self . collect_bang ( mac, Node :: KIND ) . make_ast :: < Node > ( ) ;
1984
1984
Node :: post_flat_map_node_collect_bang ( & mut res, add_semicolon) ;
1985
1985
res
@@ -2058,8 +2058,8 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
2058
2058
None if node. is_mac_call ( ) => {
2059
2059
visit_clobber ( node, |node| {
2060
2060
// 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) ;
2063
2063
self . collect_bang ( mac, Node :: KIND ) . make_ast :: < Node > ( )
2064
2064
} )
2065
2065
}
0 commit comments