about summary refs log tree commit diff
path: root/src/libsyntax_ext/deriving/clone.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-12-13 11:09:55 +0000
committerbors <bors@rust-lang.org>2017-12-13 11:09:55 +0000
commit3dfbc88a626625be01e112da11ec367e2fc71bb3 (patch)
tree3123349d2f450ac5317944d5f5803b20c3eca65b /src/libsyntax_ext/deriving/clone.rs
parent61100840e5c978a99b0489e8eaa922da06c05f65 (diff)
parent85d19b33357897c51d80727a4208f46b19c5c5a6 (diff)
Auto merge of #46550 - jseyfried:cleanup_builtin_hygiene, r=nrc
macros: hygienize use of `core`/`std` in builtin macros

Today, if a builtin macro wants to access an item from `core` or `std` (depending `#![no_std]`), it generates `::core::path::to::item` or `::std::path::to::item` respectively (c.f. `fn std_path()` in `libsyntax/ext/base.rs`).

This PR refactors the builtin macros to instead always emit `$crate::path::to::item` here. That is, the def site of builtin macros is taken to be in `extern crate core;` or `extern crate std;`. Since builtin macros are macros 1.0 (i.e. mostly unhygienic), changing the def site can only effect the resolution of `$crate`.

r? @nrc
Diffstat (limited to 'src/libsyntax_ext/deriving/clone.rs')
-rw-r--r--src/libsyntax_ext/deriving/clone.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libsyntax_ext/deriving/clone.rs b/src/libsyntax_ext/deriving/clone.rs
index 5d93c2a5f72..35def632fc1 100644
--- a/src/libsyntax_ext/deriving/clone.rs
+++ b/src/libsyntax_ext/deriving/clone.rs
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+use deriving::path_std;
 use deriving::generic::*;
 use deriving::generic::ty::*;
 
@@ -55,7 +56,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
                     }));
                 }
                 ItemKind::Union(..) => {
-                    bounds = vec![Literal(path_std!(cx, core::marker::Copy))];
+                    bounds = vec![Literal(path_std!(cx, marker::Copy))];
                     is_shallow = true;
                     substructure = combine_substructure(Box::new(|c, s, sub| {
                         cs_clone_shallow("Clone", c, s, sub, true)
@@ -79,7 +80,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
     let trait_def = TraitDef {
         span,
         attributes: Vec::new(),
-        path: path_std!(cx, core::clone::Clone),
+        path: path_std!(cx, clone::Clone),
         additional_bounds: bounds,
         generics: LifetimeBounds::empty(),
         is_unsafe: false,