Stop pointing to operators if their libcore method source is not available

This commit is contained in:
Oli Scherer 2022-12-12 15:36:08 +00:00
parent 59554a2b54
commit 6984085088
5 changed files with 16 additions and 70 deletions

View File

@ -1059,12 +1059,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
);
if self.fn_self_span_reported.insert(fn_span) {
err.span_note(
// Check whether the source is accessible
if self.infcx.tcx.sess.source_map().is_span_accessible(self_arg.span) {
self_arg.span
} else {
fn_call_span
},
self_arg.span,
"calling this operator moves the left-hand side",
);
}

View File

@ -9,10 +9,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/binop-consume-args.rs:6:5
|
LL | lhs + rhs;
| ^^^^^^^^^
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
help: consider further restricting this bound
|
LL | fn add<A: Add<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@ -45,10 +42,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/binop-consume-args.rs:12:5
|
LL | lhs - rhs;
| ^^^^^^^^^
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
help: consider further restricting this bound
|
LL | fn sub<A: Sub<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@ -81,10 +75,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/binop-consume-args.rs:18:5
|
LL | lhs * rhs;
| ^^^^^^^^^
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
help: consider further restricting this bound
|
LL | fn mul<A: Mul<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@ -117,10 +108,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/binop-consume-args.rs:24:5
|
LL | lhs / rhs;
| ^^^^^^^^^
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
help: consider further restricting this bound
|
LL | fn div<A: Div<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@ -153,10 +141,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/binop-consume-args.rs:30:5
|
LL | lhs % rhs;
| ^^^^^^^^^
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
help: consider further restricting this bound
|
LL | fn rem<A: Rem<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@ -189,10 +174,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/binop-consume-args.rs:36:5
|
LL | lhs & rhs;
| ^^^^^^^^^
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
help: consider further restricting this bound
|
LL | fn bitand<A: BitAnd<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@ -225,10 +207,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/binop-consume-args.rs:42:5
|
LL | lhs | rhs;
| ^^^^^^^^^
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
help: consider further restricting this bound
|
LL | fn bitor<A: BitOr<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@ -261,10 +240,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/binop-consume-args.rs:48:5
|
LL | lhs ^ rhs;
| ^^^^^^^^^
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
help: consider further restricting this bound
|
LL | fn bitxor<A: BitXor<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@ -297,10 +273,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/binop-consume-args.rs:54:5
|
LL | lhs << rhs;
| ^^^^^^^^^^
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
help: consider further restricting this bound
|
LL | fn shl<A: Shl<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@ -333,10 +306,7 @@ LL | drop(lhs);
| ^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/binop-consume-args.rs:60:5
|
LL | lhs >> rhs;
| ^^^^^^^^^^
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
help: consider further restricting this bound
|
LL | fn shr<A: Shr<B, Output=()> + Copy, B>(lhs: A, rhs: B) {

View File

@ -12,12 +12,7 @@ LL | | x;
| `x` moved due to usage in operator
|
note: calling this operator moves the left-hand side
--> $DIR/binop-move-semantics.rs:6:5
|
LL | / x
LL | | +
LL | | x;
| |_____^
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
help: consider further restricting this bound
|
LL | fn double_move<T: Add<Output=()> + Copy>(x: T) {
@ -79,12 +74,7 @@ LL | | *n;
| |______- `*m` moved due to usage in operator
|
note: calling this operator moves the left-hand side
--> $DIR/binop-move-semantics.rs:30:5
|
LL | / *m
LL | | +
LL | | *n;
| |______^
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error[E0507]: cannot move out of `*n` which is behind a shared reference
--> $DIR/binop-move-semantics.rs:32:5

View File

@ -109,10 +109,7 @@ LL | foo_add;
| ^^^^^^^ value used here after move
|
note: calling this operator moves the left-hand side
--> $DIR/move-fn-self-receiver.rs:58:5
|
LL | foo_add + Foo;
| ^^^^^^^^^^^^^
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
error[E0382]: use of moved value: `implicit_into_iter`
--> $DIR/move-fn-self-receiver.rs:63:5

View File

@ -10,10 +10,7 @@ LL | x.clone();
| ^^^^^^^^^ value borrowed here after move
|
note: calling this operator moves the left-hand side
--> $DIR/unop-move-semantics.rs:6:5
|
LL | !x;
| ^^
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
help: consider cloning the value if the performance cost is acceptable
|
LL | !x.clone();
@ -56,10 +53,7 @@ LL | !*m;
| `*m` moved due to usage in operator
|
note: calling this operator moves the left-hand side
--> $DIR/unop-move-semantics.rs:24:5
|
LL | !*m;
| ^^^
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
error[E0507]: cannot move out of `*n` which is behind a shared reference
--> $DIR/unop-move-semantics.rs:26:6