Skip to content

Rollup of 6 pull requests #28685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Sep 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions src/doc/trpl/iterators.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 2 additions & 0 deletions src/doc/trpl/structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,7 @@ impl<Idx: fmt::Debug> fmt::Debug for RangeTo<Idx> {
/// impl<T> Deref for DerefExample<T> {
/// type Target = T;
///
/// fn deref<'a>(&'a self) -> &'a T {
/// fn deref(&self) -> &T {
/// &self.value
/// }
/// }
Expand Down
20 changes: 13 additions & 7 deletions src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
}
}
Expand Down