mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-16 07:03:57 +00:00
fix: remove unwrap
This commit is contained in:
parent
a7f77d89a9
commit
45ee88f9cb
1 changed files with 31 additions and 24 deletions
|
@ -89,11 +89,17 @@ fn add_import(
|
|||
ctx: &AssistContext<'_>,
|
||||
edit: &mut ide_db::source_change::SourceChangeBuilder,
|
||||
) {
|
||||
if let Some(path_segment) = qualifier.segment() {
|
||||
// for `<i32 as std::ops::Add>`
|
||||
let path_type =
|
||||
qualifier.segment().unwrap().syntax().children().filter_map(ast::PathType::cast).last();
|
||||
let path_type = path_segment.syntax().children().filter_map(ast::PathType::cast).last();
|
||||
let import = match path_type {
|
||||
Some(it) => it.path().unwrap(),
|
||||
Some(it) => {
|
||||
if let Some(path) = it.path() {
|
||||
path
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
None => qualifier,
|
||||
};
|
||||
|
||||
|
@ -115,6 +121,7 @@ fn add_import(
|
|||
};
|
||||
ide_db::imports::insert_use::insert_use(&scope, import, &ctx.config.insert_use);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn needs_parens_as_receiver(expr: &ast::Expr) -> bool {
|
||||
|
|
Loading…
Reference in a new issue