Skip to content

Commit f814b34

Browse files
committed
Auto merge of #131949 - Noratrieb:fxhashup-thanks-alona, r=WaffleLapkin
Update rustc-hash to version 2 but again it's like #129533 but not closed by bors and rebased r? WaffleLapkin meow
2 parents bfab34a + 0c8d81b commit f814b34

File tree

14 files changed

+85
-70
lines changed

14 files changed

+85
-70
lines changed

Cargo.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -1907,7 +1907,7 @@ dependencies = [
19071907
"anyhow",
19081908
"clap",
19091909
"fs-err",
1910-
"rustc-hash 1.1.0",
1910+
"rustc-hash 2.0.0",
19111911
"rustdoc-json-types",
19121912
"serde",
19131913
"serde_json",
@@ -3514,7 +3514,7 @@ dependencies = [
35143514
"memmap2",
35153515
"parking_lot",
35163516
"portable-atomic",
3517-
"rustc-hash 1.1.0",
3517+
"rustc-hash 2.0.0",
35183518
"rustc-rayon",
35193519
"rustc-stable-hash",
35203520
"rustc_arena",
@@ -4211,7 +4211,7 @@ dependencies = [
42114211
name = "rustc_pattern_analysis"
42124212
version = "0.0.0"
42134213
dependencies = [
4214-
"rustc-hash 1.1.0",
4214+
"rustc-hash 2.0.0",
42154215
"rustc_apfloat",
42164216
"rustc_arena",
42174217
"rustc_data_structures",
@@ -4609,7 +4609,7 @@ name = "rustdoc-json-types"
46094609
version = "0.1.0"
46104610
dependencies = [
46114611
"bincode",
4612-
"rustc-hash 1.1.0",
4612+
"rustc-hash 2.0.0",
46134613
"serde",
46144614
"serde_json",
46154615
]
@@ -5239,7 +5239,7 @@ dependencies = [
52395239
"ignore",
52405240
"miropt-test-tools",
52415241
"regex",
5242-
"rustc-hash 1.1.0",
5242+
"rustc-hash 2.0.0",
52435243
"semver",
52445244
"similar",
52455245
"termcolor",

compiler/rustc_data_structures/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ena = "0.14.3"
1313
indexmap = { version = "2.4.0" }
1414
jobserver_crate = { version = "0.1.28", package = "jobserver" }
1515
measureme = "11"
16-
rustc-hash = "1.1.0"
16+
rustc-hash = "2.0.0"
1717
rustc-rayon = { version = "0.5.0", optional = true }
1818
rustc-stable-hash = { version = "0.1.0", features = ["nightly"] }
1919
rustc_arena = { path = "../rustc_arena" }

compiler/rustc_passes/src/hir_stats.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ impl<'k> StatCollector<'k> {
122122
// We will soon sort, so the initial order does not matter.
123123
#[allow(rustc::potential_query_instability)]
124124
let mut nodes: Vec<_> = self.nodes.iter().collect();
125-
nodes.sort_by_key(|(_, node)| node.stats.count * node.stats.size);
125+
nodes.sort_by_cached_key(|(label, node)| {
126+
(node.stats.count * node.stats.size, label.to_owned())
127+
});
126128

127129
let total_size = nodes.iter().map(|(_, node)| node.stats.count * node.stats.size).sum();
128130

compiler/rustc_pattern_analysis/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
rustc-hash = "1.1.0"
8+
rustc-hash = "2.0.0"
99
rustc_apfloat = "0.2.0"
1010
rustc_arena = { path = "../rustc_arena", optional = true }
1111
rustc_data_structures = { path = "../rustc_data_structures", optional = true }

compiler/rustc_resolve/src/build_reduced_graph.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,11 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
11931193
if !ident.as_str().starts_with('_') {
11941194
self.r.unused_macros.insert(def_id, (node_id, ident));
11951195
for (rule_i, rule_span) in &self.r.macro_map[&def_id.to_def_id()].rule_spans {
1196-
self.r.unused_macro_rules.insert((def_id, *rule_i), (ident, *rule_span));
1196+
self.r
1197+
.unused_macro_rules
1198+
.entry(def_id)
1199+
.or_default()
1200+
.insert(*rule_i, (ident, *rule_span));
11971201
}
11981202
}
11991203
}

compiler/rustc_resolve/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,8 @@ pub struct Resolver<'ra, 'tcx> {
11221122
local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>,
11231123
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
11241124
unused_macros: FxHashMap<LocalDefId, (NodeId, Ident)>,
1125-
unused_macro_rules: FxHashMap<(LocalDefId, usize), (Ident, Span)>,
1125+
/// A map from the macro to all its potentially unused arms.
1126+
unused_macro_rules: FxIndexMap<LocalDefId, FxHashMap<usize, (Ident, Span)>>,
11261127
proc_macro_stubs: FxHashSet<LocalDefId>,
11271128
/// Traces collected during macro resolution and validated when it's complete.
11281129
single_segment_macro_resolutions:

compiler/rustc_resolve/src/macros.rs

+20-12
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,9 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
340340

341341
fn record_macro_rule_usage(&mut self, id: NodeId, rule_i: usize) {
342342
let did = self.local_def_id(id);
343-
self.unused_macro_rules.remove(&(did, rule_i));
343+
if let Some(rules) = self.unused_macro_rules.get_mut(&did) {
344+
rules.remove(&rule_i);
345+
}
344346
}
345347

346348
fn check_unused_macros(&mut self) {
@@ -352,18 +354,24 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
352354
BuiltinLintDiag::UnusedMacroDefinition(ident.name),
353355
);
354356
}
355-
for (&(def_id, arm_i), &(ident, rule_span)) in self.unused_macro_rules.iter() {
356-
if self.unused_macros.contains_key(&def_id) {
357-
// We already lint the entire macro as unused
358-
continue;
357+
358+
for (&def_id, unused_arms) in self.unused_macro_rules.iter() {
359+
let mut unused_arms = unused_arms.iter().collect::<Vec<_>>();
360+
unused_arms.sort_by_key(|&(&arm_i, _)| arm_i);
361+
362+
for (&arm_i, &(ident, rule_span)) in unused_arms {
363+
if self.unused_macros.contains_key(&def_id) {
364+
// We already lint the entire macro as unused
365+
continue;
366+
}
367+
let node_id = self.def_id_to_node_id[def_id];
368+
self.lint_buffer.buffer_lint(
369+
UNUSED_MACRO_RULES,
370+
node_id,
371+
rule_span,
372+
BuiltinLintDiag::MacroRuleNeverUsed(arm_i, ident.name),
373+
);
359374
}
360-
let node_id = self.def_id_to_node_id[def_id];
361-
self.lint_buffer.buffer_lint(
362-
UNUSED_MACRO_RULES,
363-
node_id,
364-
rule_span,
365-
BuiltinLintDiag::MacroRuleNeverUsed(arm_i, ident.name),
366-
);
367375
}
368376
}
369377

src/rustdoc-json-types/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ default = ["rustc-hash"]
1111

1212
[dependencies]
1313
serde = { version = "1.0", features = ["derive"] }
14-
rustc-hash = { version = "1.1.0", optional = true }
14+
rustc-hash = { version = "2.0", optional = true }
1515

1616
[dev-dependencies]
1717
serde_json = "1.0"

src/tools/jsondoclint/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2021"
99
anyhow = "1.0.62"
1010
clap = { version = "4.0.15", features = ["derive"] }
1111
fs-err = "2.8.1"
12-
rustc-hash = "1.1.0"
12+
rustc-hash = "2.0.0"
1313
rustdoc-json-types = { version = "0.1.0", path = "../../rustdoc-json-types" }
1414
serde = { version = "1.0", features = ["derive"] }
1515
serde_json = "1.0.85"

src/tools/tidy/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ walkdir = "2"
1313
ignore = "0.4.18"
1414
semver = "1.0"
1515
termcolor = "1.1.3"
16-
rustc-hash = "1.1.0"
16+
rustc-hash = "2.0.0"
1717
fluent-syntax = "0.11.1"
1818
similar = "2.5.0"
1919

tests/ui/lint/unused/unused-macro-rules-compile-error.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ note: the lint level is defined here
1010
LL | #![deny(unused_macro_rules)]
1111
| ^^^^^^^^^^^^^^^^^^
1212

13-
error: rule #3 of macro `num2` is never used
14-
--> $DIR/unused-macro-rules-compile-error.rs:22:5
15-
|
16-
LL | (two_) => { compile_error! };
17-
| ^^^^^^
18-
1913
error: rule #2 of macro `num2` is never used
2014
--> $DIR/unused-macro-rules-compile-error.rs:20:5
2115
|
2216
LL | (two) => { fn compile_error() {} };
2317
| ^^^^^
2418

19+
error: rule #3 of macro `num2` is never used
20+
--> $DIR/unused-macro-rules-compile-error.rs:22:5
21+
|
22+
LL | (two_) => { compile_error! };
23+
| ^^^^^^
24+
2525
error: aborting due to 3 previous errors
2626

tests/ui/lint/unused/unused-macro-rules-decl.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
error: rule #4 of macro `num` is never used
2-
--> $DIR/unused-macro-rules-decl.rs:11:5
1+
error: rule #2 of macro `num` is never used
2+
--> $DIR/unused-macro-rules-decl.rs:9:5
33
|
4-
LL | (four) => { 4 },
5-
| ^^^^^^
4+
LL | (two) => { 2 },
5+
| ^^^^^
66
|
77
note: the lint level is defined here
88
--> $DIR/unused-macro-rules-decl.rs:2:9
99
|
1010
LL | #![deny(unused_macro_rules)]
1111
| ^^^^^^^^^^^^^^^^^^
1212

13-
error: rule #2 of macro `num` is never used
14-
--> $DIR/unused-macro-rules-decl.rs:9:5
13+
error: rule #4 of macro `num` is never used
14+
--> $DIR/unused-macro-rules-decl.rs:11:5
1515
|
16-
LL | (two) => { 2 },
17-
| ^^^^^
16+
LL | (four) => { 4 },
17+
| ^^^^^^
1818

1919
error: rule #3 of macro `num_rec` is never used
2020
--> $DIR/unused-macro-rules-decl.rs:31:5

tests/ui/lint/unused/unused-macro-rules.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
error: rule #4 of macro `num` is never used
2-
--> $DIR/unused-macro-rules.rs:10:5
1+
error: rule #2 of macro `num` is never used
2+
--> $DIR/unused-macro-rules.rs:8:5
33
|
4-
LL | (four) => { 4 };
5-
| ^^^^^^
4+
LL | (two) => { 2 };
5+
| ^^^^^
66
|
77
note: the lint level is defined here
88
--> $DIR/unused-macro-rules.rs:1:9
99
|
1010
LL | #![deny(unused_macro_rules)]
1111
| ^^^^^^^^^^^^^^^^^^
1212

13-
error: rule #2 of macro `num` is never used
14-
--> $DIR/unused-macro-rules.rs:8:5
13+
error: rule #4 of macro `num` is never used
14+
--> $DIR/unused-macro-rules.rs:10:5
1515
|
16-
LL | (two) => { 2 };
17-
| ^^^^^
16+
LL | (four) => { 4 };
17+
| ^^^^^^
1818

1919
error: rule #3 of macro `num_rec` is never used
2020
--> $DIR/unused-macro-rules.rs:30:5

0 commit comments

Comments
 (0)