From 0bd458d96ede521ed54616fe61fb4a651f72b659 Mon Sep 17 00:00:00 2001 From: Ticki Date: Mon, 21 Dec 2015 22:24:15 +0100 Subject: [PATCH 01/24] Internal documentation and code style --- src/compiler-rt | 2 +- src/librustc/front/map/blocks.rs | 7 ++++- src/librustc/front/map/collector.rs | 4 +++ src/librustc/front/map/definitions.rs | 32 +++++++++++++++++---- src/librustc_back/sha2.rs | 41 +++++++++++++-------------- src/librustc_back/svh.rs | 20 ++++++------- src/llvm | 2 +- 7 files changed, 67 insertions(+), 41 deletions(-) diff --git a/src/compiler-rt b/src/compiler-rt index b6087e82ba138..46081ede32546 160000 --- a/src/compiler-rt +++ b/src/compiler-rt @@ -1 +1 @@ -Subproject commit b6087e82ba1384c4af3adf2dc68e92316f0d4caf +Subproject commit 46081ede32546303dedf23dcb5f4c5ba429582d0 diff --git a/src/librustc/front/map/blocks.rs b/src/librustc/front/map/blocks.rs index 0e24a4446fbe9..a294a8171ee53 100644 --- a/src/librustc/front/map/blocks.rs +++ b/src/librustc/front/map/blocks.rs @@ -130,7 +130,12 @@ struct ClosureParts<'a> { impl<'a> ClosureParts<'a> { fn new(d: &'a FnDecl, b: &'a Block, id: NodeId, s: Span) -> ClosureParts<'a> { - ClosureParts { decl: d, body: b, id: id, span: s } + ClosureParts { + decl: d, + body: b, + id: id, + span: s + } } } diff --git a/src/librustc/front/map/collector.rs b/src/librustc/front/map/collector.rs index e85b0ec77cbbd..1a446a4260834 100644 --- a/src/librustc/front/map/collector.rs +++ b/src/librustc/front/map/collector.rs @@ -22,9 +22,13 @@ use syntax::codemap::Span; /// A Visitor that walks over an AST and collects Node's into an AST /// Map. pub struct NodeCollector<'ast> { + /// The crate pub krate: &'ast Crate, + /// The node map pub map: Vec>, + /// The definitions, used for name resolution pub definitions: Definitions, + /// The parrent of this node pub parent_node: NodeId, } diff --git a/src/librustc/front/map/definitions.rs b/src/librustc/front/map/definitions.rs index e903fcf6a56c2..6e15059748226 100644 --- a/src/librustc/front/map/definitions.rs +++ b/src/librustc/front/map/definitions.rs @@ -16,6 +16,7 @@ use syntax::ast; use syntax::parse::token::InternedString; use util::nodemap::NodeMap; +/// A definition, that defines are #[derive(Clone)] pub struct Definitions { data: Vec, @@ -66,36 +67,53 @@ pub type DefPath = Vec; pub enum DefPathData { // Root: these should only be used for the root nodes, because // they are treated specially by the `def_path` function. + /// The crate root (marker) CrateRoot, + /// An inlined root InlinedRoot(DefPath), // Catch-all for random DefId things like DUMMY_NODE_ID Misc, // Different kinds of items and item-like things: + /// An implementation Impl(ast::Name), + /// A type (struct, enum, etc.) Type(ast::Name), + /// A module declaration Mod(ast::Name), + /// A value Value(ast::Name), + /// A macro rule MacroDef(ast::Name), + /// A closure expression ClosureExpr, // Subportions of items + /// A type parameter (generic parameter) TypeParam(ast::Name), + /// A lifetime definition LifetimeDef(ast::Name), + /// A variant of a enum EnumVariant(ast::Name), + /// A positional field, for example a tuple field PositionalField, + /// A struct field Field(hir::StructFieldKind), - StructCtor, // implicit ctor for a tuple-like struct - Initializer, // initializer for a const - Binding(ast::Name), // pattern binding - - // An external crate that does not have an `extern crate` in this - // crate. + /// Implicit ctor for a tuple-like struct + StructCtor, + /// Initializer for a constant + Initializer, + /// A pattern binding + Binding(ast::Name), + + /// An external crate that does not have an `extern crate` in this + /// crate. DetachedCrate(ast::Name), } impl Definitions { + /// Create new empty definition map pub fn new() -> Definitions { Definitions { data: vec![], @@ -104,6 +122,7 @@ impl Definitions { } } + /// Get the number of definitions pub fn len(&self) -> usize { self.data.len() } @@ -138,6 +157,7 @@ impl Definitions { } } + /// Add a definition with a parrent definition pub fn create_def_with_parent(&mut self, parent: Option, node_id: ast::NodeId, diff --git a/src/librustc_back/sha2.rs b/src/librustc_back/sha2.rs index 840f9abce9363..0a5541b790708 100644 --- a/src/librustc_back/sha2.rs +++ b/src/librustc_back/sha2.rs @@ -25,11 +25,10 @@ fn write_u32_be(dst: &mut[u8], input: u32) { /// Read the value of a vector of bytes as a u32 value in big-endian format. fn read_u32_be(input: &[u8]) -> u32 { - return - (input[0] as u32) << 24 | + (input[0] as u32) << 24 | (input[1] as u32) << 16 | (input[2] as u32) << 8 | - (input[3] as u32); + (input[3] as u32) } /// Read a vector of bytes into a vector of u32s. The values are read in big-endian format. @@ -50,7 +49,7 @@ trait ToBits { impl ToBits for u64 { fn to_bits(self) -> (u64, u64) { - return (self >> 61, self << 3); + (self >> 61, self << 3) } } @@ -64,7 +63,7 @@ fn add_bytes_to_bits(bits: u64, bytes: u64) -> u64 { } match bits.checked_add(new_low_bits) { - Some(x) => return x, + Some(x) => x, None => panic!("numeric overflow occurred.") } } @@ -113,10 +112,10 @@ struct FixedBuffer64 { impl FixedBuffer64 { /// Create a new FixedBuffer64 fn new() -> FixedBuffer64 { - return FixedBuffer64 { + FixedBuffer64 { buffer: [0; 64], buffer_idx: 0 - }; + } } } @@ -175,13 +174,13 @@ impl FixedBuffer for FixedBuffer64 { fn next<'s>(&'s mut self, len: usize) -> &'s mut [u8] { self.buffer_idx += len; - return &mut self.buffer[self.buffer_idx - len..self.buffer_idx]; + &mut self.buffer[self.buffer_idx - len..self.buffer_idx] } fn full_buffer<'s>(&'s mut self) -> &'s [u8] { assert!(self.buffer_idx == 64); self.buffer_idx = 0; - return &self.buffer[..64]; + &self.buffer[..64] } fn position(&self) -> usize { self.buffer_idx } @@ -278,7 +277,7 @@ struct Engine256State { impl Engine256State { fn new(h: &[u32; 8]) -> Engine256State { - return Engine256State { + Engine256State { h0: h[0], h1: h[1], h2: h[2], @@ -287,7 +286,7 @@ impl Engine256State { h5: h[5], h6: h[6], h7: h[7] - }; + } } fn reset(&mut self, h: &[u32; 8]) { @@ -433,7 +432,7 @@ struct Engine256 { impl Engine256 { fn new(h: &[u32; 8]) -> Engine256 { - return Engine256 { + Engine256 { length_bits: 0, buffer: FixedBuffer64::new(), state: Engine256State::new(h), @@ -457,17 +456,15 @@ impl Engine256 { } fn finish(&mut self) { - if self.finished { - return; + if !self.finished { + let self_state = &mut self.state; + self.buffer.standard_padding(8, |input: &[u8]| { self_state.process_block(input) }); + write_u32_be(self.buffer.next(4), (self.length_bits >> 32) as u32 ); + write_u32_be(self.buffer.next(4), self.length_bits as u32); + self_state.process_block(self.buffer.full_buffer()); + + self.finished = true; } - - let self_state = &mut self.state; - self.buffer.standard_padding(8, |input: &[u8]| { self_state.process_block(input) }); - write_u32_be(self.buffer.next(4), (self.length_bits >> 32) as u32 ); - write_u32_be(self.buffer.next(4), self.length_bits as u32); - self_state.process_block(self.buffer.full_buffer()); - - self.finished = true; } } diff --git a/src/librustc_back/svh.rs b/src/librustc_back/svh.rs index 2532882d0127d..c8c20ecbb3126 100644 --- a/src/librustc_back/svh.rs +++ b/src/librustc_back/svh.rs @@ -67,6 +67,15 @@ impl Svh { } pub fn calculate(metadata: &Vec, krate: &hir::Crate) -> Svh { + fn hex(b: u64) -> char { + let b = (b & 0xf) as u8; + let b = match b { + 0 ... 9 => '0' as u8 + b, + _ => 'a' as u8 + b - 10, + }; + b as char + } + // FIXME (#14132): This is better than it used to be, but it still not // ideal. We now attempt to hash only the relevant portions of the // Crate AST as well as the top-level crate attributes. (However, @@ -101,17 +110,8 @@ impl Svh { } let hash = state.finish(); - return Svh { + Svh { hash: (0..64).step_by(4).map(|i| hex(hash >> i)).collect() - }; - - fn hex(b: u64) -> char { - let b = (b & 0xf) as u8; - let b = match b { - 0 ... 9 => '0' as u8 + b, - _ => 'a' as u8 + b - 10, - }; - b as char } } } diff --git a/src/llvm b/src/llvm index 3564439515985..cde1ed3196ba9 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 3564439515985dc1cc0d77057ed00901635a80ad +Subproject commit cde1ed3196ba9b39bcf028e06e08a8722113a5cb From a503c805779639c628895fa6823efda37f7c2465 Mon Sep 17 00:00:00 2001 From: Ticki Date: Mon, 21 Dec 2015 22:45:03 +0100 Subject: [PATCH 02/24] Add help for E0514 --- src/librustc_metadata/creader.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 4420da5f9b87d..1262c2233a393 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -265,6 +265,9 @@ impl<'a> CrateReader<'a> { .as_ref().map(|s|&**s) .unwrap_or("an old version of rustc") ); + + span_help!(self.sess, span, + "consider removing the compiled binaries and recompile"); self.sess.abort_if_errors(); } } From 64aea5090f9968708f3ab9520ac1e088d6e82650 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 08:56:01 +0100 Subject: [PATCH 03/24] Add is_empty() for PathBuf, fix #30259 --- src/libstd/path.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index d0b9cc4c4602f..0036fa581ae2d 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1146,6 +1146,16 @@ impl PathBuf { pub fn into_os_string(self) -> OsString { self.inner } + + /// Checks if the path buffer is empty. On Windows, it will return false if the inner string is + /// invalid unicode. On Unix, this is a no-op. + pub fn is_empty(&self) -> bool { + if let Some(b) = self.inner.to_bytes() { + b.is_empty() + } else { + true + } + } } #[stable(feature = "rust1", since = "1.0.0")] From 92ae54ce149942127149c21ece6f963883d0ba5c Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 09:10:55 +0100 Subject: [PATCH 04/24] Move the is_empty method to Path instead --- src/libstd/lib.rs | 1 + src/libstd/path.rs | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index eba0c799cd2c1..719593ddd383a 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -234,6 +234,7 @@ #![feature(const_fn)] #![feature(core_float)] #![feature(core_intrinsics)] +#![feature(convert)] #![feature(decode_utf16)] #![feature(drop_in_place)] #![feature(dropck_parametricity)] diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 0036fa581ae2d..9c5c68affaf45 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1147,15 +1147,6 @@ impl PathBuf { self.inner } - /// Checks if the path buffer is empty. On Windows, it will return false if the inner string is - /// invalid unicode. On Unix, this is a no-op. - pub fn is_empty(&self) -> bool { - if let Some(b) = self.inner.to_bytes() { - b.is_empty() - } else { - true - } - } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1869,6 +1860,17 @@ impl Path { pub fn is_dir(&self) -> bool { fs::metadata(self).map(|m| m.is_dir()).unwrap_or(false) } + + /// Checks if the path buffer is empty. On Windows, it will return false if the inner string is + /// invalid unicode. On Unix, this is a no-op. + #[unstable(feature = "path_extras", reason = "recently added", issue = "30259")] + pub fn is_empty(&self) -> bool { + if let Some(b) = self.inner.to_bytes() { + b.is_empty() + } else { + true + } + } } #[stable(feature = "rust1", since = "1.0.0")] From 3324a14ae96e88c7c5e0db16628603c7a3664bbf Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 09:22:28 +0100 Subject: [PATCH 05/24] Tests --- src/libstd/path.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 9c5c68affaf45..db726723f53a7 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1863,6 +1863,16 @@ impl Path { /// Checks if the path buffer is empty. On Windows, it will return false if the inner string is /// invalid unicode. On Unix, this is a no-op. + /// + /// # Examples + /// + /// ``` + /// use std::path::Path; + /// + /// let path = Path::new("/tmp/foo.rs"); + /// + /// assert!(!path.is_empty()); + /// ``` #[unstable(feature = "path_extras", reason = "recently added", issue = "30259")] pub fn is_empty(&self) -> bool { if let Some(b) = self.inner.to_bytes() { @@ -3200,6 +3210,17 @@ mod tests { } } + #[test] + pub fn is_empty() { + let path = Path::new("/tmp/foo.rs"); + let mut path_buf = PathBuf::new(); + + assert!(!path.is_empty()); + assert!(path_buf.is_empty()); + path_buf.push("catsarecute"); + assert!(!path_buf.is_empty()); + } + #[test] pub fn test_set_extension() { macro_rules! tfe( From 99ee08742cfee883ee7d147c90f053720c52a089 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 10:39:59 +0100 Subject: [PATCH 06/24] Overide methods in iterator implementation for EscapeDefault, see #24214 --- src/libcore/char.rs | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/libcore/char.rs b/src/libcore/char.rs index c02704217a8de..d70f080e9bab7 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -537,4 +537,56 @@ impl Iterator for EscapeDefault { EscapeDefaultState::Done => (0, Some(0)), } } + + fn count(self) -> usize { + match self.state { + EscapeDefaultState::Char(_) => 1, + EscapeDefaultState::Unicode(iter) => iter.count(), + EscapeDefaultState::Done => 0, + EscapeDefaultState::Backslash(_) => 2, + } + } + + fn nth(&mut self, n: usize) -> Option { + let ch = match self.state { + EscapeDefaultState::Backslash(c) => c, + EscapeDefaultState::Char(c) => c, + EscapeDefaultState::Done => return None, + EscapeDefaultState::Unicode(ref mut i) => return iter.nth(n), + }; + + let start = self.get_offset(); + let idx = start + n; + + // Update state + self.state = match idx { + 0 => EscapeDefaultState::Char(c), + _ => EscapeDefaultState::Done, + }; + + match idx { + 0 => Some('\\'), + 1 => Some(c), + _ => None, + } + } + + fn last(self) -> Option { + match self.state { + EscapeDefaultState::Unicode(iter) => iter.last(), + EscapeDefaultState::Done => None, + EscapeDefaultState::Backslash(c) | EscapeDefaultState::Char(c) => Some(c), + } + } +} + +impl EscapeDefault { + fn get_offset(&self) -> Option { + match self.state { + EscapeDefaultState::Backslash(c) => Some(0), + EscapeDefaultState::Char(c) => Some(1), + EscapeDefaultState::Done => None, + EscapeDefaultState::Unicode(ref mut iter) => None, + } + } } From 0435a4636181221d705f7c71011d7718c839dc8c Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 11:14:14 +0100 Subject: [PATCH 07/24] Fix style nitpicks from travis Remove tabs --- src/jemalloc | 2 +- src/libcore/char.rs | 4 ++-- src/librustc/front/map/definitions.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jemalloc b/src/jemalloc index f84e30927284b..e24a1a025a1f2 160000 --- a/src/jemalloc +++ b/src/jemalloc @@ -1 +1 @@ -Subproject commit f84e30927284b0c500ed3eaf09e8e159da20ddaf +Subproject commit e24a1a025a1f214e40eedafe3b9c7b1d69937922 diff --git a/src/libcore/char.rs b/src/libcore/char.rs index d70f080e9bab7..cf70de7788e48 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -538,8 +538,8 @@ impl Iterator for EscapeDefault { } } - fn count(self) -> usize { - match self.state { + fn count(self) -> usize { + match self.state { EscapeDefaultState::Char(_) => 1, EscapeDefaultState::Unicode(iter) => iter.count(), EscapeDefaultState::Done => 0, diff --git a/src/librustc/front/map/definitions.rs b/src/librustc/front/map/definitions.rs index 6e15059748226..4ca6eb22ff552 100644 --- a/src/librustc/front/map/definitions.rs +++ b/src/librustc/front/map/definitions.rs @@ -16,7 +16,7 @@ use syntax::ast; use syntax::parse::token::InternedString; use util::nodemap::NodeMap; -/// A definition, that defines are +/// A definition #[derive(Clone)] pub struct Definitions { data: Vec, @@ -101,7 +101,7 @@ pub enum DefPathData { /// A struct field Field(hir::StructFieldKind), /// Implicit ctor for a tuple-like struct - StructCtor, + StructCtor, /// Initializer for a constant Initializer, /// A pattern binding From ba511f2282160581ded95e97b59f0147e8b562e1 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 18 Dec 2015 14:23:01 +0100 Subject: [PATCH 08/24] Stop re-exporting the ast::BindingMode variants. --- src/librustc_front/lowering.rs | 4 ++-- src/librustc_trans/save/mod.rs | 4 ++-- src/libsyntax/ast.rs | 7 +++---- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/ext/build.rs | 6 +++--- src/libsyntax/parse/mod.rs | 4 ++-- src/libsyntax/parse/parser.rs | 16 ++++++++-------- src/libsyntax/print/pprust.rs | 8 ++++---- src/libsyntax_ext/deriving/generic/mod.rs | 2 +- 9 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index afd834a61d6ce..f99cdd39da2a8 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -1571,8 +1571,8 @@ pub fn lower_block_check_mode(lctx: &LoweringContext, b: &BlockCheckMode) -> hir pub fn lower_binding_mode(lctx: &LoweringContext, b: &BindingMode) -> hir::BindingMode { match *b { - BindByRef(m) => hir::BindByRef(lower_mutability(lctx, m)), - BindByValue(m) => hir::BindByValue(lower_mutability(lctx, m)), + BindingMode::ByRef(m) => hir::BindByRef(lower_mutability(lctx, m)), + BindingMode::ByValue(m) => hir::BindByValue(lower_mutability(lctx, m)), } } diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index cc5322d7f9f46..501ab566f1c5a 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -697,8 +697,8 @@ impl<'v> Visitor<'v> for PathCollector { // Even if the ref is mut, you can't change the ref, only // the data pointed at, so showing the initialising expression // is still worthwhile. - ast::BindByRef(_) => ast::MutImmutable, - ast::BindByValue(mt) => mt, + ast::BindingMode::ByRef(_) => ast::MutImmutable, + ast::BindingMode::ByValue(mt) => mt, }; // collect path for either visit_local or visit_arm let path = ast_util::ident_to_path(path1.span, path1.node); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index abc44407eff73..0ad655ce00bb9 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,7 +10,6 @@ // The Rust abstract syntax tree. -pub use self::BindingMode::*; pub use self::BinOp_::*; pub use self::BlockCheckMode::*; pub use self::CaptureClause::*; @@ -574,8 +573,8 @@ pub struct FieldPat { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum BindingMode { - BindByRef(Mutability), - BindByValue(Mutability), + ByRef(Mutability), + ByValue(Mutability), } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] @@ -1655,7 +1654,7 @@ impl Arg { }), pat: P(Pat { id: DUMMY_NODE_ID, - node: PatIdent(BindByValue(mutability), path, None), + node: PatIdent(BindingMode::ByValue(mutability), path, None), span: span }), id: DUMMY_NODE_ID diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index d38b771814c28..70561b1eb551d 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -68,7 +68,7 @@ pub fn path_to_ident(path: &Path) -> Option { pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P { P(Pat { id: id, - node: PatIdent(BindByValue(MutImmutable), codemap::Spanned{span:s, node:i}, None), + node: PatIdent(BindingMode::ByValue(MutImmutable), codemap::Spanned{span:s, node:i}, None), span: s }) } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 46a39b98058a2..8c19a10b4b147 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -513,7 +513,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, ex: P) -> P { let pat = if mutbl { - self.pat_ident_binding_mode(sp, ident, ast::BindByValue(ast::MutMutable)) + self.pat_ident_binding_mode(sp, ident, ast::BindingMode::ByValue(ast::MutMutable)) } else { self.pat_ident(sp, ident) }; @@ -537,7 +537,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ex: P) -> P { let pat = if mutbl { - self.pat_ident_binding_mode(sp, ident, ast::BindByValue(ast::MutMutable)) + self.pat_ident_binding_mode(sp, ident, ast::BindingMode::ByValue(ast::MutMutable)) } else { self.pat_ident(sp, ident) }; @@ -808,7 +808,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.pat(span, ast::PatLit(expr)) } fn pat_ident(&self, span: Span, ident: ast::Ident) -> P { - self.pat_ident_binding_mode(span, ident, ast::BindByValue(ast::MutImmutable)) + self.pat_ident_binding_mode(span, ident, ast::BindingMode::ByValue(ast::MutImmutable)) } fn pat_ident_binding_mode(&self, diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index cff106f838af2..6951d6319acaf 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -892,7 +892,7 @@ mod tests { assert!(panictry!(parser.parse_pat()) == P(ast::Pat{ id: ast::DUMMY_NODE_ID, - node: ast::PatIdent(ast::BindByValue(ast::MutImmutable), + node: ast::PatIdent(ast::BindingMode::ByValue(ast::MutImmutable), Spanned{ span:sp(0, 1), node: str_to_ident("b") }, @@ -928,7 +928,7 @@ mod tests { pat: P(ast::Pat { id: ast::DUMMY_NODE_ID, node: ast::PatIdent( - ast::BindByValue(ast::MutImmutable), + ast::BindingMode::ByValue(ast::MutImmutable), Spanned{ span: sp(6,7), node: str_to_ident("b")}, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b625277f2a772..dbd34b49f7d9e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -14,7 +14,7 @@ use abi; use ast::BareFnTy; use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::{Public, Unsafety}; -use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; +use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindingMode}; use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, BiLt, Block}; use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause}; use ast::{Constness, ConstTraitItem, Crate, CrateConfig}; @@ -3278,10 +3278,10 @@ impl<'a> Parser<'a> { hi = self.last_span.hi; let bind_type = match (is_ref, is_mut) { - (true, true) => BindByRef(MutMutable), - (true, false) => BindByRef(MutImmutable), - (false, true) => BindByValue(MutMutable), - (false, false) => BindByValue(MutImmutable), + (true, true) => BindingMode::ByRef(MutMutable), + (true, false) => BindingMode::ByRef(MutImmutable), + (false, true) => BindingMode::ByValue(MutMutable), + (false, false) => BindingMode::ByValue(MutImmutable), }; let fieldpath = codemap::Spanned{span:self.last_span, node:fieldname}; let fieldpat = P(ast::Pat{ @@ -3376,11 +3376,11 @@ impl<'a> Parser<'a> { // At this point, token != _, &, &&, (, [ if try!(self.eat_keyword(keywords::Mut)) { // Parse mut ident @ pat - pat = try!(self.parse_pat_ident(BindByValue(MutMutable))); + pat = try!(self.parse_pat_ident(BindingMode::ByValue(MutMutable))); } else if try!(self.eat_keyword(keywords::Ref)) { // Parse ref ident @ pat / ref mut ident @ pat let mutbl = try!(self.parse_mutability()); - pat = try!(self.parse_pat_ident(BindByRef(mutbl))); + pat = try!(self.parse_pat_ident(BindingMode::ByRef(mutbl))); } else if try!(self.eat_keyword(keywords::Box)) { // Parse box pat let subpat = try!(self.parse_pat()); @@ -3409,7 +3409,7 @@ impl<'a> Parser<'a> { // Parse ident @ pat // This can give false positives and parse nullary enums, // they are dealt with later in resolve - pat = try!(self.parse_pat_ident(BindByValue(MutImmutable))); + pat = try!(self.parse_pat_ident(BindingMode::ByValue(MutImmutable))); } } else { let (qself, path) = if try!(self.eat_lt()) { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ff01f0ac67e41..347b9f4574782 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2471,12 +2471,12 @@ impl<'a> State<'a> { ast::PatWild => try!(word(&mut self.s, "_")), ast::PatIdent(binding_mode, ref path1, ref sub) => { match binding_mode { - ast::BindByRef(mutbl) => { + ast::BindingMode::ByRef(mutbl) => { try!(self.word_nbsp("ref")); try!(self.print_mutability(mutbl)); } - ast::BindByValue(ast::MutImmutable) => {} - ast::BindByValue(ast::MutMutable) => { + ast::BindingMode::ByValue(ast::MutImmutable) => {} + ast::BindingMode::ByValue(ast::MutMutable) => { try!(self.word_nbsp("mut")); } } @@ -2682,7 +2682,7 @@ impl<'a> State<'a> { let m = match *explicit_self { ast::SelfStatic => ast::MutImmutable, _ => match decl.inputs[0].pat.node { - ast::PatIdent(ast::BindByValue(m), _, _) => m, + ast::PatIdent(ast::BindingMode::ByValue(m), _, _) => m, _ => ast::MutImmutable } }; diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 8f316649421a6..3af701739b431 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -1470,7 +1470,7 @@ impl<'a> TraitDef<'a> { -> Vec> { field_paths.iter().map(|path| { cx.pat(path.span, - ast::PatIdent(ast::BindByRef(mutbl), (*path).clone(), None)) + ast::PatIdent(ast::BindingMode::ByRef(mutbl), (*path).clone(), None)) }).collect() } From 7e487b4581646ed7bc0154b8c8d3c7fb30d49120 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 11 Dec 2015 13:07:11 -0800 Subject: [PATCH 09/24] Register new snapshots Lots of cruft to remove! --- mk/main.mk | 6 +- src/liballoc/arc.rs | 6 - src/liballoc/lib.rs | 19 +-- src/liballoc/rc.rs | 6 - src/liballoc_jemalloc/lib.rs | 6 +- src/liballoc_system/lib.rs | 6 +- src/libarena/lib.rs | 8 - src/libcollections/lib.rs | 20 +-- src/libcore/intrinsics.rs | 132 --------------- src/libcore/lib.rs | 8 +- src/libcore/nonzero.rs | 30 +--- src/libcore/num/bignum.rs | 9 - src/libcore/num/mod.rs | 161 ------------------ src/libcore/num/wrapping.rs | 181 +-------------------- src/libcore/ops.rs | 73 --------- src/libcore/ptr.rs | 26 +-- src/libflate/lib.rs | 4 - src/libfmt_macros/lib.rs | 3 - src/libgetopts/lib.rs | 4 - src/libgraphviz/lib.rs | 3 - src/liblog/lib.rs | 3 - src/librand/lib.rs | 4 - src/librbml/lib.rs | 3 - src/librustc/lib.rs | 3 - src/librustc/middle/expr_use_visitor.rs | 2 - src/librustc/util/common.rs | 1 - src/librustc_back/lib.rs | 3 - src/librustc_bitflags/lib.rs | 4 - src/librustc_borrowck/lib.rs | 3 - src/librustc_data_structures/lib.rs | 3 - src/librustc_driver/lib.rs | 30 +--- src/librustc_front/lib.rs | 3 - src/librustc_lint/lib.rs | 3 - src/librustc_llvm/lib.rs | 5 - src/librustc_metadata/lib.rs | 2 - src/librustc_platform_intrinsics/lib.rs | 2 - src/librustc_plugin/lib.rs | 2 - src/librustc_privacy/lib.rs | 3 - src/librustc_resolve/lib.rs | 3 - src/librustc_trans/lib.rs | 3 - src/librustc_typeck/lib.rs | 4 +- src/librustc_unicode/lib.rs | 6 - src/librustdoc/core.rs | 4 +- src/librustdoc/lib.rs | 9 +- src/librustdoc/test.rs | 6 +- src/libserialize/lib.rs | 3 - src/libstd/lib.rs | 9 - src/libstd/rand/os.rs | 2 - src/libstd/sys/common/libunwind.rs | 2 - src/libstd/sys/common/unwind/mod.rs | 12 +- src/libstd/sys/windows/c.rs | 2 +- src/libsyntax/lib.rs | 5 - src/libsyntax_ext/lib.rs | 2 - src/libterm/lib.rs | 3 - src/libtest/lib.rs | 3 - src/rtstartup/rsbegin.rs | 2 - src/rtstartup/rsend.rs | 2 - src/snapshots.txt | 8 + src/test/run-make/execution-engine/test.rs | 3 +- src/test/run-make/issue-19371/foo.rs | 3 +- 60 files changed, 45 insertions(+), 841 deletions(-) diff --git a/mk/main.mk b/mk/main.mk index 110bf0408d63c..2de18c9871a8d 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -131,11 +131,7 @@ endif ifdef CFG_ENABLE_DEBUGINFO $(info cfg: enabling debuginfo (CFG_ENABLE_DEBUGINFO)) - # FIXME: Re-enable -g in stage0 after new snapshot - #CFG_RUSTC_FLAGS += -g - RUSTFLAGS_STAGE1 += -g - RUSTFLAGS_STAGE2 += -g - RUSTFLAGS_STAGE3 += -g + CFG_RUSTC_FLAGS += -g endif ifdef SAVE_TEMPS diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 9479d47943eab..755e44899fc86 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -80,10 +80,8 @@ use core::mem::{align_of_val, size_of_val}; use core::intrinsics::abort; use core::mem; use core::ops::Deref; -#[cfg(not(stage0))] use core::ops::CoerceUnsized; use core::ptr::{self, Shared}; -#[cfg(not(stage0))] use core::marker::Unsize; use core::hash::{Hash, Hasher}; use core::{usize, isize}; @@ -135,8 +133,6 @@ unsafe impl Send for Arc {} #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Sync for Arc {} -// remove cfg after new snapshot -#[cfg(not(stage0))] #[unstable(feature = "coerce_unsized", issue = "27732")] impl, U: ?Sized> CoerceUnsized> for Arc {} @@ -157,8 +153,6 @@ unsafe impl Send for Weak {} #[stable(feature = "rust1", since = "1.0.0")] unsafe impl Sync for Weak {} -// remove cfg after new snapshot -#[cfg(not(stage0))] #[unstable(feature = "coerce_unsized", issue = "27732")] impl, U: ?Sized> CoerceUnsized> for Weak {} diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index f665b1e19241c..93b84cdedd4cd 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -56,11 +56,8 @@ //! The [`heap`](heap/index.html) module defines the low-level interface to the //! default global allocator. It is not compatible with the libc allocator API. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "alloc"] #![crate_type = "rlib"] -#![cfg_attr(stage0, staged_api)] #![allow(unused_attributes)] #![unstable(feature = "alloc", reason = "this library is unlikely to be stabilized in its current \ @@ -72,11 +69,8 @@ issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/", test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] #![no_std] -#![cfg_attr(not(stage0), needs_allocator)] +#![needs_allocator] -#![cfg_attr(stage0, feature(rustc_attrs))] -#![cfg_attr(stage0, feature(no_std))] -#![cfg_attr(stage0, allow(unused_attributes))] #![feature(allocator)] #![feature(box_syntax)] #![feature(coerce_unsized)] @@ -84,7 +78,6 @@ #![feature(custom_attribute)] #![feature(fundamental)] #![feature(lang_items)] -#![feature(nonzero)] #![feature(num_bits_bytes)] #![feature(optin_builtin_traits)] #![feature(placement_in_syntax)] @@ -95,23 +88,15 @@ #![feature(unboxed_closures)] #![feature(unique)] #![feature(unsafe_no_drop_flag, filling_drop)] -// SNAP 1af31d4 -#![allow(unused_features)] -// SNAP 1af31d4 -#![allow(unused_attributes)] #![feature(dropck_parametricity)] #![feature(unsize)] #![feature(drop_in_place)] #![feature(fn_traits)] -#![cfg_attr(stage0, feature(alloc_system))] -#![cfg_attr(not(stage0), feature(needs_allocator))] +#![feature(needs_allocator)] #![cfg_attr(test, feature(test, rustc_private, box_heap))] -#[cfg(stage0)] -extern crate alloc_system; - // Allow testing this library #[cfg(test)] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 8f00605d33b37..52f035b67bdc9 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -162,11 +162,9 @@ use core::fmt; use core::hash::{Hasher, Hash}; use core::intrinsics::{assume, abort}; use core::marker; -#[cfg(not(stage0))] use core::marker::Unsize; use core::mem::{self, align_of_val, size_of_val, forget}; use core::ops::Deref; -#[cfg(not(stage0))] use core::ops::CoerceUnsized; use core::ptr::{self, Shared}; use core::convert::From; @@ -196,8 +194,6 @@ impl !marker::Send for Rc {} #[stable(feature = "rust1", since = "1.0.0")] impl !marker::Sync for Rc {} -// remove cfg after new snapshot -#[cfg(not(stage0))] #[unstable(feature = "coerce_unsized", issue = "27732")] impl, U: ?Sized> CoerceUnsized> for Rc {} @@ -723,8 +719,6 @@ impl !marker::Send for Weak {} #[stable(feature = "rust1", since = "1.0.0")] impl !marker::Sync for Weak {} -// remove cfg after new snapshot -#[cfg(not(stage0))] #[unstable(feature = "coerce_unsized", issue = "27732")] impl, U: ?Sized> CoerceUnsized> for Weak {} diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index ec6c6ae31c17e..413eac3cf7942 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -8,13 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "alloc_jemalloc"] #![crate_type = "rlib"] -#![cfg_attr(stage0, staged_api)] #![no_std] -#![cfg_attr(not(stage0), allocator)] -#![cfg_attr(stage0, allow(improper_ctypes))] +#![allocator] #![unstable(feature = "alloc_jemalloc", reason = "this library is unlikely to be stabilized in its current \ form or name", @@ -22,7 +19,6 @@ #![feature(allocator)] #![feature(libc)] #![feature(staged_api)] -#![cfg_attr(stage0, feature(no_std))] extern crate libc; diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index a6e89d5d00cb8..fccc024603ebd 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -8,13 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "alloc_system"] #![crate_type = "rlib"] -#![cfg_attr(stage0, staged_api)] #![no_std] -#![cfg_attr(not(stage0), allocator)] -#![cfg_attr(stage0, allow(improper_ctypes))] +#![allocator] #![unstable(feature = "alloc_system", reason = "this library is unlikely to be stabilized in its current \ form or name", @@ -22,7 +19,6 @@ #![feature(allocator)] #![feature(libc)] #![feature(staged_api)] -#![cfg_attr(stage0, feature(no_std))] extern crate libc; diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 7871135e9c214..b5107e411e851 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -19,11 +19,8 @@ //! arena but can only hold objects of a single type, and `Arena`, which is a //! more complex, slower arena which can hold objects of any type. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "arena"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -42,11 +39,6 @@ #![feature(dropck_parametricity)] #![cfg_attr(test, feature(test))] -// SNAP 1af31d4 -#![allow(unused_features)] -// SNAP 1af31d4 -#![allow(unused_attributes)] - extern crate alloc; use std::cell::{Cell, RefCell}; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index a7797d4b0d047..000ec4f0f6610 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -13,10 +13,7 @@ //! See [std::collections](../std/collections) for a detailed discussion of //! collections in Rust. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "collections"] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![unstable(feature = "collections", reason = "library is unlikely to be stabilized with the current \ @@ -32,17 +29,14 @@ #![allow(trivial_casts)] #![cfg_attr(test, allow(deprecated))] // rand -// SNAP 1af31d4 -#![allow(unused_features)] -// SNAP 1af31d4 -#![allow(unused_attributes)] - -#![cfg_attr(stage0, feature(rustc_attrs))] -#![cfg_attr(stage0, allow(unused_attributes))] #![feature(alloc)] #![feature(box_patterns)] #![feature(box_syntax)] +#![feature(clone_from_slice)] #![feature(core_intrinsics)] +#![feature(decode_utf16)] +#![feature(drop_in_place)] +#![feature(dropck_parametricity)] #![feature(fmt_internals)] #![feature(fmt_radix)] #![feature(heap_api)] @@ -53,7 +47,6 @@ #![feature(oom)] #![feature(pattern)] #![feature(ptr_as_ref)] -#![feature(ref_slice)] #![feature(slice_bytes)] #![feature(slice_patterns)] #![feature(staged_api)] @@ -62,14 +55,9 @@ #![feature(unboxed_closures)] #![feature(unicode)] #![feature(unique)] -#![feature(dropck_parametricity)] #![feature(unsafe_no_drop_flag, filling_drop)] -#![feature(decode_utf16)] -#![feature(drop_in_place)] -#![feature(clone_from_slice)] #![cfg_attr(test, feature(clone_from_slice, rand, test))] -#![cfg_attr(stage0, feature(no_std))] #![no_std] extern crate rustc_unicode; diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index a094bcd0192d2..568c4e143e04b 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -512,164 +512,32 @@ extern "rust-intrinsic" { /// Returns the nearest integer to an `f64`. Rounds half-way cases away from zero. pub fn roundf64(x: f64) -> f64; - /// Returns the number of bits set in a `u8`. - #[cfg(stage0)] - pub fn ctpop8(x: u8) -> u8; - /// Returns the number of bits set in a `u16`. - #[cfg(stage0)] - pub fn ctpop16(x: u16) -> u16; - /// Returns the number of bits set in a `u32`. - #[cfg(stage0)] - pub fn ctpop32(x: u32) -> u32; - /// Returns the number of bits set in a `u64`. - #[cfg(stage0)] - pub fn ctpop64(x: u64) -> u64; /// Returns the number of bits set in an integer type `T` - #[cfg(not(stage0))] pub fn ctpop(x: T) -> T; - /// Returns the number of leading bits unset in a `u8`. - #[cfg(stage0)] - pub fn ctlz8(x: u8) -> u8; - /// Returns the number of leading bits unset in a `u16`. - #[cfg(stage0)] - pub fn ctlz16(x: u16) -> u16; - /// Returns the number of leading bits unset in a `u32`. - #[cfg(stage0)] - pub fn ctlz32(x: u32) -> u32; - /// Returns the number of leading bits unset in a `u64`. - #[cfg(stage0)] - pub fn ctlz64(x: u64) -> u64; /// Returns the number of leading bits unset in an integer type `T` - #[cfg(not(stage0))] pub fn ctlz(x: T) -> T; - /// Returns the number of trailing bits unset in a `u8`. - #[cfg(stage0)] - pub fn cttz8(x: u8) -> u8; - /// Returns the number of trailing bits unset in a `u16`. - #[cfg(stage0)] - pub fn cttz16(x: u16) -> u16; - /// Returns the number of trailing bits unset in a `u32`. - #[cfg(stage0)] - pub fn cttz32(x: u32) -> u32; - /// Returns the number of trailing bits unset in a `u64`. - #[cfg(stage0)] - pub fn cttz64(x: u64) -> u64; /// Returns the number of trailing bits unset in an integer type `T` - #[cfg(not(stage0))] pub fn cttz(x: T) -> T; - /// Reverses the bytes in a `u16`. - #[cfg(stage0)] - pub fn bswap16(x: u16) -> u16; - /// Reverses the bytes in a `u32`. - #[cfg(stage0)] - pub fn bswap32(x: u32) -> u32; - /// Reverses the bytes in a `u64`. - #[cfg(stage0)] - pub fn bswap64(x: u64) -> u64; /// Reverses the bytes in an integer type `T`. - #[cfg(not(stage0))] pub fn bswap(x: T) -> T; - /// Performs checked `i8` addition. - #[cfg(stage0)] - pub fn i8_add_with_overflow(x: i8, y: i8) -> (i8, bool); - /// Performs checked `i16` addition. - #[cfg(stage0)] - pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool); - /// Performs checked `i32` addition. - #[cfg(stage0)] - pub fn i32_add_with_overflow(x: i32, y: i32) -> (i32, bool); - /// Performs checked `i64` addition. - #[cfg(stage0)] - pub fn i64_add_with_overflow(x: i64, y: i64) -> (i64, bool); - - /// Performs checked `u8` addition. - #[cfg(stage0)] - pub fn u8_add_with_overflow(x: u8, y: u8) -> (u8, bool); - /// Performs checked `u16` addition. - #[cfg(stage0)] - pub fn u16_add_with_overflow(x: u16, y: u16) -> (u16, bool); - /// Performs checked `u32` addition. - #[cfg(stage0)] - pub fn u32_add_with_overflow(x: u32, y: u32) -> (u32, bool); - /// Performs checked `u64` addition. - #[cfg(stage0)] - pub fn u64_add_with_overflow(x: u64, y: u64) -> (u64, bool); - /// Performs checked integer addition. - #[cfg(not(stage0))] pub fn add_with_overflow(x: T, y: T) -> (T, bool); - /// Performs checked `i8` subtraction. - #[cfg(stage0)] - pub fn i8_sub_with_overflow(x: i8, y: i8) -> (i8, bool); - /// Performs checked `i16` subtraction. - #[cfg(stage0)] - pub fn i16_sub_with_overflow(x: i16, y: i16) -> (i16, bool); - /// Performs checked `i32` subtraction. - #[cfg(stage0)] - pub fn i32_sub_with_overflow(x: i32, y: i32) -> (i32, bool); - /// Performs checked `i64` subtraction. - #[cfg(stage0)] - pub fn i64_sub_with_overflow(x: i64, y: i64) -> (i64, bool); - - /// Performs checked `u8` subtraction. - #[cfg(stage0)] - pub fn u8_sub_with_overflow(x: u8, y: u8) -> (u8, bool); - /// Performs checked `u16` subtraction. - #[cfg(stage0)] - pub fn u16_sub_with_overflow(x: u16, y: u16) -> (u16, bool); - /// Performs checked `u32` subtraction. - #[cfg(stage0)] - pub fn u32_sub_with_overflow(x: u32, y: u32) -> (u32, bool); - /// Performs checked `u64` subtraction. - #[cfg(stage0)] - pub fn u64_sub_with_overflow(x: u64, y: u64) -> (u64, bool); - /// Performs checked integer subtraction - #[cfg(not(stage0))] pub fn sub_with_overflow(x: T, y: T) -> (T, bool); - /// Performs checked `i8` multiplication. - #[cfg(stage0)] - pub fn i8_mul_with_overflow(x: i8, y: i8) -> (i8, bool); - /// Performs checked `i16` multiplication. - #[cfg(stage0)] - pub fn i16_mul_with_overflow(x: i16, y: i16) -> (i16, bool); - /// Performs checked `i32` multiplication. - #[cfg(stage0)] - pub fn i32_mul_with_overflow(x: i32, y: i32) -> (i32, bool); - /// Performs checked `i64` multiplication. - #[cfg(stage0)] - pub fn i64_mul_with_overflow(x: i64, y: i64) -> (i64, bool); - - /// Performs checked `u8` multiplication. - #[cfg(stage0)] - pub fn u8_mul_with_overflow(x: u8, y: u8) -> (u8, bool); - /// Performs checked `u16` multiplication. - #[cfg(stage0)] - pub fn u16_mul_with_overflow(x: u16, y: u16) -> (u16, bool); - /// Performs checked `u32` multiplication. - #[cfg(stage0)] - pub fn u32_mul_with_overflow(x: u32, y: u32) -> (u32, bool); - /// Performs checked `u64` multiplication. - #[cfg(stage0)] - pub fn u64_mul_with_overflow(x: u64, y: u64) -> (u64, bool); - /// Performs checked integer multiplication - #[cfg(not(stage0))] pub fn mul_with_overflow(x: T, y: T) -> (T, bool); /// Performs an unchecked division, resulting in undefined behavior /// where y = 0 or x = `T::min_value()` and y = -1 - #[cfg(not(stage0))] pub fn unchecked_div(x: T, y: T) -> T; /// Returns the remainder of an unchecked division, resulting in /// undefined behavior where y = 0 or x = `T::min_value()` and y = -1 - #[cfg(not(stage0))] pub fn unchecked_rem(x: T, y: T) -> T; /// Returns (a + b) mod 2^N, where N is the width of T in bits. diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index cde86230d7509..e8803976937d2 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -43,11 +43,8 @@ // Since libcore defines many fundamental lang items, all tests live in a // separate crate, libcoretest, to avoid bizarre issues. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "core"] #![stable(feature = "core", since = "1.6.0")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", @@ -60,8 +57,6 @@ #![no_core] #![deny(missing_docs)] -#![cfg_attr(stage0, feature(rustc_attrs))] -#![cfg_attr(stage0, allow(unused_attributes))] #![feature(allow_internal_unstable)] #![feature(associated_type_defaults)] #![feature(concat_idents)] @@ -75,8 +70,7 @@ #![feature(optin_builtin_traits)] #![feature(reflect)] #![feature(unwind_attributes)] -#![cfg_attr(stage0, feature(simd))] -#![cfg_attr(not(stage0), feature(repr_simd, platform_intrinsics))] +#![feature(repr_simd, platform_intrinsics)] #![feature(staged_api)] #![feature(unboxed_closures)] diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs index c4ca3fa384e96..92bbc4efb7cc1 100644 --- a/src/libcore/nonzero.rs +++ b/src/libcore/nonzero.rs @@ -38,31 +38,13 @@ unsafe impl Zeroable for u64 {} #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] pub struct NonZero(T); -#[cfg(stage0)] -macro_rules! nonzero_new { - () => ( - /// Creates an instance of NonZero with the provided value. - /// You must indeed ensure that the value is actually "non-zero". - #[inline(always)] - pub unsafe fn new(inner: T) -> NonZero { - NonZero(inner) - } - ) -} -#[cfg(not(stage0))] -macro_rules! nonzero_new { - () => ( - /// Creates an instance of NonZero with the provided value. - /// You must indeed ensure that the value is actually "non-zero". - #[inline(always)] - pub const unsafe fn new(inner: T) -> NonZero { - NonZero(inner) - } - ) -} - impl NonZero { - nonzero_new!{} + /// Creates an instance of NonZero with the provided value. + /// You must indeed ensure that the value is actually "non-zero". + #[inline(always)] + pub const unsafe fn new(inner: T) -> NonZero { + NonZero(inner) + } } impl Deref for NonZero { diff --git a/src/libcore/num/bignum.rs b/src/libcore/num/bignum.rs index 5d15ada4e7509..66c6deb361564 100644 --- a/src/libcore/num/bignum.rs +++ b/src/libcore/num/bignum.rs @@ -55,15 +55,6 @@ macro_rules! impl_full_ops { ($($ty:ty: add($addfn:path), mul/div($bigty:ident);)*) => ( $( impl FullOps for $ty { - #[cfg(stage0)] - fn full_add(self, other: $ty, carry: bool) -> (bool, $ty) { - // this cannot overflow, the output is between 0 and 2*2^nbits - 1 - // FIXME will LLVM optimize this into ADC or similar??? - let (v, carry1) = unsafe { $addfn(self, other) }; - let (v, carry2) = unsafe { $addfn(v, if carry {1} else {0}) }; - (carry1 || carry2, v) - } - #[cfg(not(stage0))] fn full_add(self, other: $ty, carry: bool) -> (bool, $ty) { // this cannot overflow, the output is between 0 and 2*2^nbits - 1 // FIXME will LLVM optimize this into ADC or similar??? diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 8abb12706a5e3..f180a513b869d 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -115,11 +115,6 @@ macro_rules! zero_one_impl_float { } zero_one_impl_float! { f32 f64 } -// Just for stage0; a byte swap on a byte is a no-op -// Delete this once it becomes unused -#[cfg(stage0)] -unsafe fn bswap8(x: u8) -> u8 { x } - macro_rules! checked_op { ($U:ty, $op:path, $x:expr, $y:expr) => {{ let (result, overflowed) = unsafe { $op($x as $U, $y as $U) }; @@ -785,15 +780,6 @@ macro_rules! int_impl { } #[lang = "i8"] -#[cfg(stage0)] -impl i8 { - int_impl! { i8, u8, 8, - intrinsics::i8_add_with_overflow, - intrinsics::i8_sub_with_overflow, - intrinsics::i8_mul_with_overflow } -} -#[lang = "i8"] -#[cfg(not(stage0))] impl i8 { int_impl! { i8, u8, 8, intrinsics::add_with_overflow, @@ -802,15 +788,6 @@ impl i8 { } #[lang = "i16"] -#[cfg(stage0)] -impl i16 { - int_impl! { i16, u16, 16, - intrinsics::i16_add_with_overflow, - intrinsics::i16_sub_with_overflow, - intrinsics::i16_mul_with_overflow } -} -#[lang = "i16"] -#[cfg(not(stage0))] impl i16 { int_impl! { i16, u16, 16, intrinsics::add_with_overflow, @@ -819,15 +796,6 @@ impl i16 { } #[lang = "i32"] -#[cfg(stage0)] -impl i32 { - int_impl! { i32, u32, 32, - intrinsics::i32_add_with_overflow, - intrinsics::i32_sub_with_overflow, - intrinsics::i32_mul_with_overflow } -} -#[lang = "i32"] -#[cfg(not(stage0))] impl i32 { int_impl! { i32, u32, 32, intrinsics::add_with_overflow, @@ -836,15 +804,6 @@ impl i32 { } #[lang = "i64"] -#[cfg(stage0)] -impl i64 { - int_impl! { i64, u64, 64, - intrinsics::i64_add_with_overflow, - intrinsics::i64_sub_with_overflow, - intrinsics::i64_mul_with_overflow } -} -#[lang = "i64"] -#[cfg(not(stage0))] impl i64 { int_impl! { i64, u64, 64, intrinsics::add_with_overflow, @@ -854,16 +813,6 @@ impl i64 { #[cfg(target_pointer_width = "32")] #[lang = "isize"] -#[cfg(stage0)] -impl isize { - int_impl! { i32, u32, 32, - intrinsics::i32_add_with_overflow, - intrinsics::i32_sub_with_overflow, - intrinsics::i32_mul_with_overflow } -} -#[cfg(target_pointer_width = "32")] -#[lang = "isize"] -#[cfg(not(stage0))] impl isize { int_impl! { i32, u32, 32, intrinsics::add_with_overflow, @@ -873,16 +822,6 @@ impl isize { #[cfg(target_pointer_width = "64")] #[lang = "isize"] -#[cfg(stage0)] -impl isize { - int_impl! { i64, u64, 64, - intrinsics::i64_add_with_overflow, - intrinsics::i64_sub_with_overflow, - intrinsics::i64_mul_with_overflow } -} -#[cfg(target_pointer_width = "64")] -#[lang = "isize"] -#[cfg(not(stage0))] impl isize { int_impl! { i64, u64, 64, intrinsics::add_with_overflow, @@ -980,25 +919,6 @@ macro_rules! uint_impl { unsafe { $ctlz(self as $ActualT) as u32 } } - #[stable(feature = "rust1", since = "1.0.0")] - #[cfg(stage0)] - #[inline] - pub fn trailing_zeros(self) -> u32 { - // As of LLVM 3.6 the codegen for the zero-safe cttz8 intrinsic - // emits two conditional moves on x86_64. By promoting the value to - // u16 and setting bit 8, we get better code without any conditional - // operations. - // FIXME: There's a LLVM patch (http://reviews.llvm.org/D9284) - // pending, remove this workaround once LLVM generates better code - // for cttz8. - unsafe { - if $BITS == 8 { - intrinsics::cttz16(self as u16 | 0x100) as u32 - } else { - $cttz(self as $ActualT) as u32 - } - } - } /// Returns the number of trailing zeros in the binary representation /// of `self`. /// @@ -1012,7 +932,6 @@ macro_rules! uint_impl { /// assert_eq!(n.trailing_zeros(), 3); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg(not(stage0))] #[inline] pub fn trailing_zeros(self) -> u32 { // As of LLVM 3.6 the codegen for the zero-safe cttz8 intrinsic @@ -1563,19 +1482,6 @@ macro_rules! uint_impl { } #[lang = "u8"] -#[cfg(stage0)] -impl u8 { - uint_impl! { u8, 8, - intrinsics::ctpop8, - intrinsics::ctlz8, - intrinsics::cttz8, - bswap8, - intrinsics::u8_add_with_overflow, - intrinsics::u8_sub_with_overflow, - intrinsics::u8_mul_with_overflow } -} -#[lang = "u8"] -#[cfg(not(stage0))] impl u8 { uint_impl! { u8, 8, intrinsics::ctpop, @@ -1588,19 +1494,6 @@ impl u8 { } #[lang = "u16"] -#[cfg(stage0)] -impl u16 { - uint_impl! { u16, 16, - intrinsics::ctpop16, - intrinsics::ctlz16, - intrinsics::cttz16, - intrinsics::bswap16, - intrinsics::u16_add_with_overflow, - intrinsics::u16_sub_with_overflow, - intrinsics::u16_mul_with_overflow } -} -#[lang = "u16"] -#[cfg(not(stage0))] impl u16 { uint_impl! { u16, 16, intrinsics::ctpop, @@ -1613,19 +1506,6 @@ impl u16 { } #[lang = "u32"] -#[cfg(stage0)] -impl u32 { - uint_impl! { u32, 32, - intrinsics::ctpop32, - intrinsics::ctlz32, - intrinsics::cttz32, - intrinsics::bswap32, - intrinsics::u32_add_with_overflow, - intrinsics::u32_sub_with_overflow, - intrinsics::u32_mul_with_overflow } -} -#[lang = "u32"] -#[cfg(not(stage0))] impl u32 { uint_impl! { u32, 32, intrinsics::ctpop, @@ -1638,19 +1518,6 @@ impl u32 { } #[lang = "u64"] -#[cfg(stage0)] -impl u64 { - uint_impl! { u64, 64, - intrinsics::ctpop64, - intrinsics::ctlz64, - intrinsics::cttz64, - intrinsics::bswap64, - intrinsics::u64_add_with_overflow, - intrinsics::u64_sub_with_overflow, - intrinsics::u64_mul_with_overflow } -} -#[lang = "u64"] -#[cfg(not(stage0))] impl u64 { uint_impl! { u64, 64, intrinsics::ctpop, @@ -1664,20 +1531,6 @@ impl u64 { #[cfg(target_pointer_width = "32")] #[lang = "usize"] -#[cfg(stage0)] -impl usize { - uint_impl! { u32, 32, - intrinsics::ctpop32, - intrinsics::ctlz32, - intrinsics::cttz32, - intrinsics::bswap32, - intrinsics::u32_add_with_overflow, - intrinsics::u32_sub_with_overflow, - intrinsics::u32_mul_with_overflow } -} -#[cfg(target_pointer_width = "32")] -#[lang = "usize"] -#[cfg(not(stage0))] impl usize { uint_impl! { u32, 32, intrinsics::ctpop, @@ -1691,20 +1544,6 @@ impl usize { #[cfg(target_pointer_width = "64")] #[lang = "usize"] -#[cfg(stage0)] -impl usize { - uint_impl! { u64, 64, - intrinsics::ctpop64, - intrinsics::ctlz64, - intrinsics::cttz64, - intrinsics::bswap64, - intrinsics::u64_add_with_overflow, - intrinsics::u64_sub_with_overflow, - intrinsics::u64_mul_with_overflow } -} -#[cfg(target_pointer_width = "64")] -#[lang = "usize"] -#[cfg(not(stage0))] impl usize { uint_impl! { u64, 64, intrinsics::ctpop, diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index 88f71e63da682..a7d5fcafd5603 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -12,30 +12,7 @@ #![unstable(feature = "wrapping", reason = "may be removed or relocated", issue = "27755")] -#[cfg(stage0)] -pub use intrinsics::{ - u8_add_with_overflow, i8_add_with_overflow, - u16_add_with_overflow, i16_add_with_overflow, - u32_add_with_overflow, i32_add_with_overflow, - u64_add_with_overflow, i64_add_with_overflow, - - u8_sub_with_overflow, i8_sub_with_overflow, - u16_sub_with_overflow, i16_sub_with_overflow, - u32_sub_with_overflow, i32_sub_with_overflow, - u64_sub_with_overflow, i64_sub_with_overflow, - - u8_mul_with_overflow, i8_mul_with_overflow, - u16_mul_with_overflow, i16_mul_with_overflow, - u32_mul_with_overflow, i32_mul_with_overflow, - u64_mul_with_overflow, i64_mul_with_overflow, -}; - -#[cfg(not(stage0))] -pub use intrinsics::{ - add_with_overflow, - sub_with_overflow, - mul_with_overflow, -}; +pub use intrinsics::{add_with_overflow, sub_with_overflow, mul_with_overflow}; use super::Wrapping; @@ -203,42 +180,18 @@ macro_rules! signed_overflowing_impl { ($($t:ident)*) => ($( impl OverflowingOps for $t { #[inline(always)] - #[cfg(stage0)] - fn overflowing_add(self, rhs: $t) -> ($t, bool) { - unsafe { - concat_idents!($t, _add_with_overflow)(self, rhs) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_add(self, rhs: $t) -> ($t, bool) { unsafe { add_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_sub(self, rhs: $t) -> ($t, bool) { - unsafe { - concat_idents!($t, _sub_with_overflow)(self, rhs) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_sub(self, rhs: $t) -> ($t, bool) { unsafe { sub_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_mul(self, rhs: $t) -> ($t, bool) { - unsafe { - concat_idents!($t, _mul_with_overflow)(self, rhs) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_mul(self, rhs: $t) -> ($t, bool) { unsafe { mul_with_overflow(self, rhs) @@ -289,42 +242,18 @@ macro_rules! unsigned_overflowing_impl { ($($t:ident)*) => ($( impl OverflowingOps for $t { #[inline(always)] - #[cfg(stage0)] - fn overflowing_add(self, rhs: $t) -> ($t, bool) { - unsafe { - concat_idents!($t, _add_with_overflow)(self, rhs) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_add(self, rhs: $t) -> ($t, bool) { unsafe { add_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_sub(self, rhs: $t) -> ($t, bool) { - unsafe { - concat_idents!($t, _sub_with_overflow)(self, rhs) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_sub(self, rhs: $t) -> ($t, bool) { unsafe { sub_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_mul(self, rhs: $t) -> ($t, bool) { - unsafe { - concat_idents!($t, _mul_with_overflow)(self, rhs) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_mul(self, rhs: $t) -> ($t, bool) { unsafe { mul_with_overflow(self, rhs) @@ -365,45 +294,18 @@ unsigned_overflowing_impl! { u8 u16 u32 u64 } #[cfg(target_pointer_width = "64")] impl OverflowingOps for usize { #[inline(always)] - #[cfg(stage0)] - fn overflowing_add(self, rhs: usize) -> (usize, bool) { - unsafe { - let res = u64_add_with_overflow(self as u64, rhs as u64); - (res.0 as usize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_add(self, rhs: usize) -> (usize, bool) { unsafe { add_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_sub(self, rhs: usize) -> (usize, bool) { - unsafe { - let res = u64_sub_with_overflow(self as u64, rhs as u64); - (res.0 as usize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_sub(self, rhs: usize) -> (usize, bool) { unsafe { sub_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_mul(self, rhs: usize) -> (usize, bool) { - unsafe { - let res = u64_mul_with_overflow(self as u64, rhs as u64); - (res.0 as usize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_mul(self, rhs: usize) -> (usize, bool) { unsafe { mul_with_overflow(self, rhs) @@ -439,45 +341,18 @@ impl OverflowingOps for usize { #[cfg(target_pointer_width = "32")] impl OverflowingOps for usize { #[inline(always)] - #[cfg(stage0)] - fn overflowing_add(self, rhs: usize) -> (usize, bool) { - unsafe { - let res = u32_add_with_overflow(self as u32, rhs as u32); - (res.0 as usize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_add(self, rhs: usize) -> (usize, bool) { unsafe { add_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_sub(self, rhs: usize) -> (usize, bool) { - unsafe { - let res = u32_sub_with_overflow(self as u32, rhs as u32); - (res.0 as usize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_sub(self, rhs: usize) -> (usize, bool) { unsafe { sub_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_mul(self, rhs: usize) -> (usize, bool) { - unsafe { - let res = u32_mul_with_overflow(self as u32, rhs as u32); - (res.0 as usize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_mul(self, rhs: usize) -> (usize, bool) { unsafe { mul_with_overflow(self, rhs) @@ -513,45 +388,18 @@ impl OverflowingOps for usize { #[cfg(target_pointer_width = "64")] impl OverflowingOps for isize { #[inline(always)] - #[cfg(stage0)] - fn overflowing_add(self, rhs: isize) -> (isize, bool) { - unsafe { - let res = i64_add_with_overflow(self as i64, rhs as i64); - (res.0 as isize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_add(self, rhs: isize) -> (isize, bool) { unsafe { add_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_sub(self, rhs: isize) -> (isize, bool) { - unsafe { - let res = i64_sub_with_overflow(self as i64, rhs as i64); - (res.0 as isize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_sub(self, rhs: isize) -> (isize, bool) { unsafe { sub_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_mul(self, rhs: isize) -> (isize, bool) { - unsafe { - let res = i64_mul_with_overflow(self as i64, rhs as i64); - (res.0 as isize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_mul(self, rhs: isize) -> (isize, bool) { unsafe { mul_with_overflow(self, rhs) @@ -587,45 +435,18 @@ impl OverflowingOps for isize { #[cfg(target_pointer_width = "32")] impl OverflowingOps for isize { #[inline(always)] - #[cfg(stage0)] - fn overflowing_add(self, rhs: isize) -> (isize, bool) { - unsafe { - let res = i32_add_with_overflow(self as i32, rhs as i32); - (res.0 as isize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_add(self, rhs: isize) -> (isize, bool) { unsafe { add_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_sub(self, rhs: isize) -> (isize, bool) { - unsafe { - let res = i32_sub_with_overflow(self as i32, rhs as i32); - (res.0 as isize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_sub(self, rhs: isize) -> (isize, bool) { unsafe { sub_with_overflow(self, rhs) } } #[inline(always)] - #[cfg(stage0)] - fn overflowing_mul(self, rhs: isize) -> (isize, bool) { - unsafe { - let res = i32_mul_with_overflow(self as i32, rhs as i32); - (res.0 as isize, res.1) - } - } - #[inline(always)] - #[cfg(not(stage0))] fn overflowing_mul(self, rhs: isize) -> (isize, bool) { unsafe { mul_with_overflow(self, rhs) diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index dd4702376d43c..edbe64db08086 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -441,7 +441,6 @@ macro_rules! rem_impl_integer { rem_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 } -#[cfg(not(stage0))] macro_rules! rem_impl_float { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] @@ -456,48 +455,8 @@ macro_rules! rem_impl_float { )*) } -#[cfg(not(stage0))] rem_impl_float! { f32 f64 } -#[stable(feature = "rust1", since = "1.0.0")] -#[cfg(stage0)] -impl Rem for f32 { - type Output = f32; - - // The builtin f32 rem operator is broken when targeting - // MSVC; see comment in std::f32::floor. - // FIXME: See also #27859. - #[inline] - #[cfg(target_env = "msvc")] - fn rem(self, other: f32) -> f32 { - (self as f64).rem(other as f64) as f32 - } - - #[inline] - #[cfg(not(target_env = "msvc"))] - fn rem(self, other: f32) -> f32 { - extern { fn fmodf(a: f32, b: f32) -> f32; } - unsafe { fmodf(self, other) } - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -#[cfg(stage0)] -impl Rem for f64 { - type Output = f64; - - #[inline] - fn rem(self, other: f64) -> f64 { - extern { fn fmod(a: f64, b: f64) -> f64; } - unsafe { fmod(self, other) } - } -} - -#[cfg(stage0)] -forward_ref_binop! { impl Rem, rem for f64, f64 } -#[cfg(stage0)] -forward_ref_binop! { impl Rem, rem for f32, f32 } - /// The `Neg` trait is used to specify the functionality of unary `-`. /// /// # Examples @@ -954,7 +913,6 @@ shr_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// foo += Foo; /// } /// ``` -#[cfg(not(stage0))] #[lang = "add_assign"] #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] pub trait AddAssign { @@ -962,7 +920,6 @@ pub trait AddAssign { fn add_assign(&mut self, Rhs); } -#[cfg(not(stage0))] macro_rules! add_assign_impl { ($($t:ty)+) => ($( #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] @@ -973,7 +930,6 @@ macro_rules! add_assign_impl { )+) } -#[cfg(not(stage0))] add_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// The `SubAssign` trait is used to specify the functionality of `-=`. @@ -1004,7 +960,6 @@ add_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// foo -= Foo; /// } /// ``` -#[cfg(not(stage0))] #[lang = "sub_assign"] #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] pub trait SubAssign { @@ -1012,7 +967,6 @@ pub trait SubAssign { fn sub_assign(&mut self, Rhs); } -#[cfg(not(stage0))] macro_rules! sub_assign_impl { ($($t:ty)+) => ($( #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] @@ -1023,7 +977,6 @@ macro_rules! sub_assign_impl { )+) } -#[cfg(not(stage0))] sub_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// The `MulAssign` trait is used to specify the functionality of `*=`. @@ -1054,7 +1007,6 @@ sub_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// foo *= Foo; /// } /// ``` -#[cfg(not(stage0))] #[lang = "mul_assign"] #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] pub trait MulAssign { @@ -1062,7 +1014,6 @@ pub trait MulAssign { fn mul_assign(&mut self, Rhs); } -#[cfg(not(stage0))] macro_rules! mul_assign_impl { ($($t:ty)+) => ($( #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] @@ -1073,7 +1024,6 @@ macro_rules! mul_assign_impl { )+) } -#[cfg(not(stage0))] mul_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// The `DivAssign` trait is used to specify the functionality of `/=`. @@ -1104,7 +1054,6 @@ mul_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// foo /= Foo; /// } /// ``` -#[cfg(not(stage0))] #[lang = "div_assign"] #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] pub trait DivAssign { @@ -1112,7 +1061,6 @@ pub trait DivAssign { fn div_assign(&mut self, Rhs); } -#[cfg(not(stage0))] macro_rules! div_assign_impl { ($($t:ty)+) => ($( #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] @@ -1123,7 +1071,6 @@ macro_rules! div_assign_impl { )+) } -#[cfg(not(stage0))] div_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// The `RemAssign` trait is used to specify the functionality of `%=`. @@ -1154,7 +1101,6 @@ div_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// foo %= Foo; /// } /// ``` -#[cfg(not(stage0))] #[lang = "rem_assign"] #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] pub trait RemAssign { @@ -1162,7 +1108,6 @@ pub trait RemAssign { fn rem_assign(&mut self, Rhs); } -#[cfg(not(stage0))] macro_rules! rem_assign_impl { ($($t:ty)+) => ($( #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] @@ -1173,7 +1118,6 @@ macro_rules! rem_assign_impl { )+) } -#[cfg(not(stage0))] rem_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// The `BitAndAssign` trait is used to specify the functionality of `&=`. @@ -1204,7 +1148,6 @@ rem_assign_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 } /// foo &= Foo; /// } /// ``` -#[cfg(not(stage0))] #[lang = "bitand_assign"] #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] pub trait BitAndAssign { @@ -1212,7 +1155,6 @@ pub trait BitAndAssign { fn bitand_assign(&mut self, Rhs); } -#[cfg(not(stage0))] macro_rules! bitand_assign_impl { ($($t:ty)+) => ($( #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] @@ -1223,7 +1165,6 @@ macro_rules! bitand_assign_impl { )+) } -#[cfg(not(stage0))] bitand_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// The `BitOrAssign` trait is used to specify the functionality of `|=`. @@ -1254,7 +1195,6 @@ bitand_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// foo |= Foo; /// } /// ``` -#[cfg(not(stage0))] #[lang = "bitor_assign"] #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] pub trait BitOrAssign { @@ -1262,7 +1202,6 @@ pub trait BitOrAssign { fn bitor_assign(&mut self, Rhs); } -#[cfg(not(stage0))] macro_rules! bitor_assign_impl { ($($t:ty)+) => ($( #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] @@ -1273,7 +1212,6 @@ macro_rules! bitor_assign_impl { )+) } -#[cfg(not(stage0))] bitor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// The `BitXorAssign` trait is used to specify the functionality of `^=`. @@ -1304,7 +1242,6 @@ bitor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// foo ^= Foo; /// } /// ``` -#[cfg(not(stage0))] #[lang = "bitxor_assign"] #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] pub trait BitXorAssign { @@ -1312,7 +1249,6 @@ pub trait BitXorAssign { fn bitxor_assign(&mut self, Rhs); } -#[cfg(not(stage0))] macro_rules! bitxor_assign_impl { ($($t:ty)+) => ($( #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] @@ -1323,7 +1259,6 @@ macro_rules! bitxor_assign_impl { )+) } -#[cfg(not(stage0))] bitxor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// The `ShlAssign` trait is used to specify the functionality of `<<=`. @@ -1354,7 +1289,6 @@ bitxor_assign_impl! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 } /// foo <<= Foo; /// } /// ``` -#[cfg(not(stage0))] #[lang = "shl_assign"] #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] pub trait ShlAssign { @@ -1362,7 +1296,6 @@ pub trait ShlAssign { fn shl_assign(&mut self, Rhs); } -#[cfg(not(stage0))] macro_rules! shl_assign_impl { ($t:ty, $f:ty) => ( #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] @@ -1375,7 +1308,6 @@ macro_rules! shl_assign_impl { ) } -#[cfg(not(stage0))] macro_rules! shl_assign_impl_all { ($($t:ty)*) => ($( shl_assign_impl! { $t, u8 } @@ -1392,7 +1324,6 @@ macro_rules! shl_assign_impl_all { )*) } -#[cfg(not(stage0))] shl_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// The `ShrAssign` trait is used to specify the functionality of `>>=`. @@ -1423,7 +1354,6 @@ shl_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// foo >>= Foo; /// } /// ``` -#[cfg(not(stage0))] #[lang = "shr_assign"] #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] pub trait ShrAssign { @@ -1431,7 +1361,6 @@ pub trait ShrAssign { fn shr_assign(&mut self, Rhs); } -#[cfg(not(stage0))] macro_rules! shr_assign_impl { ($t:ty, $f:ty) => ( #[unstable(feature = "op_assign_traits", reason = "recently added", issue = "28235")] @@ -1444,7 +1373,6 @@ macro_rules! shr_assign_impl { ) } -#[cfg(not(stage0))] macro_rules! shr_assign_impl_all { ($($t:ty)*) => ($( shr_assign_impl! { $t, u8 } @@ -1461,7 +1389,6 @@ macro_rules! shr_assign_impl_all { )*) } -#[cfg(not(stage0))] shr_assign_impl_all! { u8 u16 u32 u64 usize i8 i16 i32 i64 isize } /// The `Index` trait is used to specify the functionality of indexing operations diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 53ef9cd09026b..e1e7869d548db 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -499,28 +499,12 @@ unsafe impl Send for Unique { } #[unstable(feature = "unique", issue = "27730")] unsafe impl Sync for Unique { } -#[cfg(stage0)] -macro_rules! unique_new { - () => ( - /// Creates a new `Unique`. - pub unsafe fn new(ptr: *mut T) -> Unique { - Unique { pointer: NonZero::new(ptr), _marker: PhantomData } - } - ) -} -#[cfg(not(stage0))] -macro_rules! unique_new { - () => ( - /// Creates a new `Unique`. - pub const unsafe fn new(ptr: *mut T) -> Unique { - Unique { pointer: NonZero::new(ptr), _marker: PhantomData } - } - ) -} - #[unstable(feature = "unique", issue = "27730")] impl Unique { - unique_new!{} + /// Creates a new `Unique`. + pub const unsafe fn new(ptr: *mut T) -> Unique { + Unique { pointer: NonZero::new(ptr), _marker: PhantomData } + } /// Dereferences the content. pub unsafe fn get(&self) -> &T { @@ -533,7 +517,6 @@ impl Unique { } } -#[cfg(not(stage0))] // remove cfg after new snapshot #[unstable(feature = "unique", issue = "27730")] impl CoerceUnsized> for Unique where T: Unsize { } @@ -598,7 +581,6 @@ impl Clone for Shared { #[unstable(feature = "shared", issue = "27730")] impl Copy for Shared { } -#[cfg(not(stage0))] // remove cfg after new snapshot #[unstable(feature = "shared", issue = "27730")] impl CoerceUnsized> for Shared where T: Unsize { } diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index 02810bf668a0a..a60a1c67e175d 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -14,11 +14,8 @@ //! [def]: https://en.wikipedia.org/wiki/DEFLATE //! [mz]: https://code.google.com/p/miniz/ -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "flate"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -30,7 +27,6 @@ #![feature(staged_api)] #![feature(unique)] #![cfg_attr(test, feature(rustc_private, rand, vec_push_all))] -#![cfg_attr(stage0, allow(improper_ctypes))] #[cfg(test)] #[macro_use] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 6e185c674a698..7a229ad522227 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -14,11 +14,8 @@ //! Parsing does not happen at runtime: structures of `std::fmt::rt` are //! generated instead. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "fmt_macros"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 228ceb92da661..57ce53e73b025 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -77,14 +77,10 @@ //! } //! ``` - -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "getopts"] #![unstable(feature = "rustc_private", reason = "use the crates.io `getopts` library instead", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index c1bd188d3a286..b9fd5cc1910fc 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -271,12 +271,9 @@ //! //! * [DOT language](http://www.graphviz.org/doc/info/lang.html) -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "graphviz"] #![unstable(feature = "rustc_private", issue = "27812")] #![feature(staged_api)] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 404bbd902bfd8..dbd553acd68fc 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -156,13 +156,10 @@ //! they're turned off (just a load and an integer comparison). This also means that //! if logging is disabled, none of the components of the log will be executed. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "log"] #![unstable(feature = "rustc_private", reason = "use the crates.io `log` library instead", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 013efb129d850..06f4c8dfd20a8 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -16,8 +16,6 @@ //! is not recommended to use this library directly, but rather the official //! interface through `std::rand`. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rand"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", @@ -26,7 +24,6 @@ html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))))] #![no_std] -#![cfg_attr(stage0, staged_api)] #![unstable(feature = "rand", reason = "use `rand` from crates.io", issue = "27703")] @@ -37,7 +34,6 @@ #![feature(step_by)] #![feature(custom_attribute)] #![allow(unused_attributes)] -#![cfg_attr(stage0, feature(no_std))] #![cfg_attr(test, feature(test, rand, rustc_private, iter_order_deprecated))] diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index 3c0c9951613e3..d8d6ea93f7569 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -111,11 +111,8 @@ //! //! First 0x20 tags are reserved by RBML; custom tags start at 0x20. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rbml"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 0890594f2b116..00d6237b85564 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -14,11 +14,8 @@ //! //! This API is completely unstable and subject to change. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index ff3e99d487c9e..0273d1a76e9a8 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -242,8 +242,6 @@ impl OverloadedCallType { // mem_categorization, it requires a TYPER, which is a type that // supplies types from the tree. After type checking is complete, you // can just use the tcx as the typer. -// -// FIXME(stage0): the :'t here is probably only important for stage0 pub struct ExprUseVisitor<'d, 't, 'a: 't, 'tcx:'a+'d> { typer: &'t infer::InferCtxt<'a, 'tcx>, mc: mc::MemCategorizationContext<'t, 'a, 'tcx>, diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 2a3d9cfa6b888..b5d259d9ac999 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -90,7 +90,6 @@ fn get_resident() -> Option { } #[cfg(windows)] -#[cfg_attr(stage0, allow(improper_ctypes))] fn get_resident() -> Option { type BOOL = i32; type DWORD = u32; diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs index 700cfb645bf05..844f4925bd274 100644 --- a/src/librustc_back/lib.rs +++ b/src/librustc_back/lib.rs @@ -21,11 +21,8 @@ //! one that doesn't; the one that doesn't might get decent parallel //! build speedups. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_back"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_bitflags/lib.rs b/src/librustc_bitflags/lib.rs index 97816a2b2ae84..e2a929f58e14d 100644 --- a/src/librustc_bitflags/lib.rs +++ b/src/librustc_bitflags/lib.rs @@ -9,14 +9,10 @@ // except according to those terms. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_bitflags"] #![feature(associated_consts)] #![feature(staged_api)] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] -#![cfg_attr(stage0, feature(no_std))] #![no_std] #![unstable(feature = "rustc_private", issue = "27812")] diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index 27cd9530c9be3..0e1102bd77e02 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -8,11 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_borrowck"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 0ea7cfa3902fa..3bba7d651ad71 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -16,13 +16,10 @@ //! //! This API is completely unstable and subject to change. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_data_structures"] #![unstable(feature = "rustc_private", issue = "27812")] #![crate_type = "dylib"] #![crate_type = "rlib"] -#![cfg_attr(stage0, staged_api)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 8cfaec62f4775..210b1a26c21f1 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -14,11 +14,8 @@ //! //! This API is completely unstable and subject to change. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_driver"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -32,7 +29,6 @@ #![feature(rustc_private)] #![feature(set_stdio)] #![feature(staged_api)] -#![feature(raw)] // remove after snapshot extern crate arena; extern crate flate; @@ -105,24 +101,6 @@ pub mod target_features; const BUG_REPORT_URL: &'static str = "https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.\ md#bug-reports"; -// SNAP 1af31d4 -// This is a terrible hack. Our stage0 is older than 1.4 and does not -// support DST coercions, so this function performs the corecion -// manually. This should go away. -pub fn cstore_to_cratestore(a: Rc) -> Rc CrateStore<'s>> -{ - use std::mem; - use std::raw::TraitObject; - unsafe { - let TraitObject { vtable, .. } = - mem::transmute::<&for<'s> CrateStore<'s>, TraitObject>(&*a); - mem::transmute(TraitObject { - data: mem::transmute(a), - vtable: vtable - }) - } -} - pub fn run(args: Vec) -> isize { monitor(move || run_compiler(&args, &mut RustcDefaultCalls)); 0 @@ -159,8 +137,8 @@ pub fn run_compiler<'a>(args: &[String], callbacks: &mut CompilerCalls<'a>) { }; let cstore = Rc::new(CStore::new(token::get_ident_interner())); - let cstore_ = cstore_to_cratestore(cstore.clone()); - let mut sess = build_session(sopts, input_file_path, descriptions, cstore_); + let mut sess = build_session(sopts, input_file_path, descriptions, + cstore.clone()); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); if sess.unstable_options() { sess.opts.show_span = matches.opt_str("show-span"); @@ -356,8 +334,8 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls { return None; } let cstore = Rc::new(CStore::new(token::get_ident_interner())); - let cstore_ = cstore_to_cratestore(cstore.clone()); - let sess = build_session(sopts.clone(), None, descriptions.clone(), cstore_); + let sess = build_session(sopts.clone(), None, descriptions.clone(), + cstore.clone()); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); let should_stop = RustcDefaultCalls::print_crate_info(&sess, None, odir, ofile); if should_stop == Compilation::Stop { diff --git a/src/librustc_front/lib.rs b/src/librustc_front/lib.rs index 60080854a6f17..b12c41d060a07 100644 --- a/src/librustc_front/lib.rs +++ b/src/librustc_front/lib.rs @@ -14,11 +14,8 @@ //! //! This API is completely unstable and subject to change. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_front"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 1d0c616c3b71b..80ef334fe189b 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -19,11 +19,8 @@ //! //! This API is completely unstable and subject to change. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_lint"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index ebb0caa0dfae2..e2217e367a08e 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -8,19 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(dead_code)] #![allow(trivial_casts)] -#![cfg_attr(stage0, allow(improper_ctypes))] - #![crate_name = "rustc_llvm"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index c425ba1386e25..42332c4696979 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_metadata"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_platform_intrinsics/lib.rs b/src/librustc_platform_intrinsics/lib.rs index 3de6863652ab7..e857434682d15 100644 --- a/src/librustc_platform_intrinsics/lib.rs +++ b/src/librustc_platform_intrinsics/lib.rs @@ -8,10 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_platform_intrinsics"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![feature(staged_api, rustc_private)] diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 5dedef7ab6c79..333c226c2a373 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -50,10 +50,8 @@ //! See the [Plugins Chapter](../../book/compiler-plugins.html) of the book //! for more examples. -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_plugin"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 9a869b24b8f6d..d1a894c61f7e2 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -8,11 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_privacy"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 3f7327e700bdd..5711807a6172f 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -8,11 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_resolve"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 83d0106fd4cb3..a17e0a4ccd78d 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -14,11 +14,8 @@ //! //! This API is completely unstable and subject to change. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_trans"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index c0ede6370f1b1..70c6d6f05c66a 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -62,11 +62,9 @@ independently: This API is completely unstable and subject to change. */ -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] + #![crate_name = "rustc_typeck"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_unicode/lib.rs b/src/librustc_unicode/lib.rs index 8bde24d2b0c42..161da07911061 100644 --- a/src/librustc_unicode/lib.rs +++ b/src/librustc_unicode/lib.rs @@ -20,11 +20,8 @@ //! provide for basic string-related manipulations. This crate does not //! (yet) aim to provide a full set of Unicode tables. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_unicode"] #![unstable(feature = "unicode", issue = "27783")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", @@ -34,9 +31,6 @@ test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] #![no_std] -#![cfg_attr(stage0, feature(rustc_attrs))] -#![cfg_attr(stage0, feature(no_std))] -#![cfg_attr(stage0, allow(unused_attributes))] #![feature(core_char_ext)] #![feature(lang_items)] #![feature(staged_api)] diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index c6c98851f7c34..d7190a4bea974 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -125,8 +125,8 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec, externs: Externs, codemap.clone()); let cstore = Rc::new(CStore::new(token::get_ident_interner())); - let cstore_ = ::rustc_driver::cstore_to_cratestore(cstore.clone()); - let sess = session::build_session_(sessopts, cpath, diagnostic_handler, codemap, cstore_); + let sess = session::build_session_(sessopts, cpath, diagnostic_handler, + codemap, cstore.clone()); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); let mut cfg = config::build_configuration(&sess); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 31fdc1170c026..ffda261c24f3d 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -8,17 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustdoc"] #![unstable(feature = "rustdoc", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/", - html_playground_url = "https://play.rust-lang.org/")] + html_favicon_url = "https://doc.rust-lang.org/favicon.ico", + html_root_url = "https://doc.rust-lang.org/nightly/", + html_playground_url = "https://play.rust-lang.org/")] #![feature(box_patterns)] #![feature(box_syntax)] diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index fde8299d2d2e6..7aa97d3652f5a 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -80,12 +80,11 @@ pub fn run(input: &str, codemap.clone()); let cstore = Rc::new(CStore::new(token::get_ident_interner())); - let cstore_ = ::rustc_driver::cstore_to_cratestore(cstore.clone()); let sess = session::build_session_(sessopts, Some(input_path.clone()), diagnostic_handler, codemap, - cstore_); + cstore.clone()); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); let mut cfg = config::build_configuration(&sess); @@ -235,12 +234,11 @@ fn runtest(test: &str, cratename: &str, cfgs: Vec, libs: SearchPaths, let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter); let cstore = Rc::new(CStore::new(token::get_ident_interner())); - let cstore_ = ::rustc_driver::cstore_to_cratestore(cstore.clone()); let sess = session::build_session_(sessopts, None, diagnostic_handler, codemap, - cstore_); + cstore.clone()); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); let outdir = TempDir::new("rustdoctest").ok().expect("rustdoc needs a tempdir"); diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index c919c33564005..2941f6f8a026e 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -14,13 +14,10 @@ Core encoding and decoding interfaces. */ -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "serialize"] #![unstable(feature = "rustc_private", reason = "deprecated in favor of rustc-serialize on crates.io", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 719593ddd383a..4f2236c257ba8 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -199,11 +199,8 @@ //! [other]: #what-is-in-the-standard-library-documentation //! [primitive types]: ../book/primitive-types.html -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "std"] #![stable(feature = "rust1", since = "1.0.0")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -214,12 +211,6 @@ test(no_crate_inject, attr(deny(warnings))), test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] -#![cfg_attr(stage0, allow(unused_attributes))] -#![cfg_attr(stage0, allow(improper_ctypes))] - -#![cfg_attr(stage0, feature(rustc_attrs))] -#![cfg_attr(stage0, feature(no_std))] -#![cfg_attr(stage0, allow(unused_attributes))] #![feature(alloc)] #![feature(allow_internal_unstable)] #![feature(asm)] diff --git a/src/libstd/rand/os.rs b/src/libstd/rand/os.rs index 273b17400a9ca..c7cb10a470748 100644 --- a/src/libstd/rand/os.rs +++ b/src/libstd/rand/os.rs @@ -238,8 +238,6 @@ mod imp { #[cfg(target_os = "ios")] mod imp { - #[cfg(stage0)] use prelude::v1::*; - use io; use mem; use ptr; diff --git a/src/libstd/sys/common/libunwind.rs b/src/libstd/sys/common/libunwind.rs index 75bb11216e1a2..feb05c7b56008 100644 --- a/src/libstd/sys/common/libunwind.rs +++ b/src/libstd/sys/common/libunwind.rs @@ -131,8 +131,6 @@ extern "C" { pub fn _Unwind_DeleteException(exception: *mut _Unwind_Exception); - // remove cfg after new snapshot - #[cfg(not(all(stage0, target_os="windows", target_arch="x86_64")))] #[unwind] pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !; } diff --git a/src/libstd/sys/common/unwind/mod.rs b/src/libstd/sys/common/unwind/mod.rs index aea5acc907176..0f10e7274614c 100644 --- a/src/libstd/sys/common/unwind/mod.rs +++ b/src/libstd/sys/common/unwind/mod.rs @@ -88,18 +88,8 @@ use sys_common::mutex::Mutex; #[path = "seh.rs"] #[doc(hidden)] pub mod imp; -// stage0: i686-pc-windows-gnu -#[cfg(all(stage0, windows, target_arch = "x86_64", target_env = "gnu"))] -#[path = "seh64_gnu.rs"] #[doc(hidden)] -pub mod imp; - -// stage0: x86_64-pc-windows-msvc -#[cfg(all(stage0, windows, target_arch = "x86_64", target_env = "msvc"))] -#[path = "seh.rs"] #[doc(hidden)] -pub mod imp; - // x86_64-pc-windows-* -#[cfg(all(not(stage0), windows, target_arch = "x86_64"))] +#[cfg(all(windows, target_arch = "x86_64"))] #[path = "seh64_gnu.rs"] #[doc(hidden)] pub mod imp; diff --git a/src/libstd/sys/windows/c.rs b/src/libstd/sys/windows/c.rs index 5e0368f35cc74..34e32d0d5b62a 100644 --- a/src/libstd/sys/windows/c.rs +++ b/src/libstd/sys/windows/c.rs @@ -17,7 +17,7 @@ use os::raw::{c_char, c_short, c_ulonglong}; use libc::{wchar_t, size_t, c_void}; use ptr; -#[cfg_attr(not(stage0), repr(simd))] +#[repr(simd)] #[repr(C)] struct u64x2(u64, u64); diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 47340d312242b..c09e35f1077a5 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -14,11 +14,8 @@ //! //! This API is completely unstable and subject to change. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "syntax"] #![unstable(feature = "rustc_private", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "dylib"] #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -26,8 +23,6 @@ html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] -#![cfg_attr(stage0, feature(rustc_attrs))] -#![cfg_attr(stage0, allow(unused_attributes))] #![feature(associated_consts)] #![feature(filling_drop)] #![feature(libc)] diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 01dc9662588bf..a032666595ebe 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -17,8 +17,6 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] -#![cfg_attr(stage0, feature(custom_attribute))] -#![cfg_attr(stage0, staged_api)] #![unstable(feature = "rustc_private", issue = "27812")] #![feature(rustc_private)] diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 69ad55d790899..d4c9cb8e2541b 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -40,13 +40,10 @@ //! [win]: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682010%28v=vs.85%29.aspx //! [ti]: https://en.wikipedia.org/wiki/Terminfo -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "term"] #![unstable(feature = "rustc_private", reason = "use the crates.io `term` library instead", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index d1bf9090944c2..20d7c66cf1221 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -23,11 +23,8 @@ // running tests while providing a base that other test frameworks may // build off of. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "test"] #![unstable(feature = "test", issue = "27812")] -#![cfg_attr(stage0, staged_api)] #![crate_type = "rlib"] #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/rtstartup/rsbegin.rs b/src/rtstartup/rsbegin.rs index a81eac279d062..d1b6fe6655ac6 100644 --- a/src/rtstartup/rsbegin.rs +++ b/src/rtstartup/rsbegin.rs @@ -22,8 +22,6 @@ // object (usually called `crtX.o), which then invokes initialization callbacks // of other runtime components (registered via yet another special image section). -#![cfg_attr(stage0, feature(no_std))] - #![crate_type="rlib"] #![no_std] #![allow(non_camel_case_types)] diff --git a/src/rtstartup/rsend.rs b/src/rtstartup/rsend.rs index e3b691ce2f7db..5e4e13ebd05e4 100644 --- a/src/rtstartup/rsend.rs +++ b/src/rtstartup/rsend.rs @@ -10,8 +10,6 @@ // See rsbegin.rs for details. -#![cfg_attr(stage0, feature(no_std))] - #![crate_type="rlib"] #![no_std] diff --git a/src/snapshots.txt b/src/snapshots.txt index c59170d523d7a..81ff9b051721d 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,11 @@ +S 2015-12-18 3391630 + linux-i386 a09c4a4036151d0cb28e265101669731600e01f2 + linux-x86_64 97e2a5eb8904962df8596e95d6e5d9b574d73bf4 + macos-i386 ca52d2d3ba6497ed007705ee3401cf7efc136ca1 + macos-x86_64 3c44ffa18f89567c2b81f8d695e711c86d81ffc7 + winnt-i386 f9056ebd3db9611d31c2dc6dc5f96c7208d5d227 + winnt-x86_64 a85a40e535d828016181d3aa40afe34c3e36ab8c + S 2015-08-11 1af31d4 bitrig-x86_64 739e0635cd5a1b3635f1457aae3ef6390ea9a7a8 freebsd-i386 3cd4a44fb97b3135be3d1b760bea604a381e85dc diff --git a/src/test/run-make/execution-engine/test.rs b/src/test/run-make/execution-engine/test.rs index 20dd16872a653..928f2f996a028 100644 --- a/src/test/run-make/execution-engine/test.rs +++ b/src/test/run-make/execution-engine/test.rs @@ -215,9 +215,8 @@ fn compile_program(input: &str, sysroot: PathBuf) let handle = thread.spawn(move || { let opts = build_exec_options(sysroot); let cstore = Rc::new(CStore::new(token::get_ident_interner())); - let cstore_ = ::rustc_driver::cstore_to_cratestore(cstore.clone()); let sess = build_session(opts, None, Registry::new(&rustc::DIAGNOSTICS), - cstore_); + cstore.clone()); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); let cfg = build_configuration(&sess); diff --git a/src/test/run-make/issue-19371/foo.rs b/src/test/run-make/issue-19371/foo.rs index 58bf5049cf13e..4b1c84ce64fee 100644 --- a/src/test/run-make/issue-19371/foo.rs +++ b/src/test/run-make/issue-19371/foo.rs @@ -55,8 +55,7 @@ fn basic_sess(sysroot: PathBuf) -> (Session, Rc) { let descriptions = Registry::new(&rustc::DIAGNOSTICS); let cstore = Rc::new(CStore::new(token::get_ident_interner())); - let cstore_ = ::rustc_driver::cstore_to_cratestore(cstore.clone()); - let sess = build_session(opts, None, descriptions, cstore_); + let sess = build_session(opts, None, descriptions, cstore.clone()); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); (sess, cstore) } From ed237e5de717ff5d7eed0f6f08f1a6938bd1bf40 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 16 Dec 2015 23:06:00 -0800 Subject: [PATCH 10/24] std: Update jemalloc version It's been awhile since we last updated jemalloc, and there's likely some bugs that have been fixed since the last version we're using, so let's try to update again. --- mk/rt.mk | 23 ++++++++++++++++++----- src/jemalloc | 2 +- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/mk/rt.mk b/mk/rt.mk index 8433b588e6ba4..9d12bf39825a6 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -128,12 +128,25 @@ define DEF_THIRD_PARTY_TARGETS # $(1) is the target triple -ifeq ($$(CFG_WINDOWSY_$(1)), 1) - # This isn't necessarily a desired option, but it's harmless and works around - # what appears to be a mingw-w64 bug. +ifeq ($$(CFG_WINDOWSY_$(1)),1) + # A bit of history here, this used to be --enable-lazy-lock added in #14006 + # which was filed with jemalloc in jemalloc/jemalloc#83 which was also + # reported to MinGW: http://sourceforge.net/p/mingw-w64/bugs/395/ + # + # When updating jemalloc to 4.0, however, it was found that binaries would + # exit with the status code STATUS_RESOURCE_NOT_OWNED indicating that a thread + # was unlocking a mutex it never locked. Disabling this "lazy lock" option + # seems to fix the issue, but it was enabled by default for MinGW targets in + # 13473c7 for jemalloc. + # + # As a result of all that, force disabling lazy lock on Windows, and after + # reading some code it at least *appears* that the initialization of mutexes + # is otherwise ok in jemalloc, so shouldn't cause problems hopefully... # - # https://sourceforge.net/p/mingw-w64/bugs/395/ - JEMALLOC_ARGS_$(1) := --enable-lazy-lock + # tl;dr: make windows behave like other platforms by disabling lazy locking, + # but requires passing an option due to a historical default with + # jemalloc. + JEMALLOC_ARGS_$(1) := --disable-lazy-lock else ifeq ($(OSTYPE_$(1)), apple-ios) JEMALLOC_ARGS_$(1) := --disable-tls else ifeq ($(findstring android, $(OSTYPE_$(1))), android) diff --git a/src/jemalloc b/src/jemalloc index e24a1a025a1f2..f84e30927284b 160000 --- a/src/jemalloc +++ b/src/jemalloc @@ -1 +1 @@ -Subproject commit e24a1a025a1f214e40eedafe3b9c7b1d69937922 +Subproject commit f84e30927284b0c500ed3eaf09e8e159da20ddaf From c0321ed9287fbcfad4e17ae9a6a0c5f481ca821a Mon Sep 17 00:00:00 2001 From: Peter Atashian Date: Mon, 21 Dec 2015 20:44:48 -0500 Subject: [PATCH 11/24] Fix Universal CRT detection on weird setups Checks for a `10.` prefix on the subfolder Signed-off-by: Peter Atashian --- src/librustc_trans/back/msvc/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/librustc_trans/back/msvc/mod.rs b/src/librustc_trans/back/msvc/mod.rs index 3b5b94381b372..6f0baa86579e0 100644 --- a/src/librustc_trans/back/msvc/mod.rs +++ b/src/librustc_trans/back/msvc/mod.rs @@ -152,8 +152,15 @@ pub fn link_exe_cmd(sess: &Session) -> Command { }).and_then(|root| { fs::read_dir(Path::new(&root).join("Lib")).ok() }).and_then(|readdir| { - let mut dirs: Vec<_> = readdir.filter_map(|dir| dir.ok()) - .map(|dir| dir.path()).collect(); + let mut dirs: Vec<_> = readdir.filter_map(|dir| { + dir.ok() + }).map(|dir| { + dir.path() + }).filter(|dir| { + dir.components().last().and_then(|c| { + c.as_os_str().to_str() + }).map(|c| c.starts_with("10.")).unwrap_or(false) + }).collect(); dirs.sort(); dirs.pop() }) From 2062fd399b0ca47e961b9dbf4be0971cc9b0da1a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 2 Dec 2015 10:31:29 -0800 Subject: [PATCH 12/24] std: Remove rust_builtin C support library All these definitions can now be written in Rust, so do so! --- mk/crates.mk | 2 +- mk/rt.mk | 4 +- src/liballoc_jemalloc/lib.rs | 11 + src/libstd/rtdeps.rs | 5 - src/libstd/sys/unix/fs.rs | 110 ++++---- src/libstd/sys/unix/os.rs | 67 +++-- src/libtest/lib.rs | 41 ++- src/rt/rust_android_dummy.c | 112 --------- src/rt/rust_builtin.c | 470 ----------------------------------- 9 files changed, 156 insertions(+), 666 deletions(-) delete mode 100644 src/rt/rust_android_dummy.c delete mode 100644 src/rt/rust_builtin.c diff --git a/mk/crates.mk b/mk/crates.mk index 2b66baed45b94..2597c724da96f 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -71,7 +71,7 @@ DEPS_rustc_bitflags := core DEPS_rustc_unicode := core DEPS_std := core libc rand alloc collections rustc_unicode \ - native:rust_builtin native:backtrace \ + native:backtrace \ alloc_system DEPS_arena := std DEPS_glob := std diff --git a/mk/rt.mk b/mk/rt.mk index 9d12bf39825a6..9dbbcbebb979d 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -35,7 +35,7 @@ # that's per-target so you're allowed to conditionally add files based on the # target. ################################################################################ -NATIVE_LIBS := rust_builtin hoedown miniz rust_test_helpers +NATIVE_LIBS := hoedown miniz rust_test_helpers # $(1) is the target triple define NATIVE_LIBRARIES @@ -50,8 +50,6 @@ NATIVE_DEPS_hoedown_$(1) := hoedown/src/autolink.c \ hoedown/src/stack.c \ hoedown/src/version.c NATIVE_DEPS_miniz_$(1) = miniz.c -NATIVE_DEPS_rust_builtin_$(1) := rust_builtin.c \ - rust_android_dummy.c NATIVE_DEPS_rust_test_helpers_$(1) := rust_test_helpers.c ################################################################################ diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index 413eac3cf7942..eaaa9391d3115 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -108,3 +108,14 @@ pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize { let flags = align_to_flags(align); unsafe { je_nallocx(size as size_t, flags) as usize } } + +// These symbols are used by jemalloc on android but the really old android +// we're building on doesn't have them defined, so just make sure the symbols +// are available. +#[no_mangle] +#[cfg(target_os = "android")] +pub extern fn pthread_atfork(_prefork: *mut u8, + _postfork_parent: *mut u8, + _postfork_child: *mut u8) -> i32 { + 0 +} diff --git a/src/libstd/rtdeps.rs b/src/libstd/rtdeps.rs index 8383b3ec18972..9b1046f39a7b3 100644 --- a/src/libstd/rtdeps.rs +++ b/src/libstd/rtdeps.rs @@ -12,11 +12,6 @@ //! the standard library This varies per-platform, but these libraries are //! necessary for running libstd. -// A few small shims in C that haven't been translated to Rust yet -#[cfg(all(not(test), not(windows)))] -#[link(name = "rust_builtin", kind = "static")] -extern {} - // LLVM implements the `frem` instruction as a call to `fmod`, which lives in // libm. Hence, we must explicitly link to it. // diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index e634c10d8b7dc..e8575a6c21cf1 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -14,7 +14,8 @@ use os::unix::prelude::*; use ffi::{CString, CStr, OsString, OsStr}; use fmt; use io::{self, Error, ErrorKind, SeekFrom}; -use libc::{self, c_int, off_t, c_char, mode_t}; +use libc::{dirent, readdir_r}; +use libc::{self, c_int, off_t, mode_t}; use mem; use path::{Path, PathBuf}; use ptr; @@ -43,7 +44,7 @@ unsafe impl Send for Dir {} unsafe impl Sync for Dir {} pub struct DirEntry { - buf: Vec, // actually *mut libc::dirent + entry: dirent, root: Arc, } @@ -126,32 +127,22 @@ impl Iterator for ReadDir { type Item = io::Result; fn next(&mut self) -> Option> { - extern { - fn rust_dirent_t_size() -> libc::size_t; - } - - let mut buf: Vec = Vec::with_capacity(unsafe { - rust_dirent_t_size() - }); - let ptr = buf.as_mut_ptr() as *mut libc::dirent; - - let mut entry_ptr = ptr::null_mut(); - loop { - if unsafe { libc::readdir_r(self.dirp.0, ptr, &mut entry_ptr) != 0 } { - return Some(Err(Error::last_os_error())) - } - if entry_ptr.is_null() { - return None - } - - let entry = DirEntry { - buf: buf, + unsafe { + let mut ret = DirEntry { + entry: mem::zeroed(), root: self.root.clone() }; - if entry.name_bytes() == b"." || entry.name_bytes() == b".." { - buf = entry.buf; - } else { - return Some(Ok(entry)) + let mut entry_ptr = ptr::null_mut(); + loop { + if readdir_r(self.dirp.0, &mut ret.entry, &mut entry_ptr) != 0 { + return Some(Err(Error::last_os_error())) + } + if entry_ptr.is_null() { + return None + } + if ret.name_bytes() != b"." && ret.name_bytes() != b".." { + return Some(Ok(ret)) + } } } } @@ -166,7 +157,7 @@ impl Drop for Dir { impl DirEntry { pub fn path(&self) -> PathBuf { - self.root.join(::from_bytes(self.name_bytes())) + self.root.join(OsStr::from_bytes(self.name_bytes())) } pub fn file_name(&self) -> OsString { @@ -178,35 +169,64 @@ impl DirEntry { } pub fn file_type(&self) -> io::Result { - extern { - fn rust_dir_get_mode(ptr: *mut libc::dirent) -> c_int; - } - unsafe { - match rust_dir_get_mode(self.dirent()) { - -1 => lstat(&self.path()).map(|m| m.file_type()), - n => Ok(FileType { mode: n as mode_t }), - } + match self.entry.d_type { + libc::DT_CHR => Ok(FileType { mode: libc::S_IFCHR }), + libc::DT_FIFO => Ok(FileType { mode: libc::S_IFIFO }), + libc::DT_LNK => Ok(FileType { mode: libc::S_IFLNK }), + libc::DT_REG => Ok(FileType { mode: libc::S_IFREG }), + libc::DT_SOCK => Ok(FileType { mode: libc::S_IFSOCK }), + libc::DT_DIR => Ok(FileType { mode: libc::S_IFDIR }), + libc::DT_BLK => Ok(FileType { mode: libc::S_IFBLK }), + _ => lstat(&self.path()).map(|m| m.file_type()), } } + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "linux"))] pub fn ino(&self) -> raw::ino_t { - extern { - fn rust_dir_get_ino(ptr: *mut libc::dirent) -> raw::ino_t; - } - unsafe { rust_dir_get_ino(self.dirent()) } + self.entry.d_ino + } + + #[cfg(target_os = "android")] + pub fn ino(&self) -> raw::ino_t { + self.entry.d_ino as raw::ino_t + } + + #[cfg(any(target_os = "freebsd", + target_os = "openbsd", + target_os = "bitrig", + target_os = "netbsd", + target_os = "dragonfly"))] + pub fn ino(&self) -> raw::ino_t { + self.entry.d_fileno } + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "netbsd"))] fn name_bytes(&self) -> &[u8] { - extern { - fn rust_list_dir_val(ptr: *mut libc::dirent) -> *const c_char; + unsafe { + ::slice::from_raw_parts(self.entry.d_name.as_ptr() as *const u8, + self.entry.d_namlen as usize) } + } + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd"))] + fn name_bytes(&self) -> &[u8] { unsafe { - CStr::from_ptr(rust_list_dir_val(self.dirent())).to_bytes() + ::slice::from_raw_parts(self.entry.d_name.as_ptr() as *const u8, + self.entry.d_namelen as usize) } } - - fn dirent(&self) -> *mut libc::dirent { - self.buf.as_ptr() as *mut _ + #[cfg(any(target_os = "android", + target_os = "linux"))] + fn name_bytes(&self) -> &[u8] { + unsafe { + CStr::from_ptr(self.entry.d_name.as_ptr()).to_bytes() + } } } diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 12b9d6191a05f..c62960d74cb1c 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -38,12 +38,17 @@ static ENV_LOCK: StaticMutex = StaticMutex::new(); /// Returns the platform-specific value of errno pub fn errno() -> i32 { extern { - #[cfg_attr(any(target_os = "linux", target_os = "android"), link_name = "__errno_location")] - #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd", + #[cfg_attr(any(target_os = "linux"), link_name = "__errno_location")] + #[cfg_attr(any(target_os = "bitrig", + target_os = "netbsd", + target_os = "openbsd", + target_os = "android", target_env = "newlib"), link_name = "__errno")] #[cfg_attr(target_os = "dragonfly", link_name = "__dfly_error")] - #[cfg_attr(any(target_os = "macos", target_os = "ios", target_os = "freebsd"), + #[cfg_attr(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd"), link_name = "__error")] fn errno_location() -> *const c_int; } @@ -173,17 +178,19 @@ pub fn current_exe() -> io::Result { libc::KERN_PROC_PATHNAME as c_int, -1 as c_int]; let mut sz: libc::size_t = 0; - let err = libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, - ptr::null_mut(), &mut sz, ptr::null_mut(), - 0 as libc::size_t); - if err != 0 { return Err(io::Error::last_os_error()); } - if sz == 0 { return Err(io::Error::last_os_error()); } + try!(cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, + ptr::null_mut(), &mut sz, ptr::null_mut(), + 0 as libc::size_t))); + if sz == 0 { + return Err(io::Error::last_os_error()) + } let mut v: Vec = Vec::with_capacity(sz as usize); - let err = libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, - v.as_mut_ptr() as *mut libc::c_void, &mut sz, - ptr::null_mut(), 0 as libc::size_t); - if err != 0 { return Err(io::Error::last_os_error()); } - if sz == 0 { return Err(io::Error::last_os_error()); } + try!(cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint, + v.as_mut_ptr() as *mut libc::c_void, &mut sz, + ptr::null_mut(), 0 as libc::size_t))); + if sz == 0 { + return Err(io::Error::last_os_error()); + } v.set_len(sz as usize - 1); // chop off trailing NUL Ok(PathBuf::from(OsString::from_vec(v))) } @@ -201,22 +208,28 @@ pub fn current_exe() -> io::Result { #[cfg(any(target_os = "bitrig", target_os = "openbsd"))] pub fn current_exe() -> io::Result { - use sync::StaticMutex; - static LOCK: StaticMutex = StaticMutex::new(); - - extern { - fn rust_current_exe() -> *const c_char; - } - - let _guard = LOCK.lock(); - unsafe { - let v = rust_current_exe(); - if v.is_null() { - Err(io::Error::last_os_error()) + let mut mib = [libc::CTL_KERN, + libc::KERN_PROC_ARGS, + libc::getpid(), + libc::KERN_PROC_ARGV]; + let mib = mib.as_mut_ptr(); + let mut argv_len = 0; + try!(cvt(libc::sysctl(mib, 4, 0 as *mut _, &mut argv_len, + 0 as *mut _, 0))); + let mut argv = Vec::<*const libc::c_char>::with_capacity(argv_len as usize); + try!(cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _, + &mut argv_len, 0 as *mut _, 0))); + argv.set_len(argv_len as usize); + if argv[0].is_null() { + return Err(io::Error::new(io::ErrorKind::Other, + "no current exe available")) + } + let argv0 = CStr::from_ptr(argv[0]).to_bytes(); + if argv0[0] == b'.' || argv0.iter().any(|b| *b == b'/') { + ::fs::canonicalize(OsStr::from_bytes(argv0)) } else { - let vec = CStr::from_ptr(v).to_bytes().to_vec(); - Ok(PathBuf::from(OsString::from_vec(vec))) + Ok(PathBuf::from(OsStr::from_bytes(argv0))) } } } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 20d7c66cf1221..a844bdf1351d9 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -906,10 +906,45 @@ fn get_concurrency() -> usize { } } - #[cfg(unix)] + #[cfg(any(target_os = "linux", + target_os = "macos", + target_os = "ios", + target_os = "android"))] fn num_cpus() -> usize { - extern { fn rust_get_num_cpus() -> libc::uintptr_t; } - unsafe { rust_get_num_cpus() as usize } + unsafe { + libc::sysconf(libc::_SC_NPROCESSORS_ONLN) as usize + } + } + + #[cfg(any(target_os = "freebsd", + target_os = "dragonfly", + target_os = "bitrig", + target_os = "openbsd", + target_os = "netbsd"))] + fn num_cpus() -> usize { + let mut cpus: libc::c_uint = 0; + let mut CPUS_SIZE = std::mem::size_of_val(&cpus); + let mut mib = [libc::CTL_HW, libc::HW_AVAILCPU, 0, 0]; + + unsafe { + libc::sysctl(mib.as_mut_ptr(), 2, + &mut cpus as *mut _ as *mut _, + &mut CPUS_SIZE as *mut _ as *mut _, + 0 as *mut _, 0); + } + if cpus < 1 { + mib[1] = HW_NCPU; + unsafe { + libc::sysctl(mib.as_mut_ptr(), 2, + &mut cpus as *mut _ as *mut _, + &mut CPUS_SIZE as *mut _ as *mut _, + 0 as *mut _, 0); + } + if cpus < 1 { + cpus = 1; + } + } + cpus as usize } } diff --git a/src/rt/rust_android_dummy.c b/src/rt/rust_android_dummy.c deleted file mode 100644 index c322dc6706f72..0000000000000 --- a/src/rt/rust_android_dummy.c +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifdef __ANDROID__ - -#include "rust_android_dummy.h" -#include -#include - -int backtrace(void **array, int size) { return 0; } - -char **backtrace_symbols(void *const *array, int size) { return 0; } - -void backtrace_symbols_fd (void *const *array, int size, int fd) {} - -volatile int* __errno_location() { - return &errno; -} - -float log2f(float f) -{ - return logf( f ) / logf( 2 ); -} - -double log2( double n ) -{ - return log( n ) / log( 2 ); -} - -double exp10( double x ) -{ - return pow( 10, x ); -} - -void telldir() -{ -} - -void seekdir() -{ -} - -void mkfifo() -{ -} - -void abs() -{ -} - -void labs() -{ -} - -void rand() -{ -} - -void srand() -{ -} - -void atof() -{ -} - -int glob(const char *pattern, - int flags, - int (*errfunc) (const char *epath, int eerrno), - glob_t *pglob) -{ - return 0; -} - -void globfree(glob_t *pglob) -{ -} - -int pthread_atfork(void (*prefork)(void), - void (*postfork_parent)(void), - void (*postfork_child)(void)) -{ - return 0; -} - -int mlockall(int flags) -{ - return 0; -} - -int munlockall(void) -{ - return 0; -} - -int shm_open(const char *name, int oflag, mode_t mode) -{ - return 0; -} - -int shm_unlink(const char *name) -{ - return 0; -} - -int posix_madvise(void *addr, size_t len, int advice) -{ - return 0; -} - -#endif diff --git a/src/rt/rust_builtin.c b/src/rt/rust_builtin.c deleted file mode 100644 index c2168d785b995..0000000000000 --- a/src/rt/rust_builtin.c +++ /dev/null @@ -1,470 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#if !defined(_WIN32) - -#include -#include -#include -#include -#include - - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __APPLE__ -#include -#include - -#if !(TARGET_OS_IPHONE) -#include -#endif -#endif - -char* -rust_list_dir_val(struct dirent* entry_ptr) { - return entry_ptr->d_name; -} - -// Android's struct dirent does have d_type from the very beginning -// (android-3). _DIRENT_HAVE_D_TYPE is not defined all the way to android-21 -// though... -#if defined(__ANDROID__) -# define _DIRENT_HAVE_D_TYPE -#endif - -int -rust_dir_get_mode(struct dirent* entry_ptr) { -#if defined(_DIRENT_HAVE_D_TYPE) || defined(__APPLE__) - switch (entry_ptr->d_type) { - case DT_BLK: return S_IFBLK; - case DT_CHR: return S_IFCHR; - case DT_FIFO: return S_IFIFO; - case DT_LNK: return S_IFLNK; - case DT_REG: return S_IFREG; - case DT_SOCK: return S_IFSOCK; - case DT_DIR: return S_IFDIR; - } -#endif - return -1; -} - -ino_t -rust_dir_get_ino(struct dirent* entry_ptr) { - return entry_ptr->d_ino; -} - -DIR* -rust_opendir(char *dirname) { - return opendir(dirname); -} - -int -rust_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) { - return readdir_r(dirp, entry, result); -} - -size_t -rust_dirent_t_size() { - return sizeof(struct dirent); -} - -#if defined(__BSD__) -static int -get_num_cpus() { - /* swiped from http://stackoverflow.com/questions/150355/ - programmatically-find-the-number-of-cores-on-a-machine */ - - unsigned int numCPU; - int mib[4]; - size_t len = sizeof(numCPU); - - /* set the mib for hw.ncpu */ - mib[0] = CTL_HW; - mib[1] = HW_AVAILCPU; // alternatively, try HW_NCPU; - - /* get the number of CPUs from the system */ - sysctl(mib, 2, &numCPU, &len, NULL, 0); - - if( numCPU < 1 ) { - mib[1] = HW_NCPU; - sysctl( mib, 2, &numCPU, &len, NULL, 0 ); - - if( numCPU < 1 ) { - numCPU = 1; - } - } - return numCPU; -} -#elif defined(__GNUC__) -static int -get_num_cpus() { - return sysconf(_SC_NPROCESSORS_ONLN); -} -#endif - -uintptr_t -rust_get_num_cpus() { - return get_num_cpus(); -} - -#if defined(__DragonFly__) -#include -// In DragonFly __error() is an inline function and as such -// no symbol exists for it. -int *__dfly_error(void) { return __error(); } -#endif - -#if defined(__Bitrig__) -#include -#include -#include -#include - -int rust_get_path(void *p, size_t* sz) -{ - int mib[4]; - char *eq = NULL; - char *key = NULL; - char *val = NULL; - char **menv = NULL; - size_t maxlen, len; - int nenv = 0; - int i; - - if ((p == NULL) && (sz == NULL)) - return -1; - - /* get the argv array */ - mib[0] = CTL_KERN; - mib[1] = KERN_PROC_ARGS; - mib[2] = getpid(); - mib[3] = KERN_PROC_ENV; - - /* get the number of bytes needed to get the env */ - maxlen = 0; - if (sysctl(mib, 4, NULL, &maxlen, NULL, 0) == -1) - return -1; - - /* allocate the buffer */ - if ((menv = calloc(maxlen, sizeof(char))) == NULL) - return -1; - - /* get the env array */ - if (sysctl(mib, 4, menv, &maxlen, NULL, 0) == -1) - { - free(menv); - return -1; - } - - mib[3] = KERN_PROC_NENV; - len = sizeof(int); - /* get the length of env array */ - if (sysctl(mib, 4, &nenv, &len, NULL, 0) == -1) - { - free(menv); - return -1; - } - - /* find _ key and resolve the value */ - for (i = 0; i < nenv; i++) - { - if ((eq = strstr(menv[i], "=")) == NULL) - continue; - - key = menv[i]; - val = eq + 1; - *eq = '\0'; - - if (strncmp(key, "PATH", maxlen) != 0) - continue; - - if (p == NULL) - { - /* return the length of the value + NUL */ - *sz = strnlen(val, maxlen) + 1; - free(menv); - return 0; - } - else - { - /* copy *sz bytes to the output buffer */ - memcpy(p, val, *sz); - free(menv); - return 0; - } - } - - free(menv); - return -1; -} - -int rust_get_path_array(void * p, size_t * sz) -{ - char *path, *str; - char **buf; - int i, num; - size_t len; - - if ((p == NULL) && (sz == NULL)) - return -1; - - /* get the length of the PATH value */ - if (rust_get_path(NULL, &len) == -1) - return -1; - - if (len == 0) - return -1; - - /* allocate the buffer */ - if ((path = calloc(len, sizeof(char))) == NULL) - return -1; - - /* get the PATH value */ - if (rust_get_path(path, &len) == -1) - { - free(path); - return -1; - } - - /* count the number of parts in the PATH */ - num = 1; - for(str = path; *str != '\0'; str++) - { - if (*str == ':') - num++; - } - - /* calculate the size of the buffer for the 2D array */ - len = (num * sizeof(char*) + 1) + strlen(path) + 1; - - if (p == NULL) - { - free(path); - *sz = len; - return 0; - } - - /* make sure we have enough buffer space */ - if (*sz < len) - { - free(path); - return -1; - } - - /* zero out the buffer */ - buf = (char**)p; - memset(buf, 0, *sz); - - /* copy the data into the right place */ - str = p + ((num+1) * sizeof(char*)); - memcpy(str, path, strlen(path)); - - /* parse the path into it's parts */ - for (i = 0; i < num && (buf[i] = strsep(&str, ":")) != NULL; i++) {;} - buf[num] = NULL; - - free(path); - return 0; -} - -int rust_get_argv_zero(void* p, size_t* sz) -{ - int mib[4]; - char **argv = NULL; - size_t len; - - if ((p == NULL) && (sz == NULL)) - return -1; - - /* get the argv array */ - mib[0] = CTL_KERN; - mib[1] = KERN_PROC_ARGS; - mib[2] = getpid(); - mib[3] = KERN_PROC_ARGV; - - /* request KERN_PROC_ARGV size */ - len = 0; - if (sysctl(mib, 4, NULL, &len, NULL, 0) == -1) - return -1; - - /* allocate buffer to receive the values */ - if ((argv = malloc(len)) == NULL) - return -1; - - /* get the argv array */ - if (sysctl(mib, 4, argv, &len, NULL, 0) == -1) - { - free(argv); - return -1; - } - - /* get length of argv[0] */ - len = strnlen(argv[0], len) + 1; - - if (p == NULL) - { - *sz = len; - free(argv); - return 0; - } - - if (*sz < len) - { - free(argv); - return -1; - } - - memcpy(p, argv[0], len); - free(argv); - return 0; -} - -const char * rust_current_exe() -{ - static char *self = NULL; - char *argv0; - char **paths; - size_t sz; - int i; - /* If `PATH_MAX` is defined on the platform, `realpath` will truncate the - * resolved path up to `PATH_MAX`. While this can make the resolution fail if - * the executable is placed in a deep path, the usage of a buffer whose - * length depends on `PATH_MAX` is still memory safe. */ - char buf[2*PATH_MAX], exe[PATH_MAX]; - - if (self != NULL) - return self; - - if (rust_get_argv_zero(NULL, &sz) == -1) - return NULL; - if ((argv0 = calloc(sz, sizeof(char))) == NULL) - return NULL; - if (rust_get_argv_zero(argv0, &sz) == -1) - { - free(argv0); - return NULL; - } - - /* if argv0 is a relative or absolute path, resolve it with realpath */ - if ((*argv0 == '.') || (*argv0 == '/') || (strstr(argv0, "/") != NULL)) - { - self = realpath(argv0, NULL); - free(argv0); - return self; - } - - /* get the path array */ - if (rust_get_path_array(NULL, &sz) == -1) - { - free(argv0); - return NULL; - } - if ((paths = calloc(sz, sizeof(char))) == NULL) - { - free(argv0); - return NULL; - } - if (rust_get_path_array(paths, &sz) == -1) - { - free(argv0); - free(paths); - return NULL; - } - - for(i = 0; paths[i] != NULL; i++) - { - snprintf(buf, 2*PATH_MAX, "%s/%s", paths[i], argv0); - if (realpath(buf, exe) == NULL) - continue; - - if (access(exe, F_OK | X_OK) == -1) - continue; - - self = strdup(exe); - free(argv0); - free(paths); - return self; - } - - free(argv0); - free(paths); - return NULL; -} - -#elif defined(__OpenBSD__) - -#include -#include -#include - -const char * rust_current_exe() { - static char *self = NULL; - - if (self == NULL) { - int mib[4]; - char **argv = NULL; - size_t argv_len; - - /* initialize mib */ - mib[0] = CTL_KERN; - mib[1] = KERN_PROC_ARGS; - mib[2] = getpid(); - mib[3] = KERN_PROC_ARGV; - - /* request KERN_PROC_ARGV size */ - argv_len = 0; - if (sysctl(mib, 4, NULL, &argv_len, NULL, 0) == -1) - return (NULL); - - /* allocate size */ - if ((argv = malloc(argv_len)) == NULL) - return (NULL); - - /* request KERN_PROC_ARGV */ - if (sysctl(mib, 4, argv, &argv_len, NULL, 0) == -1) { - free(argv); - return (NULL); - } - - /* get realpath if possible */ - if ((argv[0] != NULL) && ((*argv[0] == '.') || (*argv[0] == '/') - || (strstr(argv[0], "/") != NULL))) - - self = realpath(argv[0], NULL); - else - self = NULL; - - /* cleanup */ - free(argv); - } - - return (self); -} - -#endif - -#endif // !defined(_WIN32) - -// -// Local Variables: -// mode: C++ -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// End: -// From f89581e65fcb87c18e696b58b0353f1de8ac691a Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 11:14:14 +0100 Subject: [PATCH 13/24] Fix style nitpicks from travis Remove tabs --- src/jemalloc | 2 +- src/libcore/char.rs | 4 ++-- src/librustc/front/map/definitions.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jemalloc b/src/jemalloc index f84e30927284b..e24a1a025a1f2 160000 --- a/src/jemalloc +++ b/src/jemalloc @@ -1 +1 @@ -Subproject commit f84e30927284b0c500ed3eaf09e8e159da20ddaf +Subproject commit e24a1a025a1f214e40eedafe3b9c7b1d69937922 diff --git a/src/libcore/char.rs b/src/libcore/char.rs index d70f080e9bab7..cf70de7788e48 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -538,8 +538,8 @@ impl Iterator for EscapeDefault { } } - fn count(self) -> usize { - match self.state { + fn count(self) -> usize { + match self.state { EscapeDefaultState::Char(_) => 1, EscapeDefaultState::Unicode(iter) => iter.count(), EscapeDefaultState::Done => 0, diff --git a/src/librustc/front/map/definitions.rs b/src/librustc/front/map/definitions.rs index 6e15059748226..4ca6eb22ff552 100644 --- a/src/librustc/front/map/definitions.rs +++ b/src/librustc/front/map/definitions.rs @@ -16,7 +16,7 @@ use syntax::ast; use syntax::parse::token::InternedString; use util::nodemap::NodeMap; -/// A definition, that defines are +/// A definition #[derive(Clone)] pub struct Definitions { data: Vec, @@ -101,7 +101,7 @@ pub enum DefPathData { /// A struct field Field(hir::StructFieldKind), /// Implicit ctor for a tuple-like struct - StructCtor, + StructCtor, /// Initializer for a constant Initializer, /// A pattern binding From 05df0491a5178152322793172046e0798b62f637 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 15:17:09 +0100 Subject: [PATCH 14/24] Update submodules --- src/jemalloc | 2 +- src/liblibc | 2 +- src/llvm | 2 +- src/rt/hoedown | 2 +- src/rust-installer | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/jemalloc b/src/jemalloc index e24a1a025a1f2..a344dd01c74a7 160000 --- a/src/jemalloc +++ b/src/jemalloc @@ -1 +1 @@ -Subproject commit e24a1a025a1f214e40eedafe3b9c7b1d69937922 +Subproject commit a344dd01c74a7e385087819046105f689931905d diff --git a/src/liblibc b/src/liblibc index e0c0bf439add6..fb83189000026 160000 --- a/src/liblibc +++ b/src/liblibc @@ -1 +1 @@ -Subproject commit e0c0bf439add63a6a25a25ba47e4aec9547bf9af +Subproject commit fb8318900002678298f050c8581c68baf187e648 diff --git a/src/llvm b/src/llvm index cde1ed3196ba9..2e9f0d21fe321 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit cde1ed3196ba9b39bcf028e06e08a8722113a5cb +Subproject commit 2e9f0d21fe321849a4759a01fc28eae82ef196d6 diff --git a/src/rt/hoedown b/src/rt/hoedown index 4638c60dedfa5..49c64b3cb5999 160000 --- a/src/rt/hoedown +++ b/src/rt/hoedown @@ -1 +1 @@ -Subproject commit 4638c60dedfa581fd5fa7c6420d8f32274c9ca0b +Subproject commit 49c64b3cb5999cad0118fa5cb0cc60f5fcc70493 diff --git a/src/rust-installer b/src/rust-installer index c37d3747da75c..4915c75325333 160000 --- a/src/rust-installer +++ b/src/rust-installer @@ -1 +1 @@ -Subproject commit c37d3747da75c280237dc2d6b925078e69555499 +Subproject commit 4915c7532533319939c18033c62db875717a4d84 From 7db394a76f055e481717c14d135a79fdcf0e2a36 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 15:55:20 +0100 Subject: [PATCH 15/24] Add is_empty to OsStr, rename path_extras to os_extras, don\'t go through the unicode validity checking on Windows --- src/libstd/ffi/os_str.rs | 5 +++++ src/libstd/path.rs | 8 ++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 90b108e677072..79f1f7acd57cd 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -283,6 +283,11 @@ impl OsStr { self.to_bytes().and_then(|b| CString::new(b).ok()) } + #[unstable(feature = "os_extras", reason = "recently added")] + pub fn is_empty(&self) -> bool { + self.inner.inner.is_empty() + } + /// Gets the underlying byte representation. /// /// Note: it is *crucial* that this API is private, to avoid diff --git a/src/libstd/path.rs b/src/libstd/path.rs index db726723f53a7..fc2423930822d 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1873,13 +1873,9 @@ impl Path { /// /// assert!(!path.is_empty()); /// ``` - #[unstable(feature = "path_extras", reason = "recently added", issue = "30259")] + #[unstable(feature = "os_extras", reason = "recently added", issue = "30259")] pub fn is_empty(&self) -> bool { - if let Some(b) = self.inner.to_bytes() { - b.is_empty() - } else { - true - } + self.inner.is_empty() } } From 1448ce976d2d8d9ce03e9d4dc85e02a057c9b789 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 20:01:50 +0100 Subject: [PATCH 16/24] Downgrade submodules --- src/compiler-rt | 2 +- src/jemalloc | 2 +- src/liblibc | 2 +- src/libstd/path.rs | 3 +-- src/llvm | 2 +- src/rt/hoedown | 2 +- src/rust-installer | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/compiler-rt b/src/compiler-rt index 46081ede32546..b6087e82ba138 160000 --- a/src/compiler-rt +++ b/src/compiler-rt @@ -1 +1 @@ -Subproject commit 46081ede32546303dedf23dcb5f4c5ba429582d0 +Subproject commit b6087e82ba1384c4af3adf2dc68e92316f0d4caf diff --git a/src/jemalloc b/src/jemalloc index a344dd01c74a7..f84e30927284b 160000 --- a/src/jemalloc +++ b/src/jemalloc @@ -1 +1 @@ -Subproject commit a344dd01c74a7e385087819046105f689931905d +Subproject commit f84e30927284b0c500ed3eaf09e8e159da20ddaf diff --git a/src/liblibc b/src/liblibc index fb83189000026..e0c0bf439add6 160000 --- a/src/liblibc +++ b/src/liblibc @@ -1 +1 @@ -Subproject commit fb8318900002678298f050c8581c68baf187e648 +Subproject commit e0c0bf439add63a6a25a25ba47e4aec9547bf9af diff --git a/src/libstd/path.rs b/src/libstd/path.rs index fc2423930822d..8f8b032735c87 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1861,8 +1861,7 @@ impl Path { fs::metadata(self).map(|m| m.is_dir()).unwrap_or(false) } - /// Checks if the path buffer is empty. On Windows, it will return false if the inner string is - /// invalid unicode. On Unix, this is a no-op. + /// Checks if the path buffer is empty. /// /// # Examples /// diff --git a/src/llvm b/src/llvm index 2e9f0d21fe321..3564439515985 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 2e9f0d21fe321849a4759a01fc28eae82ef196d6 +Subproject commit 3564439515985dc1cc0d77057ed00901635a80ad diff --git a/src/rt/hoedown b/src/rt/hoedown index 49c64b3cb5999..4638c60dedfa5 160000 --- a/src/rt/hoedown +++ b/src/rt/hoedown @@ -1 +1 @@ -Subproject commit 49c64b3cb5999cad0118fa5cb0cc60f5fcc70493 +Subproject commit 4638c60dedfa581fd5fa7c6420d8f32274c9ca0b diff --git a/src/rust-installer b/src/rust-installer index 4915c75325333..c37d3747da75c 160000 --- a/src/rust-installer +++ b/src/rust-installer @@ -1 +1 @@ -Subproject commit 4915c7532533319939c18033c62db875717a4d84 +Subproject commit c37d3747da75c280237dc2d6b925078e69555499 From cceeb8fa6cb4d520eff4bbd8cfd6dde319aa869a Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 20:13:37 +0100 Subject: [PATCH 17/24] Fix introduced error --- src/libcore/char.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libcore/char.rs b/src/libcore/char.rs index cf70de7788e48..e850692db8dff 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -555,7 +555,11 @@ impl Iterator for EscapeDefault { EscapeDefaultState::Unicode(ref mut i) => return iter.nth(n), }; - let start = self.get_offset(); + let start = if let Some(x) = self.get_offset() { + x + } else { + return None; + }; let idx = start + n; // Update state From d410e67c52398e3f484fc19a38b1644f8490dc81 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 20:13:37 +0100 Subject: [PATCH 18/24] Fix introduced error --- src/libcore/char.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/libcore/char.rs b/src/libcore/char.rs index cf70de7788e48..10b75c1a94336 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -552,21 +552,25 @@ impl Iterator for EscapeDefault { EscapeDefaultState::Backslash(c) => c, EscapeDefaultState::Char(c) => c, EscapeDefaultState::Done => return None, - EscapeDefaultState::Unicode(ref mut i) => return iter.nth(n), + EscapeDefaultState::Unicode(ref mut i) => return i.nth(n), }; - let start = self.get_offset(); + let start = if let Some(x) = self.get_offset() { + x + } else { + return None; + }; let idx = start + n; // Update state self.state = match idx { - 0 => EscapeDefaultState::Char(c), + 0 => EscapeDefaultState::Char(ch), _ => EscapeDefaultState::Done, }; match idx { 0 => Some('\\'), - 1 => Some(c), + 1 => Some(ch), _ => None, } } @@ -580,6 +584,18 @@ impl Iterator for EscapeDefault { } } +#[test] +fn ed_iterator_specializations() { + use super::EscapeDefault; + + /// Check counting + assert_eq!('\n'.escape_default().count(), 2); + assert_eq!('c'.escape_default().count(), 1); + assert_eq!(' '.escape_default().count(), 1); + assert_eq!('\\'.escape_default().count(), 2); +} + + impl EscapeDefault { fn get_offset(&self) -> Option { match self.state { From 7c59d0c5a90dca7b50ddb665b15ee4ac86e28be2 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 20:13:37 +0100 Subject: [PATCH 19/24] Fix introduced error Fix introduced error --- src/libcore/char.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/libcore/char.rs b/src/libcore/char.rs index cf70de7788e48..10b75c1a94336 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -552,21 +552,25 @@ impl Iterator for EscapeDefault { EscapeDefaultState::Backslash(c) => c, EscapeDefaultState::Char(c) => c, EscapeDefaultState::Done => return None, - EscapeDefaultState::Unicode(ref mut i) => return iter.nth(n), + EscapeDefaultState::Unicode(ref mut i) => return i.nth(n), }; - let start = self.get_offset(); + let start = if let Some(x) = self.get_offset() { + x + } else { + return None; + }; let idx = start + n; // Update state self.state = match idx { - 0 => EscapeDefaultState::Char(c), + 0 => EscapeDefaultState::Char(ch), _ => EscapeDefaultState::Done, }; match idx { 0 => Some('\\'), - 1 => Some(c), + 1 => Some(ch), _ => None, } } @@ -580,6 +584,18 @@ impl Iterator for EscapeDefault { } } +#[test] +fn ed_iterator_specializations() { + use super::EscapeDefault; + + /// Check counting + assert_eq!('\n'.escape_default().count(), 2); + assert_eq!('c'.escape_default().count(), 1); + assert_eq!(' '.escape_default().count(), 1); + assert_eq!('\\'.escape_default().count(), 2); +} + + impl EscapeDefault { fn get_offset(&self) -> Option { match self.state { From efbd47fdeb1b819216779273d184c017f3500240 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 20:34:29 +0100 Subject: [PATCH 20/24] Complete the tests --- src/libcore/char.rs | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 10b75c1a94336..0cacfe11c468c 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -588,21 +588,43 @@ impl Iterator for EscapeDefault { fn ed_iterator_specializations() { use super::EscapeDefault; - /// Check counting + // Check counting assert_eq!('\n'.escape_default().count(), 2); assert_eq!('c'.escape_default().count(), 1); assert_eq!(' '.escape_default().count(), 1); assert_eq!('\\'.escape_default().count(), 2); + assert_eq!('\''.escape_default().count(), 2); + + // Check nth + + // Check that OoB is handled correctly + assert_eq!('\n'.escape_default().nth(2), None); + assert_eq!('c'.escape_default().nth(1), None); + assert_eq!(' '.escape_default().nth(1), None); + assert_eq!('\\'.escape_default().nth(2), None); + assert_eq!('\''.escape_default().nth(2), None); + + // Check the first char + assert_eq!('\n'.escape_default().nth(0), Some('\\')); + assert_eq!('c'.escape_default().nth(0), Some('c')); + assert_eq!(' '.escape_default().nth(0), Some(' ')); + assert_eq!('\\'.escape_default().nth(0), Some('\\')); + assert_eq!('\''.escape_default().nth(0), Some('\\')); + + // Check the second char + assert_eq!('\n'.escape_default().nth(1), Some('n')); + assert_eq!('\\'.escape_default().nth(1), Some('\\')); + assert_eq!('\''.escape_default().nth(1), Some('\'')); } impl EscapeDefault { fn get_offset(&self) -> Option { match self.state { - EscapeDefaultState::Backslash(c) => Some(0), - EscapeDefaultState::Char(c) => Some(1), - EscapeDefaultState::Done => None, - EscapeDefaultState::Unicode(ref mut iter) => None, + EscapeDefaultState::Backslash(c) => Some(0), + EscapeDefaultState::Char(c) => Some(1), + EscapeDefaultState::Done => None, + EscapeDefaultState::Unicode(_) => None, } } } From 557371394db76e8316ea1f8b51bf03a9aa89a9e2 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 21:58:31 +0100 Subject: [PATCH 21/24] Add issue to attr --- src/libstd/ffi/os_str.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 79f1f7acd57cd..1f9b9a700cad2 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -283,7 +283,7 @@ impl OsStr { self.to_bytes().and_then(|b| CString::new(b).ok()) } - #[unstable(feature = "os_extras", reason = "recently added")] + #[unstable(feature = "os_extras", reason = "recently added", issue = "30259")] pub fn is_empty(&self) -> bool { self.inner.inner.is_empty() } From 6bd9fe187531ec119936fec8164f360027bee982 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 22:06:16 +0100 Subject: [PATCH 22/24] Documentation --- src/libstd/ffi/os_str.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 1f9b9a700cad2..00ee2134fadaa 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -283,6 +283,7 @@ impl OsStr { self.to_bytes().and_then(|b| CString::new(b).ok()) } + /// Checks if the string is empty. #[unstable(feature = "os_extras", reason = "recently added", issue = "30259")] pub fn is_empty(&self) -> bool { self.inner.inner.is_empty() From 644f258430fa394d0c24eaec5fabad5a5cf659c4 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 22:15:06 +0100 Subject: [PATCH 23/24] Remove unused variables --- src/libcore/char.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 0cacfe11c468c..61f9fa7a2b631 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -621,8 +621,8 @@ fn ed_iterator_specializations() { impl EscapeDefault { fn get_offset(&self) -> Option { match self.state { - EscapeDefaultState::Backslash(c) => Some(0), - EscapeDefaultState::Char(c) => Some(1), + EscapeDefaultState::Backslash(_) => Some(0), + EscapeDefaultState::Char(_) => Some(1), EscapeDefaultState::Done => None, EscapeDefaultState::Unicode(_) => None, } From 1f9941fb6220a4c7198b14b4d57b2ffaa3819a39 Mon Sep 17 00:00:00 2001 From: Ticki Date: Tue, 22 Dec 2015 23:12:02 +0100 Subject: [PATCH 24/24] Added features --- src/libstd/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 4f2236c257ba8..9d58ea0cf775b 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -244,6 +244,7 @@ #![feature(on_unimplemented)] #![feature(oom)] #![feature(optin_builtin_traits)] +#![feature(os_extras)] #![feature(placement_in_syntax)] #![feature(rand)] #![feature(range_inclusive)]