Skip to content

libcore, libstd: Add isize, usize modules, deprecate int, uint modules #20708

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 3 commits into from
Jan 8, 2015
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
2 changes: 0 additions & 2 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ mod std {
pub use core::option; // necessary for panic!()
pub use core::clone; // deriving(Clone)
pub use core::cmp; // deriving(Eq, Ord, etc.)
#[cfg(stage0)]
pub use core::marker as kinds;
pub use core::marker; // deriving(Copy)
pub use core::hash; // deriving(Hash)
}
Expand Down
12 changes: 0 additions & 12 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -921,18 +921,6 @@ pub trait ToString {
fn to_string(&self) -> String;
}

#[cfg(stage0)]
impl<T: fmt::Show> ToString for T {
fn to_string(&self) -> String {
use core::fmt::Writer;
let mut buf = String::new();
let _ = buf.write_fmt(format_args!("{}", self));
buf.shrink_to_fit();
buf
}
}

#[cfg(not(stage0))]
impl<T: fmt::String> ToString for T {
fn to_string(&self) -> String {
use core::fmt::Writer;
Expand Down
9 changes: 0 additions & 9 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,15 +1454,6 @@ impl<T: fmt::Show> fmt::Show for Vec<T> {
}
}

#[cfg(stage0)]
#[experimental = "waiting on Show stability"]
impl<T: fmt::Show> fmt::String for Vec<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self.as_slice(), f)
}
}

#[cfg(not(stage0))]
#[experimental = "waiting on Show stability"]
impl<T: fmt::String> fmt::String for Vec<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
12 changes: 1 addition & 11 deletions src/libcore/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<T> ToOwned<T> for T where T: Clone {
/// }
/// }
/// ```
//#[deriving(Show)] NOTE(stage0): uncomment after snapshot
#[derive(Show)]
pub enum Cow<'a, T, B: ?Sized + 'a> where B: ToOwned<T> {
/// Borrowed data.
Borrowed(&'a B),
Expand All @@ -142,16 +142,6 @@ pub enum Cow<'a, T, B: ?Sized + 'a> where B: ToOwned<T> {
Owned(T)
}

//NOTE(stage0): replace with deriving(Show) after snapshot
impl<'a, T, B: ?Sized> fmt::Show for Cow<'a, T, B> where
B: fmt::String + ToOwned<T>,
T: fmt::String
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}

#[stable]
impl<'a, T, B: ?Sized> Clone for Cow<'a, T, B> where B: ToOwned<T> {
fn clone(&self) -> Cow<'a, T, B> {
Expand Down
42 changes: 0 additions & 42 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,16 +633,6 @@ impl String for bool {
}
}

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

#[cfg(not(stage0))]
//NOTE(stage0): remove cfg after snapshot
impl Show for str {
fn fmt(&self, f: &mut Formatter) -> Result {
try!(write!(f, "\""));
Expand All @@ -659,16 +649,6 @@ impl String for str {
}
}

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

#[cfg(not(stage0))]
//NOTE(stage0): remove cfg after snapshot
impl Show for char {
fn fmt(&self, f: &mut Formatter) -> Result {
use char::CharExt;
Expand Down Expand Up @@ -863,28 +843,6 @@ impl<T: Show> Show for [T] {
}
}

#[cfg(stage0)]
impl<T: Show> String for [T] {
fn fmt(&self, f: &mut Formatter) -> Result {
if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
try!(write!(f, "["));
}
let mut is_first = true;
for x in self.iter() {
if is_first {
is_first = false;
} else {
try!(write!(f, ", "));
}
try!(write!(f, "{}", *x))
}
if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
try!(write!(f, "]"));
}
Ok(())
}
}
#[cfg(not(stage0))]
impl<T: String> String for [T] {
fn fmt(&self, f: &mut Formatter) -> Result {
if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
Expand Down
16 changes: 0 additions & 16 deletions src/libcore/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,6 @@ pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {

macro_rules! radix_fmt {
($T:ty as $U:ty, $fmt:ident, $S:expr) => {
#[cfg(stage0)]
impl fmt::Show for RadixFmt<$T, Radix> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}

#[cfg(not(stage0))]
impl fmt::Show for RadixFmt<$T, Radix> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(fmt::String::fmt(self, f));
Expand All @@ -188,14 +180,6 @@ macro_rules! int_base {

macro_rules! show {
($T:ident with $S:expr) => {
#[cfg(stage0)]
impl fmt::Show for $T {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}

#[cfg(not(stage0))]
impl fmt::Show for $T {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(fmt::String::fmt(self, f));
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ mod int_macros;
mod uint_macros;

#[path = "num/int.rs"] pub mod int;
#[path = "num/isize.rs"] pub mod isize;
#[path = "num/i8.rs"] pub mod i8;
#[path = "num/i16.rs"] pub mod i16;
#[path = "num/i32.rs"] pub mod i32;
#[path = "num/i64.rs"] pub mod i64;

#[path = "num/uint.rs"] pub mod uint;
#[path = "num/usize.rs"] pub mod usize;
#[path = "num/u8.rs"] pub mod u8;
#[path = "num/u16.rs"] pub mod u16;
#[path = "num/u32.rs"] pub mod u32;
Expand Down Expand Up @@ -146,8 +148,6 @@ mod core {
mod std {
pub use clone;
pub use cmp;
#[cfg(stage0)]
pub use marker as kinds;
pub use marker;
pub use option;
pub use fmt;
Expand Down
9 changes: 6 additions & 3 deletions src/libcore/num/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Operations and constants for architecture-sized signed integers (`int` type)
//! Deprecated: replaced by `isize`.
//!
//! The rollout of the new type will gradually take place over the
//! alpha cycle along with the development of clearer conventions
//! around integer types.

#![stable]
#![doc(primitive = "int")]
#![deprecated = "replaced by isize"]

#[cfg(target_word_size = "32")] int_module! { int, 32 }
#[cfg(target_word_size = "64")] int_module! { int, 64 }
21 changes: 21 additions & 0 deletions src/libcore/num/isize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Operations and constants for pointer-sized signed integers (`isize` type)
//!
//! This type was recently added to replace `int`. The rollout of the
//! new type will gradually take place over the alpha cycle along with
//! the development of clearer conventions around integer types.

#![stable]
#![doc(primitive = "isize")]

#[cfg(target_word_size = "32")] int_module! { isize, 32 }
#[cfg(target_word_size = "64")] int_module! { isize, 64 }
9 changes: 6 additions & 3 deletions src/libcore/num/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Operations and constants for architecture-sized unsigned integers (`uint` type)
//! Deprecated: replaced by `usize`.
//!
//! The rollout of the new type will gradually take place over the
//! alpha cycle along with the development of clearer conventions
//! around integer types.

#![stable]
#![doc(primitive = "uint")]
#![deprecated = "replaced by usize"]

uint_module! { uint, int, ::int::BITS }
20 changes: 20 additions & 0 deletions src/libcore/num/usize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Operations and constants for pointer-sized unsigned integers (`usize` type)
//!
//! This type was recently added to replace `uint`. The rollout of the
//! new type will gradually take place over the alpha cycle along with
//! the development of clearer conventions around integer types.

#![stable]
#![doc(primitive = "usize")]

uint_module! { usize, isize, ::isize::BITS }
2 changes: 0 additions & 2 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5065,7 +5065,5 @@ pub fn issue_14344_workaround() {} // FIXME #14344 force linkage to happen corre
#[doc(hidden)]
#[cfg(not(test))]
mod std {
#[cfg(stage0)]
pub use core::marker as kinds;
pub use core::marker;
}
2 changes: 0 additions & 2 deletions src/librand/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,6 @@ pub struct Closed01<F>(pub F);
mod std {
pub use core::{option, fmt}; // panic!()
pub use core::clone; // derive Clone
#[cfg(stage0)]
pub use core::marker as kinds;
pub use core::marker;
}

Expand Down
9 changes: 0 additions & 9 deletions src/libregex/re.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,6 @@ impl Clone for ExNative {
}
}

#[cfg(stage0)]
//FIXME: remove after stage0 snapshot
impl fmt::Show for Regex {
/// Shows the original regular expression.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self.as_str(), f)
}
}

impl fmt::String for Regex {
/// Shows the original regular expression.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
4 changes: 1 addition & 3 deletions src/librustc_back/svh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ impl Svh {

impl fmt::Show for Svh {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
//NOTE(stage0): uncomment after snapshot
//write!(f, "Svh {{ {} }}", self.as_str())
fmt::String::fmt(self, f)
write!(f, "Svh {{ {} }}", self.as_str())
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
ast::PatRegion(ref inner, mutbl) => {
let inner_ty = fcx.infcx().next_ty_var();

// SNAP 340ac04 remove this `if`-`else` entirely after next snapshot
// SNAP 9e4e524 remove this `if`-`else` entirely after next snapshot
let mutbl = if mutbl == ast::MutImmutable {
ty::deref(fcx.infcx().shallow_resolve(expected), true)
.map(|mt| mt.mutbl).unwrap_or(ast::MutImmutable)
Expand Down
8 changes: 0 additions & 8 deletions src/librustdoc/html/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ use std::fmt;
/// string when passed to a format string.
pub struct Escape<'a>(pub &'a str);

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

impl<'a> fmt::String for Escape<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
// Because the internet is always right, turns out there's not that many
Expand Down
Loading