Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
17ba73c
Document `adt_const_params` feature in Unstable Book
Shadlock0133 Mar 2, 2023
6b85f07
Small tweaks to the linting code for bare trait object types
fmease Mar 6, 2024
d3d77a8
Update docs of hir::TypeBinding
fmease Mar 6, 2024
22b9e96
Suggest assoc ty bound on bare dyn trait in eq constraint
fmease Mar 6, 2024
3879acb
Suggest assoc ty bound on lifetime in eq constraint
fmease Mar 6, 2024
0c7f8b0
Fix diagnostics for async block cloning
wutchzone Mar 16, 2024
2c433d0
Fix typos
wutchzone Mar 16, 2024
b562795
Require DerefPure for patterns
compiler-errors Mar 21, 2024
5fdc755
Require DerefMut if deref pattern has nested ref mut binding
compiler-errors Mar 21, 2024
fc1d7d2
Extract helper, fix comment on DerefPure
compiler-errors Mar 24, 2024
69af113
enable cargo miri test doctests
onur-ozkan Mar 25, 2024
7b4e507
unix fs: Make hurd and horizon using explicit new rather than From
sthibaul Mar 25, 2024
22bc5c5
In ConstructCoroutineInClosureShim, pass receiver by ref, not pointer
compiler-errors Mar 25, 2024
2cfd532
Change `f16` and `f128` clippy stubs to be nonpanicking
tgross35 Mar 26, 2024
bf7a745
Inherited -> TypeckRootCtxt
compiler-errors Mar 26, 2024
9162776
Rollup merge of #108675 - Shadlock0133:adt_const_params, r=compiler-e…
matthiaskrgr Mar 26, 2024
ff8cdc9
Rollup merge of #122120 - fmease:sugg-assoc-ty-bound-on-eq-bound, r=c…
matthiaskrgr Mar 26, 2024
20770ac
Rollup merge of #122589 - wutchzone:121547, r=compiler-errors
matthiaskrgr Mar 26, 2024
0029a11
Rollup merge of #122835 - compiler-errors:deref-pure, r=Nadrieril
matthiaskrgr Mar 26, 2024
b63dca1
Rollup merge of #123049 - compiler-errors:coroutine-closure-rcvr, r=o…
matthiaskrgr Mar 26, 2024
b8e8d65
Rollup merge of #123055 - onur-ozkan:miri-rustdoc, r=RalfJung
matthiaskrgr Mar 26, 2024
ac5ffa5
Rollup merge of #123057 - sthibaul:systemtime, r=jhpratt
matthiaskrgr Mar 26, 2024
7af95ed
Rollup merge of #123087 - tgross35:clippy-f16-f128-check-stubs, r=bly…
matthiaskrgr Mar 26, 2024
781b225
Rollup merge of #123103 - compiler-errors:inherited-is-a-weird-name, …
matthiaskrgr Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix diagnostics for async block cloning
  • Loading branch information
wutchzone committed Mar 23, 2024
commit 0c7f8b0f89e3b4a8ed46074e39a4de160d098489
10 changes: 10 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#![allow(rustc::untranslatable_diagnostic)]

use either::Either;
use hir::ClosureKind;
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{codes::*, struct_span_code_err, Applicability, Diag, MultiSpan};
Expand Down Expand Up @@ -463,6 +464,15 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
} else if let UseSpans::FnSelfUse { kind: CallKind::Normal { .. }, .. } = move_spans
{
// We already suggest cloning for these cases in `explain_captures`.
} else if let UseSpans::ClosureUse {
closure_kind:
ClosureKind::Coroutine(CoroutineKind::Desugared(_, CoroutineSource::Block)),
args_span: _,
capture_kind_span: _,
path_span,
} = move_spans
{
self.suggest_cloning(err, ty, expr, path_span);
} else if self.suggest_hoisting_call_outside_loop(err, expr) {
// The place where the the type moves would be misleading to suggest clone.
// #121466
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/borrowck/cloning-in-async-block-121547.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ edition:2021

async fn clone_async_block(value: String) {
for _ in 0..10 {
async { //~ ERROR: use of moved value: `value` [E0382]
drop(value);
//~^ HELP: consider cloning the value if the performance cost is acceptable
}.await
}
}
fn main() {}
22 changes: 22 additions & 0 deletions tests/ui/borrowck/cloning-in-async-block-121547.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error[E0382]: use of moved value: `value`
--> $DIR/cloning-in-async-block-121547.rs:5:9
|
LL | async fn clone_async_block(value: String) {
| ----- move occurs because `value` has type `String`, which does not implement the `Copy` trait
LL | for _ in 0..10 {
| -------------- inside of this loop
LL | / async {
LL | | drop(value);
| | ----- use occurs due to use in coroutine
LL | |
LL | | }.await
| |_________^ value moved here, in previous iteration of loop
|
help: consider cloning the value if the performance cost is acceptable
|
LL | drop(value.clone());
| ++++++++

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0382`.