Skip to content

Commit 14cd5c5

Browse files
committed
auto merge of #18646 : eddyb/rust/snapshots, r=alexcrichton
2 parents 98958bc + 56dbf3d commit 14cd5c5

File tree

13 files changed

+18
-352
lines changed

13 files changed

+18
-352
lines changed

src/libcore/fmt/mod.rs

-153
Original file line numberDiff line numberDiff line change
@@ -250,37 +250,6 @@ pub trait UpperExp for Sized? {
250250
fn fmt(&self, &mut Formatter) -> Result;
251251
}
252252

253-
// NOTE(stage0): Remove macro after next snapshot
254-
#[cfg(stage0)]
255-
macro_rules! uniform_fn_call_workaround {
256-
($( $name: ident, $trait_: ident; )*) => {
257-
$(
258-
#[doc(hidden)]
259-
pub fn $name<Sized? T: $trait_>(x: &T, fmt: &mut Formatter) -> Result {
260-
x.fmt(fmt)
261-
}
262-
)*
263-
}
264-
}
265-
// NOTE(stage0): Remove macro after next snapshot
266-
#[cfg(stage0)]
267-
uniform_fn_call_workaround! {
268-
secret_show, Show;
269-
secret_bool, Bool;
270-
secret_char, Char;
271-
secret_signed, Signed;
272-
secret_unsigned, Unsigned;
273-
secret_octal, Octal;
274-
secret_binary, Binary;
275-
secret_lower_hex, LowerHex;
276-
secret_upper_hex, UpperHex;
277-
secret_string, String;
278-
secret_pointer, Pointer;
279-
secret_float, Float;
280-
secret_lower_exp, LowerExp;
281-
secret_upper_exp, UpperExp;
282-
}
283-
284253
static DEFAULT_ARGUMENT: rt::Argument<'static> = rt::Argument {
285254
position: rt::ArgumentNext,
286255
format: rt::FormatSpec {
@@ -570,33 +539,13 @@ pub fn argument<'a, T>(f: extern "Rust" fn(&T, &mut Formatter) -> Result,
570539

571540
/// When the compiler determines that the type of an argument *must* be a string
572541
/// (such as for select), then it invokes this method.
573-
// NOTE(stage0): remove function after a snapshot
574-
#[cfg(stage0)]
575-
#[doc(hidden)] #[inline]
576-
pub fn argumentstr<'a>(s: &'a &str) -> Argument<'a> {
577-
argument(secret_string, s)
578-
}
579-
580-
/// When the compiler determines that the type of an argument *must* be a string
581-
/// (such as for select), then it invokes this method.
582-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
583542
#[doc(hidden)] #[inline]
584543
pub fn argumentstr<'a>(s: &'a &str) -> Argument<'a> {
585544
argument(String::fmt, s)
586545
}
587546

588547
/// When the compiler determines that the type of an argument *must* be a uint
589548
/// (such as for plural), then it invokes this method.
590-
// NOTE(stage0): remove function after a snapshot
591-
#[cfg(stage0)]
592-
#[doc(hidden)] #[inline]
593-
pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> {
594-
argument(secret_unsigned, s)
595-
}
596-
597-
/// When the compiler determines that the type of an argument *must* be a uint
598-
/// (such as for plural), then it invokes this method.
599-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
600549
#[doc(hidden)] #[inline]
601550
pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> {
602551
argument(Unsigned::fmt, s)
@@ -614,15 +563,6 @@ impl<'a> Show for &'a Show+'a {
614563
fn fmt(&self, f: &mut Formatter) -> Result { (*self).fmt(f) }
615564
}
616565

