Skip to content

Commit 6973fa0

Browse files
committed
Remove P::map.
It's barely used, and the places that use it are better if they don't.
1 parent a35675d commit 6973fa0

File tree

4 files changed

+21
-38
lines changed

4 files changed

+21
-38
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,10 +1123,9 @@ impl Stmt {
11231123
pub fn add_trailing_semicolon(mut self) -> Self {
11241124
self.kind = match self.kind {
11251125
StmtKind::Expr(expr) => StmtKind::Semi(expr),
1126-
StmtKind::MacCall(mac) => {
1127-
StmtKind::MacCall(mac.map(|MacCallStmt { mac, style: _, attrs, tokens }| {
1128-
MacCallStmt { mac, style: MacStmtStyle::Semicolon, attrs, tokens }
1129-
}))
1126+
StmtKind::MacCall(mut mac) => {
1127+
mac.style = MacStmtStyle::Semicolon;
1128+
StmtKind::MacCall(mac)
11301129
}
11311130
kind => kind,
11321131
};

compiler/rustc_ast/src/ptr.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ impl<T> P<T> {
5151
*self.ptr
5252
}
5353

54-
/// Produce a new `P<T>` from `self` without reallocating.
55-
pub fn map<F>(mut self, f: F) -> P<T>
56-
where
57-
F: FnOnce(T) -> T,
58-
{
59-
let x = f(*self.ptr);
60-
*self.ptr = x;
61-
62-
self
63-
}
64-
6554
/// Optionally produce a new `P<T>` from `self` without reallocating.
6655
pub fn filter_map<F>(mut self, f: F) -> Option<P<T>>
6756
where

compiler/rustc_builtin_macros/src/proc_macro_harness.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -354,30 +354,28 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
354354
})
355355
.collect();
356356

357-
let decls_static = cx
358-
.item_static(
357+
let mut decls_static = cx.item_static(
358+
span,
359+
Ident::new(sym::_DECLS, span),
360+
cx.ty_ref(
359361
span,
360-
Ident::new(sym::_DECLS, span),
361-
cx.ty_ref(
362+
cx.ty(
362363
span,
363-
cx.ty(
364-
span,
365-
ast::TyKind::Slice(
366-
cx.ty_path(cx.path(span, vec![proc_macro, bridge, client, proc_macro_ty])),
367-
),
364+
ast::TyKind::Slice(
365+
cx.ty_path(cx.path(span, vec![proc_macro, bridge, client, proc_macro_ty])),
368366
),
369-
None,
370-
ast::Mutability::Not,
371367
),
368+
None,
372369
ast::Mutability::Not,
373-
cx.expr_array_ref(span, decls),
374-
)
375-
.map(|mut i| {
376-
i.attrs.push(cx.attr_word(sym::rustc_proc_macro_decls, span));
377-
i.attrs.push(cx.attr_word(sym::used, span));
378-
i.attrs.push(cx.attr_nested_word(sym::allow, sym::deprecated, span));
379-
i
380-
});
370+
),
371+
ast::Mutability::Not,
372+
cx.expr_array_ref(span, decls),
373+
);
374+
decls_static.attrs.extend([
375+
cx.attr_word(sym::rustc_proc_macro_decls, span),
376+
cx.attr_word(sym::used, span),
377+
cx.attr_nested_word(sym::allow, sym::deprecated, span),
378+
]);
381379

382380
let block = cx.expr_block(
383381
cx.block(span, thin_vec![cx.stmt_item(span, krate), cx.stmt_item(span, decls_static)]),

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,7 @@ pub(crate) fn expand_test_or_bench(
381381
.into(),
382382
),
383383
);
384-
test_const = test_const.map(|mut tc| {
385-
tc.vis.kind = ast::VisibilityKind::Public;
386-
tc
387-
});
384+
test_const.vis.kind = ast::VisibilityKind::Public;
388385

389386
// extern crate test
390387
let test_extern =

0 commit comments

Comments
 (0)