mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Fix tests being non-deterministic
This commit is contained in:
parent
0485a85ee2
commit
cdb8c3a327
10 changed files with 221 additions and 175 deletions
|
@ -295,11 +295,30 @@ pub struct CrateData {
|
|||
pub is_proc_macro: bool,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Default, Clone, PartialEq, Eq)]
|
||||
pub struct Env {
|
||||
entries: FxHashMap<String, String>,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Env {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
struct EnvDebug<'s>(Vec<(&'s String, &'s String)>);
|
||||
|
||||
impl fmt::Debug for EnvDebug<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_map().entries(self.0.iter().copied()).finish()
|
||||
}
|
||||
}
|
||||
f.debug_struct("Env")
|
||||
.field("entries", &{
|
||||
let mut entries: Vec<_> = self.entries.iter().collect();
|
||||
entries.sort();
|
||||
EnvDebug(entries)
|
||||
})
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Dependency {
|
||||
pub crate_id: CrateId,
|
||||
|
@ -660,8 +679,16 @@ impl Env {
|
|||
self.entries.get(env).cloned()
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)> {
|
||||
self.entries.iter().map(|(k, v)| (k.as_str(), v.as_str()))
|
||||
pub fn extend_from_other(&mut self, other: &Env) {
|
||||
self.entries.extend(other.entries.iter().map(|(x, y)| (x.to_owned(), y.to_owned())));
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Env> for Vec<(String, String)> {
|
||||
fn from(env: Env) -> Vec<(String, String)> {
|
||||
let mut entries: Vec<_> = env.entries.into_iter().collect();
|
||||
entries.sort();
|
||||
entries
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue