327 Commits

Author SHA1 Message Date
Adwin White 6279106e72 fix all errors 2026-04-20 00:18:28 +08:00
Nicholas Nethercote 9b64d52d78 Reduce diagnostic type visibilities.
Most diagnostic types are only used within their own crate, and so have
a `pub(crate)` visibility. We have some diagnostic types that are
unnecessarily `pub`. This is bad because (a) information hiding, and (b)
if a `pub(crate)` type becomes unused the compiler will warn but it
won't warn for a `pub` type.

This commit eliminates unnecessary `pub` visibilities for some
diagnostic types, and also some related things due to knock-on effects.
(I found these types with some ad hoc use of `grep`.)
2026-04-16 07:42:17 +10:00
WilliamTakeshi a133bb8f27 replace @ ty::AliasTy matches with just args 2026-04-11 18:00:32 +00:00
Jonathan Brouwer 5ef7a3d73f Rollup merge of #154961 - mejrs:yeet_the_fixme, r=Nadrieril
Use derived impl for `GappedRange` subdiagnostic
2026-04-08 14:22:07 +02:00
Jonathan Brouwer e1b15f4397 Rollup merge of #154934 - ChayimFriedman2:export-pat-slice, r=Nadrieril
Add getters for `rustc_pattern_analysis::constructor::Slice` fields

rust-analyzer needs that.

r? @Nadrieril
2026-04-08 14:22:05 +02:00
mejrs 975761c64d Use derived impl for GappedRange subdiagnostic 2026-04-07 19:02:37 +02:00
Chayim Refael Friedman 05320a26ed Add getters for rustc_pattern_analysis::constructor::Slice fields
rust-analyzer needs that.
2026-04-07 11:27:49 +03:00
Waffle Lapkin 0f767084b8 ty::Alias refactor: fixup all the compiler code 2026-04-07 10:08:12 +02:00
human9000 8a57f3d844 Introduce guard pattern to THIR
Co-authored-by: Max Niederman <max@maxniederman.com>
2026-03-17 10:19:23 +05:00
Guillaume Gomez e805d8c961 Remove mentions of LintDiagnostic 2026-03-04 15:16:52 +01:00
Guillaume Gomez ee855c02af Migrate rustc_pattern_analysis lint to Diagnostic 2026-03-04 11:32:19 +01:00
Guillaume Gomez 2bb3b01af2 Replace TyCtxt::emit_node_span_lint with emit_diag_node_span_lint 2026-02-24 20:34:22 +01:00
Guillaume Gomez c53fbcd726 Migrate rustc_pattern_analysis to use TyCtxt::emit_diag_node_span_lint 2026-02-24 20:12:42 +01:00
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