mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 23:25:03 +00:00
Merge #3732
3732: Assist: replace unwrap with match r=matklad a=unrealhoang attempt on #3669 Co-authored-by: Unreal Hoang <unrealhoang@gmail.com>
This commit is contained in:
commit
20c110e57f
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