diff --git a/src/doc/reference.md b/src/doc/reference.md index 4485704c3d523..3918a558cb330 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1557,8 +1557,7 @@ warnings are generated, or otherwise "you used a private item of another module and weren't allowed to." By default, everything in Rust is *private*, with one exception. Enum variants -in a `pub` enum are also public by default. You are allowed to alter this -default visibility with the `priv` keyword. When an item is declared as `pub`, +in a `pub` enum are also public by default. When an item is declared as `pub`, it can be thought of as being accessible to the outside world. For example: ``` @@ -2426,11 +2425,18 @@ Tuples are written by enclosing zero or more comma-separated expressions in parentheses. They are used to create [tuple-typed](#tuple-types) values. ```{.tuple} -(0,); (0.0, 4.5); ("a", 4usize, true); ``` +You can disambiguate a single-element tuple from a value in parentheses with a +comma: + +``` +(0,); // single-element tuple +(0); // zero in parentheses +``` + ### Unit expressions The expression `()` denotes the _unit value_, the only value of the type with diff --git a/src/doc/trpl/attributes.md b/src/doc/trpl/attributes.md index 54195a5063b7c..63496471b5a01 100644 --- a/src/doc/trpl/attributes.md +++ b/src/doc/trpl/attributes.md @@ -67,4 +67,4 @@ Rust attributes are used for a number of different things. There is a full list of attributes [in the reference][reference]. Currently, you are not allowed to create your own attributes, the Rust compiler defines them. -[reference]: reference.html#attributes +[reference]: ../reference.html#attributes diff --git a/src/doc/trpl/const-and-static.md b/src/doc/trpl/const-and-static.md index 57cbb6213963a..be0c87319b37c 100644 --- a/src/doc/trpl/const-and-static.md +++ b/src/doc/trpl/const-and-static.md @@ -19,9 +19,9 @@ this reason. # `static` Rust provides a ‘global variable’ sort of facility in static items. They’re -similar to [constants][const], but static items aren’t inlined upon use. This -means that there is only one instance for each value, and it’s at a fixed -location in memory. +similar to constants, but static items aren’t inlined upon use. This means that +there is only one instance for each value, and it’s at a fixed location in +memory. Here’s an example: @@ -29,8 +29,6 @@ Here’s an example: static N: i32 = 5; ``` -[const]: const.html - Unlike [`let`][let] bindings, you must annotate the type of a `static`. [let]: variable-bindings.html diff --git a/src/doc/trpl/iterators.md b/src/doc/trpl/iterators.md index eea575658b92c..76f6a4243a062 100644 --- a/src/doc/trpl/iterators.md +++ b/src/doc/trpl/iterators.md @@ -235,7 +235,7 @@ Ranges are one of two basic iterators that you'll see. The other is `iter()`. in turn: ```rust -let nums = [1, 2, 3]; +let nums = vec![1, 2, 3]; for num in nums.iter() { println!("{}", num); @@ -243,18 +243,7 @@ for num in nums.iter() { ``` These two basic iterators should serve you well. There are some more -advanced iterators, including ones that are infinite. Like using range syntax -and `step_by`: - -```rust -# #![feature(step_by)] -(1..).step_by(5); -``` - -This iterator counts up from one, adding five each time. It will give -you a new integer every time, forever (well, technically, until it reaches the -maximum number representable by an `i32`). But since iterators are lazy, -that's okay! You probably don't want to use `collect()` on it, though... +advanced iterators, including ones that are infinite. That's enough about iterators. Iterator adapters are the last concept we need to talk about with regards to iterators. Let's get to it! diff --git a/src/doc/trpl/nightly-rust.md b/src/doc/trpl/nightly-rust.md index 3b76cce568c72..1cb62e8b2d3e9 100644 --- a/src/doc/trpl/nightly-rust.md +++ b/src/doc/trpl/nightly-rust.md @@ -93,8 +93,7 @@ If not, there are a number of places where you can get help. The easiest is [the #rust IRC channel on irc.mozilla.org][irc], which you can access through [Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans (a silly nickname we call ourselves), and we can help you out. Other great -resources include [the user’s forum][users], and [Stack Overflow][stack -overflow]. +resources include [the user’s forum][users], and [Stack Overflow][stack overflow]. [irc]: irc://irc.mozilla.org/#rust [mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust diff --git a/src/doc/trpl/primitive-types.md b/src/doc/trpl/primitive-types.md index aca6e327c3bce..e017e222c7417 100644 --- a/src/doc/trpl/primitive-types.md +++ b/src/doc/trpl/primitive-types.md @@ -248,6 +248,14 @@ or “breaks up” the tuple, and assigns the bits to three bindings. This pattern is very powerful, and we’ll see it repeated more later. +You can disambiguate a single-element tuple from a value in parentheses with a +comma: + +``` +(0,); // single-element tuple +(0); // zero in parentheses +``` + ## Tuple Indexing You can also access fields of a tuple with indexing syntax: diff --git a/src/doc/trpl/raw-pointers.md b/src/doc/trpl/raw-pointers.md index ab6ff18501ed5..4a37af3c22782 100644 --- a/src/doc/trpl/raw-pointers.md +++ b/src/doc/trpl/raw-pointers.md @@ -80,7 +80,7 @@ Raw pointers are useful for FFI: Rust’s `*const T` and `*mut T` are similar to C’s `const T*` and `T*`, respectfully. For more about this use, consult the [FFI chapter][ffi]. -[ffi]: ffi.md +[ffi]: ffi.html # References and raw pointers diff --git a/src/doc/trpl/unsafe.md b/src/doc/trpl/unsafe.md index 7fe9a1fd27e8e..fdb9c33a2b0b5 100644 --- a/src/doc/trpl/unsafe.md +++ b/src/doc/trpl/unsafe.md @@ -101,7 +101,7 @@ Rust has a feature called ‘`static mut`’ which allows for mutable global sta Doing so can cause a data race, and as such is inherently not safe. For more details, see the [static][static] section of the book. -[static]: static.html +[static]: const-and-static.html#static ## Dereference a raw pointer diff --git a/src/doc/trpl/unsized-types.md b/src/doc/trpl/unsized-types.md index 756abeff06d35..b1a2bb5d4172f 100644 --- a/src/doc/trpl/unsized-types.md +++ b/src/doc/trpl/unsized-types.md @@ -38,9 +38,11 @@ impl Foo for &str { ``` Meaning, this implementation would only work for [references][ref], and not -other types of pointers. With this `impl`, all pointers, including (at some -point, there are some bugs to fix first) user-defined custom smart pointers, -can use this `impl`. +other types of pointers. With the `impl for str`, all pointers, including (at +some point, there are some bugs to fix first) user-defined custom smart +pointers, can use this `impl`. + +[ref]: references-and-borrowing.html # ?Sized diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs index 4480a7d7e0a09..80fa6d397c829 100644 --- a/src/libcollections/fmt.rs +++ b/src/libcollections/fmt.rs @@ -398,7 +398,7 @@ //! longer than this width, then it is truncated down to this many characters and only those are //! emitted. //! -//! For integral types, this has no meaning currently. +//! For integral types, this is ignored. //! //! For floating-point types, this indicates how many digits after the decimal point should be //! printed. diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index b8638c5b09be2..22f4e8546554d 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -113,12 +113,14 @@ macro_rules! int_impl { $mul_with_overflow:path) => { /// Returns the smallest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn min_value() -> $T { (-1 as $T) << ($BITS - 1) } /// Returns the largest value that can be represented by this integer type. #[stable(feature = "rust1", since = "1.0.0")] + #[inline] pub fn max_value() -> $T { let min = $T::min_value(); !min } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 6f78e853ebe84..014991f7ea560 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -899,7 +899,7 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) { if let ast::MethodImplItem(ref sig, _) = ii.node { // if the method specifies a visibility, use that, otherwise // inherit the visibility from the impl (so `foo` in `pub impl - // { fn foo(); }` is public, but private in `priv impl { fn + // { fn foo(); }` is public, but private in `impl { fn // foo(); }`). let method_vis = ii.vis.inherit_from(parent_visibility); Some((sig, ii.id, ii.ident, method_vis, ii.span)) diff --git a/src/librustc_unicode/u_str.rs b/src/librustc_unicode/u_str.rs index 898844e3bf12b..f4c85f18a7e67 100644 --- a/src/librustc_unicode/u_str.rs +++ b/src/librustc_unicode/u_str.rs @@ -525,7 +525,7 @@ pub struct Utf16Encoder { } impl Utf16Encoder { - /// Create an UTF-16 encoder from any `char` iterator. + /// Create a UTF-16 encoder from any `char` iterator. pub fn new(chars: I) -> Utf16Encoder where I: Iterator { Utf16Encoder { chars: chars, extra: 0 } } diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 114d0dd79a0a3..facf33de6bb63 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -27,7 +27,7 @@ use sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT, Ordering}; use sync::{StaticMutex, MUTEX_INIT}; use sys::os as os_imp; -/// Returns the current working directory as a `Path`. +/// Returns the current working directory as a `PathBuf`. /// /// # Errors /// diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 2b15a4ff83ed1..5a05c61e064df 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -643,7 +643,7 @@ impl Permissions { /// use std::fs::File; /// /// # fn foo() -> std::io::Result<()> { - /// let mut f = try!(File::create("foo.txt")); + /// let f = try!(File::create("foo.txt")); /// let metadata = try!(f.metadata()); /// let mut permissions = metadata.permissions(); /// diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 561c37ad950b0..9089b417fcb99 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -236,7 +236,7 @@ pub trait Read { /// Transforms this `Read` instance to an `Iterator` over `char`s. /// - /// This adaptor will attempt to interpret this reader as an UTF-8 encoded + /// This adaptor will attempt to interpret this reader as a UTF-8 encoded /// sequence of characters. The returned iterator will return `None` once /// EOF is reached for this reader. Otherwise each element yielded will be a /// `Result` where `E` may contain information about what I/O error diff --git a/src/libstd/os/dragonfly/raw.rs b/src/libstd/os/dragonfly/raw.rs index 22c811ead4335..86522cc1e795c 100644 --- a/src/libstd/os/dragonfly/raw.rs +++ b/src/libstd/os/dragonfly/raw.rs @@ -11,7 +11,7 @@ //! Dragonfly-specific raw type definitions use os::raw::c_long; -use os::unix::raw::{pid_t, uid_t, gid_t}; +use os::unix::raw::{uid_t, gid_t}; pub type blkcnt_t = i64; pub type blksize_t = u32; diff --git a/src/libstd/os/freebsd/raw.rs b/src/libstd/os/freebsd/raw.rs index a810eff45d32e..a3b95738a1a1a 100644 --- a/src/libstd/os/freebsd/raw.rs +++ b/src/libstd/os/freebsd/raw.rs @@ -11,7 +11,7 @@ //! FreeBSD-specific raw type definitions use os::raw::c_long; -use os::unix::raw::{uid_t, gid_t, pid_t}; +use os::unix::raw::{uid_t, gid_t}; pub type blkcnt_t = i64; pub type blksize_t = i64; diff --git a/src/libstd/os/ios/raw.rs b/src/libstd/os/ios/raw.rs index 3266b3846d899..a66e01b2c3992 100644 --- a/src/libstd/os/ios/raw.rs +++ b/src/libstd/os/ios/raw.rs @@ -11,7 +11,7 @@ //! iOS-specific raw type definitions use os::raw::c_long; -use os::unix::raw::{uid_t, gid_t, pid_t}; +use os::unix::raw::{uid_t, gid_t}; pub type blkcnt_t = i64; pub type blksize_t = i32; diff --git a/src/libstd/os/openbsd/raw.rs b/src/libstd/os/openbsd/raw.rs index 632a8c336b78d..0bdba9e3487f1 100644 --- a/src/libstd/os/openbsd/raw.rs +++ b/src/libstd/os/openbsd/raw.rs @@ -11,7 +11,7 @@ //! OpenBSD-specific raw type definitions use os::raw::c_long; -use os::unix::raw::{uid_t, gid_t, pid_t}; +use os::unix::raw::{uid_t, gid_t}; pub type blkcnt_t = i64; pub type blksize_t = u32; diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 56a952e6a7ef6..cb9239ed7ba57 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -161,7 +161,7 @@ impl Wtf8Buf { Wtf8Buf { bytes: Vec::with_capacity(n) } } - /// Creates a WTF-8 string from an UTF-8 `String`. + /// Creates a WTF-8 string from a UTF-8 `String`. /// /// This takes ownership of the `String` and does not copy. /// @@ -171,7 +171,7 @@ impl Wtf8Buf { Wtf8Buf { bytes: string.into_bytes() } } - /// Creates a WTF-8 string from an UTF-8 `&str` slice. + /// Creates a WTF-8 string from a UTF-8 `&str` slice. /// /// This copies the content of the slice. /// @@ -245,7 +245,7 @@ impl Wtf8Buf { self.bytes.capacity() } - /// Append an UTF-8 slice at the end of the string. + /// Append a UTF-8 slice at the end of the string. #[inline] pub fn push_str(&mut self, other: &str) { self.bytes.push_all(other.as_bytes()) @@ -527,7 +527,7 @@ impl Wtf8 { } /// Lossily converts the string to UTF-8. - /// Returns an UTF-8 `&str` slice if the contents are well-formed in UTF-8. + /// Returns a UTF-8 `&str` slice if the contents are well-formed in UTF-8. /// /// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “�”). /// diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 5f76c21492707..a7b1beace51d3 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4775,7 +4775,7 @@ impl<'a> Parser<'a> { return self.parse_single_struct_field(Inherited, attrs); } - /// Parse visibility: PUB, PRIV, or nothing + /// Parse visibility: PUB or nothing fn parse_visibility(&mut self) -> PResult { if try!(self.eat_keyword(keywords::Pub)) { Ok(Public) } else { Ok(Inherited) } diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index c650fc25ee163..c9b684fd65694 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -28,7 +28,7 @@ enum Result { Status(String) } -priv fn parse_data(len: usize, io: @io::Reader) -> Result { +fn parse_data(len: usize, io: @io::Reader) -> Result { let res = if (len > 0) { let bytes = io.read_bytes(len as usize); @@ -42,7 +42,7 @@ priv fn parse_data(len: usize, io: @io::Reader) -> Result { return res; } -priv fn parse_list(len: usize, io: @io::Reader) -> Result { +fn parse_list(len: usize, io: @io::Reader) -> Result { let mut list: ~[Result] = ~[]; for _ in 0..len { let v = match io.read_char() { @@ -55,11 +55,11 @@ priv fn parse_list(len: usize, io: @io::Reader) -> Result { return List(list); } -priv fn chop(s: String) -> String { +fn chop(s: String) -> String { s.slice(0, s.len() - 1).to_string() } -priv fn parse_bulk(io: @io::Reader) -> Result { +fn parse_bulk(io: @io::Reader) -> Result { match from_str::(chop(io.read_line())) { None => panic!(), Some(-1) => Nil, @@ -68,7 +68,7 @@ priv fn parse_bulk(io: @io::Reader) -> Result { } } -priv fn parse_multi(io: @io::Reader) -> Result { +fn parse_multi(io: @io::Reader) -> Result { match from_str::(chop(io.read_line())) { None => panic!(), Some(-1) => Nil, @@ -78,14 +78,14 @@ priv fn parse_multi(io: @io::Reader) -> Result { } } -priv fn parse_int(io: @io::Reader) -> Result { +fn parse_int(io: @io::Reader) -> Result { match from_str::(chop(io.read_line())) { None => panic!(), Some(i) => Int(i) } } -priv fn parse_response(io: @io::Reader) -> Result { +fn parse_response(io: @io::Reader) -> Result { match io.read_char() { '$' => parse_bulk(io), '*' => parse_multi(io), @@ -96,7 +96,7 @@ priv fn parse_response(io: @io::Reader) -> Result { } } -priv fn cmd_to_string(cmd: ~[String]) -> String { +fn cmd_to_string(cmd: ~[String]) -> String { let mut res = "*".to_string(); res.push_str(cmd.len().to_string()); res.push_str("\r\n");