Skip to content

Commit e9636ac

Browse files
committed
Auto merge of #120667 - matthiaskrgr:rollup-2gjjc2r, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #120023 (tidy: reduce allocs) - #120214 (match lowering: consistently lower bindings deepest-first) - #120396 (Account for unbounded type param receiver in suggestions) - #120423 (update indirect structural match lints to match RFC and to show up for dependencies) - #120435 (Suggest name value cfg when only value is used for check-cfg) - #120507 (Account for non-overlapping unmet trait bounds in suggestion) - #120521 (Make `NonZero` constructors generic.) - #120527 (Switch OwnedStore handle count to AtomicU32) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8c0b4f6 + d6ea81b commit e9636ac

File tree

73 files changed

+1358
-834
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1358
-834
lines changed

Cargo.lock

+36-44
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,9 @@ dependencies = [
4949

5050
[[package]]
5151
name = "aho-corasick"
52-
version = "0.7.20"
52+
version = "1.1.2"
5353
source = "registry+https://github.com/rust-lang/crates.io-index"
54-
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
55-
dependencies = [
56-
"memchr",
57-
]
58-
59-
[[package]]
60-
name = "aho-corasick"
61-
version = "1.0.2"
62-
source = "registry+https://github.com/rust-lang/crates.io-index"
63-
checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
54+
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
6455
dependencies = [
6556
"memchr",
6657
]
@@ -319,13 +310,12 @@ dependencies = [
319310

320311
[[package]]
321312
name = "bstr"
322-
version = "1.5.0"
313+
version = "1.9.0"
323314
source = "registry+https://github.com/rust-lang/crates.io-index"
324-
checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5"
315+
checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc"
325316
dependencies = [
326317
"memchr",
327-
"once_cell",
328-
"regex-automata 0.1.10",
318+
"regex-automata 0.4.3",
329319
"serde",
330320
]
331321

@@ -596,7 +586,7 @@ dependencies = [
596586
name = "clippy_dev"
597587
version = "0.0.1"
598588
dependencies = [
599-
"aho-corasick 1.0.2",
589+
"aho-corasick",
600590
"clap",
601591
"indoc",
602592
"itertools",
@@ -1597,15 +1587,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
15971587

15981588
[[package]]
15991589
name = "globset"
1600-
version = "0.4.10"
1590+
version = "0.4.14"
16011591
source = "registry+https://github.com/rust-lang/crates.io-index"
1602-
checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"
1592+
checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1"
16031593
dependencies = [
1604-
"aho-corasick 0.7.20",
1594+
"aho-corasick",
16051595
"bstr",
1606-
"fnv",
16071596
"log",
1608-
"regex",
1597+
"regex-automata 0.4.3",
1598+
"regex-syntax 0.8.2",
16091599
]
16101600

16111601
[[package]]
@@ -1944,17 +1934,16 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed"
19441934

19451935
[[package]]
19461936
name = "ignore"
1947-
version = "0.4.20"
1937+
version = "0.4.22"
19481938
source = "registry+https://github.com/rust-lang/crates.io-index"
1949-
checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492"
1939+
checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1"
19501940
dependencies = [
1941+
"crossbeam-deque",
19511942
"globset",
1952-
"lazy_static",
19531943
"log",
19541944
"memchr",
1955-
"regex",
1945+
"regex-automata 0.4.3",
19561946
"same-file",
1957-
"thread_local",
19581947
"walkdir",
19591948
"winapi-util",
19601949
]
@@ -2274,9 +2263,9 @@ dependencies = [
22742263

22752264
[[package]]
22762265
name = "log"
2277-
version = "0.4.19"
2266+
version = "0.4.20"
22782267
source = "registry+https://github.com/rust-lang/crates.io-index"
2279-
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
2268+
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
22802269

22812270
[[package]]
22822271
name = "lzma-sys"
@@ -2378,9 +2367,9 @@ dependencies = [
23782367

23792368
[[package]]
23802369
name = "memchr"
2381-
version = "2.5.0"
2370+
version = "2.7.1"
23822371
source = "registry+https://github.com/rust-lang/crates.io-index"
2383-
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
2372+
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
23842373
dependencies = [
23852374
"compiler_builtins",
23862375
"rustc-std-workspace-core",
@@ -2490,9 +2479,6 @@ dependencies = [
24902479
[[package]]
24912480
name = "miropt-test-tools"
24922481
version = "0.1.0"
2493-
dependencies = [
2494-
"regex",
2495-
]
24962482

24972483
[[package]]
24982484
name = "native-tls"
@@ -3153,13 +3139,14 @@ dependencies = [
31533139

31543140
[[package]]
31553141
name = "regex"
3156-
version = "1.8.4"
3142+
version = "1.10.2"
31573143
source = "registry+https://github.com/rust-lang/crates.io-index"
3158-
checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f"
3144+
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
31593145
dependencies = [
3160-
"aho-corasick 1.0.2",
3146+
"aho-corasick",
31613147
"memchr",
3162-
"regex-syntax 0.7.2",
3148+
"regex-automata 0.4.3",
3149+
"regex-syntax 0.8.2",
31633150
]
31643151

31653152
[[package]]
@@ -3181,16 +3168,21 @@ dependencies = [
31813168
]
31823169

31833170
[[package]]
3184-
name = "regex-syntax"
3185-
version = "0.6.29"
3171+
name = "regex-automata"
3172+
version = "0.4.3"
31863173
source = "registry+https://github.com/rust-lang/crates.io-index"
3187-
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
3174+
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
3175+
dependencies = [
3176+
"aho-corasick",
3177+
"memchr",
3178+
"regex-syntax 0.8.2",
3179+
]
31883180

31893181
[[package]]
31903182
name = "regex-syntax"
3191-
version = "0.7.2"
3183+
version = "0.6.29"
31923184
source = "registry+https://github.com/rust-lang/crates.io-index"
3193-
checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
3185+
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
31943186

31953187
[[package]]
31963188
name = "regex-syntax"
@@ -5940,9 +5932,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
59405932

59415933
[[package]]
59425934
name = "walkdir"
5943-
version = "2.3.3"
5935+
version = "2.4.0"
59445936
source = "registry+https://github.com/rust-lang/crates.io-index"
5945-
checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698"
5937+
checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
59465938
dependencies = [
59475939
"same-file",
59485940
"winapi-util",

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+1-28
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::mem;
2020
use std::ops::{ControlFlow, Deref};
2121

2222
use super::ops::{self, NonConstOp, Status};
23-
use super::qualifs::{self, CustomEq, HasMutInterior, NeedsDrop, NeedsNonConstDrop};
23+
use super::qualifs::{self, HasMutInterior, NeedsDrop, NeedsNonConstDrop};
2424
use super::resolver::FlowSensitiveAnalysis;
2525
use super::{ConstCx, Qualif};
2626
use crate::const_eval::is_unstable_const_fn;
@@ -149,37 +149,10 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
149149

150150
let return_loc = ccx.body.terminator_loc(return_block);
151151

152-
let custom_eq = match ccx.const_kind() {
153-
// We don't care whether a `const fn` returns a value that is not structurally
154-
// matchable. Functions calls are opaque and always use type-based qualification, so
155-
// this value should never be used.
156-
hir::ConstContext::ConstFn => true,
157-
158-
// If we know that all values of the return type are structurally matchable, there's no
159-
// need to run dataflow.
160-
// Opaque types do not participate in const generics or pattern matching, so we can safely count them out.
161-
_ if ccx.body.return_ty().has_opaque_types()
162-
|| !CustomEq::in_any_value_of_ty(ccx, ccx.body.return_ty()) =>
163-
{
164-
false
165-
}
166-
167-
hir::ConstContext::Const { .. } | hir::ConstContext::Static(_) => {
168-
let mut cursor = FlowSensitiveAnalysis::new(CustomEq, ccx)
169-
.into_engine(ccx.tcx, ccx.body)
170-
.iterate_to_fixpoint()
171-
.into_results_cursor(ccx.body);
172-
173-
cursor.seek_after_primary_effect(return_loc);
174-
cursor.get().contains(RETURN_PLACE)
175-
}
176-
};
177-
178152
ConstQualifs {
179153
needs_drop: self.needs_drop(ccx, RETURN_PLACE, return_loc),
180154
needs_non_const_drop: self.needs_non_const_drop(ccx, RETURN_PLACE, return_loc),
181155
has_mut_interior: self.has_mut_interior(ccx, RETURN_PLACE, return_loc),
182-
custom_eq,
183156
tainted_by_errors,
184157
}
185158
}

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

+1-31
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_middle::mir::*;
1010
use rustc_middle::traits::BuiltinImplSource;
1111
use rustc_middle::ty::{self, AdtDef, GenericArgsRef, Ty};
1212
use rustc_trait_selection::traits::{
13-
self, ImplSource, Obligation, ObligationCause, ObligationCtxt, SelectionContext,
13+
ImplSource, Obligation, ObligationCause, ObligationCtxt, SelectionContext,
1414
};
1515

1616
use super::ConstCx;
@@ -24,7 +24,6 @@ pub fn in_any_value_of_ty<'tcx>(
2424
has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),
2525
needs_drop: NeedsDrop::in_any_value_of_ty(cx, ty),
2626
needs_non_const_drop: NeedsNonConstDrop::in_any_value_of_ty(cx, ty),
27-
custom_eq: CustomEq::in_any_value_of_ty(cx, ty),
2827
tainted_by_errors,
2928
}
3029
}
@@ -213,35 +212,6 @@ impl Qualif for NeedsNonConstDrop {
213212
}
214213
}
215214

216-
/// A constant that cannot be used as part of a pattern in a `match` expression.
217-
pub struct CustomEq;
218-
219-
impl Qualif for CustomEq {
220-
const ANALYSIS_NAME: &'static str = "flow_custom_eq";
221-
222-
fn in_qualifs(qualifs: &ConstQualifs) -> bool {
223-
qualifs.custom_eq
224-
}
225-
226-
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
227-
// If *any* component of a composite data type does not implement `Structural{Partial,}Eq`,
228-
// we know that at least some values of that type are not structural-match. I say "some"
229-
// because that component may be part of an enum variant (e.g.,
230-
// `Option::<NonStructuralMatchTy>::Some`), in which case some values of this type may be
231-
// structural-match (`Option::None`).
232-
traits::search_for_structural_match_violation(cx.body.span, cx.tcx, ty).is_some()
233-
}
234-
235-
fn in_adt_inherently<'tcx>(
236-
cx: &ConstCx<'_, 'tcx>,
237-
def: AdtDef<'tcx>,
238-
args: GenericArgsRef<'tcx>,
239-
) -> bool {
240-
let ty = Ty::new_adt(cx.tcx, def, args);
241-
!ty.is_structural_eq_shallow(cx.tcx)
242-
}
243-
}
244-
245215
// FIXME: Use `mir::visit::Visitor` for the `in_*` functions if/when it supports early return.
246216

247217
/// Returns `true` if this `Rvalue` contains qualif `Q`.

0 commit comments

Comments
 (0)