@@ -796,7 +796,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
796
796
| Annotatable :: FieldDef ( ..)
797
797
| Annotatable :: Variant ( ..) => panic ! ( "unexpected annotatable" ) ,
798
798
} ;
799
- if self . cx . ecfg . proc_macro_hygiene ( ) {
799
+ if self . cx . ecfg . features . proc_macro_hygiene {
800
800
return ;
801
801
}
802
802
feature_err (
@@ -834,7 +834,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
834
834
}
835
835
}
836
836
837
- if !self . cx . ecfg . proc_macro_hygiene ( ) {
837
+ if !self . cx . ecfg . features . proc_macro_hygiene {
838
838
annotatable
839
839
. visit_with ( & mut GateProcMacroInput { parse_sess : & self . cx . sess . parse_sess } ) ;
840
840
}
@@ -1122,6 +1122,7 @@ impl InvocationCollectorNode for P<ast::Item> {
1122
1122
if let Some ( lint_store) = ecx. lint_store {
1123
1123
lint_store. pre_expansion_lint (
1124
1124
ecx. sess ,
1125
+ ecx. ecfg . features ,
1125
1126
ecx. resolver . registered_tools ( ) ,
1126
1127
ecx. current_expansion . lint_node_id ,
1127
1128
& attrs,
@@ -1580,7 +1581,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1580
1581
fn cfg ( & self ) -> StripUnconfigured < ' _ > {
1581
1582
StripUnconfigured {
1582
1583
sess : & self . cx . sess ,
1583
- features : self . cx . ecfg . features ,
1584
+ features : Some ( self . cx . ecfg . features ) ,
1584
1585
config_tokens : false ,
1585
1586
lint_node_id : self . cx . current_expansion . lint_node_id ,
1586
1587
}
@@ -1676,7 +1677,7 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
1676
1677
// Detect use of feature-gated or invalid attributes on macro invocations
1677
1678
// since they will not be detected after macro expansion.
1678
1679
fn check_attributes ( & self , attrs : & [ ast:: Attribute ] , call : & ast:: MacCall ) {
1679
- let features = self . cx . ecfg . features . unwrap ( ) ;
1680
+ let features = self . cx . ecfg . features ;
1680
1681
let mut attrs = attrs. iter ( ) . peekable ( ) ;
1681
1682
let mut span: Option < Span > = None ;
1682
1683
while let Some ( attr) = attrs. next ( ) {
@@ -1976,7 +1977,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
1976
1977
1977
1978
pub struct ExpansionConfig < ' feat > {
1978
1979
pub crate_name : String ,
1979
- pub features : Option < & ' feat Features > ,
1980
+ pub features : & ' feat Features ,
1980
1981
pub recursion_limit : Limit ,
1981
1982
pub trace_mac : bool ,
1982
1983
/// If false, strip `#[test]` nodes
@@ -1987,20 +1988,16 @@ pub struct ExpansionConfig<'feat> {
1987
1988
pub proc_macro_backtrace : bool ,
1988
1989
}
1989
1990
1990
- impl < ' feat > ExpansionConfig < ' feat > {
1991
- pub fn default ( crate_name : String ) -> ExpansionConfig < ' static > {
1991
+ impl ExpansionConfig < ' _ > {
1992
+ pub fn default ( crate_name : String , features : & Features ) -> ExpansionConfig < ' _ > {
1992
1993
ExpansionConfig {
1993
1994
crate_name,
1994
- features : None ,
1995
+ features,
1995
1996
recursion_limit : Limit :: new ( 1024 ) ,
1996
1997
trace_mac : false ,
1997
1998
should_test : false ,
1998
1999
span_debug : false ,
1999
2000
proc_macro_backtrace : false ,
2000
2001
}
2001
2002
}
2002
-
2003
- fn proc_macro_hygiene ( & self ) -> bool {
2004
- self . features . is_some_and ( |features| features. proc_macro_hygiene )
2005
- }
2006
2003
}
0 commit comments