Commit graph

314 commits

Author SHA1 Message Date
Jonathan Brouwer
65d982abd8
Rollup merge of #152469 - mu001999-contrib:cleanup/unused-features, r=nadrieril,jdonszelmann
Remove unused features

Detected by https://github.com/rust-lang/rust/pull/152164.

~~Only allow `unused_features` if there are complex platform-specific features enabled.~~
2026-02-13 13:34:58 +01:00
mu001999
a07f837491 Remove unused features in compiler 2026-02-13 09:25:39 +08:00
Jonathan Brouwer
ab4891ce74
Convert some impl Subdiagnostics to derives 2026-02-11 19:45:04 +01:00
Jonathan Brouwer
67c6cd99b7
Convert to inline diagnostics in rustc_pattern_analysis 2026-02-05 12:13:25 +01:00
Frank King
4ae5b43b0f refactor: remove Ty::pinned_ref in favor of Ty::maybe_pinned_ref
Also returns the `Region` of the reference type.
2026-01-30 14:22:41 +08:00
Zalathar
566c23de41 THIR patterns: Explicitly distinguish &pin from plain &/&mut 2026-01-20 13:41:32 +11:00
Jonathan Brouwer
0ee7d96253
Remove all allows for diagnostic_outside_of_impl and untranslatable_diagnostic throughout the codebase
This PR was mostly made by search&replacing
2026-01-19 17:39:49 +01:00
Zalathar
066eb6d2ea THIR patterns: Always use type str for string-constant-value nodes 2026-01-16 12:17:48 +11:00
Zalathar
8516c64115 Replace AscribeUserType and ExpandedConstant with per-node data 2026-01-09 16:46:08 +11:00
Sekar-C-Mca
65c10702bd Fix typo in pattern usefulness documentation
Line 171 introduced `pt_1, .., pt_n` and `qt` as variable names, but
line 172 incorrectly used `tp_1, .., tp_n, tq`. This commit fixes the
inconsistency to use the correct variable names throughout.
2026-01-03 22:46:09 +05:30
Boxy Uwu
6722805cdc Make ValTree recurse through ty::Const 2025-12-23 13:54:59 +00:00
Marijn Schouten
5d8a096afe change non-canonical clone impl to {*self}, fix some doc comments 2025-12-20 13:46:22 +00:00
Shoyu Vanilla
dae003b04b fix: Do not ICE when missing match arm with ill-formed subty is met 2025-11-13 01:36:35 +09:00
Frank King
5ef48ed448 Implement &pin patterns and ref pin bindings 2025-11-10 09:57:08 +08:00
lcnr
ad20e5c468 split definition and use site hidden tys 2025-10-31 14:48:43 +01:00
Boxy Uwu
4d41177513 Rename various "concrete opaque type" terminology to say "hidden type" 2025-09-27 22:58:02 +01:00
León Orell Valerian Liehr
26f3337d4e
Remove DynKind 2025-09-17 04:46:46 +02:00
Nicholas Nethercote
301655eafe Revert introduction of [workspace.dependencies].
This was done in #145740 and #145947. It is causing problems for people
using r-a on anything that uses the rustc-dev rustup package, e.g. Miri,
clippy.

This repository has lots of submodules and subtrees and various
different projects are carved out of pieces of it. It seems like
`[workspace.dependencies]` will just be more trouble than it's worth.
2025-09-02 19:12:54 +10:00
Nicholas Nethercote
2b26476ccd Add rustc-hash to [workspace.dependencies]. 2025-08-28 20:11:43 +10:00
Nicholas Nethercote
ce02d34b2f Add rustc_apfloat to [workspace.dependencies]. 2025-08-28 20:10:55 +10:00
Nicholas Nethercote
c50d2cc807 Add tracing to [workspace.dependencies]. 2025-08-27 14:21:19 +10:00
Samuel Tardieu
5a14685a63
Rollup merge of #145234 - dianne:1-tuple-witnesses, r=jackh726
match exhaustiveness diagnostics: show a trailing comma on singleton tuple consructors in witness patterns (and clean up a little)

Constructor patterns of type `(T,)` are written `(pat,)`, not `(pat)`. However, exhaustiveness/usefulness diagnostics would print them as `(pat)` when e.g. providing a witness of non-exhaustiveness and suggesting adding arms to make matches exhaustive; this would result in an error when applied.
rust-analyzer already prints the trailing comma, so it doesn't need changing.

This also includes some cleanup in the second commit, with justification in the commit message.
2025-08-23 22:22:15 +02:00
Ralf Jung
e2cc7757e1 avoid unnecessary type sanity checks 2025-08-14 09:44:22 +02:00
Ralf Jung
dbc030e034 shrink TestBranch::Constant and PatRangeBoundary::Finite 2025-08-14 09:44:22 +02:00
Ralf Jung
a1acbfb050 change StrLit type to ty::Value as well 2025-08-14 09:44:22 +02:00
Ralf Jung
a171eaab42 use ty::Value instead of manual pairs of types and valtrees 2025-08-14 09:44:22 +02:00
Ralf Jung
d61fdbf266 pattern testing: store constants as valtrees 2025-08-14 09:44:19 +02:00
Ralf Jung
3f1e99dca4 PatKind: store constants as valtrees 2025-08-14 09:39:39 +02:00
dianne
8f649a7e58 clean up witness printing for tuple-like constructors
By construction, `subpatterns` contains all fields in order. Witness
patterns are constructed with all fields in order by
`WitnessPat::wild_from_ctor` and `WitnessStack::apply_constructor`, and
the order is preserved at `write_struct_like`'s call-site in
`print_witness_pat`. It's thus no longer necessary to go looking for
fields or handle missing fields.
2025-08-10 16:34:11 -07:00
dianne
9449b78621 show a trailing comma on singleton tuple constructors in witness pats 2025-08-10 15:32:14 -07:00
Trevor Gross
18abf3aa44
Rollup merge of #144545 - ChayimFriedman2:bool-witness-order, r=Nadrieril
In rustc_pattern_analysis, put `true` witnesses before `false` witnesses

In rustc it doesn't really matter what the order of the witnesses is, but I'm planning to use the witnesses for implementing the "add missing match arms" assist in rust-analyzer, and there `true` before `false` is the natural order (like `Some` before `None`), and also what the current assist does.

The current order doesn't seem to be intentional; the code was created when bool ctors became their own thing, not just int ctors, but for integer, 0 before 1 is indeed the natural order.

r? `@Nadrieril`
2025-08-08 14:22:44 -05:00
Nicholas Nethercote
704f2ca172 Tidy up Cargo.toml files.
- Add some missing `tidy-alphabetical-*` markers.
- Remove some unnecessary blank lines.
2025-07-31 19:58:04 +10:00
Chayim Refael Friedman
6bf3cbe39e In rustc_pattern_analysis, put true witnesses before false witnesses
In rustc it doesn't really matter what the order of the witnesses is, but I'm planning to use the witnesses for implementing the "add missing match arms" assist in rust-analyzer, and there `true` before `false` is the natural order (like `Some` before `None`), and also what the current assist does.

The current order doesn't seem to be intentional; the code was created when bool ctors became their own thing, not just int ctors, but for integer, 0 before 1 is indeed the natural order.
2025-07-28 02:01:39 +03:00
Trevor Gross
3f7d497c8a
Rollup merge of #144171 - Nadrieril:exhaustive-witnesses, r=davidtwco
pattern_analysis: add option to get a full set of witnesses

This adds an option to the rustc_pattern_analysis machinery to have it report a complete set of patterns when a match is non-exhaustive (by default we only guarantee to report _some_ missing patterns). This is for use in rust-analyzer.

Leaving as draft until I'm sure this is what r-a needs.

r? ghost
2025-07-26 01:15:04 -05:00
Nadrieril
af07c08c60 Silence a warning 2025-07-20 18:27:30 +02:00
Nadrieril
9b01de20e1 List all the variants of non-exhaustive enums in exhaustive mode 2025-07-20 18:27:30 +02:00
Nadrieril
2bb00741d4 pattern_analysis: add option to get a full set of witnesses 2025-07-20 18:27:30 +02:00
Nadrieril
3567ab19a0 Don't consider unstable fields always-inhabited
This reverts the hack in https://github.com/rust-lang/rust/pull/133889
now that `Pin`'s field is no longer public.
2025-07-20 18:23:18 +02:00
dianne
bb64315978 only check for mixed deref/normal constructors when needed 2025-07-04 23:47:31 -07:00
dianne
50061f3b11 always check for mixed deref pattern and normal constructors
This makes it work for box patterns and in rust-analyzer.
2025-07-04 23:47:31 -07:00
dianne
98659a339d treat box patterns as deref patterns in THIR and usefulness analysis
This removes special-casing of boxes from `rustc_pattern_analysis`, as a
first step in replacing `box_patterns` with `deref_patterns`.
Incidentally, it fixes a bug caused by box patterns being represented as
structs rather than pointers, where `exhaustive_patterns` could generate
spurious `unreachable_patterns` lints on arms required for
exhaustiveness; following the lint's advice would result in an error.
2025-07-04 01:28:35 -07:00
klensy
c76d032f01 setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
bjorn3
ba5556d239
Add #[loop_match] for improved DFA codegen
Co-authored-by: Folkert de Vries <folkert@folkertdev.nl>
2025-06-23 20:43:04 +02:00
Oli Scherer
550aed825b Use builin_index instead of hand-rolling it 2025-05-28 10:03:01 +00:00
Michael Goulet
47b9e373cb Revert "Fix stack overflow in exhaustiveness due to recursive HIR opaque type values"
This reverts commit b08e9c2a60.
2025-05-20 10:09:01 +00:00
est31
258e880861 Remove #![feature(let_chains)] from library and src/librustdoc 2025-05-16 16:14:24 +02:00
dianne
fb261a179d error early when mixing deref patterns with normal constructors
Without adding proper support for mixed exhaustiveness, mixing deref
patterns with normal constructors would either violate
`ConstructorSet::split`'s invariant 4 or 7. We'd either be ignoring rows
with normal constructors or we'd have problems in unspecialization from
non-disjoint constructors. Checking mixed exhaustivenss similarly to how
unions are currently checked should work, but the diagnostics for unions
are confusing. Since mixing deref patterns with normal constructors is
pretty niche (currently it only makes sense for `Cow`), emitting an
error lets us avoid committing to supporting mixed exhaustiveness
without a good answer for the diagnostics.
2025-05-06 18:53:55 -07:00
dianne
b41d8bde00 let deref patterns participate in usefulness/exhaustiveness
This does not yet handle the case of mixed deref patterns with normal
constructors; it'll ICE in `Constructor::is_covered_by`. That'll be
fixed in a later commit.
2025-05-06 18:53:55 -07:00
est31
7493e1cdf6 Make #![feature(let_chains)] bootstrap conditional in compiler/ 2025-04-23 16:40:30 +02:00
Jake Goulding
0117884917 Move eager translation to a method on Diag
This will allow us to eagerly translate messages on a top-level
diagnostic, such as a `LintDiagnostic`. As a bonus, we can remove the
awkward closure passed into Subdiagnostic and make better use of
`Into`.
2025-04-16 21:38:59 -04:00