about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2022-11-11 16:57:01 -0800
committerEsteban Küber <esteban@kuber.com.ar>2022-11-23 12:17:48 -0800
commit3c905d4ccdcec76358716285a7f6409c3b84e7be (patch)
treea13e2242278d11745e2f3487a5949ca443ce65f7
parent53a711fdebd10e2a4426067d99fa04437f8a32dd (diff)
downloadrust-3c905d4ccdcec76358716285a7f6409c3b84e7be.tar.gz
rust-3c905d4ccdcec76358716285a7f6409c3b84e7be.zip
review comments: inline bindings and fix typo
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs14
-rw-r--r--src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr2
-rw-r--r--src/test/ui/borrowck/borrowck-consume-upcast-box.stderr2
-rw-r--r--src/test/ui/borrowck/mut-borrow-in-loop-2.stderr2
-rw-r--r--src/test/ui/liveness/liveness-move-call-arg.stderr2
-rw-r--r--src/test/ui/liveness/liveness-use-after-send.stderr2
-rw-r--r--src/test/ui/moves/borrow-closures-instead-of-move.stderr6
-rw-r--r--src/test/ui/moves/move-guard-same-consts.stderr2
-rw-r--r--src/test/ui/moves/move-in-guard-1.stderr2
-rw-r--r--src/test/ui/moves/move-in-guard-2.stderr2
-rw-r--r--src/test/ui/moves/moves-based-on-type-exprs.stderr2
-rw-r--r--src/test/ui/union/union-move.mirunsafeck.stderr4
-rw-r--r--src/test/ui/union/union-move.thirunsafeck.stderr4
-rw-r--r--src/test/ui/unsized-locals/borrow-after-move.stderr2
-rw-r--r--src/test/ui/unsized-locals/double-move.stderr2
-rw-r--r--src/test/ui/use/use-after-move-implicity-coerced-object.stderr2
16 files changed, 28 insertions, 24 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index cfbd6d12578..0d539783162 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -721,11 +721,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
         let tcx = self.infcx.tcx;
         // Try to find predicates on *generic params* that would allow copying `ty`
         let infcx = tcx.infer_ctxt().build();
