Pass symbols to ExtCtxt::std_path
instead of strings.
Because this function is hot. Also remove the dead `ty_option` function.
This commit is contained in:
parent
26451ef7b5
commit
58c68d00fd
12 changed files with 71 additions and 57 deletions
|
@ -969,10 +969,10 @@ impl<'a> ExtCtxt<'a> {
|
||||||
pub fn ident_of(&self, st: &str) -> ast::Ident {
|
pub fn ident_of(&self, st: &str) -> ast::Ident {
|
||||||
ast::Ident::from_str(st)
|
ast::Ident::from_str(st)
|
||||||
}
|
}
|
||||||
pub fn std_path(&self, components: &[&str]) -> Vec<ast::Ident> {
|
pub fn std_path(&self, components: &[Symbol]) -> Vec<ast::Ident> {
|
||||||
let def_site = DUMMY_SP.apply_mark(self.current_expansion.mark);
|
let def_site = DUMMY_SP.apply_mark(self.current_expansion.mark);
|
||||||
iter::once(Ident::new(kw::DollarCrate, def_site))
|
iter::once(Ident::new(kw::DollarCrate, def_site))
|
||||||
.chain(components.iter().map(|s| self.ident_of(s)))
|
.chain(components.iter().map(|&s| Ident::with_empty_ctxt(s)))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
pub fn name_of(&self, st: &str) -> ast::Name {
|
pub fn name_of(&self, st: &str) -> ast::Name {
|
||||||
|
|
|
@ -3,11 +3,11 @@ use crate::attr;
|
||||||
use crate::source_map::{dummy_spanned, respan, Spanned};
|
use crate::source_map::{dummy_spanned, respan, Spanned};
|
||||||
use crate::ext::base::ExtCtxt;
|
use crate::ext::base::ExtCtxt;
|
||||||
use crate::ptr::P;
|
use crate::ptr::P;
|
||||||
use crate::symbol::{Symbol, kw};
|
use crate::symbol::{kw, sym, Symbol};
|
||||||
use crate::ThinVec;
|
use crate::ThinVec;
|
||||||
|
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
use syntax_pos::{Pos, Span, DUMMY_SP};
|
use syntax_pos::{Pos, Span};
|
||||||
|
|
||||||
pub trait AstBuilder {
|
pub trait AstBuilder {
|
||||||
// paths
|
// paths
|
||||||
|
@ -49,7 +49,6 @@ pub trait AstBuilder {
|
||||||
ty: P<ast::Ty>,
|
ty: P<ast::Ty>,
|
||||||
mutbl: ast::Mutability) -> P<ast::Ty>;
|
mutbl: ast::Mutability) -> P<ast::Ty>;
|
||||||
|
|
||||||
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty>;
|
|
||||||
fn ty_infer(&self, sp: Span) -> P<ast::Ty>;
|
fn ty_infer(&self, sp: Span) -> P<ast::Ty>;
|
||||||
|
|
||||||
fn typaram(&self,
|
fn typaram(&self,
|
||||||
|
@ -425,15 +424,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
ast::TyKind::Ptr(self.ty_mt(ty, mutbl)))
|
ast::TyKind::Ptr(self.ty_mt(ty, mutbl)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_option(&self, ty: P<ast::Ty>) -> P<ast::Ty> {
|
|
||||||
self.ty_path(
|
|
||||||
self.path_all(DUMMY_SP,
|
|
||||||
true,
|
|
||||||
self.std_path(&["option", "Option"]),
|
|
||||||
vec![ast::GenericArg::Type(ty)],
|
|
||||||
Vec::new()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn ty_infer(&self, span: Span) -> P<ast::Ty> {
|
fn ty_infer(&self, span: Span) -> P<ast::Ty> {
|
||||||
self.ty(span, ast::TyKind::Infer)
|
self.ty(span, ast::TyKind::Infer)
|
||||||
}
|
}
|
||||||
|
@ -735,7 +725,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
self.expr(sp, ast::ExprKind::Array(exprs))
|
self.expr(sp, ast::ExprKind::Array(exprs))
|
||||||
}
|
}
|
||||||
fn expr_vec_ng(&self, sp: Span) -> P<ast::Expr> {
|
fn expr_vec_ng(&self, sp: Span) -> P<ast::Expr> {
|
||||||
self.expr_call_global(sp, self.std_path(&["vec", "Vec", "new"]),
|
self.expr_call_global(sp, self.std_path(&[sym::vec, sym::Vec, sym::new]),
|
||||||
Vec::new())
|
Vec::new())
|
||||||
}
|
}
|
||||||
fn expr_vec_slice(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
fn expr_vec_slice(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
||||||
|
@ -751,12 +741,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
|
|
||||||
|
|
||||||
fn expr_some(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
|
fn expr_some(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
|
||||||
let some = self.std_path(&["option", "Option", "Some"]);
|
let some = self.std_path(&[sym::option, sym::Option, sym::Some]);
|
||||||
self.expr_call_global(sp, some, vec![expr])
|
self.expr_call_global(sp, some, vec![expr])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_none(&self, sp: Span) -> P<ast::Expr> {
|
fn expr_none(&self, sp: Span) -> P<ast::Expr> {
|
||||||
let none = self.std_path(&["option", "Option", "None"]);
|
let none = self.std_path(&[sym::option, sym::Option, sym::None]);
|
||||||
let none = self.path_global(sp, none);
|
let none = self.path_global(sp, none);
|
||||||
self.expr_path(none)
|
self.expr_path(none)
|
||||||
}
|
}
|
||||||
|
@ -780,7 +770,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
let expr_loc_ptr = self.expr_addr_of(span, expr_loc_tuple);
|
let expr_loc_ptr = self.expr_addr_of(span, expr_loc_tuple);
|
||||||
self.expr_call_global(
|
self.expr_call_global(
|
||||||
span,
|
span,
|
||||||
self.std_path(&["rt", "begin_panic"]),
|
self.std_path(&[sym::rt, sym::begin_panic]),
|
||||||
vec![
|
vec![
|
||||||
self.expr_str(span, msg),
|
self.expr_str(span, msg),
|
||||||
expr_loc_ptr])
|
expr_loc_ptr])
|
||||||
|
@ -791,19 +781,19 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_ok(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
|
fn expr_ok(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
|
||||||
let ok = self.std_path(&["result", "Result", "Ok"]);
|
let ok = self.std_path(&[sym::result, sym::Result, sym::Ok]);
|
||||||
self.expr_call_global(sp, ok, vec![expr])
|
self.expr_call_global(sp, ok, vec![expr])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_err(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
|
fn expr_err(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr> {
|
||||||
let err = self.std_path(&["result", "Result", "Err"]);
|
let err = self.std_path(&[sym::result, sym::Result, sym::Err]);
|
||||||
self.expr_call_global(sp, err, vec![expr])
|
self.expr_call_global(sp, err, vec![expr])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_try(&self, sp: Span, head: P<ast::Expr>) -> P<ast::Expr> {
|
fn expr_try(&self, sp: Span, head: P<ast::Expr>) -> P<ast::Expr> {
|
||||||
let ok = self.std_path(&["result", "Result", "Ok"]);
|
let ok = self.std_path(&[sym::result, sym::Result, sym::Ok]);
|
||||||
let ok_path = self.path_global(sp, ok);
|
let ok_path = self.path_global(sp, ok);
|
||||||
let err = self.std_path(&["result", "Result", "Err"]);
|
let err = self.std_path(&[sym::result, sym::Result, sym::Err]);
|
||||||
let err_path = self.path_global(sp, err);
|
let err_path = self.path_global(sp, err);
|
||||||
|
|
||||||
let binding_variable = self.ident_of("__try_var");
|
let binding_variable = self.ident_of("__try_var");
|
||||||
|
@ -867,25 +857,25 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat_some(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
|
fn pat_some(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
|
||||||
let some = self.std_path(&["option", "Option", "Some"]);
|
let some = self.std_path(&[sym::option, sym::Option, sym::Some]);
|
||||||
let path = self.path_global(span, some);
|
let path = self.path_global(span, some);
|
||||||
self.pat_tuple_struct(span, path, vec![pat])
|
self.pat_tuple_struct(span, path, vec![pat])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat_none(&self, span: Span) -> P<ast::Pat> {
|
fn pat_none(&self, span: Span) -> P<ast::Pat> {
|
||||||
let some = self.std_path(&["option", "Option", "None"]);
|
let some = self.std_path(&[sym::option, sym::Option, sym::None]);
|
||||||
let path = self.path_global(span, some);
|
let path = self.path_global(span, some);
|
||||||
self.pat_path(span, path)
|
self.pat_path(span, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat_ok(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
|
fn pat_ok(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
|
||||||
let some = self.std_path(&["result", "Result", "Ok"]);
|
let some = self.std_path(&[sym::result, sym::Result, sym::Ok]);
|
||||||
let path = self.path_global(span, some);
|
let path = self.path_global(span, some);
|
||||||
self.pat_tuple_struct(span, path, vec![pat])
|
self.pat_tuple_struct(span, path, vec![pat])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat_err(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
|
fn pat_err(&self, span: Span, pat: P<ast::Pat>) -> P<ast::Pat> {
|
||||||
let some = self.std_path(&["result", "Result", "Err"]);
|
let some = self.std_path(&[sym::result, sym::Result, sym::Err]);
|
||||||
let path = self.path_global(span, some);
|
let path = self.path_global(span, some);
|
||||||
self.pat_tuple_struct(span, path, vec![pat])
|
self.pat_tuple_struct(span, path, vec![pat])
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use syntax::attr;
|
||||||
use syntax::ext::base::{Annotatable, ExtCtxt};
|
use syntax::ext::base::{Annotatable, ExtCtxt};
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::symbol::{kw, sym};
|
use syntax::symbol::{kw, sym, Symbol};
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
pub fn expand_deriving_clone(cx: &mut ExtCtxt<'_>,
|
pub fn expand_deriving_clone(cx: &mut ExtCtxt<'_>,
|
||||||
|
@ -115,7 +115,7 @@ fn cs_clone_shallow(name: &str,
|
||||||
// set the expn ID so we can use the unstable struct.
|
// set the expn ID so we can use the unstable struct.
|
||||||
let span = span.with_ctxt(cx.backtrace());
|
let span = span.with_ctxt(cx.backtrace());
|
||||||
let assert_path = cx.path_all(span, true,
|
let assert_path = cx.path_all(span, true,
|
||||||
cx.std_path(&["clone", helper_name]),
|
cx.std_path(&[sym::clone, Symbol::intern(helper_name)]),
|
||||||
vec![GenericArg::Type(ty)], vec![]);
|
vec![GenericArg::Type(ty)], vec![]);
|
||||||
stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path)));
|
stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path)));
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ fn cs_clone(name: &str,
|
||||||
-> P<Expr> {
|
-> P<Expr> {
|
||||||
let ctor_path;
|
let ctor_path;
|
||||||
let all_fields;
|
let all_fields;
|
||||||
let fn_path = cx.std_path(&["clone", "Clone", "clone"]);
|
let fn_path = cx.std_path(&[sym::clone, sym::Clone, sym::clone]);
|
||||||
let subcall = |cx: &mut ExtCtxt<'_>, field: &FieldInfo<'_>| {
|
let subcall = |cx: &mut ExtCtxt<'_>, field: &FieldInfo<'_>| {
|
||||||
let args = vec![cx.expr_addr_of(field.span, field.self_.clone())];
|
let args = vec![cx.expr_addr_of(field.span, field.self_.clone())];
|
||||||
cx.expr_call_global(field.span, fn_path.clone(), args)
|
cx.expr_call_global(field.span, fn_path.clone(), args)
|
||||||
|
|
|
@ -6,7 +6,7 @@ use syntax::ast::{self, Expr, MetaItem, GenericArg};
|
||||||
use syntax::ext::base::{Annotatable, ExtCtxt};
|
use syntax::ext::base::{Annotatable, ExtCtxt};
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::symbol::sym;
|
use syntax::symbol::{sym, Symbol};
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>,
|
pub fn expand_deriving_eq(cx: &mut ExtCtxt<'_>,
|
||||||
|
@ -54,7 +54,7 @@ fn cs_total_eq_assert(cx: &mut ExtCtxt<'_>,
|
||||||
// set the expn ID so we can use the unstable struct.
|
// set the expn ID so we can use the unstable struct.
|
||||||
let span = span.with_ctxt(cx.backtrace());
|
let span = span.with_ctxt(cx.backtrace());
|
||||||
let assert_path = cx.path_all(span, true,
|
let assert_path = cx.path_all(span, true,
|
||||||
cx.std_path(&["cmp", helper_name]),
|
cx.std_path(&[sym::cmp, Symbol::intern(helper_name)]),
|
||||||
vec![GenericArg::Type(ty)], vec![]);
|
vec![GenericArg::Type(ty)], vec![]);
|
||||||
stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path)));
|
stmts.push(cx.stmt_let_type_only(span, cx.ty_path(assert_path)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,9 @@ pub fn ordering_collapsed(cx: &mut ExtCtxt<'_>,
|
||||||
|
|
||||||
pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
|
pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
|
||||||
let test_id = cx.ident_of("cmp").gensym();
|
let test_id = cx.ident_of("cmp").gensym();
|
||||||
let equals_path = cx.path_global(span, cx.std_path(&["cmp", "Ordering", "Equal"]));
|
let equals_path = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal]));
|
||||||
|
|
||||||
let cmp_path = cx.std_path(&["cmp", "Ord", "cmp"]);
|
let cmp_path = cx.std_path(&[sym::cmp, sym::Ord, sym::cmp]);
|
||||||
|
|
||||||
// Builds:
|
// Builds:
|
||||||
//
|
//
|
||||||
|
|
|
@ -8,7 +8,7 @@ use syntax::ast::{self, BinOpKind, Expr, MetaItem};
|
||||||
use syntax::ext::base::{Annotatable, ExtCtxt};
|
use syntax::ext::base::{Annotatable, ExtCtxt};
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::symbol::sym;
|
use syntax::symbol::{sym, Symbol};
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt<'_>,
|
pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt<'_>,
|
||||||
|
@ -114,11 +114,11 @@ pub fn some_ordering_collapsed(cx: &mut ExtCtxt<'_>,
|
||||||
|
|
||||||
pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
|
pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<Expr> {
|
||||||
let test_id = cx.ident_of("cmp").gensym();
|
let test_id = cx.ident_of("cmp").gensym();
|
||||||
let ordering = cx.path_global(span, cx.std_path(&["cmp", "Ordering", "Equal"]));
|
let ordering = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal]));
|
||||||
let ordering_expr = cx.expr_path(ordering.clone());
|
let ordering_expr = cx.expr_path(ordering.clone());
|
||||||
let equals_expr = cx.expr_some(span, ordering_expr);
|
let equals_expr = cx.expr_some(span, ordering_expr);
|
||||||
|
|
||||||
let partial_cmp_path = cx.std_path(&["cmp", "PartialOrd", "partial_cmp"]);
|
let partial_cmp_path = cx.std_path(&[sym::cmp, sym::PartialOrd, sym::partial_cmp]);
|
||||||
|
|
||||||
// Builds:
|
// Builds:
|
||||||
//
|
//
|
||||||
|
@ -188,7 +188,8 @@ fn cs_op(less: bool,
|
||||||
span: Span,
|
span: Span,
|
||||||
substr: &Substructure<'_>) -> P<Expr> {
|
substr: &Substructure<'_>) -> P<Expr> {
|
||||||
let ordering_path = |cx: &mut ExtCtxt<'_>, name: &str| {
|
let ordering_path = |cx: &mut ExtCtxt<'_>, name: &str| {
|
||||||
cx.expr_path(cx.path_global(span, cx.std_path(&["cmp", "Ordering", name])))
|
cx.expr_path(cx.path_global(
|
||||||
|
span, cx.std_path(&[sym::cmp, sym::Ordering, Symbol::intern(name)])))
|
||||||
};
|
};
|
||||||
|
|
||||||
let par_cmp = |cx: &mut ExtCtxt<'_>, span, self_f: P<Expr>, other_fs: &[P<Expr>], default| {
|
let par_cmp = |cx: &mut ExtCtxt<'_>, span, self_f: P<Expr>, other_fs: &[P<Expr>], default| {
|
||||||
|
@ -198,9 +199,9 @@ fn cs_op(less: bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
// `PartialOrd::partial_cmp(self.fi, other.fi)`
|
// `PartialOrd::partial_cmp(self.fi, other.fi)`
|
||||||
let cmp_path = cx.expr_path(cx.path_global(span, cx.std_path(&["cmp",
|
let cmp_path = cx.expr_path(cx.path_global(span, cx.std_path(&[sym::cmp,
|
||||||
"PartialOrd",
|
sym::PartialOrd,
|
||||||
"partial_cmp"])));
|
sym::partial_cmp])));
|
||||||
let cmp = cx.expr_call(span,
|
let cmp = cx.expr_call(span,
|
||||||
cmp_path,
|
cmp_path,
|
||||||
vec![cx.expr_addr_of(span, self_f),
|
vec![cx.expr_addr_of(span, self_f),
|
||||||
|
@ -208,9 +209,9 @@ fn cs_op(less: bool,
|
||||||
|
|
||||||
let default = ordering_path(cx, default);
|
let default = ordering_path(cx, default);
|
||||||
// `Option::unwrap_or(_, Ordering::Equal)`
|
// `Option::unwrap_or(_, Ordering::Equal)`
|
||||||
let unwrap_path = cx.expr_path(cx.path_global(span, cx.std_path(&["option",
|
let unwrap_path = cx.expr_path(cx.path_global(span, cx.std_path(&[sym::option,
|
||||||
"Option",
|
sym::Option,
|
||||||
"unwrap_or"])));
|
sym::unwrap_or])));
|
||||||
cx.expr_call(span, unwrap_path, vec![cmp, default])
|
cx.expr_call(span, unwrap_path, vec![cmp, default])
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -256,9 +257,9 @@ fn cs_op(less: bool,
|
||||||
|
|
||||||
// `Ordering::then_with(Option::unwrap_or(..), ..)`
|
// `Ordering::then_with(Option::unwrap_or(..), ..)`
|
||||||
let then_with_path = cx.expr_path(cx.path_global(span,
|
let then_with_path = cx.expr_path(cx.path_global(span,
|
||||||
cx.std_path(&["cmp",
|
cx.std_path(&[sym::cmp,
|
||||||
"Ordering",
|
sym::Ordering,
|
||||||
"then_with"])));
|
sym::then_with])));
|
||||||
cx.expr_call(span, then_with_path, vec![par_cmp, cx.lambda0(span, subexpr)])
|
cx.expr_call(span, then_with_path, vec![par_cmp, cx.lambda0(span, subexpr)])
|
||||||
},
|
},
|
||||||
|cx, args| {
|
|cx, args| {
|
||||||
|
|
|
@ -6,7 +6,7 @@ use syntax::ast::{Expr, MetaItem};
|
||||||
use syntax::ext::base::{Annotatable, DummyResult, ExtCtxt};
|
use syntax::ext::base::{Annotatable, DummyResult, ExtCtxt};
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
use syntax::symbol::sym;
|
use syntax::symbol::{kw, sym};
|
||||||
use syntax::span_err;
|
use syntax::span_err;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
|
@ -47,7 +47,8 @@ fn default_substructure(cx: &mut ExtCtxt<'_>,
|
||||||
trait_span: Span,
|
trait_span: Span,
|
||||||
substr: &Substructure<'_>)
|
substr: &Substructure<'_>)
|
||||||
-> P<Expr> {
|
-> P<Expr> {
|
||||||
let default_ident = cx.std_path(&["default", "Default", "default"]);
|
// Note that `kw::Default` is "default" and `sym::Default` is "Default"!
|
||||||
|
let default_ident = cx.std_path(&[kw::Default, sym::Default, kw::Default]);
|
||||||
let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
|
let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new());
|
||||||
|
|
||||||
return match *substr.fields {
|
return match *substr.fields {
|
||||||
|
|
|
@ -6,6 +6,7 @@ use syntax::ast::{Expr, MetaItem, Mutability};
|
||||||
use syntax::ext::base::{Annotatable, ExtCtxt};
|
use syntax::ext::base::{Annotatable, ExtCtxt};
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
use syntax::ptr::P;
|
use syntax::ptr::P;
|
||||||
|
use syntax::symbol::sym;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
pub fn expand_deriving_hash(cx: &mut ExtCtxt<'_>,
|
pub fn expand_deriving_hash(cx: &mut ExtCtxt<'_>,
|
||||||
|
@ -60,7 +61,7 @@ fn hash_substructure(cx: &mut ExtCtxt<'_>, trait_span: Span, substr: &Substructu
|
||||||
};
|
};
|
||||||
let call_hash = |span, thing_expr| {
|
let call_hash = |span, thing_expr| {
|
||||||
let hash_path = {
|
let hash_path = {
|
||||||
let strs = cx.std_path(&["hash", "Hash", "hash"]);
|
let strs = cx.std_path(&[sym::hash, sym::Hash, sym::hash]);
|
||||||
|
|
||||||
cx.expr_path(cx.path_global(span, strs))
|
cx.expr_path(cx.path_global(span, strs))
|
||||||
};
|
};
|
||||||
|
|
|
@ -150,7 +150,7 @@ fn call_intrinsic(cx: &ExtCtxt<'_>,
|
||||||
mark.set_expn_info(info);
|
mark.set_expn_info(info);
|
||||||
span = span.with_ctxt(SyntaxContext::empty().apply_mark(mark));
|
span = span.with_ctxt(SyntaxContext::empty().apply_mark(mark));
|
||||||
}
|
}
|
||||||
let path = cx.std_path(&["intrinsics", intrinsic]);
|
let path = cx.std_path(&[sym::intrinsics, Symbol::intern(intrinsic)]);
|
||||||
let call = cx.expr_call_global(span, path, args);
|
let call = cx.expr_call_global(span, path, args);
|
||||||
|
|
||||||
cx.expr_block(P(ast::Block {
|
cx.expr_block(P(ast::Block {
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt<'_>,
|
||||||
let lt = cx.lifetime(sp, Ident::with_empty_ctxt(kw::StaticLifetime));
|
let lt = cx.lifetime(sp, Ident::with_empty_ctxt(kw::StaticLifetime));
|
||||||
cx.expr_path(cx.path_all(sp,
|
cx.expr_path(cx.path_all(sp,
|
||||||
true,
|
true,
|
||||||
cx.std_path(&["option", "Option", "None"]),
|
cx.std_path(&[sym::option, sym::Option, sym::None]),
|
||||||
vec![GenericArg::Type(cx.ty_rptr(sp,
|
vec![GenericArg::Type(cx.ty_rptr(sp,
|
||||||
cx.ty_ident(sp,
|
cx.ty_ident(sp,
|
||||||
Ident::with_empty_ctxt(sym::str)),
|
Ident::with_empty_ctxt(sym::str)),
|
||||||
|
@ -37,7 +37,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt<'_>,
|
||||||
}
|
}
|
||||||
Ok(s) => {
|
Ok(s) => {
|
||||||
cx.expr_call_global(sp,
|
cx.expr_call_global(sp,
|
||||||
cx.std_path(&["option", "Option", "Some"]),
|
cx.std_path(&[sym::option, sym::Option, sym::Some]),
|
||||||
vec![cx.expr_str(sp, Symbol::intern(&s))])
|
vec![cx.expr_str(sp, Symbol::intern(&s))])
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -387,7 +387,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rtpath(ecx: &ExtCtxt<'_>, s: &str) -> Vec<ast::Ident> {
|
fn rtpath(ecx: &ExtCtxt<'_>, s: &str) -> Vec<ast::Ident> {
|
||||||
ecx.std_path(&["fmt", "rt", "v1", s])
|
ecx.std_path(&[sym::fmt, sym::rt, sym::v1, Symbol::intern(s)])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_count(&self, c: parse::Count<'_>) -> P<ast::Expr> {
|
fn build_count(&self, c: parse::Count<'_>) -> P<ast::Expr> {
|
||||||
|
@ -644,7 +644,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||||
("new_v1_formatted", vec![pieces, args_slice, fmt])
|
("new_v1_formatted", vec![pieces, args_slice, fmt])
|
||||||
};
|
};
|
||||||
|
|
||||||
let path = self.ecx.std_path(&["fmt", "Arguments", fn_name]);
|
let path = self.ecx.std_path(&[sym::fmt, sym::Arguments, Symbol::intern(fn_name)]);
|
||||||
self.ecx.expr_call_global(self.macsp, path, fn_args)
|
self.ecx.expr_call_global(self.macsp, path, fn_args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,14 +675,14 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Count => {
|
Count => {
|
||||||
let path = ecx.std_path(&["fmt", "ArgumentV1", "from_usize"]);
|
let path = ecx.std_path(&[sym::fmt, sym::ArgumentV1, sym::from_usize]);
|
||||||
return ecx.expr_call_global(macsp, path, vec![arg]);
|
return ecx.expr_call_global(macsp, path, vec![arg]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let path = ecx.std_path(&["fmt", trait_, "fmt"]);
|
let path = ecx.std_path(&[sym::fmt, Symbol::intern(trait_), sym::fmt]);
|
||||||
let format_fn = ecx.path_global(sp, path);
|
let format_fn = ecx.path_global(sp, path);
|
||||||
let path = ecx.std_path(&["fmt", "ArgumentV1", "new"]);
|
let path = ecx.std_path(&[sym::fmt, sym::ArgumentV1, sym::new]);
|
||||||
ecx.expr_call_global(macsp, path, vec![arg, ecx.expr_path(format_fn)])
|
ecx.expr_call_global(macsp, path, vec![arg, ecx.expr_path(format_fn)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,8 @@ symbols! {
|
||||||
always,
|
always,
|
||||||
any,
|
any,
|
||||||
arbitrary_self_types,
|
arbitrary_self_types,
|
||||||
|
Arguments,
|
||||||
|
ArgumentV1,
|
||||||
arm_target_feature,
|
arm_target_feature,
|
||||||
asm,
|
asm,
|
||||||
associated_consts,
|
associated_consts,
|
||||||
|
@ -145,6 +147,7 @@ symbols! {
|
||||||
automatically_derived,
|
automatically_derived,
|
||||||
avx512_target_feature,
|
avx512_target_feature,
|
||||||
await_macro,
|
await_macro,
|
||||||
|
begin_panic,
|
||||||
bench,
|
bench,
|
||||||
bin,
|
bin,
|
||||||
bind_by_move_pattern_guards,
|
bind_by_move_pattern_guards,
|
||||||
|
@ -164,9 +167,11 @@ symbols! {
|
||||||
cfg_target_thread_local,
|
cfg_target_thread_local,
|
||||||
cfg_target_vendor,
|
cfg_target_vendor,
|
||||||
clone,
|
clone,
|
||||||
|
Clone,
|
||||||
clone_closures,
|
clone_closures,
|
||||||
clone_from,
|
clone_from,
|
||||||
closure_to_fn_coercion,
|
closure_to_fn_coercion,
|
||||||
|
cmp,
|
||||||
cmpxchg16b_target_feature,
|
cmpxchg16b_target_feature,
|
||||||
cold,
|
cold,
|
||||||
compile_error,
|
compile_error,
|
||||||
|
@ -200,6 +205,7 @@ symbols! {
|
||||||
custom_test_frameworks,
|
custom_test_frameworks,
|
||||||
c_variadic,
|
c_variadic,
|
||||||
decl_macro,
|
decl_macro,
|
||||||
|
Default,
|
||||||
default_lib_allocator,
|
default_lib_allocator,
|
||||||
default_type_parameter_fallback,
|
default_type_parameter_fallback,
|
||||||
default_type_params,
|
default_type_params,
|
||||||
|
@ -234,6 +240,7 @@ symbols! {
|
||||||
enable,
|
enable,
|
||||||
err,
|
err,
|
||||||
Err,
|
Err,
|
||||||
|
Equal,
|
||||||
except,
|
except,
|
||||||
exclusive_range_pattern,
|
exclusive_range_pattern,
|
||||||
exhaustive_integer_patterns,
|
exhaustive_integer_patterns,
|
||||||
|
@ -256,6 +263,7 @@ symbols! {
|
||||||
field,
|
field,
|
||||||
field_init_shorthand,
|
field_init_shorthand,
|
||||||
file,
|
file,
|
||||||
|
fmt,
|
||||||
fmt_internals,
|
fmt_internals,
|
||||||
fn_must_use,
|
fn_must_use,
|
||||||
forbid,
|
forbid,
|
||||||
|
@ -265,6 +273,7 @@ symbols! {
|
||||||
from_error,
|
from_error,
|
||||||
from_generator,
|
from_generator,
|
||||||
from_ok,
|
from_ok,
|
||||||
|
from_usize,
|
||||||
fundamental,
|
fundamental,
|
||||||
future,
|
future,
|
||||||
Future,
|
Future,
|
||||||
|
@ -275,6 +284,8 @@ symbols! {
|
||||||
global_allocator,
|
global_allocator,
|
||||||
global_asm,
|
global_asm,
|
||||||
globs,
|
globs,
|
||||||
|
hash,
|
||||||
|
Hash,
|
||||||
hexagon_target_feature,
|
hexagon_target_feature,
|
||||||
hidden,
|
hidden,
|
||||||
homogeneous_aggregate,
|
homogeneous_aggregate,
|
||||||
|
@ -371,6 +382,7 @@ symbols! {
|
||||||
negate_unsigned,
|
negate_unsigned,
|
||||||
never,
|
never,
|
||||||
never_type,
|
never_type,
|
||||||
|
new,
|
||||||
next,
|
next,
|
||||||
__next,
|
__next,
|
||||||
nll,
|
nll,
|
||||||
|
@ -405,6 +417,8 @@ symbols! {
|
||||||
option,
|
option,
|
||||||
Option,
|
Option,
|
||||||
opt_out_copy,
|
opt_out_copy,
|
||||||
|
Ord,
|
||||||
|
Ordering,
|
||||||
Output,
|
Output,
|
||||||
overlapping_marker_traits,
|
overlapping_marker_traits,
|
||||||
packed,
|
packed,
|
||||||
|
@ -413,6 +427,8 @@ symbols! {
|
||||||
panic_impl,
|
panic_impl,
|
||||||
panic_implementation,
|
panic_implementation,
|
||||||
panic_runtime,
|
panic_runtime,
|
||||||
|
partial_cmp,
|
||||||
|
PartialOrd,
|
||||||
passes,
|
passes,
|
||||||
path,
|
path,
|
||||||
pattern_parentheses,
|
pattern_parentheses,
|
||||||
|
@ -473,6 +489,7 @@ symbols! {
|
||||||
Result,
|
Result,
|
||||||
Return,
|
Return,
|
||||||
rlib,
|
rlib,
|
||||||
|
rt,
|
||||||
rtm_target_feature,
|
rtm_target_feature,
|
||||||
rust,
|
rust,
|
||||||
rust_2015_preview,
|
rust_2015_preview,
|
||||||
|
@ -576,6 +593,7 @@ symbols! {
|
||||||
test_case,
|
test_case,
|
||||||
test_removed_feature,
|
test_removed_feature,
|
||||||
test_runner,
|
test_runner,
|
||||||
|
then_with,
|
||||||
thread_local,
|
thread_local,
|
||||||
tool_attributes,
|
tool_attributes,
|
||||||
tool_lints,
|
tool_lints,
|
||||||
|
@ -615,12 +633,15 @@ symbols! {
|
||||||
untagged_unions,
|
untagged_unions,
|
||||||
unwind,
|
unwind,
|
||||||
unwind_attributes,
|
unwind_attributes,
|
||||||
|
unwrap_or,
|
||||||
used,
|
used,
|
||||||
use_extern_macros,
|
use_extern_macros,
|
||||||
use_nested_groups,
|
use_nested_groups,
|
||||||
usize,
|
usize,
|
||||||
v1,
|
v1,
|
||||||
val,
|
val,
|
||||||
|
vec,
|
||||||
|
Vec,
|
||||||
vis,
|
vis,
|
||||||
visible_private_types,
|
visible_private_types,
|
||||||
volatile,
|
volatile,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue