Remove P::map.

It's barely used, and the places that use it are better if they don't.
This commit is contained in:
Nicholas Nethercote
2025-05-27 01:42:51 +10:00
parent a35675d38f
commit 6973fa08a3
4 changed files with 21 additions and 38 deletions

View File

@@ -1123,10 +1123,9 @@ impl Stmt {
pub fn add_trailing_semicolon(mut self) -> Self { pub fn add_trailing_semicolon(mut self) -> Self {
self.kind = match self.kind { self.kind = match self.kind {
StmtKind::Expr(expr) => StmtKind::Semi(expr), StmtKind::Expr(expr) => StmtKind::Semi(expr),
StmtKind::MacCall(mac) => { StmtKind::MacCall(mut mac) => {
StmtKind::MacCall(mac.map(|MacCallStmt { mac, style: _, attrs, tokens }| { mac.style = MacStmtStyle::Semicolon;
MacCallStmt { mac, style: MacStmtStyle::Semicolon, attrs, tokens } StmtKind::MacCall(mac)
}))
} }
kind => kind, kind => kind,
}; };

View File

@@ -51,17 +51,6 @@ impl<T> P<T> {
*self.ptr *self.ptr
} }
/// Produce a new `P<T>` from `self` without reallocating.
pub fn map<F>(mut self, f: F) -> P<T>
where
F: FnOnce(T) -> T,
{
let x = f(*self.ptr);
*self.ptr = x;
self
}
/// Optionally produce a new `P<T>` from `self` without reallocating. /// Optionally produce a new `P<T>` from `self` without reallocating.
pub fn filter_map<F>(mut self, f: F) -> Option<P<T>> pub fn filter_map<F>(mut self, f: F) -> Option<P<T>>
where where

View File

@@ -354,30 +354,28 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
}) })
.collect(); .collect();
let decls_static = cx let mut decls_static = cx.item_static(
.item_static( span,
Ident::new(sym::_DECLS, span),
cx.ty_ref(
span, span,
Ident::new(sym::_DECLS, span), cx.ty(
cx.ty_ref(
span, span,
cx.ty( ast::TyKind::Slice(
span, cx.ty_path(cx.path(span, vec![proc_macro, bridge, client, proc_macro_ty])),
ast::TyKind::Slice(
cx.ty_path(cx.path(span, vec![proc_macro, bridge, client, proc_macro_ty])),
),
), ),
None,
ast::Mutability::Not,
), ),
None,
ast::Mutability::Not, ast::Mutability::Not,
cx.expr_array_ref(span, decls), ),
) ast::Mutability::Not,
.map(|mut i| { cx.expr_array_ref(span, decls),
i.attrs.push(cx.attr_word(sym::rustc_proc_macro_decls, span)); );
i.attrs.push(cx.attr_word(sym::used, span)); decls_static.attrs.extend([
i.attrs.push(cx.attr_nested_word(sym::allow, sym::deprecated, span)); cx.attr_word(sym::rustc_proc_macro_decls, span),
i cx.attr_word(sym::used, span),
}); cx.attr_nested_word(sym::allow, sym::deprecated, span),
]);
let block = cx.expr_block( let block = cx.expr_block(
cx.block(span, thin_vec![cx.stmt_item(span, krate), cx.stmt_item(span, decls_static)]), cx.block(span, thin_vec![cx.stmt_item(span, krate), cx.stmt_item(span, decls_static)]),

View File

@@ -381,10 +381,7 @@ pub(crate) fn expand_test_or_bench(
.into(), .into(),
), ),
); );
test_const = test_const.map(|mut tc| { test_const.vis.kind = ast::VisibilityKind::Public;
tc.vis.kind = ast::VisibilityKind::Public;
tc
});
// extern crate test // extern crate test
let test_extern = let test_extern =