Auto merge of #15660 - DaniPopes:hover-simple-refactor, r=HKalbasi
minor: hover_simple refactor A minor refactor of `hover_simple` opportunity I noticed while skimming through the code. - `if let`s -> `match` - `iter::once(x).cycle` -> `iter::repeat` - `classify_token` -> `classify_node`
This commit is contained in:
commit
862a3004e9
@ -257,6 +257,7 @@ fn expand(
|
||||
) -> Result<Subtree, ProcMacroExpansionError>;
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ProcMacroExpansionError {
|
||||
Panic(String),
|
||||
/// Things like "proc macro server was killed by OOM".
|
||||
|
@ -180,26 +180,24 @@ fn hover_simple(
|
||||
descended()
|
||||
.filter_map(|token| {
|
||||
let node = token.parent()?;
|
||||
let class = IdentClass::classify_token(sema, token)?;
|
||||
if let IdentClass::Operator(OperatorClass::Await(_)) = class {
|
||||
match IdentClass::classify_node(sema, &node)? {
|
||||
// It's better for us to fall back to the keyword hover here,
|
||||
// rendering poll is very confusing
|
||||
return None;
|
||||
}
|
||||
if let IdentClass::NameRefClass(NameRefClass::ExternCrateShorthand {
|
||||
IdentClass::Operator(OperatorClass::Await(_)) => None,
|
||||
|
||||
IdentClass::NameRefClass(NameRefClass::ExternCrateShorthand {
|
||||
decl,
|
||||
..
|
||||
}) = class
|
||||
{
|
||||
return Some(vec![(Definition::ExternCrateDecl(decl), node)]);
|
||||
}
|
||||
Some(
|
||||
}) => Some(vec![(Definition::ExternCrateDecl(decl), node)]),
|
||||
|
||||
class => Some(
|
||||
class
|
||||
.definitions()
|
||||
.into_iter()
|
||||
.zip(iter::once(node).cycle())
|
||||
.zip(iter::repeat(node))
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
),
|
||||
}
|
||||
})
|
||||
.flatten()
|
||||
.unique_by(|&(def, _)| def)
|
||||
|
Loading…
Reference in New Issue
Block a user