mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
5706be1854
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
94 lines
3.0 KiB
Plaintext
94 lines
3.0 KiB
Plaintext
error[E0499]: cannot borrow `*f` as mutable more than once at a time
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:50:11
|
|
|
|
|
LL | f(f(10));
|
|
| - ^ second mutable borrow occurs here
|
|
| |
|
|
| first mutable borrow occurs here
|
|
| first borrow later used by call
|
|
|
|
error[E0382]: use of moved value: `f`
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:57:11
|
|
|
|
|
LL | fn twice_ten_so<F: FnOnce(i32) -> i32>(f: Box<F>) {
|
|
| - move occurs because `f` has type `Box<F>`, which does not implement the `Copy` trait
|
|
LL | f(f(10));
|
|
| - ^ value used here after move
|
|
| |
|
|
| value moved here
|
|
|
|
error[E0499]: cannot borrow `*f` as mutable more than once at a time
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:62:11
|
|
|
|
|
LL | f(f(10));
|
|
| - ^ second mutable borrow occurs here
|
|
| |
|
|
| first mutable borrow occurs here
|
|
| first borrow later used by call
|
|
|
|
error[E0382]: use of moved value: `f`
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:69:11
|
|
|
|
|
LL | fn twice_ten_oo(f: Box<dyn FnOnce(i32) -> i32>) {
|
|
| - move occurs because `f` has type `Box<dyn FnOnce(i32) -> i32>`, which does not implement the `Copy` trait
|
|
LL | f(f(10));
|
|
| - ^ value used here after move
|
|
| |
|
|
| value moved here
|
|
|
|
error[E0502]: cannot borrow `a` as immutable because it is also borrowed as mutable
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:107:27
|
|
|
|
|
LL | double_access(&mut a, &a);
|
|
| ------------- ------ ^^ immutable borrow occurs here
|
|
| | |
|
|
| | mutable borrow occurs here
|
|
| mutable borrow later used by call
|
|
|
|
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:132:7
|
|
|
|
|
LL | i[i[3]] = 4;
|
|
| --^----
|
|
| |||
|
|
| ||immutable borrow occurs here
|
|
| |mutable borrow later used here
|
|
| mutable borrow occurs here
|
|
|
|
|
help: try adding a local storing this...
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:132:8
|
|
|
|
|
LL | i[i[3]] = 4;
|
|
| ^^^
|
|
help: ...and then using that local here
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:132:6
|
|
|
|
|
LL | i[i[3]] = 4;
|
|
| ^^^^^^
|
|
|
|
error[E0502]: cannot borrow `i` as immutable because it is also borrowed as mutable
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:138:7
|
|
|
|
|
LL | i[i[3]] = i[4];
|
|
| --^----
|
|
| |||
|
|
| ||immutable borrow occurs here
|
|
| |mutable borrow later used here
|
|
| mutable borrow occurs here
|
|
|
|
|
help: try adding a local storing this...
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:138:8
|
|
|
|
|
LL | i[i[3]] = i[4];
|
|
| ^^^
|
|
help: ...and then using that local here
|
|
--> $DIR/two-phase-nonrecv-autoref.rs:138:6
|
|
|
|
|
LL | i[i[3]] = i[4];
|
|
| ^^^^^^
|
|
|
|
error: aborting due to 7 previous errors
|
|
|
|
Some errors have detailed explanations: E0382, E0499, E0502.
|
|
For more information about an error, try `rustc --explain E0382`.
|