From 1fbbe79bcb97cc85dfe5f6c431b7aca9784a9bd4 Mon Sep 17 00:00:00 2001 From: Stjepan Glavina Date: Wed, 15 Feb 2017 23:26:29 +0100 Subject: Fix wording in LocalKey documentation --- src/libstd/sync/once.rs | 2 +- src/libstd/thread/local.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index ba993751391..1e7394c0b09 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -316,7 +316,7 @@ impl Once { } // Once we've enqueued ourselves, wait in a loop. - // Aftewards reload the state and continue with what we + // Afterwards reload the state and continue with what we // were doing from before. while !node.signaled.load(Ordering::SeqCst) { thread::park(); diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 5166ddf8a21..66f09a7069c 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -28,8 +28,8 @@ use mem; /// # Initialization and Destruction /// /// Initialization is dynamically performed on the first call to `with()` -/// within a thread, and values support destructors which will be run when a -/// thread exits. +/// within a thread, and values that implement `Drop` get destructed when a +/// thread exits. Some caveats apply, which are explained below. /// /// # Examples /// -- cgit 1.4.1-3-g733a5 From ab57e7b86817b8ca9b7e6afb2f689ae67274ec7c Mon Sep 17 00:00:00 2001 From: Amos Onn Date: Thu, 16 Feb 2017 02:16:41 +0100 Subject: std::io::cursor Added test for seeking beyond i64. --- src/libstd/io/cursor.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/libstd') diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 0cff8661d88..9427e4afa21 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -526,6 +526,43 @@ mod tests { assert_eq!(r.write(&[3]).unwrap(), 0); } + #[test] + fn seek_past_i64() { + let buf = [0xff]; + let mut r = Cursor::new(&buf[..]); + assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); + assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); + assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); + assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); + assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); + assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); + + let mut r = Cursor::new(vec![10]); + assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); + assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); + assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); + assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); + assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); + assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); + + let mut buf = [0]; + let mut r = Cursor::new(&mut buf[..]); + assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); + assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); + assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); + assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); + assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); + assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); + + let mut r = Cursor::new(vec![10].into_boxed_slice()); + assert_eq!(r.seek(SeekFrom::Start(6)).unwrap(), 6); + assert_eq!(r.seek(SeekFrom::Current(0x7ffffffffffffff0)).unwrap(), 0x7ffffffffffffff6); + assert_eq!(r.seek(SeekFrom::Current(0x10)).unwrap(), 0x8000000000000006); + assert_eq!(r.seek(SeekFrom::Current(0)).unwrap(), 0x8000000000000006); + assert!(r.seek(SeekFrom::Current(0x7ffffffffffffffd)).is_err()); + assert_eq!(r.seek(SeekFrom::Current(-0x8000000000000000)).unwrap(), 6); + } + #[test] fn seek_before_0() { let buf = [0xff]; -- cgit 1.4.1-3-g733a5 From ebf70a9a206e3ecff7d442a7edf297731e9fe042 Mon Sep 17 00:00:00 2001 From: Shawn Walker-Salas Date: Wed, 15 Feb 2017 17:48:20 -0800 Subject: libstd needs update for pending libc change Fixes #39868 --- src/libstd/sys/unix/os.rs | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 6992a17832e..1dbfa640d52 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -483,7 +483,6 @@ pub fn home_dir() -> Option { target_os = "nacl", target_os = "emscripten")))] unsafe fn fallback() -> Option { - #[cfg(not(target_os = "solaris"))] unsafe fn getpwduid_r(me: libc::uid_t, passwd: &mut libc::passwd, buf: &mut Vec) -> Option<()> { let mut result = ptr::null_mut(); @@ -495,16 +494,6 @@ pub fn home_dir() -> Option { } } - #[cfg(target_os = "solaris")] - unsafe fn getpwduid_r(me: libc::uid_t, passwd: &mut libc::passwd, - buf: &mut Vec) -> Option<()> { - // getpwuid_r semantics is different on Illumos/Solaris: - // http://illumos.org/man/3c/getpwuid_r - let result = libc::getpwuid_r(me, passwd, buf.as_mut_ptr(), - buf.capacity()); - if result.is_null() { None } else { Some(()) } - } - let amt = match libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) { n if n < 0 => 512 as usize, n => n as usize, -- cgit 1.4.1-3-g733a5 From a2d176e8f4774b84db22540a45eed7b29482f154 Mon Sep 17 00:00:00 2001 From: Amos Onn Date: Thu, 16 Feb 2017 02:21:08 +0100 Subject: std::io::cursor: Fixed Seek so test passes. --- src/libstd/io/cursor.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 9427e4afa21..60767ea4786 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -200,18 +200,20 @@ impl Cursor { #[stable(feature = "rust1", since = "1.0.0")] impl io::Seek for Cursor where T: AsRef<[u8]> { fn seek(&mut self, style: SeekFrom) -> io::Result { - let pos = match style { - SeekFrom::Start(n) => { self.pos = n; return Ok(n) } - SeekFrom::End(n) => self.inner.as_ref().len() as i64 + n, - SeekFrom::Current(n) => self.pos as i64 + n, + let (base_pos, offset) = match style { + SeekFrom::Start(n) => { self.pos = n; return Ok(n); } + SeekFrom::End(n) => (self.inner.as_ref().len() as u64, n), + SeekFrom::Current(n) => (self.pos, n), }; - - if pos < 0 { - Err(Error::new(ErrorKind::InvalidInput, - "invalid seek to a negative position")) + let new_pos = if offset >= 0 { + base_pos.checked_add(offset as u64) } else { - self.pos = pos as u64; - Ok(self.pos) + base_pos.checked_sub((offset.wrapping_neg()) as u64) + }; + match new_pos { + Some(n) => {self.pos = n; Ok(self.pos)} + None => Err(Error::new(ErrorKind::InvalidInput, + "invalid seek to a negative or overflowing position")) } } } -- cgit 1.4.1-3-g733a5 From 57895393115c61ec01fcbc9815f9821b2bfe5886 Mon Sep 17 00:00:00 2001 From: Shawn Walker-Salas Date: Wed, 15 Feb 2017 22:52:47 -0800 Subject: simplify home_dir by removing unnecessary getpwuid_r wrapper --- src/libstd/sys/unix/os.rs | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index 1dbfa640d52..e78928c2667 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -483,30 +483,21 @@ pub fn home_dir() -> Option { target_os = "nacl", target_os = "emscripten")))] unsafe fn fallback() -> Option { - unsafe fn getpwduid_r(me: libc::uid_t, passwd: &mut libc::passwd, - buf: &mut Vec) -> Option<()> { - let mut result = ptr::null_mut(); - match libc::getpwuid_r(me, passwd, buf.as_mut_ptr(), - buf.capacity(), - &mut result) { - 0 if !result.is_null() => Some(()), - _ => None - } - } - let amt = match libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) { n if n < 0 => 512 as usize, n => n as usize, }; let mut buf = Vec::with_capacity(amt); let mut passwd: libc::passwd = mem::zeroed(); - - if getpwduid_r(libc::getuid(), &mut passwd, &mut buf).is_some() { - let ptr = passwd.pw_dir as *const _; - let bytes = CStr::from_ptr(ptr).to_bytes().to_vec(); - Some(OsStringExt::from_vec(bytes)) - } else { - None + let mut result = ptr::null_mut(); + match libc::getpwuid_r(libc::getuid(), &mut passwd, buf.as_mut_ptr(), + buf.capacity(), &mut result) { + 0 if !result.is_null() => { + let ptr = passwd.pw_dir as *const _; + let bytes = CStr::from_ptr(ptr).to_bytes().to_vec(); + Some(OsStringExt::from_vec(bytes)) + }, + _ => None, } } } -- cgit 1.4.1-3-g733a5 From 84aca88cdab3df70d1dc657cc203d38672a7e95c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 18 Feb 2017 14:44:56 +0100 Subject: Add missing urls for env functions --- src/libstd/env.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 1ef2cb4ed15..dd4f1ff4f5e 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -96,7 +96,9 @@ pub struct VarsOs { inner: os_imp::Env } /// /// While iterating, the returned iterator will panic if any key or value in the /// environment is not valid unicode. If this is not desired, consider using the -/// `env::vars_os` function. +/// [`env::vars_os`] function. +/// +/// [`env::vars_os`]: fn.vars_os.html /// /// # Examples /// @@ -171,9 +173,12 @@ impl fmt::Debug for VarsOs { /// Fetches the environment variable `key` from the current process. /// -/// The returned result is `Ok(s)` if the environment variable is present and is +/// The returned result is [`Ok(s)`] if the environment variable is present and is /// valid unicode. If the environment variable is not present, or it is not -/// valid unicode, then `Err` will be returned. +/// valid unicode, then [`Err`] will be returned. +/// +/// [`Ok(s)`]: ../result/enum.Result.html#variant.Ok +/// [`Err`]: ../result/enum.Result.html#variant.Err /// /// # Examples /// @@ -199,7 +204,9 @@ fn _var(key: &OsStr) -> Result { } /// Fetches the environment variable `key` from the current process, returning -/// `None` if the variable isn't set. +/// [`None`] if the variable isn't set. +/// +/// [`None`]: ../option/enum.Option.html#variant.None /// /// # Examples /// -- cgit 1.4.1-3-g733a5 From 3b4412aa62e25c7e4952211a7844012a67792b27 Mon Sep 17 00:00:00 2001 From: arthurprs Date: Sat, 18 Feb 2017 21:06:00 +0100 Subject: Fix spelling in comments --- src/libstd/collections/hash/map.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 079dbd667d6..fd5827b4c07 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -182,15 +182,15 @@ impl DefaultResizePolicy { // ---------------------- // To protect against degenerate performance scenarios (including DOS attacks), // the implementation includes an adaptive behavior that can resize the map -// early (before it's capacity is exceeded) when suspiciously long probe or -// foward shifts sequences are encounted. +// early (before its capacity is exceeded) when suspiciously long probe or +// forward shifts sequences are encountered. // // With this algorithm in place it would be possible to turn a CPU attack into -// a memory attack due to the agressive resizing. To prevent that the +// a memory attack due to the aggressive resizing. To prevent that the // adaptive behavior only triggers when the map occupancy is half the maximum occupancy. -// This reduces the effectivenes of the algorithm but also makes it completelly safe. +// This reduces the effectiveness of the algorithm but also makes it completely safe. // -// The previous safety measure that also prevents degenerate iteractions with +// The previous safety measure also prevents degenerate interactions with // really bad quality hash algorithms that can make normal inputs look like a // DOS attack. // -- cgit 1.4.1-3-g733a5 From b4cd3d92061de90f58669d620867d42466a563ab Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 20 Feb 2017 09:09:12 -0500 Subject: Revert "Fix up links" This reverts commit 7f1d1c6d9a7be5e427bace30e740b16b25f25c92. The original commit was created because mdBook and rustdoc had different generation algorithms for header links; now with https://github.com/rust-lang/rust/pull/39966 , the algorithms are the same. So let's undo this change. ... when I came across this problem, I said "eh, this isn't fun, but it doesn't take that long." I probably should have just actually taken the time to fix upstream, given that they were amenable. Oh well! --- src/doc/book/src/casting-between-types.md | 2 +- src/doc/book/src/closures.md | 2 +- src/doc/book/src/compiler-plugins.md | 2 +- src/doc/book/src/concurrency.md | 4 +- src/doc/book/src/error-handling.md | 72 +++++++++++++++---------------- src/doc/book/src/ffi.md | 2 +- src/doc/book/src/getting-started.md | 2 +- src/doc/book/src/glossary.md | 6 +-- src/doc/book/src/guessing-game.md | 4 +- src/doc/book/src/lifetimes.md | 2 +- src/doc/book/src/macros.md | 2 +- src/doc/book/src/mutability.md | 2 +- src/doc/book/src/ownership.md | 8 ++-- src/doc/book/src/primitive-types.md | 2 +- src/doc/book/src/syntax-index.md | 50 ++++++++++----------- src/doc/book/src/traits.md | 2 +- src/doc/book/src/type-aliases.md | 2 +- src/doc/book/src/vectors.md | 2 +- src/doc/nomicon/src/lifetime-mismatch.md | 2 +- src/doc/nomicon/src/repr-rust.md | 2 +- src/doc/reference.md | 6 +-- src/liballoc/arc.rs | 2 +- src/liballoc/rc.rs | 2 +- src/libcore/mem.rs | 2 +- src/libcore/raw.rs | 2 +- src/libstd/lib.rs | 4 +- src/libstd/primitive_docs.rs | 2 +- 27 files changed, 96 insertions(+), 96 deletions(-) (limited to 'src/libstd') diff --git a/src/doc/book/src/casting-between-types.md b/src/doc/book/src/casting-between-types.md index 2f6730be665..853fb1ec254 100644 --- a/src/doc/book/src/casting-between-types.md +++ b/src/doc/book/src/casting-between-types.md @@ -8,7 +8,7 @@ most dangerous features of Rust! # Coercion Coercion between types is implicit and has no syntax of its own, but can -be spelled out with [`as`](#Explicit%20coercions). +be spelled out with [`as`](#explicit-coercions). Coercion occurs in `let`, `const`, and `static` statements; in function call arguments; in field values in struct initialization; and in a diff --git a/src/doc/book/src/closures.md b/src/doc/book/src/closures.md index 2f6d5039f4d..5426ed0ff4c 100644 --- a/src/doc/book/src/closures.md +++ b/src/doc/book/src/closures.md @@ -463,7 +463,7 @@ fn factory() -> &(Fn(i32) -> i32) { Right. Because we have a reference, we need to give it a lifetime. But our `factory()` function takes no arguments, so -[elision](lifetimes.html#Lifetime%20Elision) doesn’t kick in here. Then what +[elision](lifetimes.html#lifetime-elision) doesn’t kick in here. Then what choices do we have? Try `'static`: ```rust,ignore diff --git a/src/doc/book/src/compiler-plugins.md b/src/doc/book/src/compiler-plugins.md index 47c5e5c8291..1b7ce678982 100644 --- a/src/doc/book/src/compiler-plugins.md +++ b/src/doc/book/src/compiler-plugins.md @@ -127,7 +127,7 @@ enum. For a more involved macro example, see ## Tips and tricks -Some of the [macro debugging tips](macros.html#Debugging%20macro%20code) are applicable. +Some of the [macro debugging tips](macros.html#debugging-macro-code) are applicable. You can use `syntax::parse` to turn token trees into higher-level syntax elements like expressions: diff --git a/src/doc/book/src/concurrency.md b/src/doc/book/src/concurrency.md index e5bc7ecdd0b..a64178c26f2 100644 --- a/src/doc/book/src/concurrency.md +++ b/src/doc/book/src/concurrency.md @@ -55,7 +55,7 @@ For sharing references across threads, Rust provides a wrapper type called `Arc`. `Arc` implements `Send` and `Sync` if and only if `T` implements both `Send` and `Sync`. For example, an object of type `Arc>` cannot be transferred across threads because -[`RefCell`](choosing-your-guarantees.html#RefCell%3CT%3E) does not implement +[`RefCell`](choosing-your-guarantees.html#refcellt) does not implement `Sync`, consequently `Arc>` would not implement `Send`. These two traits allow you to use the type system to make strong guarantees @@ -126,7 +126,7 @@ closure only captures a _reference to `x`_. This is a problem, because the thread may outlive the scope of `x`, leading to a dangling pointer. To fix this, we use a `move` closure as mentioned in the error message. `move` -closures are explained in depth [here](closures.html#move%20closures); basically +closures are explained in depth [here](closures.html#move-closures); basically they move variables from their environment into themselves. ```rust diff --git a/src/doc/book/src/error-handling.md b/src/doc/book/src/error-handling.md index 1b0d2453275..c823c32a135 100644 --- a/src/doc/book/src/error-handling.md +++ b/src/doc/book/src/error-handling.md @@ -21,35 +21,35 @@ sum types and combinators, and try to motivate the way Rust does error handling incrementally. As such, programmers with experience in other expressive type systems may want to jump around. -* [The Basics](#The%20Basics) - * [Unwrapping explained](#Unwrapping%20explained) - * [The `Option` type](#The%20Option%20type) - * [Composing `Option` values](#Composing%20Option%3CT%3E%20values) - * [The `Result` type](#The%20Result%20type) - * [Parsing integers](#Parsing%20integers) - * [The `Result` type alias idiom](#The%20Result%20type%20alias%20idiom) - * [A brief interlude: unwrapping isn't evil](#A%20brief%20interlude:%20unwrapping%20isnt%20evil) -* [Working with multiple error types](#Working%20with%20multiple%20error%20types) - * [Composing `Option` and `Result`](#Composing%20Option%20and%20Result) - * [The limits of combinators](#The%20limits%20of%20combinators) - * [Early returns](#Early%20returns) - * [The `try!` macro](#The%20try%20macro) - * [Defining your own error type](#Defining%20your%20own%20error%20type) -* [Standard library traits used for error handling](#Standard%20library%20traits%20used%20for%20error%20handling) - * [The `Error` trait](#The%20Error%20trait) - * [The `From` trait](#The%20From%20trait) - * [The real `try!` macro](#The%20real%20try%20macro) - * [Composing custom error types](#Composing%20custom%20error%20types) - * [Advice for library writers](#Advice%20for%20library%20writers) -* [Case study: A program to read population data](#Case%20study:%20A%20program%20to%20read%20population%20data) - * [Initial setup](#Initial%20setup) - * [Argument parsing](#Argument%20parsing) - * [Writing the logic](#Writing%20the%20logic) - * [Error handling with `Box`](#Error%20handling%20with%20Box%3CError%3E) - * [Reading from stdin](#Reading%20from%20stdin) - * [Error handling with a custom type](#Error%20handling%20with%20a%20custom%20type) - * [Adding functionality](#Adding%20functionality) -* [The short story](#The%20short%20story) +* [The Basics](#the-basics) + * [Unwrapping explained](#unwrapping-explained) + * [The `Option` type](#the-option-type) + * [Composing `Option` values](#composing-optiont-values) + * [The `Result` type](#the-result-type) + * [Parsing integers](#parsing-integers) + * [The `Result` type alias idiom](#the-result-type-alias-idiom) + * [A brief interlude: unwrapping isn't evil](#a-brief-interlude-unwrapping-isnt-evil) +* [Working with multiple error types](#working-with-multiple-error-types) + * [Composing `Option` and `Result`](#composing-option-and-result) + * [The limits of combinators](#the-limits-of-combinators) + * [Early returns](#early-returns) + * [The `try!` macro](#the-try-macro) + * [Defining your own error type](#defining-your-own-error-type) +* [Standard library traits used for error handling](#standard-library-traits-used-for-error-handling) + * [The `Error` trait](#the-error-trait) + * [The `From` trait](#the-from-trait) + * [The real `try!` macro](#the-real-try-macro) + * [Composing custom error types](#composing-custom-error-types) + * [Advice for library writers](#advice-for-library-writers) +* [Case study: A program to read population data](#case-study-a-program-to-read-population-data) + * [Initial setup](#initial-setup) + * [Argument parsing](#argument-parsing) + * [Writing the logic](#writing-the-logic) + * [Error handling with `Box`](#error-handling-with-boxerror) + * [Reading from stdin](#reading-from-stdin) + * [Error handling with a custom type](#error-handling-with-a-custom-type) + * [Adding functionality](#adding-functionality) +* [The short story](#the-short-story) # The Basics @@ -796,7 +796,7 @@ because of the return types of [`std::fs::File::open`](../std/fs/struct.File.html#method.open) and [`std::io::Read::read_to_string`](../std/io/trait.Read.html#method.read_to_string). (Note that they both use the [`Result` type alias -idiom](#The%20Result%20type%20alias%20idiom) described previously. If you +idiom](#the-result-type-alias-idiom) described previously. If you click on the `Result` type, you'll [see the type alias](../std/io/type.Result.html), and consequently, the underlying `io::Error` type.) The third problem is described by the @@ -1120,7 +1120,7 @@ returns an `&Error`, which is itself a trait object. We'll revisit the For now, it suffices to show an example implementing the `Error` trait. Let's use the error type we defined in the -[previous section](#Defining%20your%20own%20error%20type): +[previous section](#defining-your-own-error-type): ```rust use std::io; @@ -1493,19 +1493,19 @@ representation. But certainly, this will vary depending on use cases. At a minimum, you should probably implement the [`Error`](../std/error/trait.Error.html) trait. This will give users of your library some minimum flexibility for -[composing errors](#The%20real%20try%20macro). Implementing the `Error` trait also +[composing errors](#the-real-try-macro). Implementing the `Error` trait also means that users are guaranteed the ability to obtain a string representation of an error (because it requires impls for both `fmt::Debug` and `fmt::Display`). Beyond that, it can also be useful to provide implementations of `From` on your error types. This allows you (the library author) and your users to -[compose more detailed errors](#Composing%20custom%20error%20types). For example, +[compose more detailed errors](#composing-custom-error-types). For example, [`csv::Error`](http://burntsushi.net/rustdoc/csv/enum.Error.html) provides `From` impls for both `io::Error` and `byteorder::Error`. Finally, depending on your tastes, you may also want to define a -[`Result` type alias](#The%20Result%20type%20alias%20idiom), particularly if your +[`Result` type alias](#the-result-type-alias-idiom), particularly if your library defines a single error type. This is used in the standard library for [`io::Result`](../std/io/type.Result.html) and [`fmt::Result`](../std/fmt/type.Result.html). @@ -1538,7 +1538,7 @@ and [`rustc-serialize`](https://crates.io/crates/rustc-serialize) crates. We're not going to spend a lot of time on setting up a project with Cargo because it is already covered well in [the Cargo -section](getting-started.html#Hello%20Cargo) and [Cargo's documentation][14]. +section](getting-started.html#hello-cargo) and [Cargo's documentation][14]. To get started from scratch, run `cargo new --bin city-pop` and make sure your `Cargo.toml` looks something like this: @@ -1729,7 +1729,7 @@ error types and you don't need any `From` implementations. The downside is that since `Box` is a trait object, it *erases the type*, which means the compiler can no longer reason about its underlying type. -[Previously](#The%20limits%20of%20combinators) we started refactoring our code by +[Previously](#the-limits-of-combinators) we started refactoring our code by changing the type of our function from `T` to `Result`. In this case, `OurErrorType` is only `Box`. But what's `T`? And can we add a return type to `main`? diff --git a/src/doc/book/src/ffi.md b/src/doc/book/src/ffi.md index b2994d2a29c..cccefd8dfe7 100644 --- a/src/doc/book/src/ffi.md +++ b/src/doc/book/src/ffi.md @@ -680,7 +680,7 @@ pub extern fn hello_rust() -> *const u8 { The `extern` makes this function adhere to the C calling convention, as discussed above in "[Foreign Calling -Conventions](ffi.html#Foreign%20calling%20conventions)". The `no_mangle` +Conventions](ffi.html#foreign-calling-conventions)". The `no_mangle` attribute turns off Rust's name mangling, so that it is easier to link to. # FFI and panics diff --git a/src/doc/book/src/getting-started.md b/src/doc/book/src/getting-started.md index 93846644c39..6208b1f4c12 100644 --- a/src/doc/book/src/getting-started.md +++ b/src/doc/book/src/getting-started.md @@ -236,7 +236,7 @@ language]*, which means that most things are expressions, rather than statements. The `;` indicates that this expression is over, and the next one is ready to begin. Most lines of Rust code end with a `;`. -[expression-oriented language]: glossary.html#Expression-Oriented%20Language +[expression-oriented language]: glossary.html#expression-oriented-language ## Compiling and Running Are Separate Steps diff --git a/src/doc/book/src/glossary.md b/src/doc/book/src/glossary.md index 49821d86a92..b17b89633f3 100644 --- a/src/doc/book/src/glossary.md +++ b/src/doc/book/src/glossary.md @@ -56,7 +56,7 @@ They can be used to manage control flow in a modular fashion. A type without a statically known size or alignment. ([more info][link]) -[link]: ../nomicon/exotic-sizes.html#Dynamically%20Sized%20Types%20(DSTs) +[link]: ../nomicon/exotic-sizes.html#dynamically-sized-types-dsts ### Expression @@ -76,8 +76,8 @@ In an expression-oriented language, (nearly) every statement is an expression and therefore returns a value. Consequently, these expression statements can themselves form part of larger expressions. -[expression]: glossary.html#Expression -[statement]: glossary.html#Statement +[expression]: glossary.html#expression +[statement]: glossary.html#statement ### Statement diff --git a/src/doc/book/src/guessing-game.md b/src/doc/book/src/guessing-game.md index 216db25cd95..7368d2184e5 100644 --- a/src/doc/book/src/guessing-game.md +++ b/src/doc/book/src/guessing-game.md @@ -119,7 +119,7 @@ there are no arguments, and `{` starts the body of the function. Because we didn’t include a return type, it’s assumed to be `()`, an empty [tuple][tuples]. -[tuples]: primitive-types.html#Tuples +[tuples]: primitive-types.html#tuples ```rust,ignore println!("Guess the number!"); @@ -727,7 +727,7 @@ thirty-two bit integer. Rust has [a number of built-in number types][number], but we’ve chosen `u32`. It’s a good default choice for a small positive number. [parse]: ../std/primitive.str.html#method.parse -[number]: primitive-types.html#Numeric%20types +[number]: primitive-types.html#numeric-types Just like `read_line()`, our call to `parse()` could cause an error. What if our string contained `A👍%`? There’d be no way to convert that to a number. As diff --git a/src/doc/book/src/lifetimes.md b/src/doc/book/src/lifetimes.md index c00815f49c7..8bca13c28f0 100644 --- a/src/doc/book/src/lifetimes.md +++ b/src/doc/book/src/lifetimes.md @@ -139,7 +139,7 @@ associated with it, but the compiler lets you elide (i.e. omit, see ["Lifetime Elision"][lifetime-elision] below) them in common cases. Before we get to that, though, let’s look at a short example with explicit lifetimes: -[lifetime-elision]: #Lifetime%20Elision +[lifetime-elision]: #lifetime-elision ```rust,ignore fn bar<'a>(...) diff --git a/src/doc/book/src/macros.md b/src/doc/book/src/macros.md index ae1e1c65dd2..861cb4371f9 100644 --- a/src/doc/book/src/macros.md +++ b/src/doc/book/src/macros.md @@ -430,7 +430,7 @@ Even when Rust code contains un-expanded macros, it can be parsed as a full tools that process code. It also has a few consequences for the design of Rust’s macro system. -[ast]: glossary.html#Abstract%20Syntax%20Tree +[ast]: glossary.html#abstract-syntax-tree One consequence is that Rust must determine, when it parses a macro invocation, whether the macro stands in for diff --git a/src/doc/book/src/mutability.md b/src/doc/book/src/mutability.md index 7e96849220a..fa7a259392a 100644 --- a/src/doc/book/src/mutability.md +++ b/src/doc/book/src/mutability.md @@ -89,7 +89,7 @@ philosophy, memory safety, and the mechanism by which Rust guarantees it, the > * exactly one mutable reference (`&mut T`). [ownership]: ownership.html -[borrowing]: references-and-borrowing.html#Borrowing +[borrowing]: references-and-borrowing.html#borrowing So, that’s the real definition of ‘immutability’: is this safe to have two pointers to? In `Arc`’s case, yes: the mutation is entirely contained inside diff --git a/src/doc/book/src/ownership.md b/src/doc/book/src/ownership.md index e7bf3cec55e..21ebd6333f7 100644 --- a/src/doc/book/src/ownership.md +++ b/src/doc/book/src/ownership.md @@ -65,10 +65,10 @@ elements onto them. Vectors have a [generic type][generics] `Vec`, so in this example `v` will have type `Vec`. We'll cover [generics] in detail in a later chapter. -[arrays]: primitive-types.html#Arrays +[arrays]: primitive-types.html#arrays [vectors]: vectors.html -[heap]: the-stack-and-the-heap.html#The%20Heap -[stack]: the-stack-and-the-heap.html#The%20Stack +[heap]: the-stack-and-the-heap.html#the-heap +[stack]: the-stack-and-the-heap.html#the-stack [bindings]: variable-bindings.html [generics]: generics.html @@ -136,7 +136,7 @@ Rust allocates memory for an integer [i32] on the [stack][sh], copies the bit pattern representing the value of 10 to the allocated memory and binds the variable name x to this memory region for future reference. -[i32]: primitive-types.html#Numeric%20types +[i32]: primitive-types.html#numeric-types Now consider the following code fragment: diff --git a/src/doc/book/src/primitive-types.md b/src/doc/book/src/primitive-types.md index 67d71ceba0c..8fd3d17c15e 100644 --- a/src/doc/book/src/primitive-types.md +++ b/src/doc/book/src/primitive-types.md @@ -232,7 +232,7 @@ soon. You can assign one tuple into another, if they have the same contained types and [arity]. Tuples have the same arity when they have the same length. -[arity]: glossary.html#Arity +[arity]: glossary.html#arity ```rust let mut x = (1, 2); // x: (i32, i32) diff --git a/src/doc/book/src/syntax-index.md b/src/doc/book/src/syntax-index.md index 1e1d811a1d8..d8bb4fadc0b 100644 --- a/src/doc/book/src/syntax-index.md +++ b/src/doc/book/src/syntax-index.md @@ -196,18 +196,18 @@ [Associated Types]: associated-types.html [Attributes]: attributes.html [Casting Between Types (`as`)]: casting-between-types.html#as -[Closures (`move` closures)]: closures.html#move%20closures +[Closures (`move` closures)]: closures.html#move-closures [Closures]: closures.html [Comments]: comments.html -[Crates and Modules (Defining Modules)]: crates-and-modules.html#Defining%20modules -[Crates and Modules (Exporting a Public Interface)]: crates-and-modules.html#Exporting%20a%20public%20interface -[Crates and Modules (Importing External Crates)]: crates-and-modules.html#Importing%20external%20crates -[Crates and Modules (Importing Modules with `use`)]: crates-and-modules.html#Importing%20modules%20with%20use -[Crates and Modules (Re-exporting with `pub use`)]: crates-and-modules.html#Re-exporting%20with%20pub%20use -[Diverging Functions]: functions.html#Diverging%20functions +[Crates and Modules (Defining Modules)]: crates-and-modules.html#defining-modules +[Crates and Modules (Exporting a Public Interface)]: crates-and-modules.html#exporting-a-public-interface +[Crates and Modules (Importing External Crates)]: crates-and-modules.html#importing-external-crates +[Crates and Modules (Importing Modules with `use`)]: crates-and-modules.html#importing-modules-with-use +[Crates and Modules (Re-exporting with `pub use`)]: crates-and-modules.html#re-exporting-with-pub-use +[Diverging Functions]: functions.html#diverging-functions [Enums]: enums.html [Foreign Function Interface]: ffi.html -[Functions (Early Returns)]: functions.html#Early%20returns +[Functions (Early Returns)]: functions.html#early-returns [Functions]: functions.html [Generics]: generics.html [Iterators]: iterators.html @@ -216,24 +216,24 @@ [Loops (`for`)]: loops.html#for [Loops (`loop`)]: loops.html#loop [Loops (`while`)]: loops.html#while -[Loops (Ending Iteration Early)]: loops.html#Ending%20iteration%20early -[Loops (Loops Labels)]: loops.html#Loop%20labels +[Loops (Ending Iteration Early)]: loops.html#ending-iteration-early +[Loops (Loops Labels)]: loops.html#loop-labels [Macros]: macros.html [Match]: match.html -[Method Syntax (Method Calls)]: method-syntax.html#Method%20calls +[Method Syntax (Method Calls)]: method-syntax.html#method-calls [Method Syntax]: method-syntax.html [Mutability]: mutability.html [Operators and Overloading]: operators-and-overloading.html -[Patterns (`ref` and `ref mut`)]: patterns.html#ref%20and%20ref%20mut -[Patterns (Bindings)]: patterns.html#Bindings -[Patterns (Ignoring bindings)]: patterns.html#Ignoring%20bindings -[Patterns (Multiple patterns)]: patterns.html#Multiple%20patterns -[Patterns (Ranges)]: patterns.html#Ranges +[Patterns (`ref` and `ref mut`)]: patterns.html#ref-and-ref-mut +[Patterns (Bindings)]: patterns.html#bindings +[Patterns (Ignoring bindings)]: patterns.html#ignoring-bindings +[Patterns (Multiple patterns)]: patterns.html#multiple-patterns +[Patterns (Ranges)]: patterns.html#ranges [Primitive Types (`char`)]: primitive-types.html#char -[Primitive Types (Arrays)]: primitive-types.html#Arrays -[Primitive Types (Booleans)]: primitive-types.html#Booleans -[Primitive Types (Tuple Indexing)]: primitive-types.html#Tuple%20indexing -[Primitive Types (Tuples)]: primitive-types.html#Tuples +[Primitive Types (Arrays)]: primitive-types.html#arrays +[Primitive Types (Booleans)]: primitive-types.html#booleans +[Primitive Types (Tuple Indexing)]: primitive-types.html#tuple-indexing +[Primitive Types (Tuples)]: primitive-types.html#tuples [Raw Pointers]: raw-pointers.html [Reference (Byte String Literals)]: ../reference.html#byte-string-literals [Reference (Integer literals)]: ../reference.html#integer-literals @@ -241,13 +241,13 @@ [Reference (Raw String Literals)]: ../reference.html#raw-string-literals [References and Borrowing]: references-and-borrowing.html [Strings]: strings.html -[Structs (Update syntax)]: structs.html#Update%20syntax +[Structs (Update syntax)]: structs.html#update-syntax [Structs]: structs.html -[Traits (`where` clause)]: traits.html#Where%20clause -[Traits (Multiple Trait Bounds)]: traits.html#Multiple%20trait%20bounds +[Traits (`where` clause)]: traits.html#where-clause +[Traits (Multiple Trait Bounds)]: traits.html#multiple-trait-bounds [Traits]: traits.html [Universal Function Call Syntax]: ufcs.html -[Universal Function Call Syntax (Angle-bracket Form)]: ufcs.html#Angle-bracket%20Form +[Universal Function Call Syntax (Angle-bracket Form)]: ufcs.html#angle-bracket-form [Unsafe]: unsafe.html -[Unsized Types (`?Sized`)]: unsized-types.html#Sized +[Unsized Types (`?Sized`)]: unsized-types.html#sized [Variable Bindings]: variable-bindings.html diff --git a/src/doc/book/src/traits.md b/src/doc/book/src/traits.md index a6d1c3d1d23..19a133f84b0 100644 --- a/src/doc/book/src/traits.md +++ b/src/doc/book/src/traits.md @@ -81,7 +81,7 @@ Traits are useful because they allow a type to make certain promises about its behavior. Generic functions can exploit this to constrain, or [bound][bounds], the types they accept. Consider this function, which does not compile: -[bounds]: glossary.html#Bounds +[bounds]: glossary.html#bounds ```rust,ignore fn print_area(shape: T) { diff --git a/src/doc/book/src/type-aliases.md b/src/doc/book/src/type-aliases.md index b1ce0685283..1bd0f78e368 100644 --- a/src/doc/book/src/type-aliases.md +++ b/src/doc/book/src/type-aliases.md @@ -55,7 +55,7 @@ if x == y { This compiles without error. Values of a `Num` type are the same as a value of type `i32`, in every way. You can use [tuple struct] to really get a new type. -[tuple struct]: structs.html#Tuple%20structs +[tuple struct]: structs.html#tuple-structs You can also use type aliases with generics: diff --git a/src/doc/book/src/vectors.md b/src/doc/book/src/vectors.md index 9b293880cdc..aff078718df 100644 --- a/src/doc/book/src/vectors.md +++ b/src/doc/book/src/vectors.md @@ -151,6 +151,6 @@ API documentation][vec]. [vec]: ../std/vec/index.html [box]: ../std/boxed/index.html [generic]: generics.html -[panic]: concurrency.html#Panics +[panic]: concurrency.html#panics [get]: ../std/vec/struct.Vec.html#method.get [get_mut]: ../std/vec/struct.Vec.html#method.get_mut diff --git a/src/doc/nomicon/src/lifetime-mismatch.md b/src/doc/nomicon/src/lifetime-mismatch.md index 08627130590..30b4f09f903 100644 --- a/src/doc/nomicon/src/lifetime-mismatch.md +++ b/src/doc/nomicon/src/lifetime-mismatch.md @@ -78,4 +78,4 @@ TODO: other common problems? SEME regions stuff, mostly? -[ex2]: lifetimes.html#Example%3A%20aliasing%20a%20mutable%20reference +[ex2]: lifetimes.html#example-aliasing-a-mutable-reference diff --git a/src/doc/nomicon/src/repr-rust.md b/src/doc/nomicon/src/repr-rust.md index 98411e041be..c02cf44189f 100644 --- a/src/doc/nomicon/src/repr-rust.md +++ b/src/doc/nomicon/src/repr-rust.md @@ -151,4 +151,4 @@ use fairly elaborate algorithms to cache bits throughout nested types with special constrained representations. As such it is *especially* desirable that we leave enum layout unspecified today. -[dst]: exotic-sizes.html#Dynamically%20Sized%20Types%20(DSTs) +[dst]: exotic-sizes.html#dynamically-sized-types-dsts diff --git a/src/doc/reference.md b/src/doc/reference.md index f2be20d4a75..15645fa9e31 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2108,7 +2108,7 @@ On `struct`s: list of names `#[macro_use(foo, bar)]` restricts the import to just those macros named. The `extern crate` must appear at the crate root, not inside `mod`, which ensures proper function of the [`$crate` macro - variable](book/macros.html#The%20variable%20%24crate). + variable](book/macros.html#the-variable-crate). - `macro_reexport` on an `extern crate` — re-export the named macros. @@ -2118,7 +2118,7 @@ On `struct`s: link it into the output. See the [macros section of the -book](book/macros.html#Scoping%20and%20macro%20import%2Fexport) for more information on +book](book/macros.html#scoping-and-macro-importexport) for more information on macro scope. @@ -2277,7 +2277,7 @@ For any lint check `C`: The lint checks supported by the compiler can be found via `rustc -W help`, along with their default settings. [Compiler -plugins](book/compiler-plugins.html#Lint%20plugins) can provide additional lint checks. +plugins](book/compiler-plugins.html#lint-plugins) can provide additional lint checks. ```{.ignore} pub mod m1 { diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 210917b68a2..38d843263ff 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -102,7 +102,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize; /// [downgrade]: struct.Arc.html#method.downgrade /// [upgrade]: struct.Weak.html#method.upgrade /// [`None`]: ../../std/option/enum.Option.html#variant.None -/// [assoc]: ../../book/method-syntax.html#Associated%20functions +/// [assoc]: ../../book/method-syntax.html#associated-functions /// /// # Examples /// diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index a874e938a40..6108a06634b 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -215,7 +215,7 @@ //! [downgrade]: struct.Rc.html#method.downgrade //! [upgrade]: struct.Weak.html#method.upgrade //! [`None`]: ../../std/option/enum.Option.html#variant.None -//! [assoc]: ../../book/method-syntax.html#Associated%20functions +//! [assoc]: ../../book/method-syntax.html#associated-functions //! [mutability]: ../../std/cell/index.html#introducing-mutability-inside-of-something-immutable #![stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 5655fd06604..209107ef92c 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -525,7 +525,7 @@ pub fn replace(dest: &mut T, mut src: T) -> T { /// it will not release any borrows, as borrows are based on lexical scope. /// /// This effectively does nothing for -/// [types which implement `Copy`](../../book/ownership.html#Copy%20types), +/// [types which implement `Copy`](../../book/ownership.html#copy-types), /// e.g. integers. Such values are copied and _then_ moved into the function, /// so the value persists after this function call. /// diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 652b139f1e6..a7d0d3899b1 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -25,7 +25,7 @@ /// Book][moreinfo] contains more details about the precise nature of /// these internals. /// -/// [moreinfo]: ../../book/trait-objects.html#Representation +/// [moreinfo]: ../../book/trait-objects.html#representation /// /// `TraitObject` is guaranteed to match layouts, but it is not the /// type of trait objects (e.g. the fields are not directly accessible diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 88c2310a86e..070690773b6 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -189,8 +189,8 @@ //! [`sync`]: sync/index.html //! [`thread`]: thread/index.html //! [`use std::env`]: env/index.html -//! [`use`]: ../book/crates-and-modules.html#Importing%20Modules%20with%20use -//! [crate root]: ../book/crates-and-modules.html#Basic%20terminology%3A%20Crates%20and%20Modules +//! [`use`]: ../book/crates-and-modules.html#importing-modules-with-use +//! [crate root]: ../book/crates-and-modules.html#basic-terminology-crates-and-modules //! [crates.io]: https://crates.io //! [deref coercions]: ../book/deref-coercions.html //! [files]: fs/struct.File.html diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 1b3e17c300e..11197db98a3 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -490,7 +490,7 @@ mod prim_str { } /// assert_eq!(tuple.2, 'c'); /// ``` /// -/// For more about tuples, see [the book](../book/primitive-types.html#Tuples). +/// For more about tuples, see [the book](../book/primitive-types.html#tuples). /// /// # Trait implementations /// -- cgit 1.4.1-3-g733a5 From 3eb84341506d4124290dc81f598334d774360408 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 21 Feb 2017 01:15:29 -0500 Subject: Get linkchecker clean This affects the book, some missed things in the reference, the grammar, and the standard library. Whew! --- src/doc/book/src/attributes.md | 2 +- src/doc/book/src/compiler-plugins.md | 13 +++++++------ src/doc/book/src/macros.md | 8 ++++---- src/doc/book/src/syntax-index.md | 8 ++++---- src/doc/grammar.md | 2 +- src/doc/reference/src/attributes.md | 21 +++++++++++---------- src/doc/reference/src/expressions.md | 13 +++++++------ src/doc/reference/src/identifiers.md | 6 +++--- src/doc/reference/src/items.md | 2 +- src/libcore/intrinsics.rs | 2 +- src/libcore/marker.rs | 4 ++-- src/libcore/mem.rs | 8 ++++---- src/libstd/f32.rs | 2 +- src/libstd/f64.rs | 2 +- src/libstd/macros.rs | 2 +- 15 files changed, 49 insertions(+), 46 deletions(-) (limited to 'src/libstd') diff --git a/src/doc/book/src/attributes.md b/src/doc/book/src/attributes.md index 9e3cdb7ec09..103ec39aa38 100644 --- a/src/doc/book/src/attributes.md +++ b/src/doc/book/src/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/attributes.html diff --git a/src/doc/book/src/compiler-plugins.md b/src/doc/book/src/compiler-plugins.md index 1b7ce678982..c05d808a947 100644 --- a/src/doc/book/src/compiler-plugins.md +++ b/src/doc/book/src/compiler-plugins.md @@ -119,7 +119,7 @@ The advantages over a simple `fn(&str) -> u32` are: a way to define new literal syntax for any data type. In addition to procedural macros, you can define new -[`derive`](../reference.html#derive)-like attributes and other kinds of +[`derive`](../reference/attributes.html#derive)-like attributes and other kinds of extensions. See `Registry::register_syntax_extension` and the `SyntaxExtension` enum. For a more involved macro example, see [`regex_macros`](https://github.com/rust-lang/regex/blob/master/regex_macros/src/lib.rs). @@ -165,8 +165,8 @@ quasiquote as an ordinary plugin library. # Lint plugins Plugins can extend [Rust's lint -infrastructure](../reference.html#lint-check-attributes) with additional checks for -code style, safety, etc. Now let's write a plugin +infrastructure](../reference/attributes.html#lint-check-attributes) with +additional checks for code style, safety, etc. Now let's write a plugin [`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/run-pass-fulldeps/auxiliary/lint_plugin_test.rs) that warns about any item named `lintme`. @@ -244,9 +244,10 @@ mostly use the same infrastructure as lint plugins, and provide examples of how to access type information. Lints defined by plugins are controlled by the usual [attributes and compiler -flags](../reference.html#lint-check-attributes), e.g. `#[allow(test_lint)]` or -`-A test-lint`. These identifiers are derived from the first argument to -`declare_lint!`, with appropriate case and punctuation conversion. +flags](../reference/attributes.html#lint-check-attributes), e.g. +`#[allow(test_lint)]` or `-A test-lint`. These identifiers are derived from the +first argument to `declare_lint!`, with appropriate case and punctuation +conversion. You can run `rustc -W help foo.rs` to see a list of lints known to `rustc`, including those provided by plugins loaded by `foo.rs`. diff --git a/src/doc/book/src/macros.md b/src/doc/book/src/macros.md index 861cb4371f9..93f63ddc0a5 100644 --- a/src/doc/book/src/macros.md +++ b/src/doc/book/src/macros.md @@ -101,7 +101,7 @@ trees, at compile time. The semicolon is optional on the last (here, only) case. The "pattern" on the left-hand side of `=>` is known as a ‘matcher’. These have [their own little grammar] within the language. -[their own little grammar]: ../reference.html#macros +[their own little grammar]: ../reference/macros.html The matcher `$x:expr` will match any Rust expression, binding that syntax tree to the ‘metavariable’ `$x`. The identifier `expr` is a ‘fragment specifier’; @@ -363,7 +363,7 @@ fn main() { } ``` -[items]: ../reference.html#items +[items]: ../reference/items.html # Recursive macros @@ -490,7 +490,7 @@ be forced to choose between parsing `$i` and parsing `$e`. Changing the invocation syntax to put a distinctive token in front can solve the problem. In this case, you can write `$(I $i:ident)* E $e:expr`. -[item]: ../reference.html#items +[item]: ../reference/items.html # Scoping and macro import/export @@ -565,7 +565,7 @@ When this library is loaded with `#[macro_use] extern crate`, only `m2` will be imported. The Rust Reference has a [listing of macro-related -attributes](../reference.html#macro-related-attributes). +attributes](../reference/attributes.html#macro-related-attributes). # The variable `$crate` diff --git a/src/doc/book/src/syntax-index.md b/src/doc/book/src/syntax-index.md index b2cd59c87af..a06520f4ac2 100644 --- a/src/doc/book/src/syntax-index.md +++ b/src/doc/book/src/syntax-index.md @@ -235,10 +235,10 @@ [Primitive Types (Tuple Indexing)]: primitive-types.html#tuple-indexing [Primitive Types (Tuples)]: primitive-types.html#tuples [Raw Pointers]: raw-pointers.html -[Reference (Byte String Literals)]: ../reference.html#byte-string-literals -[Reference (Integer literals)]: ../reference.html#integer-literals -[Reference (Raw Byte String Literals)]: ../reference.html#raw-byte-string-literals -[Reference (Raw String Literals)]: ../reference.html#raw-string-literals +[Reference (Byte String Literals)]: ../reference/tokens.html/#byte-string-literals +[Reference (Integer literals)]: ../reference/tokens.html#integer-literals +[Reference (Raw Byte String Literals)]: ../reference/tokens.html#raw-byte-string-literals +[Reference (Raw String Literals)]: ../reference/tokens.html#raw-string-literals [References and Borrowing]: references-and-borrowing.html [Strings]: strings.html [Structs (Update syntax)]: structs.html#update-syntax diff --git a/src/doc/grammar.md b/src/doc/grammar.md index c81f2e2282b..8e803aff4d6 100644 --- a/src/doc/grammar.md +++ b/src/doc/grammar.md @@ -187,7 +187,7 @@ literal : [ string_lit | char_lit | byte_string_lit | byte_lit | num_lit | bool_ The optional `lit_suffix` production is only used for certain numeric literals, but is reserved for future extension. That is, the above gives the lexical grammar, but a Rust parser will reject everything but the 12 special cases -mentioned in [Number literals](reference.html#number-literals) in the +mentioned in [Number literals](reference/tokens.html#number-literals) in the reference. #### Character and string literals diff --git a/src/doc/reference/src/attributes.md b/src/doc/reference/src/attributes.md index 4a839676ed3..da43e1cc057 100644 --- a/src/doc/reference/src/attributes.md +++ b/src/doc/reference/src/attributes.md @@ -46,7 +46,7 @@ type int8_t = i8; ## Crate-only attributes - `crate_name` - specify the crate's crate name. -- `crate_type` - see [linkage](#linkage). +- `crate_type` - see [linkage](linkage.html). - `feature` - see [compiler features](#compiler-features). - `no_builtins` - disable optimizing certain code patterns to invocations of library functions that are assumed to exist @@ -106,7 +106,7 @@ On an `extern` block, the following attributes are interpreted: - `link` - indicate that a native library should be linked to for the declarations in this block to be linked correctly. `link` supports an optional `kind` key with three possible values: `dylib`, `static`, and `framework`. See - [external blocks](#external-blocks) for more about external blocks. Two + [external blocks](items.html#external-blocks) for more about external blocks. Two examples: `#[link(name = "readline")]` and `#[link(name = "CoreFoundation", kind = "framework")]`. - `linked_from` - indicates what native library this block of FFI items is @@ -149,7 +149,7 @@ On `struct`s: list of names `#[macro_use(foo, bar)]` restricts the import to just those macros named. The `extern crate` must appear at the crate root, not inside `mod`, which ensures proper function of the [`$crate` macro - variable](book/macros.html#The%20variable%20%24crate). + variable](../book/macros.html#the-variable-crate). - `macro_reexport` on an `extern crate` — re-export the named macros. @@ -159,7 +159,7 @@ On `struct`s: link it into the output. See the [macros section of the -book](book/macros.html#Scoping%20and%20macro%20import%2Fexport) for more information on +book](../book/macros.html#scoping-and-macro-importexport) for more information on macro scope. ## Miscellaneous attributes @@ -317,7 +317,8 @@ For any lint check `C`: The lint checks supported by the compiler can be found via `rustc -W help`, along with their default settings. [Compiler -plugins](book/compiler-plugins.html#lint-plugins) can provide additional lint checks. +plugins](../book/compiler-plugins.html#lint-plugins) can provide additional +lint checks. ```{.ignore} pub mod m1 { @@ -442,7 +443,7 @@ impl PartialEq for Foo { ``` You can implement `derive` for your own type through [procedural -macros](#procedural-macros). +macros](procedural-macros.html). ### Compiler Features @@ -464,10 +465,10 @@ considered off, and using the features will result in a compiler error. The currently implemented features of the reference compiler are: -* `advanced_slice_patterns` - See the [match expressions](#match-expressions) - section for discussion; the exact semantics of - slice patterns are subject to change, so some types - are still unstable. +* `advanced_slice_patterns` - See the [match + expressions](expressions.html#match-expressions) + section for discussion; the exact semantics of +slice patterns are subject to change, so some types are still unstable. * `slice_patterns` - OK, actually, slice patterns are just scary and completely unstable. diff --git a/src/doc/reference/src/expressions.md b/src/doc/reference/src/expressions.md index e2fb41e424b..c9c0496dac6 100644 --- a/src/doc/reference/src/expressions.md +++ b/src/doc/reference/src/expressions.md @@ -85,7 +85,7 @@ be copied if its type implements `Copy`. All others are moved. ## Literal expressions -A _literal expression_ consists of one of the [literal](tokens.md#literals) forms +A _literal expression_ consists of one of the [literal](tokens.html#literals) forms described earlier. It directly describes a number, character, string, boolean value, or the unit value. @@ -124,19 +124,19 @@ comma: ## Struct expressions There are several forms of struct expressions. A _struct expression_ -consists of the [path](#paths) of a [struct item](items.html#structs), followed +consists of the [path](paths.html) of a [struct item](items.html#structs), followed by a brace-enclosed list of zero or more comma-separated name-value pairs, providing the field values of a new instance of the struct. A field name can be any identifier, and is separated from its value expression by a colon. The location denoted by a struct field is mutable if and only if the enclosing struct is mutable. -A _tuple struct expression_ consists of the [path](#paths) of a [struct +A _tuple struct expression_ consists of the [path](paths.html) of a [struct item](items.html#structs), followed by a parenthesized list of one or more comma-separated expressions (in other words, the path of a struct item followed by a tuple expression). The struct item must be a tuple struct item. -A _unit-like struct expression_ consists only of the [path](#paths) of a +A _unit-like struct expression_ consists only of the [path](paths.html) of a [struct item](items.html#structs). The following are examples of struct expressions: @@ -217,7 +217,8 @@ A _method call_ consists of an expression followed by a single dot, an identifier, and a parenthesized expression-list. Method calls are resolved to methods on specific traits, either statically dispatching to a method if the exact `self`-type of the left-hand-side is known, or dynamically dispatching if -the left-hand-side expression is an indirect [trait object](trait-objects.html). +the left-hand-side expression is an indirect [trait +object](types.html#trait-objects). ## Field expressions @@ -504,7 +505,7 @@ The `+`, `-`, `*`, `/`, `%`, `&`, `|`, `^`, `<<`, and `>>` operators may be composed with the `=` operator. The expression `lval OP= val` is equivalent to `lval = lval OP val`. For example, `x = x + 1` may be written as `x += 1`. -Any such expression always has the [`unit`](#tuple-types) type. +Any such expression always has the [`unit`](types.html#tuple-types) type. ### Operator precedence diff --git a/src/doc/reference/src/identifiers.md b/src/doc/reference/src/identifiers.md index 4df68b39b91..de657e3e312 100644 --- a/src/doc/reference/src/identifiers.md +++ b/src/doc/reference/src/identifiers.md @@ -13,12 +13,12 @@ Or * The identifier is more than one character, `_` alone is not an identifier * The remaining characters have property `XID_continue` -that does _not_ occur in the set of [keywords][keywords]. +that does _not_ occur in the set of [keywords]. > **Note**: `XID_start` and `XID_continue` as character properties cover the > character ranges used to form the more familiar C and Java language-family > identifiers. -keywords: ../grammar.html#keywords +[keywords]: ../grammar.html#keywords [^non_ascii_idents]: Non-ASCII characters in identifiers are currently feature - gated. This is expected to improve soon. \ No newline at end of file + gated. This is expected to improve soon. diff --git a/src/doc/reference/src/items.md b/src/doc/reference/src/items.md index ccace77795c..ba3f4195ba6 100644 --- a/src/doc/reference/src/items.md +++ b/src/doc/reference/src/items.md @@ -5,7 +5,7 @@ nested set of [modules]. Every crate has a single "outermost" anonymous module; all further items within the crate have [paths] within the module tree of the crate. -[modules]: modules.html +[modules]: #modules [paths]: paths.html Items are entirely determined at compile-time, generally remain fixed during diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 31a0cc68841..12410c08f39 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -687,7 +687,7 @@ extern "rust-intrinsic" { /// The [nomicon](../../nomicon/transmutes.html) has additional /// documentation. /// - /// [ub]: ../../reference.html#behavior-considered-undefined + /// [ub]: ../../reference/behavior-considered-undefined.html /// /// # Examples /// diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index ede22ccddc6..1e9eaaf5f32 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -36,7 +36,7 @@ use hash::Hasher; /// /// [`Rc`]: ../../std/rc/struct.Rc.html /// [arc]: ../../std/sync/struct.Arc.html -/// [ub]: ../../reference.html#behavior-considered-undefined +/// [ub]: ../../reference/behavior-considered-undefined.html #[stable(feature = "rust1", since = "1.0.0")] #[lang = "send"] #[rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely"] @@ -338,7 +338,7 @@ pub trait Copy : Clone { /// [mutex]: ../../std/sync/struct.Mutex.html /// [rwlock]: ../../std/sync/struct.RwLock.html /// [unsafecell]: ../cell/struct.UnsafeCell.html -/// [ub]: ../../reference.html#behavior-considered-undefined +/// [ub]: ../../reference/behavior-considered-undefined.html /// [transmute]: ../../std/mem/fn.transmute.html #[stable(feature = "rust1", since = "1.0.0")] #[lang = "sync"] diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 209107ef92c..f4ce4697d7c 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -167,7 +167,7 @@ pub use intrinsics::transmute; /// [FFI]: ../../book/ffi.html /// [box]: ../../std/boxed/struct.Box.html /// [into_raw]: ../../std/boxed/struct.Box.html#method.into_raw -/// [ub]: ../../reference.html#behavior-considered-undefined +/// [ub]: ../../reference/behavior-considered-undefined.html #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn forget(t: T) { @@ -318,7 +318,7 @@ pub fn align_of_val(val: &T) -> usize { /// /// [uninit]: fn.uninitialized.html /// [FFI]: ../../book/ffi.html -/// [ub]: ../../reference.html#behavior-considered-undefined +/// [ub]: ../../reference/behavior-considered-undefined.html /// /// # Examples /// @@ -417,7 +417,7 @@ pub unsafe fn zeroed() -> T { /// [`Vec`]: ../../std/vec/struct.Vec.html /// [`vec!`]: ../../std/macro.vec.html /// [`Clone`]: ../../std/clone/trait.Clone.html -/// [ub]: ../../reference.html#behavior-considered-undefined +/// [ub]: ../../reference/behavior-considered-undefined.html /// [write]: ../ptr/fn.write.html /// [copy]: ../intrinsics/fn.copy.html /// [copy_no]: ../intrinsics/fn.copy_nonoverlapping.html @@ -626,7 +626,7 @@ pub fn drop(_x: T) { } /// same size. This function triggers [undefined behavior][ub] if `U` is larger than /// `T`. /// -/// [ub]: ../../reference.html#behavior-considered-undefined +/// [ub]: ../../reference/behavior-considered-undefined.html /// [size_of]: fn.size_of.html /// /// # Examples diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 7a676c041ad..544f4f9ddbe 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -264,7 +264,7 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - /// [floating-point]: ../reference.html#machine-types + /// [floating-point]: ../reference/types.html#machine-types #[unstable(feature = "float_extras", reason = "signature is undecided", issue = "27752")] #[rustc_deprecated(since = "1.11.0", diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index 67a1c302483..dd4bc253bed 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -206,7 +206,7 @@ impl f64 { /// /// assert!(abs_difference < 1e-10); /// ``` - /// [floating-point]: ../reference.html#machine-types + /// [floating-point]: ../reference/types.html#machine-types #[unstable(feature = "float_extras", reason = "signature is undecided", issue = "27752")] #[rustc_deprecated(since = "1.11.0", diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index d79a9a202d9..a1f092621cb 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -441,7 +441,7 @@ pub mod builtin { /// leads to less duplicated code. /// /// The syntax given to this macro is the same syntax as [the `cfg` - /// attribute](../reference.html#conditional-compilation). + /// attribute](../book/conditional-compilation.html). /// /// # Examples /// -- cgit 1.4.1-3-g733a5