Skip to content

Commit a1db344

Browse files
committed
Auto merge of #151924 - JonathanBrouwer:rollup-Pqp8PIn, r=JonathanBrouwer
Rollup of 5 pull requests Successful merges: - #151886 (Skip unused_allocation lint when method takes &Box<Self>) - #150300 (Constify `fmt::from_fn`) - #151102 (Feature-gate `mut ref` patterns in struct pattern field shorthand) - #151866 (Reorganizing `tests/ui/issues` 10 tests [4/N] ) - #151890 (Re-export `hashbrown::hash_table` from `rustc_data_structures`)
2 parents 905b926 + d853e9e commit a1db344

29 files changed

+114
-30
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4354,7 +4354,6 @@ name = "rustc_mir_transform"
43544354
version = "0.0.0"
43554355
dependencies = [
43564356
"either",
4357-
"hashbrown 0.16.1",
43584357
"itertools",
43594358
"rustc_abi",
43604359
"rustc_arena",
@@ -4565,7 +4564,6 @@ dependencies = [
45654564
name = "rustc_query_system"
45664565
version = "0.0.0"
45674566
dependencies = [
4568-
"hashbrown 0.16.1",
45694567
"parking_lot",
45704568
"rustc_abi",
45714569
"rustc_ast",

compiler/rustc_data_structures/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ pub use std::{assert_matches, debug_assert_matches};
4949

5050
pub use atomic_ref::AtomicRef;
5151
pub use ena::{snapshot_vec, undo_log, unify};
52+
// Re-export `hashbrown::hash_table`, because it's part of our API
53+
// (via `ShardedHashMap`), and because it lets other compiler crates use the
54+
// lower-level `HashTable` API without a tricky `hashbrown` dependency.
55+
pub use hashbrown::hash_table;
5256
pub use rustc_index::static_assert_size;
5357
// Re-export some data-structure crates which are part of our public API.
5458
pub use {either, indexmap, smallvec, thin_vec};

compiler/rustc_data_structures/src/sharded.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::hash::{Hash, Hasher};
33
use std::{iter, mem};
44

55
use either::Either;
6-
use hashbrown::hash_table::{Entry, HashTable};
6+
use hashbrown::hash_table::{self, Entry, HashTable};
77

88
use crate::fx::FxHasher;
99
use crate::sync::{CacheAligned, Lock, LockGuard, Mode, is_dyn_thread_safe};
@@ -140,7 +140,7 @@ pub fn shards() -> usize {
140140
1
141141
}
142142

143-
pub type ShardedHashMap<K, V> = Sharded<HashTable<(K, V)>>;
143+
pub type ShardedHashMap<K, V> = Sharded<hash_table::HashTable<(K, V)>>;
144144

145145
impl<K: Eq, V> ShardedHashMap<K, V> {
146146
pub fn with_capacity(cap: usize) -> Self {

compiler/rustc_lint/src/unused.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1785,7 +1785,7 @@ declare_lint! {
17851785
declare_lint_pass!(UnusedAllocation => [UNUSED_ALLOCATION]);
17861786

17871787
impl<'tcx> LateLintPass<'tcx> for UnusedAllocation {
1788-
fn check_expr(&mut self, cx: &LateContext<'_>, e: &hir::Expr<'_>) {
1788+
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &hir::Expr<'_>) {
17891789
match e.kind {
17901790
hir::ExprKind::Call(path_expr, [_])
17911791
if let hir::ExprKind::Path(qpath) = &path_expr.kind
@@ -1796,6 +1796,12 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAllocation {
17961796

17971797
for adj in cx.typeck_results().expr_adjustments(e) {
17981798
if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(m)) = adj.kind {
1799+
if let ty::Ref(_, inner_ty, _) = adj.target.kind()
1800+
&& inner_ty.is_box()
1801+
{
1802+
// If the target type is `&Box<T>` or `&mut Box<T>`, the allocation is necessary
1803+
continue;
1804+
}
17991805
match m {
18001806
adjustment::AutoBorrowMutability::Not => {
18011807
cx.emit_span_lint(UNUSED_ALLOCATION, e.span, UnusedAllocationDiag);

compiler/rustc_mir_transform/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
either = "1"
9-
hashbrown = { version = "0.16.1", default-features = false }
109
itertools = "0.12"
1110
rustc_abi = { path = "../rustc_abi" }
1211
rustc_arena = { path = "../rustc_arena" }

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ use std::borrow::Cow;
8888
use std::hash::{Hash, Hasher};
8989

9090
use either::Either;
91-
use hashbrown::hash_table::{Entry, HashTable};
9291
use itertools::Itertools as _;
9392
use rustc_abi::{self as abi, BackendRepr, FIRST_VARIANT, FieldIdx, Primitive, Size, VariantIdx};
9493
use rustc_arena::DroplessArena;
@@ -99,6 +98,7 @@ use rustc_const_eval::interpret::{
9998
};
10099
use rustc_data_structures::fx::FxHasher;
101100
use rustc_data_structures::graph::dominators::Dominators;
101+
use rustc_data_structures::hash_table::{Entry, HashTable};
102102
use rustc_hir::def::DefKind;
103103
use rustc_index::bit_set::DenseBitSet;
104104
use rustc_index::{IndexVec, newtype_index};

compiler/rustc_parse/src/parser/pat.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,12 @@ impl<'a> Parser<'a> {
17491749
hi = self.prev_token.span;
17501750
let ann = BindingMode(by_ref, mutability);
17511751
let fieldpat = self.mk_pat_ident(boxed_span.to(hi), ann, fieldname);
1752+
if matches!(
1753+
fieldpat.kind,
1754+
PatKind::Ident(BindingMode(ByRef::Yes(..), Mutability::Mut), ..)
1755+
) {
1756+
self.psess.gated_spans.gate(sym::mut_ref, fieldpat.span);
1757+
}
17521758
let subpat = if is_box {
17531759
self.mk_pat(lo.to(hi), PatKind::Box(Box::new(fieldpat)))
17541760
} else {

compiler/rustc_query_system/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,3 @@ rustc_thread_pool = { path = "../rustc_thread_pool" }
2323
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2424
tracing = "0.1"
2525
# tidy-alphabetical-end
26-
27-
[dependencies.hashbrown]
28-
version = "0.16.1"
29-
default-features = false
30-
features = ["nightly"] # for may_dangle

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ use std::fmt::Debug;
77
use std::hash::Hash;
88
use std::mem;
99

10-
use hashbrown::HashTable;
11-
use hashbrown::hash_table::Entry;
1210
use rustc_data_structures::fingerprint::Fingerprint;
11+
use rustc_data_structures::hash_table::{self, Entry, HashTable};
1312
use rustc_data_structures::sharded::{self, Sharded};
1413
use rustc_data_structures::stack::ensure_sufficient_stack;
1514
use rustc_data_structures::sync::LockGuard;
@@ -35,7 +34,7 @@ fn equivalent_key<K: Eq, V>(k: &K) -> impl Fn(&(K, V)) -> bool + '_ {
3534
}
3635

3736
pub struct QueryState<'tcx, K> {
38-
active: Sharded<hashbrown::HashTable<(K, QueryResult<'tcx>)>>,
37+
active: Sharded<hash_table::HashTable<(K, QueryResult<'tcx>)>>,
3938
}
4039

4140
/// Indicates the state of a query for a given key in a query map.

library/core/src/fmt/builders.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,8 +1227,9 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
12271227
/// assert_eq!(format!("{:?}", wrapped), "'a'");
12281228
/// ```
12291229
#[stable(feature = "fmt_from_fn", since = "1.93.0")]
1230+
#[rustc_const_stable(feature = "const_fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
12301231
#[must_use = "returns a type implementing Debug and Display, which do not have any effects unless they are used"]
1231-
pub fn from_fn<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result>(f: F) -> FromFn<F> {
1232+
pub const fn from_fn<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result>(f: F) -> FromFn<F> {
12321233
FromFn(f)
12331234
}
12341235

0 commit comments

Comments
 (0)