mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Inline find_suffix
closure that's only used once
This commit is contained in:
parent
5497f158af
commit
141df6f60e
@ -1549,23 +1549,6 @@ impl Disambiguator {
|
||||
fn from_str(link: &str) -> Result<Option<(Self, &str)>, (String, Range<usize>)> {
|
||||
use Disambiguator::{Kind, Namespace as NS, Primitive};
|
||||
|
||||
let find_suffix = || {
|
||||
let suffixes = [
|
||||
("!()", DefKind::Macro(MacroKind::Bang)),
|
||||
("()", DefKind::Fn),
|
||||
("!", DefKind::Macro(MacroKind::Bang)),
|
||||
];
|
||||
for &(suffix, kind) in &suffixes {
|
||||
if let Some(link) = link.strip_suffix(suffix) {
|
||||
// Avoid turning `!` or `()` into an empty string
|
||||
if !link.is_empty() {
|
||||
return Some((Kind(kind), link));
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
};
|
||||
|
||||
if let Some(idx) = link.find('@') {
|
||||
let (prefix, rest) = link.split_at(idx);
|
||||
let d = match prefix {
|
||||
@ -1586,7 +1569,20 @@ impl Disambiguator {
|
||||
};
|
||||
Ok(Some((d, &rest[1..])))
|
||||
} else {
|
||||
Ok(find_suffix())
|
||||
let suffixes = [
|
||||
("!()", DefKind::Macro(MacroKind::Bang)),
|
||||
("()", DefKind::Fn),
|
||||
("!", DefKind::Macro(MacroKind::Bang)),
|
||||
];
|
||||
for &(suffix, kind) in &suffixes {
|
||||
if let Some(link) = link.strip_suffix(suffix) {
|
||||
// Avoid turning `!` or `()` into an empty string
|
||||
if !link.is_empty() {
|
||||
return Ok(Some((Kind(kind), link)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user