From 5af6cf9fa422cb492525e139752a57d2d89f42c7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 29 Jul 2015 14:14:01 -0700 Subject: std: Remove the curious inner module This isn't actually necessary any more with the advent of `$crate` and changes in the compiler to expand macros to `::core::$foo` in the context of a `#![no_std]` crate. The libcore inner module was also trimmed down a bit to the bare bones. --- src/libcore/lib.rs | 32 +++++++++++++++++--------------- src/libcore/macros.rs | 4 ++-- src/libcore/ptr.rs | 2 +- src/libcore/str/pattern.rs | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) (limited to 'src/libcore') diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index ef2a33c37dd..47d630a3864 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -157,21 +157,23 @@ pub mod fmt; // note: does not need to be public mod tuple; +// A curious inner-module that's not exported that contains the bindings of core +// so that compiler-expanded references to `core::$foo` can be resolved within +// core itself. +// +// Note that no crate-defined macros require this module due to the existence of +// the `$crate` meta variable, only those expansions defined in the compiler +// require this. This is because the compiler doesn't currently know that it's +// compiling the core library when it's compiling this library, so it expands +// all references to `::core::$foo` #[doc(hidden)] mod core { - pub use intrinsics; - pub use panicking; - pub use fmt; - pub use clone; - pub use cmp; - pub use hash; - pub use marker; - pub use option; - pub use iter; -} - -#[doc(hidden)] -mod std { - // range syntax - pub use ops; + pub use intrinsics; // derive(PartialOrd) + pub use fmt; // format_args! + pub use clone; // derive(Clone) + pub use cmp; // derive(Ord) + pub use hash; // derive(Hash) + pub use marker; // derive(Copy) + pub use option; // iterator protocol + pub use iter; // iterator protocol } diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index 14bb82dff7d..9f4d61a50d5 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -17,7 +17,7 @@ macro_rules! panic { ); ($msg:expr) => ({ static _MSG_FILE_LINE: (&'static str, &'static str, u32) = ($msg, file!(), line!()); - ::core::panicking::panic(&_MSG_FILE_LINE) + $crate::panicking::panic(&_MSG_FILE_LINE) }); ($fmt:expr, $($arg:tt)*) => ({ // The leading _'s are to avoid dead code warnings if this is @@ -25,7 +25,7 @@ macro_rules! panic { // insufficient, since the user may have // `#[forbid(dead_code)]` and which cannot be overridden. static _FILE_LINE: (&'static str, u32) = (file!(), line!()); - ::core::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE) + $crate::panicking::panic_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE) }); } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 6fed89547d4..116c1dfaa3e 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -20,7 +20,7 @@ use mem; use clone::Clone; use intrinsics; use ops::Deref; -use core::fmt; +use fmt; use option::Option::{self, Some, None}; use marker::{PhantomData, Send, Sized, Sync}; use nonzero::NonZero; diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 707f7fcf2ab..2b3fc39fc8b 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -17,7 +17,7 @@ reason = "API not fully fleshed out and ready to be stabilized")] use prelude::*; -use core::cmp; +use cmp; use usize; // Pattern -- cgit 1.4.1-3-g733a5