Skip to content

Commit 6984085

Browse files
committed
Stop pointing to operators if their libcore method source is not available
1 parent 59554a2 commit 6984085

File tree

5 files changed

+16
-70
lines changed

5 files changed

+16
-70
lines changed

compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1059,12 +1059,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
10591059
);
10601060
if self.fn_self_span_reported.insert(fn_span) {
10611061
err.span_note(
1062-
// Check whether the source is accessible
1063-
if self.infcx.tcx.sess.source_map().is_span_accessible(self_arg.span) {
1064-
self_arg.span
1065-
} else {
1066-
fn_call_span
1067-
},
1062+
self_arg.span,
10681063
"calling this operator moves the left-hand side",
10691064
);
10701065
}

src/test/ui/binop/binop-consume-args.stderr

+10-40
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ LL | drop(lhs);
99
| ^^^ value used here after move
1010
|
1111
note: calling this operator moves the left-hand side
12-
--> $DIR/binop-consume-args.rs:6:5
13-
|
14-
LL | lhs + rhs;
15-
| ^^^^^^^^^
12+
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
1613
help: consider further restricting this bound
1714
|
1815
LL | fn add<A: Add<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@@ -45,10 +42,7 @@ LL | drop(lhs);
4542
| ^^^ value used here after move
4643
|
4744
note: calling this operator moves the left-hand side
48-
--> $DIR/binop-consume-args.rs:12:5
49-
|
50-
LL | lhs - rhs;
51-
| ^^^^^^^^^
45+
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
5246
help: consider further restricting this bound
5347
|
5448
LL | fn sub<A: Sub<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@@ -81,10 +75,7 @@ LL | drop(lhs);
8175
| ^^^ value used here after move
8276
|
8377
note: calling this operator moves the left-hand side
84-
--> $DIR/binop-consume-args.rs:18:5
85-
|
86-
LL | lhs * rhs;
87-
| ^^^^^^^^^
78+
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
8879
help: consider further restricting this bound
8980
|
9081
LL | fn mul<A: Mul<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@@ -117,10 +108,7 @@ LL | drop(lhs);
117108
| ^^^ value used here after move
118109
|
119110
note: calling this operator moves the left-hand side
120-
--> $DIR/binop-consume-args.rs:24:5
121-
|
122-
LL | lhs / rhs;
123-
| ^^^^^^^^^
111+
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
124112
help: consider further restricting this bound
125113
|
126114
LL | fn div<A: Div<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@@ -153,10 +141,7 @@ LL | drop(lhs);
153141
| ^^^ value used here after move
154142
|
155143
note: calling this operator moves the left-hand side
156-
--> $DIR/binop-consume-args.rs:30:5
157-
|
158-
LL | lhs % rhs;
159-
| ^^^^^^^^^
144+
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
160145
help: consider further restricting this bound
161146
|
162147
LL | fn rem<A: Rem<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@@ -189,10 +174,7 @@ LL | drop(lhs);
189174
| ^^^ value used here after move
190175
|
191176
note: calling this operator moves the left-hand side
192-
--> $DIR/binop-consume-args.rs:36:5
193-
|
194-
LL | lhs & rhs;
195-
| ^^^^^^^^^
177+
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
196178
help: consider further restricting this bound
197179
|
198180
LL | fn bitand<A: BitAnd<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@@ -225,10 +207,7 @@ LL | drop(lhs);
225207
| ^^^ value used here after move
226208
|
227209
note: calling this operator moves the left-hand side
228-
--> $DIR/binop-consume-args.rs:42:5
229-
|
230-
LL | lhs | rhs;
231-
| ^^^^^^^^^
210+
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
232211
help: consider further restricting this bound
233212
|
234213
LL | fn bitor<A: BitOr<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@@ -261,10 +240,7 @@ LL | drop(lhs);
261240
| ^^^ value used here after move
262241
|
263242
note: calling this operator moves the left-hand side
264-
--> $DIR/binop-consume-args.rs:48:5
265-
|
266-
LL | lhs ^ rhs;
267-
| ^^^^^^^^^
243+
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
268244
help: consider further restricting this bound
269245
|
270246
LL | fn bitxor<A: BitXor<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@@ -297,10 +273,7 @@ LL | drop(lhs);
297273
| ^^^ value used here after move
298274
|
299275
note: calling this operator moves the left-hand side
300-
--> $DIR/binop-consume-args.rs:54:5
301-
|
302-
LL | lhs << rhs;
303-
| ^^^^^^^^^^
276+
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
304277
help: consider further restricting this bound
305278
|
306279
LL | fn shl<A: Shl<B, Output=()> + Copy, B>(lhs: A, rhs: B) {
@@ -333,10 +306,7 @@ LL | drop(lhs);
333306
| ^^^ value used here after move
334307
|
335308
note: calling this operator moves the left-hand side
336-
--> $DIR/binop-consume-args.rs:60:5
337-
|
338-
LL | lhs >> rhs;
339-
| ^^^^^^^^^^
309+
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
340310
help: consider further restricting this bound
341311
|
342312
LL | fn shr<A: Shr<B, Output=()> + Copy, B>(lhs: A, rhs: B) {

src/test/ui/binop/binop-move-semantics.stderr

+2-12
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ LL | | x;
1212
| `x` moved due to usage in operator
1313
|
1414
note: calling this operator moves the left-hand side
15-
--> $DIR/binop-move-semantics.rs:6:5
16-
|
17-
LL | / x
18-
LL | | +
19-
LL | | x;
20-
| |_____^
15+
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
2116
help: consider further restricting this bound
2217
|
2318
LL | fn double_move<T: Add<Output=()> + Copy>(x: T) {
@@ -79,12 +74,7 @@ LL | | *n;
7974
| |______- `*m` moved due to usage in operator
8075
|
8176
note: calling this operator moves the left-hand side
82-
--> $DIR/binop-move-semantics.rs:30:5
83-
|
84-
LL | / *m
85-
LL | | +
86-
LL | | *n;
87-
| |______^
77+
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
8878

8979
error[E0507]: cannot move out of `*n` which is behind a shared reference
9080
--> $DIR/binop-move-semantics.rs:32:5

src/test/ui/moves/move-fn-self-receiver.stderr

+1-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ LL | foo_add;
109109
| ^^^^^^^ value used here after move
110110
|
111111
note: calling this operator moves the left-hand side
112-
--> $DIR/move-fn-self-receiver.rs:58:5
113-
|
114-
LL | foo_add + Foo;
115-
| ^^^^^^^^^^^^^
112+
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
116113

117114
error[E0382]: use of moved value: `implicit_into_iter`
118115
--> $DIR/move-fn-self-receiver.rs:63:5

src/test/ui/unop-move-semantics.stderr

+2-8
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ LL | x.clone();
1010
| ^^^^^^^^^ value borrowed here after move
1111
|
1212
note: calling this operator moves the left-hand side
13-
--> $DIR/unop-move-semantics.rs:6:5
14-
|
15-
LL | !x;
16-
| ^^
13+
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
1714
help: consider cloning the value if the performance cost is acceptable
1815
|
1916
LL | !x.clone();
@@ -56,10 +53,7 @@ LL | !*m;
5653
| `*m` moved due to usage in operator
5754
|
5855
note: calling this operator moves the left-hand side
59-
--> $DIR/unop-move-semantics.rs:24:5
60-
|
61-
LL | !*m;
62-
| ^^^
56+
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
6357

6458
error[E0507]: cannot move out of `*n` which is behind a shared reference
6559
--> $DIR/unop-move-semantics.rs:26:6

0 commit comments

Comments
 (0)