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`.
This commit is contained in:
commit
a1de2a2d05
4 changed files with 126 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue