From 0f491bee6976191ea977b4e400e6831844766f84 Mon Sep 17 00:00:00 2001 From: DenisKolodin Date: Sat, 26 Sep 2015 12:16:55 +0300 Subject: [PATCH 1/6] Typo fix in use declaration section of reference --- src/doc/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index eeae2de827a..b50e3af0fdd 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -881,7 +881,7 @@ mod foo { } use foo::example::iter; // good: foo is at crate root -// use example::iter; // bad: core is not at the crate root +// use example::iter; // bad: example is not at the crate root use self::baz::foobaz; // good: self refers to module 'foo' use foo::bar::foobar; // good: foo is at crate root From 08181d2a3bec3484dc7d0cc7a903922f9d2a302f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 26 Sep 2015 00:03:10 +0200 Subject: [PATCH 2/6] Remove warning of duplicated error code --- src/librustc/middle/check_const.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index c6ff38d0f09..b5901762e30 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -709,20 +709,26 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, if !is_const { v.add_qualif(ConstQualif::NOT_CONST); if v.mode != Mode::Var { + fn span_limited_call_error(tcx: &ty::ctxt, span: Span, s: &str) { + span_err!(tcx.sess, span, E0015, "{}", s); + } + // FIXME(#24111) Remove this check when const fn stabilizes if let UnstableFeatures::Disallow = v.tcx.sess.opts.unstable_features { - span_err!(v.tcx.sess, e.span, E0015, - "function calls in {}s are limited to \ - struct and enum constructors", v.msg()); + span_limited_call_error(&v.tcx, e.span, + &format!("function calls in {}s are limited to \ + struct and enum constructors", + v.msg())); v.tcx.sess.span_note(e.span, "a limited form of compile-time function \ evaluation is available on a nightly \ compiler via `const fn`"); } else { - span_err!(v.tcx.sess, e.span, E0015, - "function calls in {}s are limited to \ - constant functions, \ - struct and enum constructors", v.msg()); + span_limited_call_error(&v.tcx, e.span, + &format!("function calls in {}s are limited \ + to constant functions, \ + struct and enum constructors", + v.msg())); } } } From ded2370a740e7d3b3bd631012f1a724c11b315cf Mon Sep 17 00:00:00 2001 From: David Elliott Date: Sat, 26 Sep 2015 10:36:37 -0700 Subject: [PATCH 3/6] clarify that `find` returns first match the example for `find` was misleading in that it fails to mention the result is either `None` or `Some` containing only the first match. Further confusing the issue is the `println!` statement, "We got some numbers!" --- src/doc/trpl/iterators.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/doc/trpl/iterators.md b/src/doc/trpl/iterators.md index 1c574f02091..b52e0fefa57 100644 --- a/src/doc/trpl/iterators.md +++ b/src/doc/trpl/iterators.md @@ -150,15 +150,16 @@ let greater_than_forty_two = (0..100) .find(|x| *x > 42); match greater_than_forty_two { - Some(_) => println!("We got some numbers!"), - None => println!("No numbers found :("), + Some(_) => println!("Found a match!"), + None => println!("No match found :("), } ``` `find` takes a closure, and works on a reference to each element of an iterator. This closure returns `true` if the element is the element we're -looking for, and `false` otherwise. Because we might not find a matching -element, `find` returns an `Option` rather than the element itself. +looking for, and `false` otherwise. `find` returns the first element satisfying +the specified predicate. Because we might not find a matching element, `find` +returns an `Option` rather than the element itself. Another important consumer is `fold`. Here's what it looks like: From c3a74fa4c6239f7396b0d1980c2510ffed8501af Mon Sep 17 00:00:00 2001 From: Florian Hartwig Date: Sat, 26 Sep 2015 20:40:22 +0200 Subject: [PATCH 4/6] Elide lifetime in Deref doc example --- src/libcore/ops.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 350ade22707..582c091091f 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -1628,7 +1628,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { /// impl Deref for DerefExample { /// type Target = T; /// -/// fn deref<'a>(&'a self) -> &'a T { +/// fn deref(&self) -> &T { /// &self.value /// } /// } From 3885a81e5fa9913075537c9df857fa1753c5d7c1 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Sat, 26 Sep 2015 11:59:00 -0700 Subject: [PATCH 5/6] Add an example of constructing a unit-like struct. This was non-obvious to me: with no example, I assumed `Electron {}` and didn't know what else to try when it didn't work. The correct form is weird because it looks like you're assigning the struct name rather than an instance of the struct. --- src/doc/trpl/structs.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/doc/trpl/structs.md b/src/doc/trpl/structs.md index 85b11d0b6b5..b51ad8e087d 100644 --- a/src/doc/trpl/structs.md +++ b/src/doc/trpl/structs.md @@ -184,6 +184,8 @@ You can define a `struct` with no members at all: ```rust struct Electron; + +let x = Electron; ``` Such a `struct` is called ‘unit-like’ because it resembles the empty From 865889a2ccf6c217df158b5e088b2fba71e86da4 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Sat, 26 Sep 2015 12:03:42 -0700 Subject: [PATCH 6/6] Fix meta-documentation for generating all docs. This wasn't complete (you need a `./configure`), and it is already documented well in the main README. Also adds a reference to the books that this also generates. --- src/doc/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/doc/README.md b/src/doc/README.md index c09f28ae4f6..0882b073ea4 100644 --- a/src/doc/README.md +++ b/src/doc/README.md @@ -2,9 +2,10 @@ ## Building -To generate all the docs, just run `make docs` from the root of the repository. -This will convert the distributed Markdown docs to HTML and generate HTML doc -for the 'std' and 'extra' libraries. +To generate all the docs, follow the "Building Documentation" instructions in +the README in the root of the repository. This will convert the distributed +Markdown docs to HTML and generate HTML doc for the books, 'std' and 'extra' +libraries. To generate HTML documentation from one source file/crate, do something like: