Skip to content

Commit 2698d24

Browse files
committed
review comments: inline bindings and fix typo
1 parent 95a5beb commit 2698d24

16 files changed

+28
-24
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
726726
let tcx = self.infcx.tcx;
727727
// Try to find predicates on *generic params* that would allow copying `ty`
728728
let infcx = tcx.infer_ctxt().build();
729-
let clone_did = tcx.lang_items().clone_trait().unwrap();
730-
let params = ty::List::empty();
731-
let ty = tcx.erase_regions(ty);
732-
let env = self.param_env;
733-
if infcx.type_implements_trait(clone_did, ty, params, env).must_apply_modulo_regions() {
729+
if infcx
730+
.type_implements_trait(
731+
tcx.lang_items().clone_trait().unwrap(),
732+
tcx.erase_regions(ty),
733+
ty::List::empty(),
734+
self.param_env,
735+
)
736+
.must_apply_modulo_regions()
737+
{
734738
err.span_suggestion_verbose(
735739
span.shrink_to_hi(),
736740
"consider cloning the value if the performance cost is acceptable",

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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 }

0 commit comments

Comments
 (0)