This documentation confused me when trying to use truncate on a project. Originally, it was unclear whether truncate removed the last `len` elements, or whether it cut down the vector to be exactly `len` elements long. The example was also ambiguous.
This fixes#29048 (though I think adding better transactional support would be a better fix for that issue, but that is more difficult). It also simplifies region inference and changes the model to a pure data flow one, as discussed in [this internals thread](https://internals.rust-lang.org/t/rough-thoughts-on-the-impl-of-region-inference-mir-etc/2800). I am not 100% sure though if this PR is the right thing to do -- or at least maybe not at this moment, so thoughts on that would be appreciated.
r? @pnkfelix
cc @arielb1
This is two sentences that have been comma spliced, and should
be split with a full stop. (This error made me stop and re-read,
and I submit this as an actual improvement to readability, not
as a grammar weird-o!)
This helps for the case where a match, such as below:
```rust
let foo = match foo {
Some(x) => x,
None => 0
};
```
gets refactored to no longer need the match, but the match keyword has been left accidentally:
```rust
let foo = match foo.unwrap_or(0);
```
This can be hard to spot as the expression grows more complex.
r? @alexcrichton
This documentation confused me when trying to use truncate on a project. Originally, it was unclear whether truncate removed the last `len` elements, or whether it cut down the vector to be exactly `len` elements long. The example was also ambiguous.
This is two sentences that have been comma spliced, and should
be split with a full stop. (This error made me stop and re-read,
and I submit this as an actual improvement to readability, not
as a grammar weird-o!)
I put the reference under the function return operator `->` rather than near the suggested `!` operators as I thought it was more relevant there.
Resolves#29431
…m message
I recently discovered that this is not mentioned in the docs, only in
the examples, and it's not evident for people coming from C++
r? @steveklabnik
expansion already by growing the RHS to be bigger than LHS (all the way
to `'static` if necessary). This is needed because contraction doesn't
handle givens. Fixes#28934.
empty region, and they complicate region inference to no particular end.
They also lead in some cases to spurious errors like #29048 (though in
some cases these errors are helpful in tracking down missing
constraints).
Fix corner case in privacy that was causing ICEs when the `source_did` was not crate-local.
Full confession: I only kinda sorta understand this code, but afaict it's legit for `source_did` to be from another crate.
r? @alexcrichton
when evaluating a recursive type, the `type_of` of the interior could be
still in progress, so trying to get its size would cause an ICE.
Fixes#19001
r? @eddyb
This makes the error message in #28981 a bit shorter (152 to 115 lines).
Previous output (the local impl was always printed twice when it conflicted with an external impl):
```
test.rs:3:1: 3:23 error: conflicting implementations for trait `core::ops::Deref` [E0119]
test.rs:3 impl<T> Deref for T {}
^~~~~~~~~~~~~~~~~~~~~~
test.rs:3:1: 3:23 help: run `rustc --explain E0119` to see a detailed explanation
test.rs:3:1: 3:23 note: conflicting implementation in crate `std`
test.rs:3 impl<T> Deref for T {}
^~~~~~~~~~~~~~~~~~~~~~
```
Output after this patch:
```
test.rs:3:1: 3:23 error: conflicting implementations for trait `core::ops::Deref` [E0119]
test.rs:3 impl<T> Deref for T {}
^~~~~~~~~~~~~~~~~~~~~~
test.rs:3:1: 3:23 help: run `rustc --explain E0119` to see a detailed explanation
note: conflicting implementation in crate `std`
```
Closes#29314
The code from #29314:
```rust
fn main() {
if let Some(b) = None {
()
} else {
1
};
}
```
now prints this:
```
test.rs:2:5: 6:6 error: `if let` arms have incompatible types: expected `()`, found `_` (expected (), found integral variable) [E0308]
test.rs:2 if let Some(b) = None {
test.rs:3 ()
test.rs:4 } else {
test.rs:5 1
test.rs:6 };
test.rs:2:5: 6:6 help: run `rustc --explain E0308` to see a detailed explanation
test.rs:4:12: 6:6 note: `if let` arm with an incompatible type
test.rs:4 } else {
test.rs:5 1
test.rs:6 };
error: aborting due to previous error
```