]> git.lizzy.rs Git - rust.git/commit
fix: "Extract to function" assist preserves `break` and `continue` labels
authorMorgan Thomas <corp@m0rg.dev>
Sat, 12 Mar 2022 16:44:37 +0000 (08:44 -0800)
committerMorgan Thomas <corp@m0rg.dev>
Sat, 12 Mar 2022 16:54:06 +0000 (08:54 -0800)
commit3fafbca32e8671a38aef9d6cfc8ad0f05e4a00c9
tree0dca2e2bc084cf0cba0ab6906885be4f3c312d60
parent5fcf979f8a09e6504bbe540cbff6d640b959935c
fix: "Extract to function" assist preserves `break` and `continue` labels

Adds a label / lifetime parameter to `ide_assists::handlers::extract_function::FlowKind::{Break, Continue}`, adds support for emitting labels to `syntax::ast::make::{expr_break, expr_continue}`, and implements the required machinery to let `extract_function` make use of them.

This does modify the external API of the `syntax` crate, but the changes there are simple, not used outside `ide_assists`, and, well, we should probably support emitting `break` and `continue` labels through `syntax` anyways, they're part of the language spec.

Closes #11413.
crates/ide_assists/src/handlers/convert_to_guarded_return.rs
crates/ide_assists/src/handlers/convert_while_to_loop.rs
crates/ide_assists/src/handlers/extract_function.rs
crates/syntax/src/ast/make.rs