-        let clone_did = tcx.lang_items().clone_trait().unwrap();
-        let params = ty::List::empty();
-        let ty = tcx.erase_regions(ty);
-        let env = self.param_env;
-        if infcx.type_implements_trait(clone_did, ty, params, env).must_apply_modulo_regions() {
+        if infcx
+            .type_implements_trait(
+                tcx.lang_items().clone_trait().unwrap(),
+                tcx.erase_regions(ty),
+                ty::List::empty(),
+                self.param_env,
+            )
+            .must_apply_modulo_regions()
+        {
             err.span_suggestion_verbose(
                 span.shrink_to_hi(),
                 "consider cloning the value if the performance cost is acceptable",
diff --git a/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr b/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr
index c25337c0c6c..d2e9497d079 100644
--- a/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr
+++ b/src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr
@@ -8,7 +8,7 @@ LL |     consume(b);
 LL |     consume(b);
    |             ^ value used here after move
    |
-note: consider changing this parameter type in function `consume` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `consume` to borrow instead if owning the value isn't necessary
   --> $DIR/borrowck-consume-unsize-vec.rs:3:15
    |
 LL | fn consume(_: Box<[i32]>) {
diff --git a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr
index 49d85cd5fa2..ed7e883ca63 100644
--- a/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr
+++ b/src/test/ui/borrowck/borrowck-consume-upcast-box.stderr
@@ -8,7 +8,7 @@ LL |     consume(b);
 LL |     consume(b);
    |             ^ value used here after move
    |
-note: consider changing this parameter type in function `consume` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `consume` to borrow instead if owning the value isn't necessary
   --> $DIR/borrowck-consume-upcast-box.rs:5:15
    |
 LL | fn consume(_: Box<dyn Foo>) {
diff --git a/src/test/ui/borrowck/mut-borrow-in-loop-2.stderr b/src/test/ui/borrowck/mut-borrow-in-loop-2.stderr
index b441244cdfd..74e7067c9af 100644
--- a/src/test/ui/borrowck/mut-borrow-in-loop-2.stderr
+++ b/src/test/ui/borrowck/mut-borrow-in-loop-2.stderr
@@ -8,7 +8,7 @@ LL |     for _ in 0..3 {
 LL |         Other::handle(value);
    |                       ^^^^^ value moved here, in previous iteration of loop
    |
-note: consider changing this parameter type in function `handle` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `handle` to borrow instead if owning the value isn't necessary
   --> $DIR/mut-borrow-in-loop-2.rs:9:22
    |
 LL |     fn handle(value: T) -> Self;
diff --git a/src/test/ui/liveness/liveness-move-call-arg.stderr b/src/test/ui/liveness/liveness-move-call-arg.stderr
index 5b5ac65113f..d14cd6cb4e0 100644
--- a/src/test/ui/liveness/liveness-move-call-arg.stderr
+++ b/src/test/ui/liveness/liveness-move-call-arg.stderr
@@ -9,7 +9,7 @@ LL |     loop {
 LL |         take(x);
    |              ^ value moved here, in previous iteration of loop
    |
-note: consider changing this parameter type in function `take` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
   --> $DIR/liveness-move-call-arg.rs:1:13
    |
 LL | fn take(_x: Box<isize>) {}
diff --git a/src/test/ui/liveness/liveness-use-after-send.stderr b/src/test/ui/liveness/liveness-use-after-send.stderr
index 3dbe5ac517e..65d55ca8f70 100644
--- a/src/test/ui/liveness/liveness-use-after-send.stderr
+++ b/src/test/ui/liveness/liveness-use-after-send.stderr
@@ -8,7 +8,7 @@ LL |     send(ch, message);
 LL |     println!("{}", message);
    |                    ^^^^^^^ value borrowed here after move
    |
-note: consider changing this parameter type in function `send` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `send` to borrow instead if owning the value isn't necessary
   --> $DIR/liveness-use-after-send.rs:3:54
    |
 LL | fn send<T:Send + std::fmt::Debug>(ch: Chan<T>, data: T) {
diff --git a/src/test/ui/moves/borrow-closures-instead-of-move.stderr b/src/test/ui/moves/borrow-closures-instead-of-move.stderr
index b6855222039..fbeeaf646e1 100644
--- a/src/test/ui/moves/borrow-closures-instead-of-move.stderr
+++ b/src/test/ui/moves/borrow-closures-instead-of-move.stderr
@@ -8,7 +8,7 @@ LL |     loop {
 LL |         takes_fnonce(f);
    |                      ^ value moved here, in previous iteration of loop
    |
-note: consider changing this parameter type in function `takes_fnonce` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
   --> $DIR/borrow-closures-instead-of-move.rs:34:20
    |
 LL | fn takes_fnonce(_: impl FnOnce()) {}
@@ -32,7 +32,7 @@ LL |         takes_fnonce(m);
 LL |     takes_fnonce(m);
    |                  ^ value used here after move
    |
-note: consider changing this parameter type in function `takes_fnonce` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
   --> $DIR/borrow-closures-instead-of-move.rs:34:20
    |
 LL | fn takes_fnonce(_: impl FnOnce()) {}
@@ -58,7 +58,7 @@ note: closure cannot be moved more than once as it is not `Copy` due to moving t
    |
 LL |         x += 1;
    |         ^
-note: consider changing this parameter type in function `takes_fnonce` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
   --> $DIR/borrow-closures-instead-of-move.rs:34:20
    |
 LL | fn takes_fnonce(_: impl FnOnce()) {}
diff --git a/src/test/ui/moves/move-guard-same-consts.stderr b/src/test/ui/moves/move-guard-same-consts.stderr
index 440a908a3c6..86e5f65248b 100644
--- a/src/test/ui/moves/move-guard-same-consts.stderr
+++ b/src/test/ui/moves/move-guard-same-consts.stderr
@@ -9,7 +9,7 @@ LL |         (1, 2) if take(x) => (),
 LL |         (1, 2) if take(x) => (),
    |                        ^ value used here after move
    |
-note: consider changing this parameter type in function `take` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
   --> $DIR/move-guard-same-consts.rs:25:15
    |
 LL | fn take<T>(_: T) -> bool { false }
diff --git a/src/test/ui/moves/move-in-guard-1.stderr b/src/test/ui/moves/move-in-guard-1.stderr
index e054f31349a..f04cb34d7c4 100644
--- a/src/test/ui/moves/move-in-guard-1.stderr
+++ b/src/test/ui/moves/move-in-guard-1.stderr
@@ -9,7 +9,7 @@ LL |         (1, _) if take(x) => (),
 LL |         (_, 2) if take(x) => (),
    |                        ^ value used here after move
    |
-note: consider changing this parameter type in function `take` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
   --> $DIR/move-in-guard-1.rs:15:15
    |
 LL | fn take<T>(_: T) -> bool { false }
diff --git a/src/test/ui/moves/move-in-guard-2.stderr b/src/test/ui/moves/move-in-guard-2.stderr
index 49267c27631..26047861f55 100644
--- a/src/test/ui/moves/move-in-guard-2.stderr
+++ b/src/test/ui/moves/move-in-guard-2.stderr
@@ -7,7 +7,7 @@ LL |     let x: Box<_> = Box::new(1);
 LL |         (_, 2) if take(x) => (),
    |                        ^ value used here after move
    |
-note: consider changing this parameter type in function `take` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
   --> $DIR/move-in-guard-2.rs:13:15
    |
 LL | fn take<T>(_: T) -> bool { false }
diff --git a/src/test/ui/moves/moves-based-on-type-exprs.stderr b/src/test/ui/moves/moves-based-on-type-exprs.stderr
index 6efda8c5e83..838b1282cb4 100644
--- a/src/test/ui/moves/moves-based-on-type-exprs.stderr
+++ b/src/test/ui/moves/moves-based-on-type-exprs.stderr
@@ -108,7 +108,7 @@ LL |         _ if guard(x) => 10,
 LL |     touch(&x);
    |           ^^ value borrowed here after move
    |
-note: consider changing this parameter type in function `guard` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `guard` to borrow instead if owning the value isn't necessary
   --> $DIR/moves-based-on-type-exprs.rs:6:14
    |
 LL | fn guard(_s: String) -> bool {panic!()}
diff --git a/src/test/ui/union/union-move.mirunsafeck.stderr b/src/test/ui/union/union-move.mirunsafeck.stderr
index c695282fbb0..6381ae874ba 100644
--- a/src/test/ui/union/union-move.mirunsafeck.stderr
+++ b/src/test/ui/union/union-move.mirunsafeck.stderr
@@ -9,7 +9,7 @@ LL |         move_out(x.f1_nocopy);
 LL |         move_out(x.f2_nocopy);
    |                  ^^^^^^^^^^^ value used here after move
    |
-note: consider changing this parameter type in function `move_out` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
   --> $DIR/union-move.rs:10:19
    |
 LL | fn move_out<T>(x: T) {}
@@ -28,7 +28,7 @@ LL |         move_out(x.f2_nocopy);
 LL |         move_out(x.f3_copy);
    |                  ^^^^^^^^^ value used here after move
    |
-note: consider changing this parameter type in function `move_out` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
   --> $DIR/union-move.rs:10:19
    |
 LL | fn move_out<T>(x: T) {}
diff --git a/src/test/ui/union/union-move.thirunsafeck.stderr b/src/test/ui/union/union-move.thirunsafeck.stderr
index c695282fbb0..6381ae874ba 100644
--- a/src/test/ui/union/union-move.thirunsafeck.stderr
+++ b/src/test/ui/union/union-move.thirunsafeck.stderr
@@ -9,7 +9,7 @@ LL |         move_out(x.f1_nocopy);
 LL |         move_out(x.f2_nocopy);
    |                  ^^^^^^^^^^^ value used here after move
    |
-note: consider changing this parameter type in function `move_out` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
   --> $DIR/union-move.rs:10:19
    |
 LL | fn move_out<T>(x: T) {}
@@ -28,7 +28,7 @@ LL |         move_out(x.f2_nocopy);
 LL |         move_out(x.f3_copy);
    |                  ^^^^^^^^^ value used here after move
    |
-note: consider changing this parameter type in function `move_out` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
   --> $DIR/union-move.rs:10:19
    |
 LL | fn move_out<T>(x: T) {}
diff --git a/src/test/ui/unsized-locals/borrow-after-move.stderr b/src/test/ui/unsized-locals/borrow-after-move.stderr
index e11c398e8d0..d8bffd4f9cf 100644
--- a/src/test/ui/unsized-locals/borrow-after-move.stderr
+++ b/src/test/ui/unsized-locals/borrow-after-move.stderr
@@ -29,7 +29,7 @@ LL |         drop_unsized(y);
 LL |         println!("{}", &y);
    |                        ^^ value borrowed here after move
    |
-note: consider changing this parameter type in function `drop_unsized` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary
   --> $DIR/borrow-after-move.rs:14:31
    |
 LL | fn drop_unsized<T: ?Sized>(_: T) {}
diff --git a/src/test/ui/unsized-locals/double-move.stderr b/src/test/ui/unsized-locals/double-move.stderr
index 84192e75098..71534818141 100644
--- a/src/test/ui/unsized-locals/double-move.stderr
+++ b/src/test/ui/unsized-locals/double-move.stderr
@@ -17,7 +17,7 @@ LL |         drop_unsized(y);
 LL |         drop_unsized(y);
    |                      ^ value used here after move
    |
-note: consider changing this parameter type in function `drop_unsized` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary
   --> $DIR/double-move.rs:14:31
    |
 LL | fn drop_unsized<T: ?Sized>(_: T) {}
diff --git a/src/test/ui/use/use-after-move-implicity-coerced-object.stderr b/src/test/ui/use/use-after-move-implicity-coerced-object.stderr
index 395bb4019fd..dfa0c04836e 100644
--- a/src/test/ui/use/use-after-move-implicity-coerced-object.stderr
+++ b/src/test/ui/use/use-after-move-implicity-coerced-object.stderr
@@ -10,7 +10,7 @@ LL |
 LL |     let x = n.to_string();
    |             ^^^^^^^^^^^^^ value borrowed here after move
    |
-note: consider changing this parameter type in method `push` to borrow instead if ownering the value isn't necessary
+note: consider changing this parameter type in method `push` to borrow instead if owning the value isn't necessary
   --> $DIR/use-after-move-implicity-coerced-object.rs:17:27
    |
 LL |     fn push(&mut self, n: Box<dyn ToString + 'static>) {