Improve the documentation for std::convert (From, Into, AsRef and AsMut)
# Description
In this PR I updated the documentation of From, Into, AsRef and AsMut, as well as the general std::convert module documentation. The discussion in #59163 provided information that was not yet present in the docs, or was not expressed clearly enough. I tried to clarify the examples that were already present in the docs as well as add more information about considered best-practices that came out of the discussion in #59163
@steveklabnik I hope I didn't change too much. This is an initial version! I will scan through everything tomorrow as well again to see if I made any typo's or errors, and maybe make some small changes here and there.
All suggestions are welcome!
closes#59163
Exclude old book redirect stubs from search engines
Adds `<meta name="robots" content="noindex,follow">` to the `<head>` of old stub pages pointing to the second edition of the book.
This is continuation of https://github.com/rust-lang/book/pull/1788
Simplify checked_duration_since
This follows the same design as we updated to in #56490. Internally, all the system specific time implementations are checked, no panics. Then the panicking publicly exported API can just call the checked version of itself and make do with a single panic (`expect`) at the top.
Since the internal sys implementations are now checked, this gets rid of the extra `if self >= &earlier` check in `checked_duration_since`. Except likely making the generated machine code simpler, it also reduces the algorithm from "Check panic condition -> call possibly panicking method" to just "call non panicking method".
Added two test cases:
* Edge case: Make sure `checked_duration_since` on two equal `Instant`s produce a zero duration, not a `None`.
* Most common/intended usage: Make sure `later.checked_duration_since(earlier)`, returns an expected value.
Demo `FromIterator` short-circuiting
while looking at a FIXME in `FromIterator for Option` and `FromIterator for Result`, I realized that the current documentation does not have example code showing exactly what is meant by "no further elements are taken."
The code snippets provided here are meant to correct that.
Update build instructions in README.md
Add additional instructions when `sudo ./x.py install` fails to
complete the build.
This resolves issues #40108 and #49269.
r? @steveklabnik
Provide suggestion when using field access instead of path
When trying to access an associated constant as if it were a field of
an instance, provide a suggestion for the correct syntax.
Fix#57316.
SGX target: fix std unit tests
This fixes some tests and some code in the SGX sys implementation to make the `std` unit test suite pass.
#59009 must be merged first.
filter suggestions from extern prelude
Fixes#59027.
Modifies the candidate gathering code to call `filter_fn` on extern crates, which causes them to be filtered out when looking for a type.
make asm diagnostic instruction optional
`DiagnosticInfoInlineAsm::getInstruction` may return a null pointer, so
the instruction shouldn't be blindly unwrapped.
Reopening from #55193. I was unable to trigger the assertion on Windows after rebasing.
Fixes#23458.
Fixes#55216.
When moving out of a for loop head, suggest borrowing it
When encountering code like the following, suggest borrowing the for loop
head to avoid moving it into the for loop pattern:
```
fn main() {
let a = vec![1, 2, 3];
for i in &a {
for j in a {
println!("{} * {} = {}", i, j, i * j);
}
}
}
```
Fix#25534.
When encountering code like the following, suggest borrowing the for loop
head to avoid moving it into the for loop pattern:
```
fn main() {
let a = vec![1, 2, 3];
for i in &a {
for j in a {
println!("{} * {} = {}", i, j, i * j);
}
}
}
```
Rollup of 7 pull requests
Successful merges:
- #59213 (Track changes to robots.txt)
- #59239 (Remove inline assembly from hint::spin_loop)
- #59251 (Use a valid name for graphviz graphs)
- #59296 (Do not encode gensymed imports in metadata)
- #59328 (Implement specialized nth_back() for Box and Windows.)
- #59355 (Fix ICE with const generic param in struct)
- #59377 (Correct minimum system LLVM version in tests)
This commit removes `CtorOf` from `Node::Ctor` as the parent of the
constructor can be determined by looking at the node's parent in the few
places where knowing this is necessary.
Correct minimum system LLVM version in tests
Since commit 9452a8dfa3, the new debug info format is only generated
for LLVM 8 and newer versions. However, the tests still assume that LLVM
7 will use the new debug info format. Fix the tests (and a comment in
the code) to match the actual version check.
(WIP) Small fixes in chalkification
Small fixes around region constraints and builtin impls. There are still some type inference errors, for example the following code errors out:
```rust
fn main() {
let mut x: Vec<i32> = Vec::new();
// ^^^^^^^^ cannot infer type for `std::vec::Vec<_>`
}
```
but explicitly specifying `Vec::<i32>::new` works.
With these few fixes, the following code now passes type-checking:
```rust
fn main() {
let mut x: Vec<i32> = Vec::<i32>::new();
x.push(5);
println!("{:?}", x);
}
```
I also fixed the implied bounds bug as discussed on Zulip and in https://github.com/rust-lang-nursery/chalk/pull/206
cc @tmandry
r? @nikomatsakis