about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-16 13:45:29 +0200
committerGitHub <noreply@github.com>2025-04-16 13:45:29 +0200
commita1de2a2d0523f530cc84f400f075a811fc7d2f53 (patch)
tree2ace453fc9c105b854b788b7e3cd335fe00cc564 /compiler
parentb65e6b7c40cc84ed4dc9f338d9afa065155625ed (diff)
parent2020adba86cb2852b11ab11a440975fb331e8424 (diff)
downloadrust-a1de2a2d0523f530cc84f400f075a811fc7d2f53.tar.gz
rust-a1de2a2d0523f530cc84f400f075a811fc7d2f53.zip
Rollup merge of #139871 - GuillaumeGomez:async-gen-move, r=compiler-errors
Fix wrong "move keyword" suggestion for async gen block

Fixes #139839.

It was just missing a string comparison with `async gen`.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
index fe6dff7ff1b..959cf9fa513 100644
--- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
+++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
@@ -3376,10 +3376,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
 
         let (sugg_span, suggestion) = match tcx.sess.source_map().span_to_snippet(args_span) {
             Ok(string) => {
-                let coro_prefix = if string.starts_with("async") {
-                    // `async` is 5 chars long. Not using `.len()` to avoid the cast from `usize`
-                    // to `u32`.
-                    Some(5)
+                let coro_prefix = if let Some(sub) = string.strip_prefix("async") {
+                    let trimmed_sub = sub.trim_end();
+                    if trimmed_sub.ends_with("gen") {
+                        // `async` is 5 chars long.
+                        Some((trimmed_sub.len() + 5) as _)
+                    } else {
+                        // `async` is 5 chars long.
+                        Some(5)
+                    }
                 } else if string.starts_with("gen") {
                     // `gen` is 3 chars long
                     Some(3)