diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index d6450f00c8b..a1e3bbcbf8e 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -444,7 +444,8 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro { .insert(local_span, (name.to_string(), data.get_span(id.index, sess))); LoadedMacro::MacroDef(ast::Item { - ident: ast::Ident::from_str(&name.as_str()), + // FIXME: cross-crate hygiene + ident: ast::Ident::with_dummy_span(name.as_symbol()), id: ast::DUMMY_NODE_ID, span: local_span, attrs: attrs.iter().cloned().collect(), diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 06a55316f31..eea66f9147d 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -363,7 +363,7 @@ pub fn expr_field_access( self.expr(sp, ast::ExprKind::Field(expr, ident.with_span_pos(sp))) } pub fn expr_tup_field_access(&self, sp: Span, expr: P, idx: usize) -> P { - let ident = Ident::from_str(&idx.to_string()).with_span_pos(sp); + let ident = Ident::new(sym::integer(idx), sp); self.expr(sp, ast::ExprKind::Field(expr, ident)) } pub fn expr_addr_of(&self, sp: Span, e: P) -> P { diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index c53fa7dc706..da16ee7a544 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -237,7 +237,7 @@ pub struct MethodDef<'a> { /// Whether there is a self argument (outer Option) i.e., whether /// this is a static function, and whether it is a pointer (inner /// Option) - pub explicit_self: Option>>, + pub explicit_self: Option>, /// Arguments other than the self argument pub args: Vec<(Ty<'a>, &'a str)>, diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index cb1c7b21fee..d47ef2c5d59 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -13,9 +13,9 @@ /// The types of pointers #[derive(Clone)] -pub enum PtrTy<'a> { +pub enum PtrTy { /// &'lifetime mut - Borrowed(Option<&'a str>, ast::Mutability), + Borrowed(Option, ast::Mutability), /// *mut #[allow(dead_code)] Raw(ast::Mutability), @@ -26,7 +26,7 @@ pub enum PtrTy<'a> { #[derive(Clone)] pub struct Path<'a> { path: Vec<&'a str>, - lifetime: Option<&'a str>, + lifetime: Option, params: Vec>>, kind: PathKind, } @@ -46,7 +46,7 @@ pub fn new_local(path: &str) -> Path<'_> { Path::new_(vec![path], None, Vec::new(), PathKind::Local) } pub fn new_<'r>(path: Vec<&'r str>, - lifetime: Option<&'r str>, + lifetime: Option, params: Vec>>, kind: PathKind) -> Path<'r> { @@ -99,7 +99,7 @@ pub fn to_path(&self, pub enum Ty<'a> { Self_, /// &/Box/ Ty - Ptr(Box>, PtrTy<'a>), + Ptr(Box>, PtrTy), /// mod::mod::Type<[lifetime], [Params...]>, including a plain type /// parameter, and things like `i32` Literal(Path<'a>), @@ -107,14 +107,14 @@ pub enum Ty<'a> { Tuple(Vec>), } -pub fn borrowed_ptrty<'r>() -> PtrTy<'r> { +pub fn borrowed_ptrty() -> PtrTy { Borrowed(None, ast::Mutability::Immutable) } pub fn borrowed(ty: Box>) -> Ty<'_> { Ptr(ty, borrowed_ptrty()) } -pub fn borrowed_explicit_self<'r>() -> Option>> { +pub fn borrowed_explicit_self() -> Option> { Some(Some(borrowed_ptrty())) } @@ -126,13 +126,11 @@ pub fn nil_ty<'r>() -> Ty<'r> { Tuple(Vec::new()) } -fn mk_lifetime(cx: &ExtCtxt<'_>, span: Span, lt: &Option<&str>) -> Option { - lt.map(|s| - cx.lifetime(span, Ident::from_str(s)) - ) +fn mk_lifetime(cx: &ExtCtxt<'_>, span: Span, lt: &Option) -> Option { + lt.map(|ident| cx.lifetime(span, ident)) } -fn mk_lifetimes(cx: &ExtCtxt<'_>, span: Span, lt: &Option<&str>) -> Vec { +fn mk_lifetimes(cx: &ExtCtxt<'_>, span: Span, lt: &Option) -> Vec { mk_lifetime(cx, span, lt).into_iter().collect() } @@ -265,7 +263,7 @@ pub fn to_generics(&self, pub fn get_explicit_self(cx: &ExtCtxt<'_>, span: Span, - self_ptr: &Option>) + self_ptr: &Option) -> (P, ast::ExplicitSelf) { // this constructs a fresh `self` path let self_path = cx.expr_self(span); @@ -276,7 +274,7 @@ pub fn get_explicit_self(cx: &ExtCtxt<'_>, respan(span, match *ptr { Borrowed(ref lt, mutbl) => { - let lt = lt.map(|s| cx.lifetime(span, Ident::from_str(s))); + let lt = lt.map(|s| cx.lifetime(span, s)); SelfKind::Region(lt, mutbl) } Raw(_) => { diff --git a/src/libsyntax_ext/test_harness.rs b/src/libsyntax_ext/test_harness.rs index b93c11fad38..257c967d0d0 100644 --- a/src/libsyntax_ext/test_harness.rs +++ b/src/libsyntax_ext/test_harness.rs @@ -288,7 +288,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P { // Honor the reexport_test_harness_main attribute let main_id = match cx.reexport_test_harness_main { Some(sym) => Ident::new(sym, sp.with_ctxt(SyntaxContext::root())), - None => Ident::from_str_and_span("main", sp), + None => Ident::new(sym::main, sp), }; let main = P(ast::Item {