617-
// NOTE(stage0): remove impl after a snapshot
618-
#[cfg(stage0)]
619-
impl Bool for bool {
620-
fn fmt(&self, f: &mut Formatter) -> Result {
621-
secret_string(&(if *self {"true"} else {"false"}), f)
622-
}
623-
}
624-
625-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
626566
impl Bool for bool {
627567
fn fmt(&self, f: &mut Formatter) -> Result {
628568
String::fmt(if *self { "true" } else { "false" }, f)
@@ -641,20 +581,6 @@ impl String for str {
641581
}
642582
}
643583

644-
// NOTE(stage0): remove impl after a snapshot
645-
#[cfg(stage0)]
646-
impl Char for char {
647-
fn fmt(&self, f: &mut Formatter) -> Result {
648-
use char::Char;
649-
650-
let mut utf8 = [0u8, ..4];
651-
let amt = self.encode_utf8(utf8).unwrap_or(0);
652-
let s: &str = unsafe { mem::transmute(utf8[..amt]) };
653-
secret_string(&s, f)
654-
}
655-
}
656-
657-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
658584
impl Char for char {
659585
fn fmt(&self, f: &mut Formatter) -> Result {
660586
use char::Char;
@@ -666,62 +592,25 @@ impl Char for char {
666592
}
667593
}
668594

669-
// NOTE(stage0): remove impl after a snapshot
670-
#[cfg(stage0)]
671-
impl<T> Pointer for *const T {
672-
fn fmt(&self, f: &mut Formatter) -> Result {
673-
f.flags |= 1 << (rt::FlagAlternate as uint);
674-
secret_lower_hex::<uint>(&(*self as uint), f)
675-
}
676-
}
677-
678-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
679595
impl<T> Pointer for *const T {
680596
fn fmt(&self, f: &mut Formatter) -> Result {
681597
f.flags |= 1 << (rt::FlagAlternate as uint);
682598
LowerHex::fmt(&(*self as uint), f)
683599
}
684600
}
685601

686-
// NOTE(stage0): remove impl after a snapshot
687-
#[cfg(stage0)]
688-
impl<T> Pointer for *mut T {
689-
fn fmt(&self, f: &mut Formatter) -> Result {
690-
secret_pointer::<*const T>(&(*self as *const T), f)
691-
}
692-
}
693-
694-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
695602
impl<T> Pointer for *mut T {
696603
fn fmt(&self, f: &mut Formatter) -> Result {
697604
Pointer::fmt(&(*self as *const T), f)
698605
}
699606
}
700607

701-
// NOTE(stage0): remove impl after a snapshot
702-
#[cfg(stage0)]
703-
impl<'a, T> Pointer for &'a T {
704-
fn fmt(&self, f: &mut Formatter) -> Result {
705-
secret_pointer::<*const T>(&(&**self as *const T), f)
706-
}
707-
}
708-
709-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
710608
impl<'a, T> Pointer for &'a T {
711609
fn fmt(&self, f: &mut Formatter) -> Result {
712610
Pointer::fmt(&(*self as *const T), f)
713611
}
714612
}
715613

716-
// NOTE(stage0): remove impl after a snapshot
717-
#[cfg(stage0)]
718-
impl<'a, T> Pointer for &'a mut T {
719-
fn fmt(&self, f: &mut Formatter) -> Result {
720-
secret_pointer::<*const T>(&(&**self as *const T), f)
721-
}
722-
}
723-
724-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
725614
impl<'a, T> Pointer for &'a mut T {
726615
fn fmt(&self, f: &mut Formatter) -> Result {
727616
Pointer::fmt(&(&**self as *const T), f)
@@ -797,65 +686,23 @@ floating!(f64)
797686

798687
// Implementation of Show for various core types
799688

800-
// NOTE(stage0): remove macro after a snapshot
801-
#[cfg(stage0)]
802-
macro_rules! delegate(($ty:ty to $other:ident) => {
803-
impl Show for $ty {
804-
fn fmt(&self, f: &mut Formatter) -> Result {
805-
(concat_idents!(secret_, $other)(self, f))
806-
}
807-
}
808-
})
809-
810-
// NOTE(stage0): remove these macros after a snapshot
811-
#[cfg(stage0)]
812-
delegate!(str to string)
813-
#[cfg(stage0)]
814-
delegate!(bool to bool)
815-
#[cfg(stage0)]
816-
delegate!(char to char)
817-
#[cfg(stage0)]
818-
delegate!(f32 to float)
819-
#[cfg(stage0)]
820-
delegate!(f64 to float)
821-
822-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
823689
macro_rules! delegate(($ty:ty to $other:ident) => {
824690
impl Show for $ty {
825691
fn fmt(&self, f: &mut Formatter) -> Result {
826692
$other::fmt(self, f)
827693
}
828694
}
829695
})
830-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
831696
delegate!(str to String)
832-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
833697
delegate!(bool to Bool)
834-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
835698
delegate!(char to Char)
836-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
837699
delegate!(f32 to Float)
838-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
839700
delegate!(f64 to Float)
840701

841-
// NOTE(stage0): remove impl after a snapshot
842-
#[cfg(stage0)]
843-
impl<T> Show for *const T {
844-
fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) }
845-
}
846-
847-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
848702
impl<T> Show for *const T {
849703
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
850704
}
851705

852-
// NOTE(stage0): remove impl after a snapshot
853-
#[cfg(stage0)]
854-
impl<T> Show for *mut T {
855-
fn fmt(&self, f: &mut Formatter) -> Result { secret_pointer(self, f) }
856-
}
857-
858-
#[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot
859706
impl<T> Show for *mut T {
860707
fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
861708
}

src/libcore/intrinsics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ extern "rust-intrinsic" {
171171
/// with optimization of surrounding code and reduce performance. It should
172172
/// not be used if the invariant can be discovered by the optimizer on its
173173
/// own, or if it does not enable any significant optimizations.
174-
#[cfg(not(stage0))]
175174
pub fn assume(b: bool);
176175

177176
/// Execute a breakpoint trap, for inspection by a debugger.

src/libcore/ops.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -849,34 +849,30 @@ pub trait DerefMut<Sized? Result>: Deref<Result> {
849849
#[lang="fn"]
850850
pub trait Fn<Args,Result> {
851851
/// This is called when the call operator is used.
852-
#[rust_call_abi_hack]
853-
fn call(&self, args: Args) -> Result;
852+
extern "rust-call" fn call(&self, args: Args) -> Result;
854853
}
855854

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

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

872869
macro_rules! def_fn_mut(
873870
($($args:ident)*) => (
874871
impl<Result$(,$args)*>
875872
FnMut<($($args,)*),Result>
876873
for extern "Rust" fn($($args: $args,)*) -> Result {
877-
#[rust_call_abi_hack]
878874
#[allow(non_snake_case)]
879-
fn call_mut(&mut self, args: ($($args,)*)) -> Result {
875+
extern "rust-call" fn call_mut(&mut self, args: ($($args,)*)) -> Result {
880876
let ($($args,)*) = args;
881877
(*self)($($args,)*)
882878
}

src/libcore/panicking.rs

-47
Original file line numberDiff line numberDiff line change
@@ -33,49 +33,6 @@
3333
use fmt;
3434
use intrinsics;
3535

36-
// NOTE(stage0): remove after a snapshot
37-
#[cfg(stage0)]
38-
#[cold] #[inline(never)] // this is the slow path, always
39-
#[lang="fail"]
40-
pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
41-
let (expr, file, line) = *expr_file_line;
42-
let ref file_line = (file, line);
43-
format_args!(|args| -> () {
44-
panic_fmt(args, file_line);
45-
}, "{}", expr);
46-
47-
unsafe { intrinsics::abort() }
48-
}
49-
50-
// NOTE(stage0): remove after a snapshot
51-
#[cfg(stage0)]
52-
#[cold] #[inline(never)]
53-
#[lang="fail_bounds_check"]
54-
fn panic_bounds_check(file_line: &(&'static str, uint),
55-
index: uint, len: uint) -> ! {
56-
format_args!(|args| -> () {
57-
panic_fmt(args, file_line);
58-
}, "index out of bounds: the len is {} but the index is {}", len, index);
59-
unsafe { intrinsics::abort() }
60-
}
61-
62-
// NOTE(stage0): remove after a snapshot
63-
#[cfg(stage0)]
64-
#[cold] #[inline(never)]
65-
pub fn panic_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
66-
#[allow(improper_ctypes)]
67-
extern {
68-
#[lang = "fail_fmt"]
69-
fn panic_impl(fmt: &fmt::Arguments, file: &'static str,
70-
line: uint) -> !;
71-
72-
}
73-
let (file, line) = *file_line;
74-
unsafe { panic_impl(fmt, file, line) }
75-
}
76-
77-
// NOTE(stage0): remove cfg after a snapshot
78-
#[cfg(not(stage0))]
7936
#[cold] #[inline(never)] // this is the slow path, always
8037
#[lang="panic"]
8138
pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
@@ -88,8 +45,6 @@ pub fn panic(expr_file_line: &(&'static str, &'static str, uint)) -> ! {
8845
unsafe { intrinsics::abort() }
8946
}
9047

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

103-
// NOTE(stage0): remove cfg after a snapshot
104-
#[cfg(not(stage0))]
10558
#[cold] #[inline(never)]
10659
pub fn panic_fmt(fmt: &fmt::Arguments, file_line: &(&'static str, uint)) -> ! {
10760
#[allow(improper_ctypes)]

src/librustc/middle/typeck/collect.rs

+2-16
Original file line numberDiff line numberDiff line change
@@ -574,20 +574,6 @@ fn convert_methods<'a,I>(ccx: &CrateCtxt,
574574
rcvr_ty_generics: &ty::Generics,
575575
rcvr_visibility: ast::Visibility)
576576
-> ty::Method {
577-
// FIXME(pcwalton): Hack until we have syntax in stage0 for snapshots.
578-
let real_abi = match container {
579-
ty::TraitContainer(trait_id) => {
580-
if ccx.tcx.lang_items.fn_trait() == Some(trait_id) ||
581-
ccx.tcx.lang_items.fn_mut_trait() == Some(trait_id) ||
582-
ccx.tcx.lang_items.fn_once_trait() == Some(trait_id) {
583-
abi::RustCall
584-
} else {
585-
m.pe_abi()
586-
}
587-
}
588-
_ => m.pe_abi(),
589-
};
590-
591577
let m_ty_generics =
592578
ty_generics_for_fn_or_method(
593579
ccx,
@@ -607,7 +593,7 @@ fn convert_methods<'a,I>(ccx: &CrateCtxt,
607593
untransformed_rcvr_ty,
608594
m.pe_explicit_self(),
609595
&*m.pe_fn_decl(),
610-
real_abi)
596+
m.pe_abi())
611597
}
612598
TraitConvertMethodContext(trait_id, trait_items) => {
613599
let tmcx = TraitMethodCtxt {
@@ -622,7 +608,7 @@ fn convert_methods<'a,I>(ccx: &CrateCtxt,
622608
untransformed_rcvr_ty,
623609
m.pe_explicit_self(),
624610
&*m.pe_fn_decl(),
625-
real_abi)
611+
m.pe_abi())
626612
}
627613
};
628614

0 commit comments

Comments
 (0)