Skip to content

Register snapshots. #18646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 0 additions & 153 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,37 +250,6 @@ pub trait UpperExp for Sized? {
fn fmt(&self, &mut Formatter) -> Result;
}

// NOTE(stage0): Remove macro after next snapshot
#[cfg(stage0)]
macro_rules! uniform_fn_call_workaround {
($( $name: ident, $trait_: ident; )*) => {
$(
#[doc(hidden)]
pub fn $name<Sized? T: $trait_>(x: &T, fmt: &mut Formatter) -> Result {
x.fmt(fmt)
}
)*
}
}
// NOTE(stage0): Remove macro after next snapshot
#[cfg(stage0)]
uniform_fn_call_workaround! {
secret_show, Show;
secret_bool, Bool;
secret_char, Char;
secret_signed, Signed;
secret_unsigned, Unsigned;
secret_octal, Octal;
secret_binary, Binary;
secret_lower_hex, LowerHex;
secret_upper_hex, UpperHex;
secret_string, String;
secret_pointer, Pointer;
secret_float, Float;
secret_lower_exp, LowerExp;
secret_upper_exp, UpperExp;
}

static DEFAULT_ARGUMENT: rt::Argument<'static> = rt::Argument {
position: rt::ArgumentNext,
format: rt::FormatSpec {
Expand Down Expand Up @@ -570,33 +539,13 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter) -> Result,

/// When the compiler determines that the type of an argument *must* be a string
/// (such as for select), then it invokes this method.
// NOTE(stage0): remove function after a snapshot
#[cfg(stage0)]
#[doc(hidden)] #[inline]
pub fn argumentstr<'a>(s: &'a &str) -> Argument<'a> {
argument(secret_string, s)
}

/// When the compiler determines that the type of an argument *must* be a string
/// (such as for select), then it invokes this method.
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
#[doc(hidden)] #[inline]
pub fn argumentstr<'a>(s: &'a &str) -> Argument<'a> {
argument(String::fmt, s)
}

/// When the compiler determines that the type of an argument *must* be a uint
/// (such as for plural), then it invokes this method.
// NOTE(stage0): remove function after a snapshot
#[cfg(stage0)]
#[doc(hidden)] #[inline]
pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> {
argument(secret_unsigned, s)
}

/// When the compiler determines that the type of an argument *must* be a uint
/// (such as for plural), then it invokes this method.
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
#[doc(hidden)] #[inline]
pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> {
argument(Unsigned::fmt, s)
Expand All @@ -614,15 +563,6 @@ impl<'a> Show for &'a Show+'a {
fn fmt(&self, f: &mut Formatter) -> Result { (*self).fmt(f) }
}

// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl Bool for bool {
fn fmt(&self, f: &mut Formatter) -> Result {
secret_string(&(if *self {"true"} else {"false"}), f)
}
}

#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl Bool for bool {
fn fmt(&self, f: &mut Formatter) -> Result {
String::fmt(if *self { "true" } else { "false" }, f)
Expand All @@ -641,20 +581,6 @@ impl String for str {
}
}

// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl Char for char {
fn fmt(&self, f: &mut Formatter) -> Result {
use char::Char;

let mut utf8 = [0u8, ..4];
let amt = self.encode_utf8(utf8).unwrap_or(0);
let s: &str = unsafe { mem::transmute(utf8[..amt]) };
secret_string(&s, f)
}
}

#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl Char for char {
fn fmt(&self, f: &mut Formatter) -> Result {
use char::Char;
Expand All @@ -666,62 +592,25 @@ impl Char for char {
}
}

// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T> Pointer for *const T {
fn fmt(&self, f: &mut Formatter) -> Result {
f.flags |= 1 << (rt::FlagAlternate as uint);
secret_lower_hex::<uint>(&(*self as uint), f)
}
}

#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T> Pointer for *const T {
fn fmt(&self, f: &mut Formatter) -> Result {
f.flags |= 1 << (rt::FlagAlternate as uint);
LowerHex::fmt(&(*self as uint), f)
}
}

// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T> Pointer for *mut T {
fn fmt(&self, f: &mut Formatter) -> Result {
secret_pointer::<*const T>(&(*self as *const T), f)
}
}

#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T> Pointer for *mut T {
fn fmt(&self, f: &mut Formatter) -> Result {
Pointer::fmt(&(*self as *const T), f)
}
}

// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, T> Pointer for &'a T {
fn fmt(&self, f: &mut Formatter) -> Result {
secret_pointer::<*const T>(&(&**self as *const T), f)
}
}

#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> Pointer for &'a T {
fn fmt(&self, f: &mut Formatter) -> Result {
Pointer::fmt(&(*self as *const T), f)
}
}

// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<'a, T> Pointer for &'a mut T {
fn fmt(&self, f: &mut Formatter) -> Result {
secret_pointer::<*const T>(&(&**self as *const T), f)
}
}

#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<'a, T> Pointer for &'a mut T {
fn fmt(&self, f: &mut Formatter) -> Result {
Pointer::fmt(&(&**self as *const T), f)
Expand Down Expand Up @@ -797,65 +686,23 @@ floating!(f64)

// Implementation of Show for various core types

// NOTE(stage0): remove macro after a snapshot
#[cfg(stage0)]
macro_rules! delegate(($ty:ty to $other:ident) => {
impl Show for $ty {
fn fmt(&self, f: &mut Formatter) -> Result {
(concat_idents!(secret_, $other)(self, f))
}
}
})

// NOTE(stage0): remove these macros after a snapshot
#[cfg(stage0)]
delegate!(str to string)
#[cfg(stage0)]
delegate!(bool to bool)
#[cfg(stage0)]
delegate!(char to char)
#[cfg(stage0)]
delegate!(f32 to float)
#[cfg(stage0)]
delegate!(f64 to float)

#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
macro_rules! delegate(($ty:ty to $other:ident) => {
impl Show for $ty {
fn fmt(&self, f: &mut Formatter) -> Result {
$other::fmt(self, f)
}
}
})
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
delegate!(str to String)
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
delegate!(bool to Bool)
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
delegate!(char to Char)
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
delegate!(f32 to Float)
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
delegate!(f64 to Float)

// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T> Show for *const T {
fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) }
}

#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T> Show for *const T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}

// NOTE(stage0): remove impl after a snapshot
#[cfg(stage0)]
impl<T> Show for *mut T {
fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) }
}

