Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

std: Remove public bool,tuple,unit modules #20006

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ pub mod default;

pub mod any;
pub mod atomic;
pub mod bool;
pub mod borrow;
pub mod cell;
pub mod char;
Expand All @@ -120,15 +119,11 @@ pub mod result;
pub mod simd;
pub mod slice;
pub mod str;
pub mod tuple;
pub mod hash;
// FIXME #15320: primitive documentation needs top-level modules, this
// should be `core::tuple::unit`.
#[path = "tuple/unit.rs"]
pub mod unit;
pub mod fmt;

// note: does not need to be public
mod tuple;
mod array;

#[doc(hidden)]
Expand Down
2 changes: 0 additions & 2 deletions src/libcore/tuple/mod.rs → src/libcore/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@
//! assert_eq!(d, (0u32, 0.0f32));
//! ```

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

#[unstable = "this is just a documentation module and should not be part \
of the public api"]
pub use unit;

use clone::Clone;
use cmp::*;
Expand Down
23 changes: 7 additions & 16 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,33 +163,24 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
};
let mut tmp = Vec::new();
for child in m.items.iter_mut() {
let inner = match child.inner {
ModuleItem(ref mut m) => m,
match child.inner {
ModuleItem(..) => {}
_ => continue,
};
}
let prim = match PrimitiveType::find(child.attrs.as_slice()) {
Some(prim) => prim,
None => continue,
};
primitives.push(prim);
let mut i = Item {
tmp.push(Item {
source: Span::empty(),
name: Some(prim.to_url_str().to_string()),
attrs: Vec::new(),
visibility: None,
attrs: child.attrs.clone(),
visibility: Some(ast::Public),
stability: None,
def_id: ast_util::local_def(prim.to_node_id()),
inner: PrimitiveItem(prim),
};
// Push one copy to get indexed for the whole crate, and push a
// another copy in the proper location which will actually get
// documented. The first copy will also serve as a redirect to
// the other copy.
tmp.push(i.clone());
i.visibility = Some(ast::Public);
i.attrs = child.attrs.clone();
inner.items.push(i);

});
}
m.items.extend(tmp.into_iter());
}
Expand Down
3 changes: 1 addition & 2 deletions src/libcore/bool.rs → src/libstd/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
//! The boolean type

#![doc(primitive = "bool")]
#![unstable = "this module is purely for documentation and it will likely be \
removed from the public api"]
#![stable]

11 changes: 6 additions & 5 deletions src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ extern crate rustrt;
// NB: These reexports are in the order they should be listed in rustdoc

pub use core::any;
pub use core::bool;
pub use core::borrow;
pub use core::cell;
pub use core::clone;
Expand All @@ -152,10 +151,6 @@ pub use core::mem;
pub use core::ptr;
pub use core::raw;
pub use core::simd;
pub use core::tuple;
// FIXME #15320: primitive documentation needs top-level modules, this
// should be `std::tuple::unit`.
pub use core::unit;
pub use core::result;
pub use core::option;

Expand Down Expand Up @@ -246,6 +241,12 @@ pub mod comm;
pub mod rt;
mod failure;

// Documentation for primitive types

mod bool;
mod unit;
mod tuple;

// A curious inner-module that's not exported that contains the binding
// 'std' so that macro-expanded references to std::error and such
// can be resolved within libstd.
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
#[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek, BufferPrelude};
#[doc(no_inline)] pub use str::{Str, StrVector, StrPrelude};
#[doc(no_inline)] pub use str::{StrAllocating, UnicodeStrPrelude};
#[doc(no_inline)] pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
#[doc(no_inline)] pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
#[doc(no_inline)] pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
#[doc(no_inline)] pub use core::prelude::{Tuple1, Tuple2, Tuple3, Tuple4};
#[doc(no_inline)] pub use core::prelude::{Tuple5, Tuple6, Tuple7, Tuple8};
#[doc(no_inline)] pub use core::prelude::{Tuple9, Tuple10, Tuple11, Tuple12};
#[doc(no_inline)] pub use slice::AsSlice;
#[doc(no_inline)] pub use slice::{VectorVector, PartialEqSliceExt};
#[doc(no_inline)] pub use slice::{CloneSliceExt, OrdSliceExt, SliceExt};
Expand Down
66 changes: 66 additions & 0 deletions src/libstd/tuple.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! Operations on tuples
//!
//! To access a single element of a tuple one can use the following
//! methods:
//!
//! * `valN` - returns a value of _N_-th element
//! * `refN` - returns a reference to _N_-th element
//! * `mutN` - returns a mutable reference to _N_-th element
//!
//! Indexing starts from zero, so `val0` returns first value, `val1`
//! returns second value, and so on. In general, a tuple with _S_
//! elements provides aforementioned methods suffixed with numbers
//! from `0` to `S-1`. Traits which contain these methods are
//! implemented for tuples with up to 12 elements.
//!
//! If every type inside a tuple implements one of the following
//! traits, then a tuple itself also implements it.
//!
//! * `Clone`
//! * `PartialEq`
//! * `Eq`
//! * `PartialOrd`
//! * `Ord`
//! * `Default`
//!
//! # Examples
//!
//! Using methods:
//!
//! ```
//! #[allow(deprecated)]
//! # fn main() {
//! let pair = ("pi", 3.14f64);
//! assert_eq!(pair.val0(), "pi");
//! assert_eq!(pair.val1(), 3.14f64);
//! # }
//! ```
//!
//! Using traits implemented for tuples:
//!
//! ```
//! use std::default::Default;
//!
//! let a = (1i, 2i);
//! let b = (3i, 4i);
//! assert!(a != b);
//!
//! let c = b.clone();
//! assert!(b == c);
//!
//! let d : (u32, f32) = Default::default();
//! assert_eq!(d, (0u32, 0.0f32));
//! ```

#![doc(primitive = "tuple")]
#![stable]
3 changes: 1 addition & 2 deletions src/libcore/tuple/unit.rs → src/libstd/unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
// except according to those terms.

#![doc(primitive = "unit")]
#![unstable = "this module is purely for documentation and it will likely be \
removed from the public api"]
#![stable]

//! The `()` type, sometimes called "unit" or "nil".
//!
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-9957.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
pub extern crate core; //~ ERROR: `pub` visibility is not allowed

fn main() {
pub use std::bool; //~ ERROR: imports in functions are never reachable
pub use std::uint; //~ ERROR: imports in functions are never reachable
}