diff --git a/src/doc/README.md b/src/doc/README.md index c09f28ae4f62d..0882b073ea48c 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: diff --git a/src/doc/reference.md b/src/doc/reference.md index eeae2de827ae6..b50e3af0fdd95 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 diff --git a/src/doc/trpl/iterators.md b/src/doc/trpl/iterators.md index 1c574f02091f8..b52e0fefa57e2 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: diff --git a/src/doc/trpl/structs.md b/src/doc/trpl/structs.md index 85b11d0b6b5ee..b51ad8e087d22 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 diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 350ade22707ca..582c091091fb2 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -1628,7 +1628,7 @@ impl fmt::Debug for RangeTo { /// impl Deref for DerefExample { /// type Target = T; /// -/// fn deref<'a>(&'a self) -> &'a T { +/// fn deref(&self) -> &T { /// &self.value /// } /// } diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index c6ff38d0f093d..b5901762e30d7 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())); } } }