Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync from rust-lang/rust #12871

Merged
merged 11 commits into from
Jul 25, 2022
Merged
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
* text=auto eol=lf

# git grep shouldn't match entries in this benchmark data
bench_data/** binary
crates/syntax/test_data/** -text eof=LF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a fun story! The short answer it: it caused bors to fail to merge the rust-lang/rust subtree PR.

The longer story is: that change was introduced in #2166 - but it never did what was intended.

eof is not a gitattribute setting. eol is, but even that line used eol, it still wouldn't do anything, because of -text. So by mistake, 3 files were treated as binary, and checked out with CRLF line endings (those were the ones bors choked on).

After removing this line from .gitattribute, I re-added the folder to git, removed it from disk and used git restore to write it with the proper line endings. The relevant commit is here: rust-lang/rust@1bb63df

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just did a fresh clone of that branch from Windows and ran cargo test with the latest stable, no issues whatsoever.

I'm still convinced #2166 wasn't needed, as explained here: #2166 (comment)


# Older git versions try to fix line endings on images, this prevents it.
*.png binary
*.jpg binary
Expand Down
80 changes: 42 additions & 38 deletions crates/hir-def/src/import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ mod tests {
mark
))
})
// HashSet iteration order isn't defined - it's different on
// x86_64 and i686 at the very least
.sorted()
.collect::<String>();
expect.assert_eq(&actual)
}
Expand Down Expand Up @@ -588,6 +591,7 @@ mod tests {

Some(format!("{}:\n{:?}\n", name, map))
})
.sorted()
.collect::<String>();

expect.assert_eq(&actual)
Expand Down Expand Up @@ -621,15 +625,15 @@ mod tests {
struct Priv;
",
expect![[r#"
lib:
- Pub (t)
- Pub2 (t)
- Pub2 (v)
main:
- publ1 (t)
- real_pu2 (t)
- real_pub (t)
- real_pub::Pub (t)
lib:
- Pub (t)
- Pub2 (t)
- Pub2 (v)
"#]],
);
}
Expand Down Expand Up @@ -671,13 +675,13 @@ mod tests {
pub struct S;
",
expect![[r#"
lib:
- S (t)
- S (v)
main:
- m (t)
- m::S (t)
- m::S (v)
lib:
- S (t)
- S (v)
"#]],
);
}
Expand All @@ -697,11 +701,11 @@ mod tests {
}
",
expect![[r#"
lib:
- pub_macro (m)
main:
- m (t)
- m::pub_macro (m)
lib:
- pub_macro (m)
"#]],
);
}
Expand All @@ -719,14 +723,14 @@ mod tests {
}
",
expect![[r#"
main:
- reexported_module (t)
- reexported_module::S (t)
- reexported_module::S (v)
lib:
- module (t)
- module::S (t)
- module::S (v)
main:
- reexported_module (t)
- reexported_module::S (t)
- reexported_module::S (v)
"#]],
);
}
Expand Down Expand Up @@ -831,10 +835,10 @@ mod tests {
Query::new("fmt".to_string()).search_mode(SearchMode::Fuzzy),
expect![[r#"
dep::fmt (t)
dep::fmt::Display::format_method (a)
dep::fmt::Display (t)
dep::fmt::Display::FMT_CONST (a)
dep::fmt::Display::format_function (a)
dep::fmt::Display::format_method (a)
"#]],
);
}
Expand All @@ -860,10 +864,10 @@ mod tests {
"main",
Query::new("fmt".to_string()).search_mode(SearchMode::Fuzzy).assoc_items_only(),
expect![[r#"
dep::fmt::Display::format_method (a)
dep::fmt::Display::FMT_CONST (a)
dep::fmt::Display::format_function (a)
"#]],
dep::fmt::Display::FMT_CONST (a)
dep::fmt::Display::format_function (a)
dep::fmt::Display::format_method (a)
"#]],
);

check_search(
Expand Down Expand Up @@ -920,13 +924,13 @@ mod tests {
"main",
Query::new("fmt".to_string()).search_mode(SearchMode::Fuzzy),
expect![[r#"
dep::fmt (t)
dep::format (f)
dep::Fmt (v)
dep::Fmt (m)
dep::Fmt (t)
dep::fmt::Display::fmt (a)
dep::Fmt (v)
dep::fmt (t)
dep::fmt::Display (t)
dep::fmt::Display::fmt (a)
dep::format (f)
"#]],
);

Expand All @@ -935,10 +939,10 @@ mod tests {
"main",
Query::new("fmt".to_string()).search_mode(SearchMode::Equals),
expect![[r#"
dep::fmt (t)
dep::Fmt (v)
dep::Fmt (m)
dep::Fmt (t)
dep::Fmt (v)
dep::fmt (t)
dep::fmt::Display::fmt (a)
"#]],
);
Expand All @@ -948,12 +952,12 @@ mod tests {
"main",
Query::new("fmt".to_string()).search_mode(SearchMode::Contains),
expect![[r#"
dep::fmt (t)
dep::Fmt (v)
dep::Fmt (m)
dep::Fmt (t)
dep::fmt::Display::fmt (a)
dep::Fmt (v)
dep::fmt (t)
dep::fmt::Display (t)
dep::fmt::Display::fmt (a)
"#]],
);
}
Expand Down Expand Up @@ -989,12 +993,12 @@ mod tests {
"main",
Query::new("fmt".to_string()),
expect![[r#"
dep::fmt (t)
dep::Fmt (v)
dep::Fmt (m)
dep::Fmt (t)
dep::fmt::Display::fmt (a)
dep::Fmt (v)
dep::fmt (t)
dep::fmt::Display (t)
dep::fmt::Display::fmt (a)
"#]],
);

Expand All @@ -1003,10 +1007,10 @@ mod tests {
"main",
Query::new("fmt".to_string()).name_only(),
expect![[r#"
dep::fmt (t)
dep::Fmt (v)
dep::Fmt (m)
dep::Fmt (t)
dep::Fmt (v)
dep::fmt (t)
dep::fmt::Display::fmt (a)
"#]],
);
Expand All @@ -1027,10 +1031,10 @@ mod tests {
"main",
Query::new("FMT".to_string()),
expect![[r#"
dep::fmt (t)
dep::FMT (t)
dep::FMT (v)
dep::fmt (t)
dep::fmt (v)
dep::FMT (t)
"#]],
);

Expand Down Expand Up @@ -1068,10 +1072,10 @@ mod tests {
"main",
Query::new("".to_string()).limit(2),
expect![[r#"
dep::fmt (t)
dep::Fmt (m)
dep::Fmt (t)
dep::Fmt (v)
dep::Fmt (m)
dep::fmt (t)
"#]],
);
}
Expand All @@ -1091,10 +1095,10 @@ mod tests {
"main",
Query::new("FMT".to_string()),
expect![[r#"
dep::fmt (t)
dep::FMT (t)
dep::FMT (v)
dep::fmt (t)
dep::fmt (v)
dep::FMT (t)
"#]],
);

Expand Down
9 changes: 6 additions & 3 deletions crates/hir-def/src/nameres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,20 @@
//! the result

pub mod attr_resolution;
pub mod diagnostics;
mod collector;
pub mod diagnostics;
mod mod_resolution;
mod path_resolution;
mod proc_macro;

#[cfg(test)]
mod tests;

use std::sync::Arc;
use std::{cmp::Ord, sync::Arc};

use base_db::{CrateId, Edition, FileId};
use hir_expand::{name::Name, InFile, MacroDefId};
use itertools::Itertools;
use la_arena::Arena;
use profile::Count;
use rustc_hash::FxHashMap;
Expand Down Expand Up @@ -431,7 +432,9 @@ impl DefMap {

map.modules[module].scope.dump(buf);

for (name, child) in map.modules[module].children.iter() {
for (name, child) in
map.modules[module].children.iter().sorted_by(|a, b| Ord::cmp(&a.0, &b.0))
{
let path = format!("{}::{}", path, name);
buf.push('\n');
go(buf, map, &path, *child);
Expand Down
20 changes: 10 additions & 10 deletions crates/hir-def/src/nameres/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,11 @@ mod b {
a: t
b: t

crate::b
T: v

crate::a
T: t v

crate::b
T: v
"#]],
);
}
Expand Down Expand Up @@ -704,13 +704,13 @@ use crate::reex::*;
reex: t
tr: t

crate::tr
PrivTr: t
PubTr: t

crate::reex
_: t
_: t

crate::tr
PrivTr: t
PubTr: t
"#]],
);
}
Expand Down Expand Up @@ -920,14 +920,14 @@ use some_module::unknown_func;
some_module: t
unknown_func: v

crate::some_module
unknown_func: v

crate::other_module
some_submodule: t

crate::other_module::some_submodule
unknown_func: v

crate::some_module
unknown_func: v
"#]],
)
}
18 changes: 9 additions & 9 deletions crates/hir-def/src/nameres/tests/globs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,13 @@ mod d {
c: t
d: t

crate::d
Y: t v
crate::a
foo: t

crate::a::foo
X: t v

crate::b
foo: t

crate::c
Expand All @@ -325,14 +330,9 @@ mod d {
crate::c::foo
Y: t v

crate::b
foo: t

crate::a
crate::d
Y: t v
foo: t

crate::a::foo
X: t v
"#]],
);
}
Loading