The escaped newline in the middle of the variable reference breaks the
short hash substitution, leaving the link text exmpty; rewrap so that
each replacement is on its own line.
This causes borrowck to correctly reject mutation or mutable borrows
of upvars in `Fn` unboxed closures since the closure environment is
aliasable.
This also tracks the responsible closure in the aliasability
information returned and uses it to give a helpful diagnostic.
Closes issue #17780
There is an issue with lev_distance, where
```
fn main() {
println!("{}", "\x80".lev_distance("\x80"))
}
```
prints `2`.
This is due to using the byte length instead of the char length.
The escaped newline in the middle of the variable reference breaks the
short hash substitution, leaving the link text exmpty; rewrap so that
each replacement is on its own line.
Hi,
These are a few small edits to the Guide that I made while reading online. Really well done and approachable.
I have a few questions below, but I don't know if this is the proper place to ask them, so feel free to ignore the below.
1. Trailing commas seem to be a convention in Rust and are used quite a bit throughout the Guide, but are never explicitly mentioned. Maybe adding a short mention about them when they first appear in the Structs section might be helpful to those who are unfamiliar with or don't use them in other languages.
2. In the Iterators section, there is a block of code like this:
```rust
let mut range = range(0i, 10i);
loop {
match range.next() {
Some(x) => {
println!("{}", x);
} // no comma needed?
None => { break }
}
}
```
My inclination would be to put a comma where the comment is to separate the two arms to get this to compile, but it runs fine either way. Is there a convention on commas for scenarios like this where each arm is enclosed in `{}`?
All the best,
O-I
`v.len()` counts code units, not UTF-16 bytes. The lower bound is one UTF-8 byte per code unit, not per two code units.
I believe this is correct, but it’s late. Someone please double check.
This is a quick fix that prevents an ICE by mimicing the visitor
glue for boxed closures and bare functions. Ideally, the `TyVisitor`
interface will be improved in the future to allow representing
more information about unboxed closures such as Fn/FnMut/FnOnce
status, capture mode, and captured free variable types and offsets.
Closes issue #17737
This began as an attempt to fix an ICE in borrowck (issue #17655), but the rabbit hole went pretty deep. I ended up plumbing support for capture-by-reference unboxed closures all the way into trans.
Closes issue #17655.