mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-28 15:43:21 +00:00
simplify
This commit is contained in:
parent
6f02f176c8
commit
4fa972cffb
@ -121,7 +121,7 @@ impl CallInfo {
|
||||
node.syntax().text().to_string()
|
||||
};
|
||||
|
||||
if let Some((comment_range, docs)) = CallInfo::extract_doc_comments(node) {
|
||||
if let Some((comment_range, docs)) = extract_doc_comments(node) {
|
||||
let comment_range = comment_range
|
||||
.checked_sub(node.syntax().range().start())
|
||||
.unwrap();
|
||||
@ -154,14 +154,15 @@ impl CallInfo {
|
||||
}
|
||||
|
||||
Some(CallInfo {
|
||||
parameters: CallInfo::param_list(node),
|
||||
parameters: param_list(node),
|
||||
label: label.trim().to_owned(),
|
||||
doc,
|
||||
active_parameter: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_doc_comments(node: &ast::FnDef) -> Option<(TextRange, String)> {
|
||||
fn extract_doc_comments(node: &ast::FnDef) -> Option<(TextRange, String)> {
|
||||
if node.doc_comments().count() == 0 {
|
||||
return None;
|
||||
}
|
||||
@ -179,9 +180,9 @@ impl CallInfo {
|
||||
let range = TextRange::from_to(TextUnit::from_usize(begin), TextUnit::from_usize(end));
|
||||
|
||||
Some((range, comment_text))
|
||||
}
|
||||
}
|
||||
|
||||
fn param_list(node: &ast::FnDef) -> Vec<String> {
|
||||
fn param_list(node: &ast::FnDef) -> Vec<String> {
|
||||
let mut res = vec![];
|
||||
if let Some(param_list) = node.param_list() {
|
||||
if let Some(self_param) = param_list.self_param() {
|
||||
@ -198,7 +199,6 @@ impl CallInfo {
|
||||
);
|
||||
}
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Loading…
Reference in New Issue
Block a user