remove P
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::{
|
||||
self as ast, Fn, FnHeader, FnSig, Generics, ItemKind, Safety, Stmt, StmtKind, TyKind,
|
||||
};
|
||||
@@ -46,7 +45,7 @@ pub(crate) fn expand(
|
||||
let const_body = ecx.expr_block(ecx.block(span, stmts));
|
||||
let const_item = ecx.item_const(span, Ident::new(kw::Underscore, span), const_ty, const_body);
|
||||
let const_item = if is_stmt {
|
||||
Annotatable::Stmt(P(ecx.stmt_item(span, const_item)))
|
||||
Annotatable::Stmt(Box::new(ecx.stmt_item(span, const_item)))
|
||||
} else {
|
||||
Annotatable::Item(const_item)
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use lint::BuiltinLintDiag;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::{AsmMacro, token};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||
@@ -19,7 +18,7 @@ use crate::{errors, fluent_generated as fluent};
|
||||
|
||||
/// Validated assembly arguments, ready for macro expansion.
|
||||
struct ValidatedAsmArgs {
|
||||
pub templates: Vec<P<ast::Expr>>,
|
||||
pub templates: Vec<Box<ast::Expr>>,
|
||||
pub operands: Vec<(ast::InlineAsmOperand, Span)>,
|
||||
named_args: FxIndexMap<Symbol, usize>,
|
||||
reg_args: GrowableBitSet<usize>,
|
||||
@@ -600,9 +599,9 @@ pub(super) fn expand_asm<'cx>(
|
||||
return ExpandResult::Retry(());
|
||||
};
|
||||
let expr = match mac {
|
||||
Ok(inline_asm) => P(ast::Expr {
|
||||
Ok(inline_asm) => Box::new(ast::Expr {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: ast::ExprKind::InlineAsm(P(inline_asm)),
|
||||
kind: ast::ExprKind::InlineAsm(Box::new(inline_asm)),
|
||||
span: sp,
|
||||
attrs: ast::AttrVec::new(),
|
||||
tokens: None,
|
||||
@@ -630,9 +629,9 @@ pub(super) fn expand_naked_asm<'cx>(
|
||||
return ExpandResult::Retry(());
|
||||
};
|
||||
let expr = match mac {
|
||||
Ok(inline_asm) => P(ast::Expr {
|
||||
Ok(inline_asm) => Box::new(ast::Expr {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: ast::ExprKind::InlineAsm(P(inline_asm)),
|
||||
kind: ast::ExprKind::InlineAsm(Box::new(inline_asm)),
|
||||
span: sp,
|
||||
attrs: ast::AttrVec::new(),
|
||||
tokens: None,
|
||||
@@ -660,7 +659,7 @@ pub(super) fn expand_global_asm<'cx>(
|
||||
return ExpandResult::Retry(());
|
||||
};
|
||||
match mac {
|
||||
Ok(inline_asm) => MacEager::items(smallvec![P(ast::Item {
|
||||
Ok(inline_asm) => MacEager::items(smallvec![Box::new(ast::Item {
|
||||
attrs: ast::AttrVec::new(),
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: ast::ItemKind::GlobalAsm(Box::new(inline_asm)),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
mod context;
|
||||
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::token::Delimiter;
|
||||
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
|
||||
use rustc_ast::{DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp, token};
|
||||
@@ -55,9 +54,9 @@ pub(crate) fn expand_assert<'cx>(
|
||||
let expr = if let Some(tokens) = custom_message {
|
||||
let then = cx.expr(
|
||||
call_site_span,
|
||||
ExprKind::MacCall(P(MacCall {
|
||||
ExprKind::MacCall(Box::new(MacCall {
|
||||
path: panic_path(),
|
||||
args: P(DelimArgs {
|
||||
args: Box::new(DelimArgs {
|
||||
dspan: DelimSpan::from_single(call_site_span),
|
||||
delim: Delimiter::Parenthesis,
|
||||
tokens,
|
||||
@@ -96,7 +95,7 @@ pub(crate) fn expand_assert<'cx>(
|
||||
}
|
||||
|
||||
struct Assert {
|
||||
cond_expr: P<Expr>,
|
||||
cond_expr: Box<Expr>,
|
||||
custom_message: Option<TokenStream>,
|
||||
}
|
||||
|
||||
@@ -104,10 +103,10 @@ struct Assert {
|
||||
fn expr_if_not(
|
||||
cx: &ExtCtxt<'_>,
|
||||
span: Span,
|
||||
cond: P<Expr>,
|
||||
then: P<Expr>,
|
||||
els: Option<P<Expr>>,
|
||||
) -> P<Expr> {
|
||||
cond: Box<Expr>,
|
||||
then: Box<Expr>,
|
||||
els: Option<Box<Expr>>,
|
||||
) -> Box<Expr> {
|
||||
cx.expr_if(span, cx.expr(span, ExprKind::Unary(UnOp::Not, cond)), then, els)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::token::{self, Delimiter, IdentIsRaw};
|
||||
use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
|
||||
use rustc_ast::{
|
||||
@@ -70,7 +69,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
pub(super) fn build(mut self, mut cond_expr: P<Expr>, panic_path: Path) -> P<Expr> {
|
||||
pub(super) fn build(mut self, mut cond_expr: Box<Expr>, panic_path: Path) -> Box<Expr> {
|
||||
let expr_str = pprust::expr_to_string(&cond_expr);
|
||||
self.manage_cond_expr(&mut cond_expr);
|
||||
let initial_imports = self.build_initial_imports();
|
||||
@@ -129,7 +128,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
||||
}
|
||||
|
||||
/// Takes the conditional expression of `assert!` and then wraps it inside `unlikely`
|
||||
fn build_unlikely(&self, cond_expr: P<Expr>) -> P<Expr> {
|
||||
fn build_unlikely(&self, cond_expr: Box<Expr>) -> Box<Expr> {
|
||||
let unlikely_path = self.cx.std_path(&[sym::intrinsics, sym::unlikely]);
|
||||
self.cx.expr_call(
|
||||
self.span,
|
||||
@@ -145,7 +144,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
||||
/// __capture0,
|
||||
/// ...
|
||||
/// );
|
||||
fn build_panic(&self, expr_str: &str, panic_path: Path) -> P<Expr> {
|
||||
fn build_panic(&self, expr_str: &str, panic_path: Path) -> Box<Expr> {
|
||||
let escaped_expr_str = escape_to_fmt(expr_str);
|
||||
let initial = [
|
||||
TokenTree::token_joint(
|
||||
@@ -176,9 +175,9 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
||||
});
|
||||
self.cx.expr(
|
||||
self.span,
|
||||
ExprKind::MacCall(P(MacCall {
|
||||
ExprKind::MacCall(Box::new(MacCall {
|
||||
path: panic_path,
|
||||
args: P(DelimArgs {
|
||||
args: Box::new(DelimArgs {
|
||||
dspan: DelimSpan::from_single(self.span),
|
||||
delim: Delimiter::Parenthesis,
|
||||
tokens: initial.into_iter().chain(captures).collect::<TokenStream>(),
|
||||
@@ -190,7 +189,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
||||
/// Recursive function called until `cond_expr` and `fmt_str` are fully modified.
|
||||
///
|
||||
/// See [Self::manage_initial_capture] and [Self::manage_try_capture]
|
||||
fn manage_cond_expr(&mut self, expr: &mut P<Expr>) {
|
||||
fn manage_cond_expr(&mut self, expr: &mut Box<Expr>) {
|
||||
match &mut expr.kind {
|
||||
ExprKind::AddrOf(_, mutability, local_expr) => {
|
||||
self.with_is_consumed_management(matches!(mutability, Mutability::Mut), |this| {
|
||||
@@ -331,7 +330,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
||||
///
|
||||
/// `fmt_str`, the formatting string used for debugging, is constructed to show possible
|
||||
/// captured variables.
|
||||
fn manage_initial_capture(&mut self, expr: &mut P<Expr>, path_ident: Ident) {
|
||||
fn manage_initial_capture(&mut self, expr: &mut Box<Expr>, path_ident: Ident) {
|
||||
if self.paths.contains(&path_ident) {
|
||||
return;
|
||||
} else {
|
||||
@@ -360,7 +359,12 @@ impl<'cx, 'a> Context<'cx, 'a> {
|
||||
/// (&Wrapper(__local_bindN)).try_capture(&mut __captureN);
|
||||
/// __local_bindN
|
||||
/// }
|
||||
fn manage_try_capture(&mut self, capture: Ident, curr_capture_idx: usize, expr: &mut P<Expr>) {
|
||||
fn manage_try_capture(
|
||||
&mut self,
|
||||
capture: Ident,
|
||||
curr_capture_idx: usize,
|
||||
expr: &mut Box<Expr>,
|
||||
) {
|
||||
let local_bind_string = format!("__local_bind{curr_capture_idx}");
|
||||
let local_bind = Ident::new(Symbol::intern(&local_bind_string), self.span);
|
||||
self.local_bind_decls.push(self.cx.stmt_let(
|
||||
@@ -441,20 +445,20 @@ fn escape_to_fmt(s: &str) -> String {
|
||||
rslt
|
||||
}
|
||||
|
||||
fn expr_addr_of_mut(cx: &ExtCtxt<'_>, sp: Span, e: P<Expr>) -> P<Expr> {
|
||||
fn expr_addr_of_mut(cx: &ExtCtxt<'_>, sp: Span, e: Box<Expr>) -> Box<Expr> {
|
||||
cx.expr(sp, ExprKind::AddrOf(BorrowKind::Ref, Mutability::Mut, e))
|
||||
}
|
||||
|
||||
fn expr_method_call(
|
||||
cx: &ExtCtxt<'_>,
|
||||
seg: PathSegment,
|
||||
receiver: P<Expr>,
|
||||
args: ThinVec<P<Expr>>,
|
||||
receiver: Box<Expr>,
|
||||
args: ThinVec<Box<Expr>>,
|
||||
span: Span,
|
||||
) -> P<Expr> {
|
||||
) -> Box<Expr> {
|
||||
cx.expr(span, ExprKind::MethodCall(Box::new(MethodCall { seg, receiver, args, span })))
|
||||
}
|
||||
|
||||
fn expr_paren(cx: &ExtCtxt<'_>, sp: Span, e: P<Expr>) -> P<Expr> {
|
||||
fn expr_paren(cx: &ExtCtxt<'_>, sp: Span, e: Box<Expr>) -> Box<Expr> {
|
||||
cx.expr(sp, ExprKind::Paren(e))
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ mod llvm_enzyme {
|
||||
AutoDiffAttrs, DiffActivity, DiffMode, valid_input_activity, valid_ret_activity,
|
||||
valid_ty_for_activity,
|
||||
};
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::token::{Lit, LitKind, Token, TokenKind};
|
||||
use rustc_ast::tokenstream::*;
|
||||
use rustc_ast::visit::AssocCtxt::*;
|
||||
@@ -27,7 +26,7 @@ mod llvm_enzyme {
|
||||
use crate::errors;
|
||||
|
||||
pub(crate) fn outer_normal_attr(
|
||||
kind: &P<rustc_ast::NormalAttr>,
|
||||
kind: &Box<rustc_ast::NormalAttr>,
|
||||
id: rustc_ast::AttrId,
|
||||
span: Span,
|
||||
) -> rustc_ast::Attribute {
|
||||
@@ -73,7 +72,7 @@ mod llvm_enzyme {
|
||||
}
|
||||
|
||||
// Get information about the function the macro is applied to
|
||||
fn extract_item_info(iitem: &P<ast::Item>) -> Option<(Visibility, FnSig, Ident, Generics)> {
|
||||
fn extract_item_info(iitem: &Box<ast::Item>) -> Option<(Visibility, FnSig, Ident, Generics)> {
|
||||
match &iitem.kind {
|
||||
ItemKind::Fn(box ast::Fn { sig, ident, generics, .. }) => {
|
||||
Some((iitem.vis.clone(), sig.clone(), ident.clone(), generics.clone()))
|
||||
@@ -346,7 +345,7 @@ mod llvm_enzyme {
|
||||
define_opaque: None,
|
||||
});
|
||||
let mut rustc_ad_attr =
|
||||
P(ast::NormalAttr::from_ident(Ident::with_dummy_span(sym::rustc_autodiff)));
|
||||
Box::new(ast::NormalAttr::from_ident(Ident::with_dummy_span(sym::rustc_autodiff)));
|
||||
|
||||
let ts2: Vec<TokenTree> = vec![TokenTree::Token(
|
||||
Token::new(TokenKind::Ident(sym::never, false.into()), span),
|
||||
@@ -363,7 +362,7 @@ mod llvm_enzyme {
|
||||
args: ast::AttrArgs::Delimited(never_arg),
|
||||
tokens: None,
|
||||
};
|
||||
let inline_never_attr = P(ast::NormalAttr { item: inline_item, tokens: None });
|
||||
let inline_never_attr = Box::new(ast::NormalAttr { item: inline_item, tokens: None });
|
||||
let new_id = ecx.sess.psess.attr_id_generator.mk_attr_id();
|
||||
let attr = outer_normal_attr(&rustc_ad_attr, new_id, span);
|
||||
let new_id = ecx.sess.psess.attr_id_generator.mk_attr_id();
|
||||
@@ -433,7 +432,7 @@ mod llvm_enzyme {
|
||||
let d_annotatable = match &item {
|
||||
Annotatable::AssocItem(_, _) => {
|
||||
let assoc_item: AssocItemKind = ast::AssocItemKind::Fn(asdf);
|
||||
let d_fn = P(ast::AssocItem {
|
||||
let d_fn = Box::new(ast::AssocItem {
|
||||
attrs: thin_vec![d_attr, inline_never],
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span,
|
||||
@@ -453,7 +452,7 @@ mod llvm_enzyme {
|
||||
let mut d_fn = ecx.item(span, thin_vec![d_attr, inline_never], ItemKind::Fn(asdf));
|
||||
d_fn.vis = vis;
|
||||
|
||||
Annotatable::Stmt(P(ast::Stmt {
|
||||
Annotatable::Stmt(Box::new(ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: ast::StmtKind::Item(d_fn),
|
||||
span,
|
||||
@@ -506,7 +505,7 @@ mod llvm_enzyme {
|
||||
idents: &[Ident],
|
||||
errored: bool,
|
||||
generics: &Generics,
|
||||
) -> (P<ast::Block>, P<ast::Expr>, P<ast::Expr>, P<ast::Expr>) {
|
||||
) -> (Box<ast::Block>, Box<ast::Expr>, Box<ast::Expr>, Box<ast::Expr>) {
|
||||
let blackbox_path = ecx.std_path(&[sym::hint, sym::black_box]);
|
||||
let noop = ast::InlineAsm {
|
||||
asm_macro: ast::AsmMacro::Asm,
|
||||
@@ -517,7 +516,7 @@ mod llvm_enzyme {
|
||||
options: ast::InlineAsmOptions::PURE | ast::InlineAsmOptions::NOMEM,
|
||||
line_spans: vec![],
|
||||
};
|
||||
let noop_expr = ecx.expr_asm(span, P(noop));
|
||||
let noop_expr = ecx.expr_asm(span, Box::new(noop));
|
||||
let unsf = ast::BlockCheckMode::Unsafe(ast::UnsafeSource::CompilerGenerated);
|
||||
let unsf_block = ast::Block {
|
||||
stmts: thin_vec![ecx.stmt_semi(noop_expr)],
|
||||
@@ -526,7 +525,7 @@ mod llvm_enzyme {
|
||||
rules: unsf,
|
||||
span,
|
||||
};
|
||||
let unsf_expr = ecx.expr_block(P(unsf_block));
|
||||
let unsf_expr = ecx.expr_block(Box::new(unsf_block));
|
||||
let blackbox_call_expr = ecx.expr_path(ecx.path(span, blackbox_path));
|
||||
let primal_call = gen_primal_call(ecx, span, primal, idents, generics);
|
||||
let black_box_primal_call = ecx.expr_call(
|
||||
@@ -578,7 +577,7 @@ mod llvm_enzyme {
|
||||
idents: Vec<Ident>,
|
||||
errored: bool,
|
||||
generics: &Generics,
|
||||
) -> P<ast::Block> {
|
||||
) -> Box<ast::Block> {
|
||||
let new_decl_span = d_sig.span;
|
||||
|
||||
// Just adding some default inline-asm and black_box usages to prevent early inlining
|
||||
@@ -634,7 +633,7 @@ mod llvm_enzyme {
|
||||
return body;
|
||||
}
|
||||
|
||||
let mut exprs: P<ast::Expr> = primal_call;
|
||||
let mut exprs: Box<ast::Expr> = primal_call;
|
||||
let d_ret_ty = match d_sig.decl.output {
|
||||
FnRetTy::Ty(ref ty) => ty.clone(),
|
||||
FnRetTy::Default(span) => {
|
||||
@@ -653,7 +652,7 @@ mod llvm_enzyme {
|
||||
} else {
|
||||
let q = QSelf { ty: d_ret_ty, path_span: span, position: 0 };
|
||||
let y = ExprKind::Path(
|
||||
Some(P(q)),
|
||||
Some(Box::new(q)),
|
||||
ecx.path_ident(span, Ident::with_dummy_span(kw::Default)),
|
||||
);
|
||||
let default_call_expr = ecx.expr(span, y);
|
||||
@@ -703,7 +702,7 @@ mod llvm_enzyme {
|
||||
primal: Ident,
|
||||
idents: &[Ident],
|
||||
generics: &Generics,
|
||||
) -> P<ast::Expr> {
|
||||
) -> Box<ast::Expr> {
|
||||
let has_self = idents.len() > 0 && idents[0].name == kw::SelfLower;
|
||||
|
||||
if has_self {
|
||||
@@ -740,7 +739,7 @@ mod llvm_enzyme {
|
||||
},
|
||||
);
|
||||
|
||||
ast::AngleBracketedArg::Arg(ast::GenericArg::Type(P(ast::Ty {
|
||||
ast::AngleBracketedArg::Arg(ast::GenericArg::Type(Box::new(ast::Ty {
|
||||
id: type_param.id,
|
||||
span,
|
||||
kind: generic_param,
|
||||
@@ -750,7 +749,7 @@ mod llvm_enzyme {
|
||||
.collect();
|
||||
|
||||
function_path.args =
|
||||
Some(P(ast::GenericArgs::AngleBracketed(ast::AngleBracketedArgs {
|
||||
Some(Box::new(ast::GenericArgs::AngleBracketed(ast::AngleBracketedArgs {
|
||||
span,
|
||||
args: generated_generic_types,
|
||||
})));
|
||||
@@ -856,7 +855,7 @@ mod llvm_enzyme {
|
||||
for i in 0..x.width {
|
||||
let mut shadow_arg = arg.clone();
|
||||
// We += into the shadow in reverse mode.
|
||||
shadow_arg.ty = P(assure_mut_ref(&arg.ty));
|
||||
shadow_arg.ty = Box::new(assure_mut_ref(&arg.ty));
|
||||
let old_name = if let PatKind::Ident(_, ident, _) = arg.pat.kind {
|
||||
ident.name
|
||||
} else {
|
||||
@@ -866,7 +865,7 @@ mod llvm_enzyme {
|
||||
let name: String = format!("d{}_{}", old_name, i);
|
||||
new_inputs.push(name.clone());
|
||||
let ident = Ident::from_str_and_span(&name, shadow_arg.pat.span);
|
||||
shadow_arg.pat = P(ast::Pat {
|
||||
shadow_arg.pat = Box::new(ast::Pat {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: PatKind::Ident(BindingMode::NONE, ident, None),
|
||||
span: shadow_arg.pat.span,
|
||||
@@ -898,7 +897,7 @@ mod llvm_enzyme {
|
||||
let name: String = format!("b{}_{}", old_name, i);
|
||||
new_inputs.push(name.clone());
|
||||
let ident = Ident::from_str_and_span(&name, shadow_arg.pat.span);
|
||||
shadow_arg.pat = P(ast::Pat {
|
||||
shadow_arg.pat = Box::new(ast::Pat {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: PatKind::Ident(BindingMode::NONE, ident, None),
|
||||
span: shadow_arg.pat.span,
|
||||
@@ -942,7 +941,7 @@ mod llvm_enzyme {
|
||||
let shadow_arg = ast::Param {
|
||||
attrs: ThinVec::new(),
|
||||
ty: ty.clone(),
|
||||
pat: P(ast::Pat {
|
||||
pat: Box::new(ast::Pat {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: PatKind::Ident(BindingMode::NONE, ident, None),
|
||||
span: ty.span,
|
||||
@@ -966,7 +965,12 @@ mod llvm_enzyme {
|
||||
FnRetTy::Default(span) => {
|
||||
// We want to return std::hint::black_box(()).
|
||||
let kind = TyKind::Tup(ThinVec::new());
|
||||
let ty = P(rustc_ast::Ty { kind, id: ast::DUMMY_NODE_ID, span, tokens: None });
|
||||
let ty = Box::new(rustc_ast::Ty {
|
||||
kind,
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span,
|
||||
tokens: None,
|
||||
});
|
||||
d_decl.output = FnRetTy::Ty(ty.clone());
|
||||
assert!(matches!(x.ret_activity, DiffActivity::None));
|
||||
// this won't be used below, so any type would be fine.
|
||||
@@ -987,7 +991,7 @@ mod llvm_enzyme {
|
||||
};
|
||||
TyKind::Array(ty.clone(), anon_const)
|
||||
};
|
||||
let ty = P(rustc_ast::Ty { kind, id: ty.id, span: ty.span, tokens: None });
|
||||
let ty = Box::new(rustc_ast::Ty { kind, id: ty.id, span: ty.span, tokens: None });
|
||||
d_decl.output = FnRetTy::Ty(ty);
|
||||
}
|
||||
if matches!(x.ret_activity, DiffActivity::DualOnly | DiffActivity::DualvOnly) {
|
||||
@@ -1000,7 +1004,8 @@ mod llvm_enzyme {
|
||||
value: ecx.expr_usize(span, x.width as usize),
|
||||
};
|
||||
let kind = TyKind::Array(ty.clone(), anon_const);
|
||||
let ty = P(rustc_ast::Ty { kind, id: ty.id, span: ty.span, tokens: None });
|
||||
let ty =
|
||||
Box::new(rustc_ast::Ty { kind, id: ty.id, span: ty.span, tokens: None });
|
||||
d_decl.output = FnRetTy::Ty(ty);
|
||||
}
|
||||
}
|
||||
@@ -1022,14 +1027,14 @@ mod llvm_enzyme {
|
||||
act_ret.insert(0, ty.clone());
|
||||
}
|
||||
let kind = TyKind::Tup(act_ret);
|
||||
P(rustc_ast::Ty { kind, id: ty.id, span: ty.span, tokens: None })
|
||||
Box::new(rustc_ast::Ty { kind, id: ty.id, span: ty.span, tokens: None })
|
||||
}
|
||||
FnRetTy::Default(span) => {
|
||||
if act_ret.len() == 1 {
|
||||
act_ret[0].clone()
|
||||
} else {
|
||||
let kind = TyKind::Tup(act_ret.iter().map(|arg| arg.clone()).collect());
|
||||
P(rustc_ast::Ty { kind, id: ast::DUMMY_NODE_ID, span, tokens: None })
|
||||
Box::new(rustc_ast::Ty { kind, id: ast::DUMMY_NODE_ID, span, tokens: None })
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@ use core::ops::ControlFlow;
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast::mut_visit::MutVisitor;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::visit::{AssocCtxt, Visitor};
|
||||
use rustc_ast::{Attribute, HasAttrs, HasTokens, NodeId, mut_visit, visit};
|
||||
use rustc_errors::PResult;
|
||||
@@ -132,7 +131,7 @@ impl CfgEval<'_> {
|
||||
let stmt = parser
|
||||
.parse_stmt_without_recovery(false, ForceCollect::Yes, false)?
|
||||
.unwrap();
|
||||
Annotatable::Stmt(P(self.flat_map_stmt(stmt).pop().unwrap()))
|
||||
Annotatable::Stmt(Box::new(self.flat_map_stmt(stmt).pop().unwrap()))
|
||||
}
|
||||
Annotatable::Expr(_) => {
|
||||
let mut expr = parser.parse_expr_force_collect()?;
|
||||
@@ -166,7 +165,7 @@ impl MutVisitor for CfgEval<'_> {
|
||||
mut_visit::walk_expr(self, expr);
|
||||
}
|
||||
|
||||
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
|
||||
fn filter_map_expr(&mut self, expr: Box<ast::Expr>) -> Option<Box<ast::Expr>> {
|
||||
let mut expr = configure!(self, expr);
|
||||
mut_visit::walk_expr(self, &mut expr);
|
||||
Some(expr)
|
||||
@@ -185,24 +184,24 @@ impl MutVisitor for CfgEval<'_> {
|
||||
mut_visit::walk_flat_map_stmt(self, stmt)
|
||||
}
|
||||
|
||||
fn flat_map_item(&mut self, item: P<ast::Item>) -> SmallVec<[P<ast::Item>; 1]> {
|
||||
fn flat_map_item(&mut self, item: Box<ast::Item>) -> SmallVec<[Box<ast::Item>; 1]> {
|
||||
let item = configure!(self, item);
|
||||
mut_visit::walk_flat_map_item(self, item)
|
||||
}
|
||||
|
||||
fn flat_map_assoc_item(
|
||||
&mut self,
|
||||
item: P<ast::AssocItem>,
|
||||
item: Box<ast::AssocItem>,
|
||||
ctxt: AssocCtxt,
|
||||
) -> SmallVec<[P<ast::AssocItem>; 1]> {
|
||||
) -> SmallVec<[Box<ast::AssocItem>; 1]> {
|
||||
let item = configure!(self, item);
|
||||
mut_visit::walk_flat_map_assoc_item(self, item, ctxt)
|
||||
}
|
||||
|
||||
fn flat_map_foreign_item(
|
||||
&mut self,
|
||||
foreign_item: P<ast::ForeignItem>,
|
||||
) -> SmallVec<[P<ast::ForeignItem>; 1]> {
|
||||
foreign_item: Box<ast::ForeignItem>,
|
||||
) -> SmallVec<[Box<ast::ForeignItem>; 1]> {
|
||||
let foreign_item = configure!(self, foreign_item);
|
||||
mut_visit::walk_flat_map_foreign_item(self, foreign_item)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::{ExprKind, LitIntType, LitKind, StrStyle, UintTy, token};
|
||||
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
|
||||
@@ -90,7 +89,7 @@ fn handle_array_element(
|
||||
cx: &ExtCtxt<'_>,
|
||||
guar: &mut Option<ErrorGuaranteed>,
|
||||
missing_literals: &mut Vec<rustc_span::Span>,
|
||||
expr: &P<rustc_ast::Expr>,
|
||||
expr: &Box<rustc_ast::Expr>,
|
||||
) -> Option<u8> {
|
||||
let dcx = cx.dcx();
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::{BinOpKind, BorrowKind, Expr, ExprKind, MetaItem, Mutability};
|
||||
use rustc_expand::base::{Annotatable, ExtCtxt};
|
||||
use rustc_span::{Span, sym};
|
||||
@@ -119,7 +118,7 @@ fn get_substructure_equality_expr(
|
||||
cx: &ExtCtxt<'_>,
|
||||
span: Span,
|
||||
substructure: &Substructure<'_>,
|
||||
) -> P<Expr> {
|
||||
) -> Box<Expr> {
|
||||
use SubstructureFields::*;
|
||||
|
||||
match substructure.fields {
|
||||
@@ -180,7 +179,7 @@ fn get_substructure_equality_expr(
|
||||
///
|
||||
/// Panics if there are not exactly two arguments to compare (should be `self`
|
||||
/// and `other`).
|
||||
fn get_field_equality_expr(cx: &ExtCtxt<'_>, field: &FieldInfo) -> P<Expr> {
|
||||
fn get_field_equality_expr(cx: &ExtCtxt<'_>, field: &FieldInfo) -> Box<Expr> {
|
||||
let [rhs] = &field.other_selflike_exprs[..] else {
|
||||
cx.dcx().span_bug(field.span, "not exactly 2 arguments in `derive(PartialEq)`");
|
||||
};
|
||||
@@ -198,7 +197,7 @@ fn get_field_equality_expr(cx: &ExtCtxt<'_>, field: &FieldInfo) -> P<Expr> {
|
||||
/// This is used to strip away any number of leading `&` from an expression
|
||||
/// (e.g., `&&&T` becomes `T`). Only removes immutable references; mutable
|
||||
/// references are preserved.
|
||||
fn peel_refs(mut expr: &P<Expr>) -> P<Expr> {
|
||||
fn peel_refs(mut expr: &Box<Expr>) -> Box<Expr> {
|
||||
while let ExprKind::AddrOf(BorrowKind::Ref, Mutability::Not, inner) = &expr.kind {
|
||||
expr = &inner;
|
||||
}
|
||||
@@ -210,7 +209,7 @@ fn peel_refs(mut expr: &P<Expr>) -> P<Expr> {
|
||||
///
|
||||
/// If the given expression is a block, it is wrapped in parentheses; otherwise,
|
||||
/// it is returned unchanged.
|
||||
fn wrap_block_expr(cx: &ExtCtxt<'_>, expr: P<Expr>) -> P<Expr> {
|
||||
fn wrap_block_expr(cx: &ExtCtxt<'_>, expr: Box<Expr>) -> Box<Expr> {
|
||||
if matches!(&expr.kind, ExprKind::Block(..)) {
|
||||
return cx.expr_paren(expr.span, expr);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ fn show_substructure(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) ->
|
||||
field: &FieldInfo,
|
||||
index: usize,
|
||||
len: usize,
|
||||
) -> ast::ptr::P<ast::Expr> {
|
||||
) -> Box<ast::Expr> {
|
||||
if index < len - 1 {
|
||||
field.self_expr.clone()
|
||||
} else {
|
||||
|
||||
@@ -56,7 +56,7 @@ pub(crate) fn expand_deriving_default(
|
||||
trait_def.expand(cx, mitem, item, push)
|
||||
}
|
||||
|
||||
fn default_call(cx: &ExtCtxt<'_>, span: Span) -> ast::ptr::P<ast::Expr> {
|
||||
fn default_call(cx: &ExtCtxt<'_>, span: Span) -> Box<ast::Expr> {
|
||||
// Note that `kw::Default` is "default" and `sym::Default` is "Default"!
|
||||
let default_ident = cx.std_path(&[kw::Default, sym::Default, kw::Default]);
|
||||
cx.expr_call_global(span, default_ident, ThinVec::new())
|
||||
|
||||
@@ -180,7 +180,6 @@ use std::{iter, vec};
|
||||
|
||||
pub(crate) use StaticFields::*;
|
||||
pub(crate) use SubstructureFields::*;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::token::{IdentIsRaw, LitKind, Token, TokenKind};
|
||||
use rustc_ast::tokenstream::{DelimSpan, Spacing, TokenTree};
|
||||
use rustc_ast::{
|
||||
@@ -272,7 +271,7 @@ pub(crate) struct Substructure<'a> {
|
||||
pub type_ident: Ident,
|
||||
/// Verbatim access to any non-selflike arguments, i.e. arguments that
|
||||
/// don't have type `&Self`.
|
||||
pub nonselflike_args: &'a [P<Expr>],
|
||||
pub nonselflike_args: &'a [Box<Expr>],
|
||||
pub fields: &'a SubstructureFields<'a>,
|
||||
}
|
||||
|
||||
@@ -284,10 +283,10 @@ pub(crate) struct FieldInfo {
|
||||
pub name: Option<Ident>,
|
||||
/// The expression corresponding to this field of `self`
|
||||
/// (specifically, a reference to it).
|
||||
pub self_expr: P<Expr>,
|
||||
pub self_expr: Box<Expr>,
|
||||
/// The expressions corresponding to references to this field in
|
||||
/// the other selflike arguments.
|
||||
pub other_selflike_exprs: Vec<P<Expr>>,
|
||||
pub other_selflike_exprs: Vec<Box<Expr>>,
|
||||
pub maybe_scalar: bool,
|
||||
}
|
||||
|
||||
@@ -323,7 +322,7 @@ pub(crate) enum SubstructureFields<'a> {
|
||||
/// The discriminant of an enum. The first field is a `FieldInfo` for the discriminants, as
|
||||
/// if they were fields. The second field is the expression to combine the
|
||||
/// discriminant expression with; it will be `None` if no match is necessary.
|
||||
EnumDiscr(FieldInfo, Option<P<Expr>>),
|
||||
EnumDiscr(FieldInfo, Option<Box<Expr>>),
|
||||
|
||||
/// A static method where `Self` is a struct.
|
||||
StaticStruct(&'a ast::VariantData, StaticFields),
|
||||
@@ -345,7 +344,7 @@ pub(crate) fn combine_substructure(
|
||||
|
||||
struct TypeParameter {
|
||||
bound_generic_params: ThinVec<ast::GenericParam>,
|
||||
ty: P<ast::Ty>,
|
||||
ty: Box<ast::Ty>,
|
||||
}
|
||||
|
||||
/// The code snippets built up for derived code are sometimes used as blocks
|
||||
@@ -354,23 +353,23 @@ struct TypeParameter {
|
||||
/// avoiding the insertion of any unnecessary blocks.
|
||||
///
|
||||
/// The statements come before the expression.
|
||||
pub(crate) struct BlockOrExpr(ThinVec<ast::Stmt>, Option<P<Expr>>);
|
||||
pub(crate) struct BlockOrExpr(ThinVec<ast::Stmt>, Option<Box<Expr>>);
|
||||
|
||||
impl BlockOrExpr {
|
||||
pub(crate) fn new_stmts(stmts: ThinVec<ast::Stmt>) -> BlockOrExpr {
|
||||
BlockOrExpr(stmts, None)
|
||||
}
|
||||
|
||||
pub(crate) fn new_expr(expr: P<Expr>) -> BlockOrExpr {
|
||||
pub(crate) fn new_expr(expr: Box<Expr>) -> BlockOrExpr {
|
||||
BlockOrExpr(ThinVec::new(), Some(expr))
|
||||
}
|
||||
|
||||
pub(crate) fn new_mixed(stmts: ThinVec<ast::Stmt>, expr: Option<P<Expr>>) -> BlockOrExpr {
|
||||
pub(crate) fn new_mixed(stmts: ThinVec<ast::Stmt>, expr: Option<Box<Expr>>) -> BlockOrExpr {
|
||||
BlockOrExpr(stmts, expr)
|
||||
}
|
||||
|
||||
// Converts it into a block.
|
||||
fn into_block(mut self, cx: &ExtCtxt<'_>, span: Span) -> P<ast::Block> {
|
||||
fn into_block(mut self, cx: &ExtCtxt<'_>, span: Span) -> Box<ast::Block> {
|
||||
if let Some(expr) = self.1 {
|
||||
self.0.push(cx.stmt_expr(expr));
|
||||
}
|
||||
@@ -378,7 +377,7 @@ impl BlockOrExpr {
|
||||
}
|
||||
|
||||
// Converts it into an expression.
|
||||
fn into_expr(self, cx: &ExtCtxt<'_>, span: Span) -> P<Expr> {
|
||||
fn into_expr(self, cx: &ExtCtxt<'_>, span: Span) -> Box<Expr> {
|
||||
if self.0.is_empty() {
|
||||
match self.1 {
|
||||
None => cx.expr_block(cx.block(span, ThinVec::new())),
|
||||
@@ -432,7 +431,7 @@ fn find_type_parameters(
|
||||
{
|
||||
self.type_params.push(TypeParameter {
|
||||
bound_generic_params: self.bound_generic_params_stack.clone(),
|
||||
ty: P(ty.clone()),
|
||||
ty: Box::new(ty.clone()),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -544,7 +543,7 @@ impl<'a> TraitDef<'a> {
|
||||
})
|
||||
.cloned(),
|
||||
);
|
||||
push(Annotatable::Item(P(ast::Item { attrs, ..(*newitem).clone() })))
|
||||
push(Annotatable::Item(Box::new(ast::Item { attrs, ..(*newitem).clone() })))
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
@@ -590,15 +589,15 @@ impl<'a> TraitDef<'a> {
|
||||
cx: &ExtCtxt<'_>,
|
||||
type_ident: Ident,
|
||||
generics: &Generics,
|
||||
field_tys: Vec<P<ast::Ty>>,
|
||||
methods: Vec<P<ast::AssocItem>>,
|
||||
field_tys: Vec<Box<ast::Ty>>,
|
||||
methods: Vec<Box<ast::AssocItem>>,
|
||||
is_packed: bool,
|
||||
) -> P<ast::Item> {
|
||||
) -> Box<ast::Item> {
|
||||
let trait_path = self.path.to_path(cx, self.span, type_ident, generics);
|
||||
|
||||
// Transform associated types from `deriving::ty::Ty` into `ast::AssocItem`
|
||||
let associated_types = self.associated_types.iter().map(|&(ident, ref type_def)| {
|
||||
P(ast::AssocItem {
|
||||
Box::new(ast::AssocItem {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
span: self.span,
|
||||
vis: ast::Visibility {
|
||||
@@ -853,8 +852,8 @@ impl<'a> TraitDef<'a> {
|
||||
generics: &Generics,
|
||||
from_scratch: bool,
|
||||
is_packed: bool,
|
||||
) -> P<ast::Item> {
|
||||
let field_tys: Vec<P<ast::Ty>> =
|
||||
) -> Box<ast::Item> {
|
||||
let field_tys: Vec<Box<ast::Ty>> =
|
||||
struct_def.fields().iter().map(|field| field.ty.clone()).collect();
|
||||
|
||||
let methods = self
|
||||
@@ -906,7 +905,7 @@ impl<'a> TraitDef<'a> {
|
||||
type_ident: Ident,
|
||||
generics: &Generics,
|
||||
from_scratch: bool,
|
||||
) -> P<ast::Item> {
|
||||
) -> Box<ast::Item> {
|
||||
let mut field_tys = Vec::new();
|
||||
|
||||
for variant in &enum_def.variants {
|
||||
@@ -962,7 +961,7 @@ impl<'a> MethodDef<'a> {
|
||||
cx: &ExtCtxt<'_>,
|
||||
trait_: &TraitDef<'_>,
|
||||
type_ident: Ident,
|
||||
nonselflike_args: &[P<Expr>],
|
||||
nonselflike_args: &[Box<Expr>],
|
||||
fields: &SubstructureFields<'_>,
|
||||
) -> BlockOrExpr {
|
||||
let span = trait_.span;
|
||||
@@ -978,7 +977,7 @@ impl<'a> MethodDef<'a> {
|
||||
trait_: &TraitDef<'_>,
|
||||
generics: &Generics,
|
||||
type_ident: Ident,
|
||||
) -> P<ast::Ty> {
|
||||
) -> Box<ast::Ty> {
|
||||
self.ret_ty.to_ty(cx, trait_.span, type_ident, generics)
|
||||
}
|
||||
|
||||
@@ -999,7 +998,8 @@ impl<'a> MethodDef<'a> {
|
||||
trait_: &TraitDef<'_>,
|
||||
type_ident: Ident,
|
||||
generics: &Generics,
|
||||
) -> (Option<ast::ExplicitSelf>, ThinVec<P<Expr>>, Vec<P<Expr>>, Vec<(Ident, P<ast::Ty>)>) {
|
||||
) -> (Option<ast::ExplicitSelf>, ThinVec<Box<Expr>>, Vec<Box<Expr>>, Vec<(Ident, Box<ast::Ty>)>)
|
||||
{
|
||||
let mut selflike_args = ThinVec::new();
|
||||
let mut nonselflike_args = Vec::new();
|
||||
let mut nonself_arg_tys = Vec::new();
|
||||
@@ -1036,9 +1036,9 @@ impl<'a> MethodDef<'a> {
|
||||
type_ident: Ident,
|
||||
generics: &Generics,
|
||||
explicit_self: Option<ast::ExplicitSelf>,
|
||||
nonself_arg_tys: Vec<(Ident, P<ast::Ty>)>,
|
||||
nonself_arg_tys: Vec<(Ident, Box<ast::Ty>)>,
|
||||
body: BlockOrExpr,
|
||||
) -> P<ast::AssocItem> {
|
||||
) -> Box<ast::AssocItem> {
|
||||
let span = trait_.span;
|
||||
// Create the generics that aren't for `Self`.
|
||||
let fn_generics = self.generics.to_generics(cx, span, type_ident, generics);
|
||||
@@ -1065,7 +1065,7 @@ impl<'a> MethodDef<'a> {
|
||||
let defaultness = ast::Defaultness::Final;
|
||||
|
||||
// Create the method.
|
||||
P(ast::AssocItem {
|
||||
Box::new(ast::AssocItem {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
attrs: self.attributes.clone(),
|
||||
span,
|
||||
@@ -1128,8 +1128,8 @@ impl<'a> MethodDef<'a> {
|
||||
trait_: &TraitDef<'b>,
|
||||
struct_def: &'b VariantData,
|
||||
type_ident: Ident,
|
||||
selflike_args: &[P<Expr>],
|
||||
nonselflike_args: &[P<Expr>],
|
||||
selflike_args: &[Box<Expr>],
|
||||
nonselflike_args: &[Box<Expr>],
|
||||
is_packed: bool,
|
||||
) -> BlockOrExpr {
|
||||
assert!(selflike_args.len() == 1 || selflike_args.len() == 2);
|
||||
@@ -1151,7 +1151,7 @@ impl<'a> MethodDef<'a> {
|
||||
trait_: &TraitDef<'_>,
|
||||
struct_def: &VariantData,
|
||||
type_ident: Ident,
|
||||
nonselflike_args: &[P<Expr>],
|
||||
nonselflike_args: &[Box<Expr>],
|
||||
) -> BlockOrExpr {
|
||||
let summary = trait_.summarise_struct(cx, struct_def);
|
||||
|
||||
@@ -1205,8 +1205,8 @@ impl<'a> MethodDef<'a> {
|
||||
trait_: &TraitDef<'b>,
|
||||
enum_def: &'b EnumDef,
|
||||
type_ident: Ident,
|
||||
mut selflike_args: ThinVec<P<Expr>>,
|
||||
nonselflike_args: &[P<Expr>],
|
||||
mut selflike_args: ThinVec<Box<Expr>>,
|
||||
nonselflike_args: &[Box<Expr>],
|
||||
) -> BlockOrExpr {
|
||||
assert!(
|
||||
!selflike_args.is_empty(),
|
||||
@@ -1418,7 +1418,7 @@ impl<'a> MethodDef<'a> {
|
||||
// ...
|
||||
// _ => ::core::intrinsics::unreachable(),
|
||||
// }
|
||||
let get_match_expr = |mut selflike_args: ThinVec<P<Expr>>| {
|
||||
let get_match_expr = |mut selflike_args: ThinVec<Box<Expr>>| {
|
||||
let match_arg = if selflike_args.len() == 1 {
|
||||
selflike_args.pop().unwrap()
|
||||
} else {
|
||||
@@ -1454,7 +1454,7 @@ impl<'a> MethodDef<'a> {
|
||||
trait_: &TraitDef<'_>,
|
||||
enum_def: &EnumDef,
|
||||
type_ident: Ident,
|
||||
nonselflike_args: &[P<Expr>],
|
||||
nonselflike_args: &[Box<Expr>],
|
||||
) -> BlockOrExpr {
|
||||
self.call_substructure_method(
|
||||
cx,
|
||||
@@ -1503,7 +1503,7 @@ impl<'a> TraitDef<'a> {
|
||||
struct_def: &'a VariantData,
|
||||
prefixes: &[String],
|
||||
by_ref: ByRef,
|
||||
) -> ThinVec<P<ast::Pat>> {
|
||||
) -> ThinVec<Box<ast::Pat>> {
|
||||
prefixes
|
||||
.iter()
|
||||
.map(|prefix| {
|
||||
@@ -1558,7 +1558,7 @@ impl<'a> TraitDef<'a> {
|
||||
|
||||
fn create_fields<F>(&self, struct_def: &'a VariantData, mk_exprs: F) -> Vec<FieldInfo>
|
||||
where
|
||||
F: Fn(usize, &ast::FieldDef, Span) -> Vec<P<ast::Expr>>,
|
||||
F: Fn(usize, &ast::FieldDef, Span) -> Vec<Box<ast::Expr>>,
|
||||
{
|
||||
struct_def
|
||||
.fields()
|
||||
@@ -1606,7 +1606,7 @@ impl<'a> TraitDef<'a> {
|
||||
fn create_struct_field_access_fields(
|
||||
&self,
|
||||
cx: &ExtCtxt<'_>,
|
||||
selflike_args: &[P<Expr>],
|
||||
selflike_args: &[Box<Expr>],
|
||||
struct_def: &'a VariantData,
|
||||
is_packed: bool,
|
||||
) -> Vec<FieldInfo> {
|
||||
@@ -1651,7 +1651,7 @@ pub(crate) enum CsFold<'a> {
|
||||
|
||||
/// The combination of two field expressions. E.g. for `PartialEq::eq` this
|
||||
/// is something like `<field1 equality> && <field2 equality>`.
|
||||
Combine(Span, P<Expr>, P<Expr>),
|
||||
Combine(Span, Box<Expr>, Box<Expr>),
|
||||
|
||||
// The fallback case for a struct or enum variant with no fields.
|
||||
Fieldless,
|
||||
@@ -1665,9 +1665,9 @@ pub(crate) fn cs_fold<F>(
|
||||
trait_span: Span,
|
||||
substructure: &Substructure<'_>,
|
||||
mut f: F,
|
||||
) -> P<Expr>
|
||||
) -> Box<Expr>
|
||||
where
|
||||
F: FnMut(&ExtCtxt<'_>, CsFold<'_>) -> P<Expr>,
|
||||
F: FnMut(&ExtCtxt<'_>, CsFold<'_>) -> Box<Expr>,
|
||||
{
|
||||
match substructure.fields {
|
||||
EnumMatching(.., all_fields) | Struct(_, all_fields) => {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
//! when specifying impls to be derived.
|
||||
|
||||
pub(crate) use Ty::*;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind};
|
||||
use rustc_expand::base::ExtCtxt;
|
||||
use rustc_span::source_map::respan;
|
||||
@@ -41,7 +40,7 @@ impl Path {
|
||||
span: Span,
|
||||
self_ty: Ident,
|
||||
self_generics: &Generics,
|
||||
) -> P<ast::Ty> {
|
||||
) -> Box<ast::Ty> {
|
||||
cx.ty_path(self.to_path(cx, span, self_ty, self_generics))
|
||||
}
|
||||
pub(crate) fn to_path(
|
||||
@@ -90,7 +89,7 @@ impl Ty {
|
||||
span: Span,
|
||||
self_ty: Ident,
|
||||
self_generics: &Generics,
|
||||
) -> P<ast::Ty> {
|
||||
) -> Box<ast::Ty> {
|
||||
match self {
|
||||
Ref(ty, mutbl) => {
|
||||
let raw_ty = ty.to_ty(cx, span, self_ty, self_generics);
|
||||
@@ -192,7 +191,7 @@ impl Bounds {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn get_explicit_self(cx: &ExtCtxt<'_>, span: Span) -> (P<Expr>, ast::ExplicitSelf) {
|
||||
pub(crate) fn get_explicit_self(cx: &ExtCtxt<'_>, span: Span) -> (Box<Expr>, ast::ExplicitSelf) {
|
||||
// This constructs a fresh `self` path.
|
||||
let self_path = cx.expr_self(span);
|
||||
let self_ty = respan(span, SelfKind::Region(None, ast::Mutability::Not));
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! The compiler code necessary to implement the `#[derive]` extensions.
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::{GenericArg, MetaItem};
|
||||
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, MultiItemModifier};
|
||||
use rustc_span::{Span, Symbol, sym};
|
||||
@@ -66,7 +65,7 @@ impl MultiItemModifier for BuiltinDerive {
|
||||
&mut |a| {
|
||||
// Cannot use 'ecx.stmt_item' here, because we need to pass 'ecx'
|
||||
// to the function
|
||||
items.push(Annotatable::Stmt(P(ast::Stmt {
|
||||
items.push(Annotatable::Stmt(Box::new(ast::Stmt {
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: ast::StmtKind::Item(a.expect_item()),
|
||||
span,
|
||||
@@ -91,20 +90,20 @@ fn call_intrinsic(
|
||||
cx: &ExtCtxt<'_>,
|
||||
span: Span,
|
||||
intrinsic: Symbol,
|
||||
args: ThinVec<P<ast::Expr>>,
|
||||
) -> P<ast::Expr> {
|
||||
args: ThinVec<Box<ast::Expr>>,
|
||||
) -> Box<ast::Expr> {
|
||||
let span = cx.with_def_site_ctxt(span);
|
||||
let path = cx.std_path(&[sym::intrinsics, intrinsic]);
|
||||
cx.expr_call_global(span, path, args)
|
||||
}
|
||||
|
||||
/// Constructs an expression that calls the `unreachable` intrinsic.
|
||||
fn call_unreachable(cx: &ExtCtxt<'_>, span: Span) -> P<ast::Expr> {
|
||||
fn call_unreachable(cx: &ExtCtxt<'_>, span: Span) -> Box<ast::Expr> {
|
||||
let span = cx.with_def_site_ctxt(span);
|
||||
let path = cx.std_path(&[sym::intrinsics, sym::unreachable]);
|
||||
let call = cx.expr_call_global(span, path, ThinVec::new());
|
||||
|
||||
cx.expr_block(P(ast::Block {
|
||||
cx.expr_block(Box::new(ast::Block {
|
||||
stmts: thin_vec![cx.stmt_expr(call)],
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
rules: ast::BlockCheckMode::Unsafe(ast::CompilerGenerated),
|
||||
@@ -116,7 +115,7 @@ fn call_unreachable(cx: &ExtCtxt<'_>, span: Span) -> P<ast::Expr> {
|
||||
fn assert_ty_bounds(
|
||||
cx: &ExtCtxt<'_>,
|
||||
stmts: &mut ThinVec<ast::Stmt>,
|
||||
ty: P<ast::Ty>,
|
||||
ty: Box<ast::Ty>,
|
||||
span: Span,
|
||||
assert_path: &[Symbol],
|
||||
) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::token::Delimiter;
|
||||
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
|
||||
use rustc_ast::*;
|
||||
@@ -48,7 +47,7 @@ fn expand<'cx>(
|
||||
ExpandResult::Ready(MacEager::expr(
|
||||
cx.expr(
|
||||
sp,
|
||||
ExprKind::MacCall(P(MacCall {
|
||||
ExprKind::MacCall(Box::new(MacCall {
|
||||
path: Path {
|
||||
span: sp,
|
||||
segments: cx
|
||||
@@ -58,7 +57,7 @@ fn expand<'cx>(
|
||||
.collect(),
|
||||
tokens: None,
|
||||
},
|
||||
args: P(DelimArgs {
|
||||
args: Box::new(DelimArgs {
|
||||
dspan: DelimSpan::from_single(sp),
|
||||
delim: Delimiter::Parenthesis,
|
||||
tokens: tts,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::ops::Range;
|
||||
|
||||
use parse::Position::ArgumentNamed;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::{
|
||||
Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs,
|
||||
@@ -45,7 +44,7 @@ use PositionUsedAs::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct MacroInput {
|
||||
fmtstr: P<Expr>,
|
||||
fmtstr: Box<Expr>,
|
||||
args: FormatArguments,
|
||||
/// Whether the first argument was a string literal or a result from eager macro expansion.
|
||||
/// If it's not a string literal, we disallow implicit argument capturing.
|
||||
@@ -1018,7 +1017,7 @@ fn expand_format_args_impl<'cx>(
|
||||
};
|
||||
match mac {
|
||||
Ok(format_args) => {
|
||||
MacEager::expr(ecx.expr(sp, ExprKind::FormatArgs(P(format_args))))
|
||||
MacEager::expr(ecx.expr(sp, ExprKind::FormatArgs(Box::new(format_args))))
|
||||
}
|
||||
Err(guar) => MacEager::expr(DummyResult::raw_expr(sp, Some(guar))),
|
||||
}
|
||||
|
||||
@@ -346,18 +346,18 @@ pub(crate) mod printf {
|
||||
// ```regex
|
||||
// (?x)
|
||||
// ^ %
|
||||
// (?: (?P<parameter> \d+) \$ )?
|
||||
// (?P<flags> [-+ 0\#']* )
|
||||
// (?P<width> \d+ | \* (?: (?P<widtha> \d+) \$ )? )?
|
||||
// (?: \. (?P<precision> \d+ | \* (?: (?P<precisiona> \d+) \$ )? ) )?
|
||||
// (?P<length>
|
||||
// (?: (?Box<parameter> \d+) \$ )?
|
||||
// (?Box<flags> [-+ 0\#']* )
|
||||
// (?Box<width> \d+ | \* (?: (?Box<widtha> \d+) \$ )? )?
|
||||
// (?: \. (?Box<precision> \d+ | \* (?: (?Box<precisiona> \d+) \$ )? ) )?
|
||||
// (?Box<length>
|
||||
// # Standard
|
||||
// hh | h | ll | l | L | z | j | t
|
||||
//
|
||||
// # Other
|
||||
// | I32 | I64 | I | q
|
||||
// )?
|
||||
// (?P<type> . )
|
||||
// (?Box<type> . )
|
||||
// ```
|
||||
|
||||
// Used to establish the full span at the end.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use rustc_ast::expand::allocator::{
|
||||
ALLOCATOR_METHODS, AllocatorMethod, AllocatorMethodInput, AllocatorTy, global_fn_name,
|
||||
};
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::{
|
||||
self as ast, AttrVec, Expr, Fn, FnHeader, FnSig, Generics, ItemKind, Mutability, Param, Safety,
|
||||
Stmt, StmtKind, Ty, TyKind,
|
||||
@@ -51,7 +50,7 @@ pub(crate) fn expand(
|
||||
let const_body = ecx.expr_block(ecx.block(span, stmts));
|
||||
let const_item = ecx.item_const(span, Ident::new(kw::Underscore, span), const_ty, const_body);
|
||||
let const_item = if is_stmt {
|
||||
Annotatable::Stmt(P(ecx.stmt_item(span, const_item)))
|
||||
Annotatable::Stmt(Box::new(ecx.stmt_item(span, const_item)))
|
||||
} else {
|
||||
Annotatable::Item(const_item)
|
||||
};
|
||||
@@ -90,7 +89,7 @@ impl AllocFnFactory<'_, '_> {
|
||||
self.cx.stmt_item(self.ty_span, item)
|
||||
}
|
||||
|
||||
fn call_allocator(&self, method: Symbol, mut args: ThinVec<P<Expr>>) -> P<Expr> {
|
||||
fn call_allocator(&self, method: Symbol, mut args: ThinVec<Box<Expr>>) -> Box<Expr> {
|
||||
let method = self.cx.std_path(&[sym::alloc, sym::GlobalAlloc, method]);
|
||||
let method = self.cx.expr_path(self.cx.path(self.ty_span, method));
|
||||
let allocator = self.cx.path_ident(self.ty_span, self.global);
|
||||
@@ -105,7 +104,7 @@ impl AllocFnFactory<'_, '_> {
|
||||
thin_vec![self.cx.attr_word(sym::rustc_std_internal_symbol, self.span)]
|
||||
}
|
||||
|
||||
fn arg_ty(&self, input: &AllocatorMethodInput, args: &mut ThinVec<Param>) -> P<Expr> {
|
||||
fn arg_ty(&self, input: &AllocatorMethodInput, args: &mut ThinVec<Param>) -> Box<Expr> {
|
||||
match input.ty {
|
||||
AllocatorTy::Layout => {
|
||||
// If an allocator method is ever introduced having multiple
|
||||
@@ -148,7 +147,7 @@ impl AllocFnFactory<'_, '_> {
|
||||
}
|
||||
}
|
||||
|
||||
fn ret_ty(&self, ty: &AllocatorTy) -> P<Ty> {
|
||||
fn ret_ty(&self, ty: &AllocatorTy) -> Box<Ty> {
|
||||
match *ty {
|
||||
AllocatorTy::ResultPtr => self.ptr_u8(),
|
||||
|
||||
@@ -160,12 +159,12 @@ impl AllocFnFactory<'_, '_> {
|
||||
}
|
||||
}
|
||||
|
||||
fn usize(&self) -> P<Ty> {
|
||||
fn usize(&self) -> Box<Ty> {
|
||||
let usize = self.cx.path_ident(self.span, Ident::new(sym::usize, self.span));
|
||||
self.cx.ty_path(usize)
|
||||
}
|
||||
|
||||
fn ptr_u8(&self) -> P<Ty> {
|
||||
fn ptr_u8(&self) -> Box<Ty> {
|
||||
let u8 = self.cx.path_ident(self.span, Ident::new(sym::u8, self.span));
|
||||
let ty_u8 = self.cx.ty_path(u8);
|
||||
self.cx.ty_ptr(self.span, ty_u8, Mutability::Mut)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::{CoroutineKind, DUMMY_NODE_ID, Expr, ast, token};
|
||||
use rustc_errors::PResult;
|
||||
@@ -24,7 +23,7 @@ fn parse_closure<'a>(
|
||||
cx: &mut ExtCtxt<'a>,
|
||||
span: Span,
|
||||
stream: TokenStream,
|
||||
) -> PResult<'a, P<Expr>> {
|
||||
) -> PResult<'a, Box<Expr>> {
|
||||
let mut closure_parser = cx.new_parser_from_tts(stream);
|
||||
|
||||
let coroutine_kind = Some(CoroutineKind::Gen {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::{AnonConst, DUMMY_NODE_ID, Ty, TyPat, TyPatKind, ast, token};
|
||||
use rustc_errors::PResult;
|
||||
@@ -22,7 +21,10 @@ pub(crate) fn expand<'cx>(
|
||||
ExpandResult::Ready(base::MacEager::ty(cx.ty(sp, ast::TyKind::Pat(ty, pat))))
|
||||
}
|
||||
|
||||
fn parse_pat_ty<'a>(cx: &mut ExtCtxt<'a>, stream: TokenStream) -> PResult<'a, (P<Ty>, P<TyPat>)> {
|
||||
fn parse_pat_ty<'a>(
|
||||
cx: &mut ExtCtxt<'a>,
|
||||
stream: TokenStream,
|
||||
) -> PResult<'a, (Box<Ty>, Box<TyPat>)> {
|
||||
let mut parser = cx.new_parser_from_tts(stream);
|
||||
|
||||
let ty = parser.parse_ty()?;
|
||||
@@ -45,15 +47,15 @@ fn parse_pat_ty<'a>(cx: &mut ExtCtxt<'a>, stream: TokenStream) -> PResult<'a, (P
|
||||
Ok((ty, pat))
|
||||
}
|
||||
|
||||
fn ty_pat(kind: TyPatKind, span: Span) -> P<TyPat> {
|
||||
P(TyPat { id: DUMMY_NODE_ID, kind, span, tokens: None })
|
||||
fn ty_pat(kind: TyPatKind, span: Span) -> Box<TyPat> {
|
||||
Box::new(TyPat { id: DUMMY_NODE_ID, kind, span, tokens: None })
|
||||
}
|
||||
|
||||
fn pat_to_ty_pat(cx: &mut ExtCtxt<'_>, pat: ast::Pat) -> P<TyPat> {
|
||||
fn pat_to_ty_pat(cx: &mut ExtCtxt<'_>, pat: ast::Pat) -> Box<TyPat> {
|
||||
let kind = match pat.kind {
|
||||
ast::PatKind::Range(start, end, include_end) => TyPatKind::Range(
|
||||
start.map(|value| P(AnonConst { id: DUMMY_NODE_ID, value })),
|
||||
end.map(|value| P(AnonConst { id: DUMMY_NODE_ID, value })),
|
||||
start.map(|value| Box::new(AnonConst { id: DUMMY_NODE_ID, value })),
|
||||
end.map(|value| Box::new(AnonConst { id: DUMMY_NODE_ID, value })),
|
||||
include_end,
|
||||
),
|
||||
ast::PatKind::Or(variants) => {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use std::{mem, slice};
|
||||
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::visit::{self, Visitor};
|
||||
use rustc_ast::{self as ast, HasNodeId, NodeId, attr};
|
||||
use rustc_ast_pretty::pprust;
|
||||
@@ -286,7 +285,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
|
||||
// // ...
|
||||
// ];
|
||||
// }
|
||||
fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
|
||||
fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> Box<ast::Item> {
|
||||
let expn_id = cx.resolver.expansion_for_ast_pass(
|
||||
DUMMY_SP,
|
||||
AstPass::ProcMacroHarness,
|
||||
|
||||
@@ -3,7 +3,6 @@ use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::{join_path_idents, token};
|
||||
use rustc_ast_pretty::pprust;
|
||||
@@ -144,7 +143,7 @@ pub(crate) fn expand_include<'cx>(
|
||||
node_id: ast::NodeId,
|
||||
}
|
||||
impl<'a> MacResult for ExpandInclude<'a> {
|
||||
fn make_expr(mut self: Box<ExpandInclude<'a>>) -> Option<P<ast::Expr>> {
|
||||
fn make_expr(mut self: Box<ExpandInclude<'a>>) -> Option<Box<ast::Expr>> {
|
||||
let expr = parse_expr(&mut self.p).ok()?;
|
||||
if self.p.token != token::Eof {
|
||||
self.p.psess.buffer_lint(
|
||||
@@ -157,7 +156,7 @@ pub(crate) fn expand_include<'cx>(
|
||||
Some(expr)
|
||||
}
|
||||
|
||||
fn make_items(mut self: Box<ExpandInclude<'a>>) -> Option<SmallVec<[P<ast::Item>; 1]>> {
|
||||
fn make_items(mut self: Box<ExpandInclude<'a>>) -> Option<SmallVec<[Box<ast::Item>; 1]>> {
|
||||
let mut ret = SmallVec::new();
|
||||
loop {
|
||||
match self.p.parse_item(ForceCollect::No) {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::iter;
|
||||
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::{self as ast, GenericParamKind, HasNodeId, attr, join_path_idents};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_attr_parsing::AttributeParser;
|
||||
@@ -78,7 +77,7 @@ pub(crate) fn expand_test_case(
|
||||
}
|
||||
|
||||
let ret = if is_stmt {
|
||||
Annotatable::Stmt(P(ecx.stmt_item(item.span, item)))
|
||||
Annotatable::Stmt(Box::new(ecx.stmt_item(item.span, item)))
|
||||
} else {
|
||||
Annotatable::Item(item)
|
||||
};
|
||||
@@ -131,7 +130,7 @@ pub(crate) fn expand_test_or_bench(
|
||||
let ast::ItemKind::Fn(fn_) = &item.kind else {
|
||||
not_testable_error(cx, attr_sp, Some(&item));
|
||||
return if is_stmt {
|
||||
vec![Annotatable::Stmt(P(cx.stmt_item(item.span, item)))]
|
||||
vec![Annotatable::Stmt(Box::new(cx.stmt_item(item.span, item)))]
|
||||
} else {
|
||||
vec![Annotatable::Item(item)]
|
||||
};
|
||||
@@ -155,7 +154,7 @@ pub(crate) fn expand_test_or_bench(
|
||||
};
|
||||
if check_result.is_err() {
|
||||
return if is_stmt {
|
||||
vec![Annotatable::Stmt(P(cx.stmt_item(item.span, item)))]
|
||||
vec![Annotatable::Stmt(Box::new(cx.stmt_item(item.span, item)))]
|
||||
} else {
|
||||
vec![Annotatable::Item(item)]
|
||||
};
|
||||
@@ -201,7 +200,7 @@ pub(crate) fn expand_test_or_bench(
|
||||
// `-Cinstrument-coverage` builds.
|
||||
// This requires `#[allow_internal_unstable(coverage_attribute)]` on the
|
||||
// corresponding macro declaration in `core::macros`.
|
||||
let coverage_off = |mut expr: P<ast::Expr>| {
|
||||
let coverage_off = |mut expr: Box<ast::Expr>| {
|
||||
assert_matches!(expr.kind, ast::ExprKind::Closure(_));
|
||||
expr.attrs.push(cx.attr_nested_word(sym::coverage, sym::off, sp));
|
||||
expr
|
||||
@@ -388,11 +387,11 @@ pub(crate) fn expand_test_or_bench(
|
||||
if is_stmt {
|
||||
vec![
|
||||
// Access to libtest under a hygienic name
|
||||
Annotatable::Stmt(P(cx.stmt_item(sp, test_extern))),
|
||||
Annotatable::Stmt(Box::new(cx.stmt_item(sp, test_extern))),
|
||||
// The generated test case
|
||||
Annotatable::Stmt(P(cx.stmt_item(sp, test_const))),
|
||||
Annotatable::Stmt(Box::new(cx.stmt_item(sp, test_const))),
|
||||
// The original item
|
||||
Annotatable::Stmt(P(cx.stmt_item(sp, item))),
|
||||
Annotatable::Stmt(Box::new(cx.stmt_item(sp, item))),
|
||||
]
|
||||
} else {
|
||||
vec![
|
||||
|
||||
@@ -5,7 +5,6 @@ use std::mem;
|
||||
use rustc_ast as ast;
|
||||
use rustc_ast::entry::EntryPointType;
|
||||
use rustc_ast::mut_visit::*;
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::visit::Visitor;
|
||||
use rustc_ast::{ModKind, attr};
|
||||
use rustc_errors::DiagCtxtHandle;
|
||||
@@ -284,7 +283,7 @@ fn generate_test_harness(
|
||||
/// [`TestCtxt::reexport_test_harness_main`] provides a different name for the `main`
|
||||
/// function and [`TestCtxt::test_runner`] provides a path that replaces
|
||||
/// `test::test_main_static`.
|
||||
fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
|
||||
fn mk_main(cx: &mut TestCtxt<'_>) -> Box<ast::Item> {
|
||||
let sp = cx.def_site;
|
||||
let ecx = &cx.ext_cx;
|
||||
let test_ident = Ident::new(sym::test, sp);
|
||||
@@ -348,7 +347,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
|
||||
define_opaque: None,
|
||||
}));
|
||||
|
||||
let main = P(ast::Item {
|
||||
let main = Box::new(ast::Item {
|
||||
attrs: thin_vec![main_attr, coverage_attr, doc_hidden_attr],
|
||||
id: ast::DUMMY_NODE_ID,
|
||||
kind: main,
|
||||
@@ -364,7 +363,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P<ast::Item> {
|
||||
|
||||
/// Creates a slice containing every test like so:
|
||||
/// &[&test1, &test2]
|
||||
fn mk_tests_slice(cx: &TestCtxt<'_>, sp: Span) -> P<ast::Expr> {
|
||||
fn mk_tests_slice(cx: &TestCtxt<'_>, sp: Span) -> Box<ast::Expr> {
|
||||
debug!("building test vector from {} tests", cx.test_cases.len());
|
||||
let ecx = &cx.ext_cx;
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::tokenstream::TokenStream;
|
||||
use rustc_ast::{self as ast, AttrStyle, Attribute, MetaItem, attr, token};
|
||||
use rustc_errors::{Applicability, Diag, ErrorGuaranteed};
|
||||
@@ -83,7 +82,7 @@ type UnexpectedExprKind<'a> = Result<(Diag<'a>, bool /* has_suggestions */), Err
|
||||
#[allow(rustc::untranslatable_diagnostic)]
|
||||
pub(crate) fn expr_to_spanned_string<'a>(
|
||||
cx: &'a mut ExtCtxt<'_>,
|
||||
expr: P<ast::Expr>,
|
||||
expr: Box<ast::Expr>,
|
||||
err_msg: &'static str,
|
||||
) -> ExpandResult<ExprToSpannedStringResult<'a>, ()> {
|
||||
if !cx.force_mode
|
||||
@@ -135,7 +134,7 @@ pub(crate) fn expr_to_spanned_string<'a>(
|
||||
/// compilation on error, merely emits a non-fatal error and returns `Err`.
|
||||
pub(crate) fn expr_to_string(
|
||||
cx: &mut ExtCtxt<'_>,
|
||||
expr: P<ast::Expr>,
|
||||
expr: Box<ast::Expr>,
|
||||
err_msg: &'static str,
|
||||
) -> ExpandResult<Result<(Symbol, ast::StrStyle), ErrorGuaranteed>, ()> {
|
||||
expr_to_spanned_string(cx, expr, err_msg).map(|res| {
|
||||
@@ -158,7 +157,7 @@ pub(crate) fn check_zero_tts(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream, nam
|
||||
}
|
||||
|
||||
/// Parse an expression. On error, emit it, advancing to `Eof`, and return `Err`.
|
||||
pub(crate) fn parse_expr(p: &mut parser::Parser<'_>) -> Result<P<ast::Expr>, ErrorGuaranteed> {
|
||||
pub(crate) fn parse_expr(p: &mut parser::Parser<'_>) -> Result<Box<ast::Expr>, ErrorGuaranteed> {
|
||||
let guar = match p.parse_expr() {
|
||||
Ok(expr) => return Ok(expr),
|
||||
Err(err) => err.emit(),
|
||||
@@ -209,7 +208,7 @@ pub(crate) fn get_single_expr_from_tts(
|
||||
span: Span,
|
||||
tts: TokenStream,
|
||||
name: &str,
|
||||
) -> ExpandResult<Result<P<ast::Expr>, ErrorGuaranteed>, ()> {
|
||||
) -> ExpandResult<Result<Box<ast::Expr>, ErrorGuaranteed>, ()> {
|
||||
let mut p = cx.new_parser_from_tts(tts);
|
||||
if p.token == token::Eof {
|
||||
let guar = cx.dcx().emit_err(errors::OnlyOneArgument { span, name });
|
||||
@@ -232,7 +231,7 @@ pub(crate) fn get_single_expr_from_tts(
|
||||
pub(crate) fn get_exprs_from_tts(
|
||||
cx: &mut ExtCtxt<'_>,
|
||||
tts: TokenStream,
|
||||
) -> ExpandResult<Result<Vec<P<ast::Expr>>, ErrorGuaranteed>, ()> {
|
||||
) -> ExpandResult<Result<Vec<Box<ast::Expr>>, ErrorGuaranteed>, ()> {
|
||||
let mut p = cx.new_parser_from_tts(tts);
|
||||
let mut es = Vec::new();
|
||||
while p.token != token::Eof {
|
||||
|
||||
Reference in New Issue
Block a user