Skip to content

Commit 4c745d2

Browse files
committed
remove some crates.io deps
1 parent 1fa842c commit 4c745d2

File tree

3 files changed

+31
-102
lines changed

3 files changed

+31
-102
lines changed

Cargo.lock

Lines changed: 1 addition & 84 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_ide/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ indexmap = "1.3.2"
1717
itertools = "0.9.0"
1818
log = "0.4.8"
1919
rustc-hash = "1.1.0"
20-
rand = { version = "0.7.3", features = ["small_rng"] }
2120
url = "*"
22-
maplit = "*"
23-
lazy_static = "*"
2421
pulldown-cmark-to-cmark = "4.0.2"
2522
pulldown-cmark = "0.7.0"
2623
oorandom = "11.1.2"
24+
once_cell = "1"
2725

2826
stdx = { path = "../stdx" }
2927

crates/ra_ide/src/hover.rs

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
use std::collections::{HashMap, HashSet};
2-
use std::iter::once;
2+
use std::{
3+
iter::{once, FromIterator},
4+
sync::Mutex,
5+
};
36

47
use hir::{
58
db::DefDatabase, Adt, AsAssocItem, AsName, AssocItemContainer, AttrDef, Crate, Documentation,
69
FieldSource, HasSource, HirDisplay, Hygiene, ItemInNs, ModPath, Module, ModuleDef,
710
ModuleSource, Semantics,
811
};
912
use itertools::Itertools;
10-
use lazy_static::lazy_static;
11-
use maplit::{hashmap, hashset};
13+
use once_cell::sync::Lazy;
1214
use pulldown_cmark::{CowStr, Event, Options, Parser, Tag};
1315
use pulldown_cmark_to_cmark::cmark;
1416
use ra_db::SourceDatabase;
@@ -419,14 +421,26 @@ enum Namespace {
419421
Macros,
420422
}
421423

422-
lazy_static!(
423-
/// Map of namespaces to identifying prefixes and suffixes as defined by RFC1946.
424-
static ref NS_MAP: HashMap<Namespace, (HashSet<&'static str>, HashSet<&'static str>)> = hashmap!{
425-
Namespace::Types => (hashset!{"type", "struct", "enum", "mod", "trait", "union", "module"}, hashset!{}),
426-
Namespace::Values => (hashset!{"value", "function", "fn", "method", "const", "static", "mod", "module"}, hashset!{"()"}),
427-
Namespace::Macros => (hashset!{"macro"}, hashset!{"!"})
428-
};
429-
);
424+
static NS_MAP: Lazy<
425+
HashMap<Namespace, (HashSet<&'static &'static str>, HashSet<&'static &'static str>)>,
426+
> = Lazy::new(|| {
427+
let mut map = HashMap::new();
428+
map.insert(Namespace::Types, (HashSet::new(), HashSet::new()));
429+
map.insert(
430+
Namespace::Values,
431+
(
432+
HashSet::from_iter(
433+
["value", "function", "fn", "method", "const", "static", "mod", "module"].iter(),
434+
),
435+
HashSet::from_iter(["()"].iter()),
436+
),
437+
);
438+
map.insert(
439+
Namespace::Macros,
440+
(HashSet::from_iter(["macro"].iter()), HashSet::from_iter(["!"].iter())),
441+
);
442+
map
443+
});
430444

431445
impl Namespace {
432446
/// Extract the specified namespace from an intra-doc-link if one exists.
@@ -437,7 +451,7 @@ impl Namespace {
437451
prefixes
438452
.iter()
439453
.map(|prefix| {
440-
s.starts_with(prefix)
454+
s.starts_with(*prefix)
441455
&& s.chars()
442456
.nth(prefix.len() + 1)
443457
.map(|c| c == '@' || c == ' ')
@@ -447,7 +461,7 @@ impl Namespace {
447461
|| suffixes
448462
.iter()
449463
.map(|suffix| {
450-
s.starts_with(suffix)
464+
s.starts_with(*suffix)
451465
&& s.chars()
452466
.nth(suffix.len() + 1)
453467
.map(|c| c == '@' || c == ' ')
@@ -464,8 +478,8 @@ impl Namespace {
464478
fn strip_prefixes_suffixes(mut s: &str) -> &str {
465479
s = s.trim_matches('`');
466480
NS_MAP.iter().for_each(|(_, (prefixes, suffixes))| {
467-
prefixes.iter().for_each(|prefix| s = s.trim_start_matches(prefix));
468-
suffixes.iter().for_each(|suffix| s = s.trim_end_matches(suffix));
481+
prefixes.iter().for_each(|prefix| s = s.trim_start_matches(*prefix));
482+
suffixes.iter().for_each(|suffix| s = s.trim_end_matches(*suffix));
469483
});
470484
s.trim_start_matches("@").trim()
471485
}

0 commit comments

Comments
 (0)