mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Simplify
This commit is contained in:
parent
bc4d047267
commit
3e688d2a93
1 changed files with 5 additions and 9 deletions
|
@ -83,11 +83,11 @@ impl Directories {
|
|||
self.includes_path(path)
|
||||
}
|
||||
fn includes_path(&self, path: &AbsPath) -> bool {
|
||||
let mut include = None;
|
||||
let mut include: Option<&AbsPathBuf> = None;
|
||||
for incl in &self.include {
|
||||
if is_prefix(incl, path) {
|
||||
if path.starts_with(incl) {
|
||||
include = Some(match include {
|
||||
Some(prev) if is_prefix(incl, prev) => prev,
|
||||
Some(prev) if prev.starts_with(incl) => prev,
|
||||
_ => incl,
|
||||
})
|
||||
}
|
||||
|
@ -97,15 +97,11 @@ impl Directories {
|
|||
None => return false,
|
||||
};
|
||||
for excl in &self.exclude {
|
||||
if is_prefix(excl, path) && is_prefix(include, excl) {
|
||||
if path.starts_with(excl) && excl.starts_with(include) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
fn is_prefix(short: &AbsPath, long: &AbsPath) -> bool {
|
||||
long.strip_prefix(short).is_some()
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue