Auto merge of #28685 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #28666, #28674, #28677, #28678, #28679, #28680 - Failed merges: #28621
This commit is contained in:
commit
90c04d0362
@ -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:
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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
|
||||
|
@ -1628,7 +1628,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
/// impl<T> Deref for DerefExample<T> {
|
||||
/// type Target = T;
|
||||
///
|
||||
/// fn deref<'a>(&'a self) -> &'a T {
|
||||
/// fn deref(&self) -> &T {
|
||||
/// &self.value
|
||||
/// }
|
||||
/// }
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user