#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
impl<T> Show for *mut T {
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
}
Expand Down
1 change: 0 additions & 1 deletion src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ extern "rust-intrinsic" {
/// with optimization of surrounding code and reduce performance. It should
/// not be used if the invariant can be discovered by the optimizer on its
/// own, or if it does not enable any significant optimizations.
#[cfg(not(stage0))]
pub fn assume(b: bool);

/// Execute a breakpoint trap, for inspection by a debugger.
Expand Down
12 changes: 4 additions & 8 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,34 +849,30 @@ pub trait DerefMut<Sized? Result>: Deref<Result> {
#[lang="fn"]
pub trait Fn<Args,Result> {
/// This is called when the call operator is used.
#[rust_call_abi_hack]
fn call(&self, args: Args) -> Result;
extern "rust-call" fn call(&self, args: Args) -> Result;
}

/// A version of the call operator that takes a mutable receiver.
#[lang="fn_mut"]
pub trait FnMut<Args,Result> {
/// This is called when the call operator is used.
#[rust_call_abi_hack]
fn call_mut(&mut self, args: Args) -> Result;
extern "rust-call" fn call_mut(&mut self, args: Args) -> Result;
}

/// A version of the call operator that takes a by-value receiver.
#[lang="fn_once"]
pub trait FnOnce<Args,Result> {
/// This is called when the call operator is used.
#[rust_call_abi_hack]
fn call_once(self, args: Args) -> Result;
extern "rust-call" fn call_once(self, args: Args) -> Result;
}

macro_rules! def_fn_mut(
($($args:ident)*) => (
impl<Result$(,$args)*>
FnMut<($($args,)*),Result>
for extern "Rust" fn($($args: $args,)*) -> Result {
#[rust_call_abi_hack]
#[allow(non_snake_case)]
fn call_mut(&mut self, args: ($($args,)*)) -> Result {
extern "rust-call" fn call_mut(&mut self, args: ($($args,)*)) -> Result {
let ($($args,)*) = args;
(*self)($($args,)*)
}
Expand Down
47 changes: 0 additions & 47 deletions src/libcore/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,49 +33,6 @@
use fmt;
use intrinsics;

// NOTE(stage0): remove after a snapshot
#[cfg(stage0)]
#[cold] #[inline(never)] // this is the slow path, always
#[lang="fail"]
pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
let (expr, file, line) = *expr_file_line;
let ref file_line = (file, line);
format_args!(|args| -> () {
panic_fmt(args, file_line);
}, "{}", expr);

unsafe { intrinsics::abort() }
}

// NOTE(stage0): remove after a snapshot
#[cfg(stage0)]
#[cold] #[inline(never)]
#[lang="fail_bounds_check"]
fn panic_bounds_check(file_line: &(&'static str, uint),
index: uint, len: uint) -> ! {
format_args!(|args| -> () {
panic_fmt(args, file_line);
}, "index out of bounds: the len is {} but the index is {}", len, index);
unsafe { intrinsics::abort() }
}

// NOTE(stage0): remove after a snapshot
#[cfg(stage0)]
#[cold] #[inline(never)]
pub fn panic_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
#[allow(improper_ctypes)]
extern {
#[lang = "fail_fmt"]
fn panic_impl(fmt: &fmt::Arguments, file: &'static str,
line: uint) -> !;

}
let (file, line) = *file_line;
unsafe { panic_impl(fmt, file, line) }
}

// NOTE(stage0): remove cfg after a snapshot
#[cfg(not(stage0))]
#[cold] #[inline(never)] // this is the slow path, always
#[lang="panic"]
pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
Expand All @@ -88,8 +45,6 @@ pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
unsafe { intrinsics::abort() }
}

// NOTE(stage0): remove cfg after a snapshot
#[cfg(not(stage0))]
#[cold] #[inline(never)]
#[lang="panic_bounds_check"]
fn panic_bounds_check(file_line: &(&'static str, uint),
Expand All @@ -100,8 +55,6 @@ fn panic_bounds_check(file_line: &(&'static str, uint),
unsafe { intrinsics::abort() }
}

// NOTE(stage0): remove cfg after a snapshot
#[cfg(not(stage0))]
#[cold] #[inline(never)]
pub fn panic_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
#[allow(improper_ctypes)]
Expand Down
18 changes: 2 additions & 16 deletions src/librustc/middle/typeck/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,20 +574,6 @@ fn convert_methods<'a,I>(ccx: &CrateCtxt,
rcvr_ty_generics: &ty::Generics,
rcvr_visibility: ast::Visibility)
-> ty::Method {
// FIXME(pcwalton): Hack until we have syntax in stage0 for snapshots.
let real_abi = match container {
ty::TraitContainer(trait_id) => {
if ccx.tcx.lang_items.fn_trait() == Some(trait_id) ||
ccx.tcx.lang_items.fn_mut_trait() == Some(trait_id) ||
ccx.tcx.lang_items.fn_once_trait() == Some(trait_id) {
abi::RustCall
} else {
m.pe_abi()
}
}
_ => m.pe_abi(),
};

let m_ty_generics =
ty_generics_for_fn_or_method(
ccx,
Expand All @@ -607,7 +593,7 @@ fn convert_methods<'a,I>(ccx: &CrateCtxt,
untransformed_rcvr_ty,
m.pe_explicit_self(),
&*m.pe_fn_decl(),
real_abi)
m.pe_abi())
}
TraitConvertMethodContext(trait_id, trait_items) => {
let tmcx = TraitMethodCtxt {
Expand All @@ -622,7 +608,7 @@ fn convert_methods<'a,I>(ccx: &CrateCtxt,
untransformed_rcvr_ty,
m.pe_explicit_self(),
&*m.pe_fn_decl(),
real_abi)
m.pe_abi())
}
};

Expand Down
Loading