diff options
| author | bors <bors@rust-lang.org> | 2017-12-13 11:09:55 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-12-13 11:09:55 +0000 |
| commit | 3dfbc88a626625be01e112da11ec367e2fc71bb3 (patch) | |
| tree | 3123349d2f450ac5317944d5f5803b20c3eca65b /src/libsyntax_ext/deriving/cmp | |
| parent | 61100840e5c978a99b0489e8eaa922da06c05f65 (diff) | |
| parent | 85d19b33357897c51d80727a4208f46b19c5c5a6 (diff) | |
| download | rust-3dfbc88a626625be01e112da11ec367e2fc71bb3.tar.gz rust-3dfbc88a626625be01e112da11ec367e2fc71bb3.zip | |
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/cmp')
| -rw-r--r-- | src/libsyntax_ext/deriving/cmp/eq.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/cmp/ord.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/cmp/partial_eq.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax_ext/deriving/cmp/partial_ord.rs | 9 |
4 files changed, 12 insertions, 8 deletions
diff --git a/src/libsyntax_ext/deriving/cmp/eq.rs b/src/libsyntax_ext/deriving/cmp/eq.rs index a282ff5bd04..237c8654edf 100644 --- a/src/libsyntax_ext/deriving/cmp/eq.rs +++ b/src/libsyntax_ext/deriving/cmp/eq.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::*; @@ -30,7 +31,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt, let trait_def = TraitDef { span, attributes: Vec::new(), - path: path_std!(cx, core::cmp::Eq), + path: path_std!(cx, cmp::Eq), additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, diff --git a/src/libsyntax_ext/deriving/cmp/ord.rs b/src/libsyntax_ext/deriving/cmp/ord.rs index 9b057aacece..1a392ac3765 100644 --- a/src/libsyntax_ext/deriving/cmp/ord.rs +++ b/src/libsyntax_ext/deriving/cmp/ord.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::*; @@ -28,7 +29,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, let trait_def = TraitDef { span, attributes: Vec::new(), - path: path_std!(cx, core::cmp::Ord), + path: path_std!(cx, cmp::Ord), additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, @@ -38,7 +39,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt, generics: LifetimeBounds::empty(), explicit_self: borrowed_explicit_self(), args: vec![borrowed_self()], - ret_ty: Literal(path_std!(cx, core::cmp::Ordering)), + ret_ty: Literal(path_std!(cx, cmp::Ordering)), attributes: attrs, is_unsafe: false, unify_fieldless_variants: true, diff --git a/src/libsyntax_ext/deriving/cmp/partial_eq.rs b/src/libsyntax_ext/deriving/cmp/partial_eq.rs index e635c6bebcd..75db7cc1e4c 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_eq.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_eq.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use deriving::{path_local, path_std}; use deriving::generic::*; use deriving::generic::ty::*; @@ -93,7 +94,7 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt, let trait_def = TraitDef { span, attributes: Vec::new(), - path: path_std!(cx, core::cmp::PartialEq), + path: path_std!(cx, cmp::PartialEq), additional_bounds: Vec::new(), generics: LifetimeBounds::empty(), is_unsafe: false, diff --git a/src/libsyntax_ext/deriving/cmp/partial_ord.rs b/src/libsyntax_ext/deriving/cmp/partial_ord.rs index e7e1c108760..92183c58eb2 100644 --- a/src/libsyntax_ext/deriving/cmp/partial_ord.rs +++ b/src/libsyntax_ext/deriving/cmp/partial_ord.rs @@ -10,6 +10,7 @@ pub use self::OrderingOp::*; +use deriving::{path_local, pathvec_std, path_std}; use deriving::generic::*; use deriving::generic::ty::*; @@ -45,11 +46,11 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt, } } } - let ordering_ty = Literal(path_std!(cx, core::cmp::Ordering)); - let ret_ty = Literal(Path::new_(pathvec_std!(cx, core::option::Option), + let ordering_ty = Literal(path_std!(cx, cmp::Ordering)); + let ret_ty = Literal(Path::new_(pathvec_std!(cx, option::Option), None, vec![Box::new(ordering_ty)], - true)); + PathKind::Std)); let inline = cx.meta_word(span, Symbol::intern("inline")); let attrs = vec![cx.attribute(span, inline)]; @@ -84,7 +85,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt, let trait_def = TraitDef { span, attributes: vec![], - path: path_std!(cx, core::cmp::PartialOrd), + path: path_std!(cx, cmp::PartialOrd), additional_bounds: vec![], generics: LifetimeBounds::empty(), is_unsafe: false, |
