diff --git a/src/doc/book/choosing-your-guarantees.md b/src/doc/book/choosing-your-guarantees.md index 50350213074bf..d88f619260ac0 100644 --- a/src/doc/book/choosing-your-guarantees.md +++ b/src/doc/book/choosing-your-guarantees.md @@ -232,7 +232,7 @@ indicator (one word in size) along with the data. At runtime each borrow causes a modification/check of the refcount. -[cell-mod]: ../std/cell/ +[cell-mod]: ../std/cell/index.html [cell]: ../std/cell/struct.Cell.html [refcell]: ../std/cell/struct.RefCell.html diff --git a/src/doc/book/documentation.md b/src/doc/book/documentation.md index 4a41bb7b7f37e..3c6643fbfe155 100644 --- a/src/doc/book/documentation.md +++ b/src/doc/book/documentation.md @@ -76,7 +76,7 @@ This [unfortunate error](https://github.com/rust-lang/rust/issues/22547) is correct; documentation comments apply to the thing after them, and there's nothing after that last comment. -[rc-new]: https://doc.rust-lang.org/nightly/std/rc/struct.Rc.html#method.new +[rc-new]: ../std/rc/struct.Rc.html#method.new ### Writing documentation comments diff --git a/src/doc/book/error-handling.md b/src/doc/book/error-handling.md index c914c33a5a4b9..bca3418706771 100644 --- a/src/doc/book/error-handling.md +++ b/src/doc/book/error-handling.md @@ -2205,7 +2205,7 @@ heuristics! [3]: ../std/option/enum.Option.html#method.unwrap_or [4]: ../std/option/enum.Option.html#method.unwrap_or_else [5]: ../std/option/enum.Option.html -[6]: ../std/result/ +[6]: ../std/result/index.html [7]: ../std/result/enum.Result.html#method.unwrap [8]: ../std/fmt/trait.Debug.html [9]: ../std/primitive.str.html#method.parse diff --git a/src/doc/book/using-rust-without-the-standard-library.md b/src/doc/book/using-rust-without-the-standard-library.md index 1179aebe54c55..69958dd3e68a4 100644 --- a/src/doc/book/using-rust-without-the-standard-library.md +++ b/src/doc/book/using-rust-without-the-standard-library.md @@ -22,11 +22,12 @@ fn plus_one(x: i32) -> i32 { ``` Much of the functionality that’s exposed in the standard library is also -available via the [`core` crate](../core/). When we’re using the standard -library, Rust automatically brings `std` into scope, allowing you to use -its features without an explicit import. By the same token, when using +available via the [`core` crate](../core/index.html). When we’re using the +standard library, Rust automatically brings `std` into scope, allowing you to +use its features without an explicit import. By the same token, when using `#![no_std]`, Rust will bring `core` into scope for you, as well as [its -prelude](../core/prelude/v1/). This means that a lot of code will Just Work: +prelude](../core/prelude/v1/index.html). This means that a lot of code will Just +Work: ```rust #![no_std] diff --git a/src/doc/book/vectors.md b/src/doc/book/vectors.md index 1c44af2f21a71..f3854b8ffddce 100644 --- a/src/doc/book/vectors.md +++ b/src/doc/book/vectors.md @@ -152,5 +152,5 @@ API documentation][vec]. [box]: ../std/boxed/index.html [generic]: generics.html [panic]: concurrency.html#panics -[get]: http://doc.rust-lang.org/std/vec/struct.Vec.html#method.get -[get_mut]: http://doc.rust-lang.org/std/vec/struct.Vec.html#method.get_mut +[get]: ../std/vec/struct.Vec.html#method.get +[get_mut]: ../std/vec/struct.Vec.html#method.get_mut diff --git a/src/doc/nomicon/README.md b/src/doc/nomicon/README.md index 4554652a17a2a..b2e1eac5e0dcc 100644 --- a/src/doc/nomicon/README.md +++ b/src/doc/nomicon/README.md @@ -35,4 +35,4 @@ exception-safety, pointer aliasing, memory models, and even some type-theory. We will also be spending a lot of time talking about the different kinds of safety and guarantees. -[trpl]: ../book/ +[trpl]: ../book/index.html diff --git a/src/librustc_const_eval/diagnostics.rs b/src/librustc_const_eval/diagnostics.rs index 8b1d7bed7c42d..f2abdf831a3b8 100644 --- a/src/librustc_const_eval/diagnostics.rs +++ b/src/librustc_const_eval/diagnostics.rs @@ -384,18 +384,19 @@ let irr = Irrefutable(0); // This fails to compile because the match is irrefutable. while let Irrefutable(x) = irr { - ... + // ... } +``` Try this instead: -``` +```no_run struct Irrefutable(i32); let irr = Irrefutable(0); loop { let Irrefutable(x) = irr; - ... + // ... } ``` "##, diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index d06030637afd8..e9e52a0121a36 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -2040,6 +2040,7 @@ impl Foo for Bar { // the trait fn foo(&self) {} } +``` "##, E0186: r##" diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 734f774043d6d..0180c3118a586 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -32,6 +32,8 @@ use time::SystemTime; /// it was opened with. Files also implement `Seek` to alter the logical cursor /// that the file contains internally. /// +/// Files are automatically closed when they go out of scope. +/// /// # Examples /// /// ```no_run @@ -1341,8 +1343,9 @@ pub fn remove_dir_all>(path: P) -> io::Result<()> { /// if dir.is_dir() { /// for entry in try!(fs::read_dir(dir)) { /// let entry = try!(entry); -/// if try!(entry.file_type()).is_dir() { -/// try!(visit_dirs(&entry.path(), cb)); +/// let path = entry.path(); +/// if path.is_dir() { +/// try!(visit_dirs(&path, cb)); /// } else { /// cb(&entry); /// } diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index e083605a2acd5..11af768c5b9b0 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -28,7 +28,7 @@ /// ``` /// /// [`assert!`]: macro.assert!.html -/// [`if` conditionals]: ../book/if.html +/// [`if`]: ../book/if.html /// [`BitAnd`]: ops/trait.BitAnd.html /// [`BitOr`]: ops/trait.BitOr.html /// [`Not`]: ops/trait.Not.html diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 1b6f6c3e875c9..3ce9bcc79f24a 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -195,7 +195,7 @@ impl FromInner for ChildStderr { /// .arg("-c") /// .arg("echo hello") /// .output() -/// .expect("failed to execute proces"); +/// .expect("failed to execute process"); /// /// let hello = output.stdout; /// ``` diff --git a/src/test/compile-fail/E0162.rs b/src/test/compile-fail/E0162.rs new file mode 100644 index 0000000000000..e13b0af6f7977 --- /dev/null +++ b/src/test/compile-fail/E0162.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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. + +struct Irrefutable(i32); + +fn main() { + let irr = Irrefutable(0); + if let Irrefutable(x) = irr { //~ ERROR E0162 + println!("{}", x); + } +} diff --git a/src/test/compile-fail/E0163.rs b/src/test/compile-fail/E0163.rs new file mode 100644 index 0000000000000..5cb6f4d2803e1 --- /dev/null +++ b/src/test/compile-fail/E0163.rs @@ -0,0 +1,20 @@ +// Copyright 2016 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. + +enum Foo { B(u32) } + +fn bar(foo: Foo) -> u32 { + match foo { + Foo::B { i } => i, //~ ERROR E0163 + } +} + +fn main() { +} diff --git a/src/test/compile-fail/E0164.rs b/src/test/compile-fail/E0164.rs new file mode 100644 index 0000000000000..491b2e9e5b246 --- /dev/null +++ b/src/test/compile-fail/E0164.rs @@ -0,0 +1,20 @@ +// Copyright 2016 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. + +enum Foo { B { i: u32 } } + +fn bar(foo: Foo) -> u32 { + match foo { + Foo::B(i) => i, //~ ERROR E0164 + } +} + +fn main() { +} diff --git a/src/test/compile-fail/E0165.rs b/src/test/compile-fail/E0165.rs new file mode 100644 index 0000000000000..cca714bbcc1bf --- /dev/null +++ b/src/test/compile-fail/E0165.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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. + +struct Irrefutable(i32); + +fn main() { + let irr = Irrefutable(0); + while let Irrefutable(x) = irr { //~ ERROR E0165 + // ... + } +} diff --git a/src/test/compile-fail/E0166.rs b/src/test/compile-fail/E0166.rs new file mode 100644 index 0000000000000..9fa41249aa50b --- /dev/null +++ b/src/test/compile-fail/E0166.rs @@ -0,0 +1,14 @@ +// Copyright 2016 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. + +fn foo() -> ! { return; } //~ ERROR E0166 + +fn main() { +} diff --git a/src/test/compile-fail/E0172.rs b/src/test/compile-fail/E0172.rs new file mode 100644 index 0000000000000..7011bf0e93734 --- /dev/null +++ b/src/test/compile-fail/E0172.rs @@ -0,0 +1,14 @@ +// Copyright 2016 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. + +fn foo(bar: i32+std::fmt::Display) {} //~ ERROR E0172 + +fn main() { +} diff --git a/src/test/compile-fail/E0178.rs b/src/test/compile-fail/E0178.rs new file mode 100644 index 0000000000000..f34f3834e05b1 --- /dev/null +++ b/src/test/compile-fail/E0178.rs @@ -0,0 +1,21 @@ +// Copyright 2016 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. + +trait Foo {} + +struct Bar<'a> { + w: &'a Foo + Copy, //~ ERROR E0178 + x: &'a Foo + 'a, //~ ERROR E0178 + y: &'a mut Foo + 'a, //~ ERROR E0178 + z: fn() -> Foo + 'a, //~ ERROR E0178 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0184.rs b/src/test/compile-fail/E0184.rs new file mode 100644 index 0000000000000..5d72d00ffe876 --- /dev/null +++ b/src/test/compile-fail/E0184.rs @@ -0,0 +1,20 @@ +// Copyright 2016 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. + +#[derive(Copy)] //~ ERROR E0184 +struct Foo; + +impl Drop for Foo { + fn drop(&mut self) { + } +} + +fn main() { +} diff --git a/src/test/compile-fail/E0185.rs b/src/test/compile-fail/E0185.rs new file mode 100644 index 0000000000000..0e33687a84dfb --- /dev/null +++ b/src/test/compile-fail/E0185.rs @@ -0,0 +1,22 @@ +// Copyright 2016 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. + +trait Foo { + fn foo(); +} + +struct Bar; + +impl Foo for Bar { + fn foo(&self) {} //~ ERROR E0185 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0186.rs b/src/test/compile-fail/E0186.rs new file mode 100644 index 0000000000000..aa0a38bedcb54 --- /dev/null +++ b/src/test/compile-fail/E0186.rs @@ -0,0 +1,22 @@ +// Copyright 2016 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. + +trait Foo { + fn foo(&self); +} + +struct Bar; + +impl Foo for Bar { + fn foo() {} //~ ERROR E0186 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0191.rs b/src/test/compile-fail/E0191.rs new file mode 100644 index 0000000000000..489ebb033f84e --- /dev/null +++ b/src/test/compile-fail/E0191.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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. + +trait Trait { + type Bar; +} + +type Foo = Trait; //~ ERROR E0191 + +fn main() { +} diff --git a/src/test/compile-fail/E0192.rs b/src/test/compile-fail/E0192.rs new file mode 100644 index 0000000000000..92f5876ee04d5 --- /dev/null +++ b/src/test/compile-fail/E0192.rs @@ -0,0 +1,22 @@ +// Copyright 2016 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. + +#![feature(optin_builtin_traits)] + +trait Trait { + type Bar; +} + +struct Foo; + +impl !Trait for Foo { } //~ ERROR E0192 + +fn main() { +} diff --git a/src/test/compile-fail/E0194.rs b/src/test/compile-fail/E0194.rs new file mode 100644 index 0000000000000..96b3062cacb78 --- /dev/null +++ b/src/test/compile-fail/E0194.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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. + +trait Foo { + fn do_something(&self) -> T; + fn do_something_else(&self, bar: T); //~ ERROR E0194 +} + +fn main() { +} diff --git a/src/test/compile-fail/E0195.rs b/src/test/compile-fail/E0195.rs new file mode 100644 index 0000000000000..0630dfea5e64b --- /dev/null +++ b/src/test/compile-fail/E0195.rs @@ -0,0 +1,23 @@ +// Copyright 2016 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. + +trait Trait { + fn bar<'a,'b:'a>(x: &'a str, y: &'b str); +} + +struct Foo; + +impl Trait for Foo { + fn bar<'a,'b>(x: &'a str, y: &'b str) { //~ ERROR E0195 + } +} + +fn main() { +} diff --git a/src/test/compile-fail/E0197.rs b/src/test/compile-fail/E0197.rs new file mode 100644 index 0000000000000..f25fa9b92b9a0 --- /dev/null +++ b/src/test/compile-fail/E0197.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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. + +struct Foo; + +unsafe impl Foo { } //~ ERROR E0197 + +fn main() { +} diff --git a/src/test/compile-fail/E0199.rs b/src/test/compile-fail/E0199.rs new file mode 100644 index 0000000000000..8bd3ffdf6f6ee --- /dev/null +++ b/src/test/compile-fail/E0199.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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. + +#![feature(optin_builtin_traits)] + +struct Foo; + +unsafe impl !Clone for Foo { } //~ ERROR E0199 + +fn main() { +} diff --git a/src/test/compile-fail/E0200.rs b/src/test/compile-fail/E0200.rs new file mode 100644 index 0000000000000..6bfea0e59d76e --- /dev/null +++ b/src/test/compile-fail/E0200.rs @@ -0,0 +1,18 @@ +// Copyright 2016 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. + +struct Foo; + +unsafe trait Bar { } + +impl Bar for Foo { } //~ ERROR E0200 + +fn main() { +}