Skip to content

Commit 285ea2f

Browse files
Rollup merge of #82107 - petrochenkov:minexpclean, r=Aaron1011
expand: Some cleanup See individual commits for details. r? ``@Aaron1011``
2 parents 40d85a5 + 6e11a8b commit 285ea2f

File tree

4 files changed

+9
-39
lines changed

4 files changed

+9
-39
lines changed

compiler/rustc_expand/src/expand.rs

+5-25
Original file line numberDiff line numberDiff line change
@@ -1067,8 +1067,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
10671067
fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
10681068
self.cfg.configure_expr(expr);
10691069
visit_clobber(expr.deref_mut(), |mut expr| {
1070-
self.cfg.configure_expr_kind(&mut expr.kind);
1071-
10721070
if let Some(attr) = self.take_first_attr(&mut expr) {
10731071
// Collect the invoc regardless of whether or not attributes are permitted here
10741072
// expansion will eat the attribute so it won't error later.
@@ -1166,8 +1164,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
11661164
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
11671165
let expr = configure!(self, expr);
11681166
expr.filter_map(|mut expr| {
1169-
self.cfg.configure_expr_kind(&mut expr.kind);
1170-
11711167
if let Some(attr) = self.take_first_attr(&mut expr) {
11721168
self.cfg.maybe_emit_expr_attr_err(&attr.0);
11731169

@@ -1192,7 +1188,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
11921188
}
11931189

11941190
fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
1195-
self.cfg.configure_pat(pat);
11961191
match pat.kind {
11971192
PatKind::MacCall(_) => {}
11981193
_ => return noop_visit_pat(pat, self),
@@ -1406,15 +1401,12 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
14061401
});
14071402
}
14081403

1409-
fn visit_foreign_mod(&mut self, foreign_mod: &mut ast::ForeignMod) {
1410-
self.cfg.configure_foreign_mod(foreign_mod);
1411-
noop_visit_foreign_mod(foreign_mod, self);
1412-
}
1413-
14141404
fn flat_map_foreign_item(
14151405
&mut self,
1416-
mut foreign_item: P<ast::ForeignItem>,
1406+
foreign_item: P<ast::ForeignItem>,
14171407
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
1408+
let mut foreign_item = configure!(self, foreign_item);
1409+
14181410
if let Some(attr) = self.take_first_attr(&mut foreign_item) {
14191411
return self
14201412
.collect_attr(
@@ -1439,11 +1431,6 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
14391431
}
14401432
}
14411433

1442-
fn visit_item_kind(&mut self, item: &mut ast::ItemKind) {
1443-
self.cfg.configure_item_kind(item);
1444-
noop_visit_item_kind(item, self);
1445-
}
1446-
14471434
fn flat_map_generic_param(
14481435
&mut self,
14491436
param: ast::GenericParam,
@@ -1602,21 +1589,15 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
16021589
*id = self.cx.resolver.next_node_id()
16031590
}
16041591
}
1605-
1606-
fn visit_fn_decl(&mut self, mut fn_decl: &mut P<ast::FnDecl>) {
1607-
self.cfg.configure_fn_decl(&mut fn_decl);
1608-
noop_visit_fn_decl(fn_decl, self);
1609-
}
16101592
}
16111593

16121594
pub struct ExpansionConfig<'feat> {
16131595
pub crate_name: String,
16141596
pub features: Option<&'feat Features>,
16151597
pub recursion_limit: Limit,
16161598
pub trace_mac: bool,
1617-
pub should_test: bool, // If false, strip `#[test]` nodes
1618-
pub keep_macs: bool,
1619-
pub span_debug: bool, // If true, use verbose debugging for `proc_macro::Span`
1599+
pub should_test: bool, // If false, strip `#[test]` nodes
1600+
pub span_debug: bool, // If true, use verbose debugging for `proc_macro::Span`
16201601
pub proc_macro_backtrace: bool, // If true, show backtraces for proc-macro panics
16211602
}
16221603

@@ -1628,7 +1609,6 @@ impl<'feat> ExpansionConfig<'feat> {
16281609
recursion_limit: Limit::new(1024),
16291610
trace_mac: false,
16301611
should_test: false,
1631-
keep_macs: false,
16321612
span_debug: false,
16331613
proc_macro_backtrace: false,
16341614
}

compiler/rustc_expand/src/placeholders.rs

-8
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,4 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
371371
}
372372
}
373373
}
374-
375-
fn visit_mod(&mut self, module: &mut ast::Mod) {
376-
noop_visit_mod(module, self);
377-
// remove macro definitions
378-
module.items.retain(
379-
|item| !matches!(item.kind, ast::ItemKind::MacCall(_) if !self.cx.ecfg.keep_macs),
380-
);
381-
}
382374
}

compiler/rustc_span/src/lib.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,10 @@ impl Span {
510510
/// items can be used (that is, a macro marked with
511511
/// `#[allow_internal_unstable]`).
512512
pub fn allows_unstable(&self, feature: Symbol) -> bool {
513-
self.ctxt().outer_expn_data().allow_internal_unstable.map_or(false, |features| {
514-
features
515-
.iter()
516-
.any(|&f| f == feature || f == sym::allow_internal_unstable_backcompat_hack)
517-
})
513+
self.ctxt()
514+
.outer_expn_data()
515+
.allow_internal_unstable
516+
.map_or(false, |features| features.iter().any(|&f| f == feature))
518517
}
519518

520519
/// Checks if this span arises from a compiler desugaring of kind `kind`.

compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ symbols! {
252252
allow_fail,
253253
allow_internal_unsafe,
254254
allow_internal_unstable,
255-
allow_internal_unstable_backcompat_hack,
256255
allowed,
257256
always,
258257
and,

0 commit comments

Comments
 (0)