Skip to content

Commit 3c905d4

Browse files
committed
review comments: inline bindings and fix typo
1 parent 53a711f commit 3c905d4

16 files changed

+28
-24
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
721721
let tcx = self.infcx.tcx;
722722
// Try to find predicates on *generic params* that would allow copying `ty`
723723
let infcx = tcx.infer_ctxt().build();
724-
let clone_did = tcx.lang_items().clone_trait().unwrap();
725-
let params = ty::List::empty();
726-
let ty = tcx.erase_regions(ty);
727-
let env = self.param_env;
728-
if infcx.type_implements_trait(clone_did, ty, params, env).must_apply_modulo_regions() {
724+
if infcx
725+
.type_implements_trait(
726+
tcx.lang_items().clone_trait().unwrap(),
727+
tcx.erase_regions(ty),
728+
ty::List::empty(),
729+
self.param_env,
730+
)
731+
.must_apply_modulo_regions()
732+
{
729733
err.span_suggestion_verbose(
730734
span.shrink_to_hi(),
731735
"consider cloning the value if the performance cost is acceptable",

src/test/ui/borrowck/borrowck-consume-unsize-vec.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | consume(b);
88
LL | consume(b);
99
| ^ value used here after move
1010
|
11-
note: consider changing this parameter type in function `consume` to borrow instead if ownering the value isn't necessary
11+
note: consider changing this parameter type in function `consume` to borrow instead if owning the value isn't necessary
1212
--> $DIR/borrowck-consume-unsize-vec.rs:3:15
1313
|
1414
LL | fn consume(_: Box<[i32]>) {

src/test/ui/borrowck/borrowck-consume-upcast-box.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | consume(b);
88
LL | consume(b);
99
| ^ value used here after move
1010
|
11-
note: consider changing this parameter type in function `consume` to borrow instead if ownering the value isn't necessary
11+
note: consider changing this parameter type in function `consume` to borrow instead if owning the value isn't necessary
1212
--> $DIR/borrowck-consume-upcast-box.rs:5:15
1313
|
1414
LL | fn consume(_: Box<dyn Foo>) {

src/test/ui/borrowck/mut-borrow-in-loop-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | for _ in 0..3 {
88
LL | Other::handle(value);
99
| ^^^^^ value moved here, in previous iteration of loop
1010
|
11-
note: consider changing this parameter type in function `handle` to borrow instead if ownering the value isn't necessary
11+
note: consider changing this parameter type in function `handle` to borrow instead if owning the value isn't necessary
1212
--> $DIR/mut-borrow-in-loop-2.rs:9:22
1313
|
1414
LL | fn handle(value: T) -> Self;

src/test/ui/liveness/liveness-move-call-arg.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | loop {
99
LL | take(x);
1010
| ^ value moved here, in previous iteration of loop
1111
|
12-
note: consider changing this parameter type in function `take` to borrow instead if ownering the value isn't necessary
12+
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
1313
--> $DIR/liveness-move-call-arg.rs:1:13
1414
|
1515
LL | fn take(_x: Box<isize>) {}

src/test/ui/liveness/liveness-use-after-send.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | send(ch, message);
88
LL | println!("{}", message);
99
| ^^^^^^^ value borrowed here after move
1010
|
11-
note: consider changing this parameter type in function `send` to borrow instead if ownering the value isn't necessary
11+
note: consider changing this parameter type in function `send` to borrow instead if owning the value isn't necessary
1212
--> $DIR/liveness-use-after-send.rs:3:54
1313
|
1414
LL | fn send<T:Send + std::fmt::Debug>(ch: Chan<T>, data: T) {

src/test/ui/moves/borrow-closures-instead-of-move.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | loop {
88
LL | takes_fnonce(f);
99
| ^ value moved here, in previous iteration of loop
1010
|
11-
note: consider changing this parameter type in function `takes_fnonce` to borrow instead if ownering the value isn't necessary
11+
note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
1212
--> $DIR/borrow-closures-instead-of-move.rs:34:20
1313
|
1414
LL | fn takes_fnonce(_: impl FnOnce()) {}
@@ -32,7 +32,7 @@ LL | takes_fnonce(m);
3232
LL | takes_fnonce(m);
3333
| ^ value used here after move
3434
|
35-
note: consider changing this parameter type in function `takes_fnonce` to borrow instead if ownering the value isn't necessary
35+
note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
3636
--> $DIR/borrow-closures-instead-of-move.rs:34:20
3737
|
3838
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
5858
|
5959
LL | x += 1;
6060
| ^
61-
note: consider changing this parameter type in function `takes_fnonce` to borrow instead if ownering the value isn't necessary
61+
note: consider changing this parameter type in function `takes_fnonce` to borrow instead if owning the value isn't necessary
6262
--> $DIR/borrow-closures-instead-of-move.rs:34:20
6363
|
6464
LL | fn takes_fnonce(_: impl FnOnce()) {}

src/test/ui/moves/move-guard-same-consts.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | (1, 2) if take(x) => (),
99
LL | (1, 2) if take(x) => (),
1010
| ^ value used here after move
1111
|
12-
note: consider changing this parameter type in function `take` to borrow instead if ownering the value isn't necessary
12+
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
1313
--> $DIR/move-guard-same-consts.rs:25:15
1414
|
1515
LL | fn take<T>(_: T) -> bool { false }

src/test/ui/moves/move-in-guard-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | (1, _) if take(x) => (),
99
LL | (_, 2) if take(x) => (),
1010
| ^ value used here after move
1111
|
12-
note: consider changing this parameter type in function `take` to borrow instead if ownering the value isn't necessary
12+
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
1313
--> $DIR/move-in-guard-1.rs:15:15
1414
|
1515
LL | fn take<T>(_: T) -> bool { false }

src/test/ui/moves/move-in-guard-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | let x: Box<_> = Box::new(1);
77
LL | (_, 2) if take(x) => (),
88
| ^ value used here after move
99
|
10-
note: consider changing this parameter type in function `take` to borrow instead if ownering the value isn't necessary
10+
note: consider changing this parameter type in function `take` to borrow instead if owning the value isn't necessary
1111
--> $DIR/move-in-guard-2.rs:13:15
1212
|
1313
LL | fn take<T>(_: T) -> bool { false }

src/test/ui/moves/moves-based-on-type-exprs.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ LL | _ if guard(x) => 10,
108108
LL | touch(&x);
109109
| ^^ value borrowed here after move
110110
|
111-
note: consider changing this parameter type in function `guard` to borrow instead if ownering the value isn't necessary
111+
note: consider changing this parameter type in function `guard` to borrow instead if owning the value isn't necessary
112112
--> $DIR/moves-based-on-type-exprs.rs:6:14
113113
|
114114
LL | fn guard(_s: String) -> bool {panic!()}

src/test/ui/union/union-move.mirunsafeck.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | move_out(x.f1_nocopy);
99
LL | move_out(x.f2_nocopy);
1010
| ^^^^^^^^^^^ value used here after move
1111
|
12-
note: consider changing this parameter type in function `move_out` to borrow instead if ownering the value isn't necessary
12+
note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
1313
--> $DIR/union-move.rs:10:19
1414
|
1515
LL | fn move_out<T>(x: T) {}
@@ -28,7 +28,7 @@ LL | move_out(x.f2_nocopy);
2828
LL | move_out(x.f3_copy);
2929
| ^^^^^^^^^ value used here after move
3030
|
31-
note: consider changing this parameter type in function `move_out` to borrow instead if ownering the value isn't necessary
31+
note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
3232
--> $DIR/union-move.rs:10:19
3333
|
3434
LL | fn move_out<T>(x: T) {}

src/test/ui/union/union-move.thirunsafeck.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | move_out(x.f1_nocopy);
99
LL | move_out(x.f2_nocopy);
1010
| ^^^^^^^^^^^ value used here after move
1111
|
12-
note: consider changing this parameter type in function `move_out` to borrow instead if ownering the value isn't necessary
12+
note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
1313
--> $DIR/union-move.rs:10:19
1414
|
1515
LL | fn move_out<T>(x: T) {}
@@ -28,7 +28,7 @@ LL | move_out(x.f2_nocopy);
2828
LL | move_out(x.f3_copy);
2929
| ^^^^^^^^^ value used here after move
3030
|
31-
note: consider changing this parameter type in function `move_out` to borrow instead if ownering the value isn't necessary
31+
note: consider changing this parameter type in function `move_out` to borrow instead if owning the value isn't necessary
3232
--> $DIR/union-move.rs:10:19
3333
|
3434
LL | fn move_out<T>(x: T) {}

src/test/ui/unsized-locals/borrow-after-move.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ LL | drop_unsized(y);
2929
LL | println!("{}", &y);
3030
| ^^ value borrowed here after move
3131
|
32-
note: consider changing this parameter type in function `drop_unsized` to borrow instead if ownering the value isn't necessary
32+
note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary
3333
--> $DIR/borrow-after-move.rs:14:31
3434
|
3535
LL | fn drop_unsized<T: ?Sized>(_: T) {}

src/test/ui/unsized-locals/double-move.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LL | drop_unsized(y);
1717
LL | drop_unsized(y);
1818
| ^ value used here after move
1919
|
20-
note: consider changing this parameter type in function `drop_unsized` to borrow instead if ownering the value isn't necessary
20+
note: consider changing this parameter type in function `drop_unsized` to borrow instead if owning the value isn't necessary
2121
--> $DIR/double-move.rs:14:31
2222
|
2323
LL | fn drop_unsized<T: ?Sized>(_: T) {}

src/test/ui/use/use-after-move-implicity-coerced-object.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL |
1010
LL | let x = n.to_string();
1111
| ^^^^^^^^^^^^^ value borrowed here after move
1212
|
13-
note: consider changing this parameter type in method `push` to borrow instead if ownering the value isn't necessary
13+
note: consider changing this parameter type in method `push` to borrow instead if owning the value isn't necessary
1414
--> $DIR/use-after-move-implicity-coerced-object.rs:17:27
1515
|
1616
LL | fn push(&mut self, n: Box<dyn ToString + 'static>) {

0 commit comments

Comments
 (0)