about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-12-12 15:36:08 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-12-13 10:06:11 +0000
commit6984085088d365395690ffd148ee70d0c48b8d72 (patch)
tree8622f2fadf061d738dc7c2c1987b1e38ad3f9f11
parent59554a2b54c3510b062825801064541a4caa662d (diff)
downloadrust-6984085088d365395690ffd148ee70d0c48b8d72.tar.gz
rust-6984085088d365395690ffd148ee70d0c48b8d72.zip
Stop pointing to operators if their libcore method source is not available
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/mod.rs7
-rw-r--r--src/test/ui/binop/binop-consume-args.stderr50
-rw-r--r--src/test/ui/binop/binop-move-semantics.stderr14
-rw-r--r--src/test/ui/moves/move-fn-self-receiver.stderr5
-rw-r--r--src/test/ui/unop-move-semantics.stderr10
5 files changed, 16 insertions, 70 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs
index 1e51ab14f25..cbd59005200 100644
--- a/compiler/rustc_borrowck/src/diagnostics/mod.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs
@@ -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",
                         );
                     }
diff --git a/src/test/ui/binop/binop-consume-args.stderr b/src/test/ui/binop/binop-consume-args.stderr
index 2a992d26fd1..6fbbb55437e 100644
--- a/src/test/ui/binop/binop-consume-args.stderr
+++ b/src/test/ui/binop/binop-consume-args.stderr
@@ -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) {
diff --git a/src/test/ui/binop/binop-move-semantics.stderr b/src/test/ui/binop/binop-move-semantics.stderr
index ceb8beec770..dae267da05d 100644
--- a/src/test/ui/binop/binop-move-semantics.stderr
+++ b/src/test/ui/binop/binop-move-semantics.stderr
@@ -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
diff --git a/src/test/ui/moves/move-fn-self-receiver.stderr b/src/test/ui/moves/move-fn-self-receiver.stderr
index dda07934e3a..b3f95ee192a 100644
--- a/src/test/ui/moves/move-fn-self-receiver.stderr
+++ b/src/test/ui/moves/move-fn-self-receiver.stderr
@@ -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
diff --git a/src/test/ui/unop-move-semantics.stderr b/src/test/ui/unop-move-semantics.stderr
index c0e615ca1a8..2a3ca14433f 100644
--- a/src/test/ui/unop-move-semantics.stderr
+++ b/src/test/ui/unop-move-semantics.stderr
@@ -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