Skip to content

Commit

Permalink
Auto merge of rust-lang#131949 - Noratrieb:fxhashup-thanks-alona, r=<…
Browse files Browse the repository at this point in the history
…try>

Update rustc-hash to version 2 but again

it's like rust-lang#129533 but not closed by bors and rebased

r? WaffleLapkin meow
  • Loading branch information
bors committed Oct 19, 2024
2 parents 8069f8d + 8208f88 commit a39b690
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 70 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ dependencies = [
"anyhow",
"clap",
"fs-err",
"rustc-hash 1.1.0",
"rustc-hash 2.0.0",
"rustdoc-json-types",
"serde",
"serde_json",
Expand Down Expand Up @@ -3514,7 +3514,7 @@ dependencies = [
"memmap2",
"parking_lot",
"portable-atomic",
"rustc-hash 1.1.0",
"rustc-hash 2.0.0",
"rustc-rayon",
"rustc-stable-hash",
"rustc_arena",
Expand Down Expand Up @@ -4211,7 +4211,7 @@ dependencies = [
name = "rustc_pattern_analysis"
version = "0.0.0"
dependencies = [
"rustc-hash 1.1.0",
"rustc-hash 2.0.0",
"rustc_apfloat",
"rustc_arena",
"rustc_data_structures",
Expand Down Expand Up @@ -4609,7 +4609,7 @@ name = "rustdoc-json-types"
version = "0.1.0"
dependencies = [
"bincode",
"rustc-hash 1.1.0",
"rustc-hash 2.0.0",
"serde",
"serde_json",
]
Expand Down Expand Up @@ -5239,7 +5239,7 @@ dependencies = [
"ignore",
"miropt-test-tools",
"regex",
"rustc-hash 1.1.0",
"rustc-hash 2.0.0",
"semver",
"similar",
"termcolor",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ena = "0.14.3"
indexmap = { version = "2.4.0" }
jobserver_crate = { version = "0.1.28", package = "jobserver" }
measureme = "11"
rustc-hash = "1.1.0"
rustc-hash = "2.0.0"
rustc-rayon = { version = "0.5.0", optional = true }
rustc-stable-hash = { version = "0.1.0", features = ["nightly"] }
rustc_arena = { path = "../rustc_arena" }
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_passes/src/hir_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ impl<'k> StatCollector<'k> {
// We will soon sort, so the initial order does not matter.
#[allow(rustc::potential_query_instability)]
let mut nodes: Vec<_> = self.nodes.iter().collect();
nodes.sort_by_key(|(_, node)| node.stats.count * node.stats.size);
nodes.sort_by_cached_key(|(label, node)| {
(node.stats.count * node.stats.size, label.to_owned())
});

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

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_pattern_analysis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
# tidy-alphabetical-start
rustc-hash = "1.1.0"
rustc-hash = "2.0.0"
rustc_apfloat = "0.2.0"
rustc_arena = { path = "../rustc_arena", optional = true }
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,11 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
if !ident.as_str().starts_with('_') {
self.r.unused_macros.insert(def_id, (node_id, ident));
for (rule_i, rule_span) in &self.r.macro_map[&def_id.to_def_id()].rule_spans {
self.r.unused_macro_rules.insert((def_id, *rule_i), (ident, *rule_span));
self.r
.unused_macro_rules
.entry(def_id)
.or_default()
.insert(*rule_i, (ident, *rule_span));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,8 @@ pub struct Resolver<'ra, 'tcx> {
local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>,
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
unused_macros: FxHashMap<LocalDefId, (NodeId, Ident)>,
unused_macro_rules: FxHashMap<(LocalDefId, usize), (Ident, Span)>,
/// A map from the macro to all its potentially unused arms.
unused_macro_rules: FxIndexMap<LocalDefId, FxHashMap<usize, (Ident, Span)>>,
proc_macro_stubs: FxHashSet<LocalDefId>,
/// Traces collected during macro resolution and validated when it's complete.
single_segment_macro_resolutions:
Expand Down
32 changes: 20 additions & 12 deletions compiler/rustc_resolve/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {

fn record_macro_rule_usage(&mut self, id: NodeId, rule_i: usize) {
let did = self.local_def_id(id);
self.unused_macro_rules.remove(&(did, rule_i));
if let Some(rules) = self.unused_macro_rules.get_mut(&did) {
rules.remove(&rule_i);
}
}

fn check_unused_macros(&mut self) {
Expand All @@ -352,18 +354,24 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
BuiltinLintDiag::UnusedMacroDefinition(ident.name),
);
}
for (&(def_id, arm_i), &(ident, rule_span)) in self.unused_macro_rules.iter() {
if self.unused_macros.contains_key(&def_id) {
// We already lint the entire macro as unused
continue;

for (&def_id, unused_arms) in self.unused_macro_rules.iter() {
let mut unused_arms = unused_arms.iter().collect::<Vec<_>>();
unused_arms.sort_by_key(|&(&arm_i, _)| arm_i);

for (&arm_i, &(ident, rule_span)) in unused_arms {
if self.unused_macros.contains_key(&def_id) {
// We already lint the entire macro as unused
continue;
}
let node_id = self.def_id_to_node_id[def_id];
self.lint_buffer.buffer_lint(
UNUSED_MACRO_RULES,
node_id,
rule_span,
BuiltinLintDiag::MacroRuleNeverUsed(arm_i, ident.name),
);
}
let node_id = self.def_id_to_node_id[def_id];
self.lint_buffer.buffer_lint(
UNUSED_MACRO_RULES,
node_id,
rule_span,
BuiltinLintDiag::MacroRuleNeverUsed(arm_i, ident.name),
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/rustdoc-json-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ path = "lib.rs"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
rustc-hash = "1.1.0"
rustc-hash = "2.0.0"

[dev-dependencies]
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/tools/jsondoclint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
anyhow = "1.0.62"
clap = { version = "4.0.15", features = ["derive"] }
fs-err = "2.8.1"
rustc-hash = "1.1.0"
rustc-hash = "2.0.0"
rustdoc-json-types = { version = "0.1.0", path = "../../rustdoc-json-types" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0.85"
2 changes: 1 addition & 1 deletion src/tools/tidy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ walkdir = "2"
ignore = "0.4.18"
semver = "1.0"
termcolor = "1.1.3"
rustc-hash = "1.1.0"
rustc-hash = "2.0.0"
fluent-syntax = "0.11.1"
similar = "2.5.0"

Expand Down
12 changes: 6 additions & 6 deletions tests/ui/lint/unused/unused-macro-rules-compile-error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ note: the lint level is defined here
LL | #![deny(unused_macro_rules)]
| ^^^^^^^^^^^^^^^^^^

error: rule #3 of macro `num2` is never used
--> $DIR/unused-macro-rules-compile-error.rs:22:5
|
LL | (two_) => { compile_error! };
| ^^^^^^

error: rule #2 of macro `num2` is never used
--> $DIR/unused-macro-rules-compile-error.rs:20:5
|
LL | (two) => { fn compile_error() {} };
| ^^^^^

error: rule #3 of macro `num2` is never used
--> $DIR/unused-macro-rules-compile-error.rs:22:5
|
LL | (two_) => { compile_error! };
| ^^^^^^

error: aborting due to 3 previous errors

16 changes: 8 additions & 8 deletions tests/ui/lint/unused/unused-macro-rules-decl.stderr
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
error: rule #4 of macro `num` is never used
--> $DIR/unused-macro-rules-decl.rs:11:5
error: rule #2 of macro `num` is never used
--> $DIR/unused-macro-rules-decl.rs:9:5
|
LL | (four) => { 4 },
| ^^^^^^
LL | (two) => { 2 },
| ^^^^^
|
note: the lint level is defined here
--> $DIR/unused-macro-rules-decl.rs:2:9
|
LL | #![deny(unused_macro_rules)]
| ^^^^^^^^^^^^^^^^^^

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

error: rule #3 of macro `num_rec` is never used
--> $DIR/unused-macro-rules-decl.rs:31:5
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/lint/unused/unused-macro-rules.stderr
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
error: rule #4 of macro `num` is never used
--> $DIR/unused-macro-rules.rs:10:5
error: rule #2 of macro `num` is never used
--> $DIR/unused-macro-rules.rs:8:5
|
LL | (four) => { 4 };
| ^^^^^^
LL | (two) => { 2 };
| ^^^^^
|
note: the lint level is defined here
--> $DIR/unused-macro-rules.rs:1:9
|
LL | #![deny(unused_macro_rules)]
| ^^^^^^^^^^^^^^^^^^

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

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

0 comments on commit a39b690

Please sign in to comment.