mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Assist: replace unwrap with match
This commit is contained in:
parent
785eb32f49
commit
d9df0f43ac
5 changed files with 230 additions and 0 deletions
|
@ -250,6 +250,10 @@ pub fn token(kind: SyntaxKind) -> SyntaxToken {
|
|||
.unwrap_or_else(|| panic!("unhandled token: {:?}", kind))
|
||||
}
|
||||
|
||||
pub fn unreachable_macro_call() -> ast::MacroCall {
|
||||
ast_from_text(&format!("unreachable!()"))
|
||||
}
|
||||
|
||||
fn ast_from_text<N: AstNode>(text: &str) -> N {
|
||||
let parse = SourceFile::parse(text);
|
||||
let node = parse.tree().syntax().descendants().find_map(N::cast).unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue