Commit Graph

40 Commits

Author SHA1 Message Date
Kivooeo 2a2da782d3 add check for uninhabited types along side never 2025-12-09 13:18:09 +00:00
reddevilmidzy d3e4dd29a8 Use let...else consistently in user-facing diagnostics 2025-11-24 11:41:52 +09:00
Jamie Hill-Daniel 98141e0beb Reduce confusing unreachable_code lints 2025-11-21 16:07:54 +00:00
Camille GILLOT aacf9a612a Add test for uninhabited std::mem::uninitialized uses. 2025-10-11 20:50:20 +00:00
Esteban Küber d216ca0506 Detect missing if let or let-else
During `let` binding parse error and encountering a block, detect if there is a likely missing `if` or `else`:

```
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `{`
  --> $DIR/missing-if-let-or-let-else.rs:14:25
   |
LL |     let Some(x) = foo() {
   |                         ^ expected one of `.`, `;`, `?`, `else`, or an operator
   |
help: you might have meant to use `if let`
   |
LL |     if let Some(x) = foo() {
   |     ++
help: alternatively, you might have meant to use `let else`
   |
LL |     let Some(x) = foo() else {
   |                         ++++
```
2025-08-20 18:26:04 +00:00
Oneirical aa543963c6 Rehome tests/ui/issues/ tests [4/?] 2025-08-10 11:54:15 -04:00
Guillaume Gomez de93fb13fe Add ignore-backends annotations in failing GCC backend ui tests 2025-07-23 13:48:04 +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
Nadrieril e9fb744207 Add test 2025-07-20 14:49:43 +02: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
Vadim Petrochenkov b3f75353a2 UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00
Michael Goulet 0a6a0e47d2 Dont consider fields that are forced unstable due to -Zforce-unstable-if-unmarked to be uninhabited 2025-03-18 18:24:02 +00:00
Michael Goulet f6107ca173 Consider fields to be inhabited if they are unstable 2025-03-18 18:23:36 +00:00
Zachary S 58ebf6afdd Add test that uninhabited repr(transparent) type has same function return ABI as wrapped type.
Fix codegen of uninhabited PassMode::Indirect return types.

Add codegen test for uninhabited PassMode::Indirect return types.

Enable optimizations for uninhabited return type codegen test
2025-02-20 13:41:11 -06:00
León Orell Valerian Liehr 0b18b4fbbc Remove all dead files inside tests/ui/ 2025-01-27 02:28:04 +01:00
Chris Krycho d4275e08e7 Update tests for new TRPL chapter order 2024-11-23 08:57:25 -07:00
Nadrieril 1f69638400 Add a machine-applicable suggestion to "unreachable pattern" 2024-09-13 21:01:29 +02:00
Nadrieril 5b7be148ea Revert warning empty patterns as unreachable 2024-09-11 18:36:45 +02:00
Nadrieril f30392a985 Move the "matches no value" note to be a span label 2024-08-20 21:53:47 +02:00
Nadrieril efb28bdd90 Add a note with a link to explain empty types 2024-08-19 21:57:37 +02:00
Nadrieril 25964b541e Reword the "unreachable pattern" explanations 2024-08-19 21:39:57 +02:00
Nadrieril 99468bb760 Update tests 2024-08-10 12:07:17 +02:00
Nadrieril 64ac2b8082 Explain why a given pattern is considered unreachable 2024-07-24 08:02:55 +02:00
Esteban Küber e17388b809 Handle more cases of value suggestions 2024-04-10 20:36:14 +00:00
Esteban Küber a983dd8563 Tweak value suggestions in borrowck and hir_analysis
Unify the output of `suggest_assign_value` and `ty_kind_suggestion`.

Ideally we'd make these a single function, but doing so would likely require modify the crate dependency tree.
2024-04-09 23:37:13 +00:00
Matthias Krüger 26cb6c7287 Rollup merge of #120742 - Nadrieril:use-min_exh_pats, r=compiler-errors
mark `min_exhaustive_patterns` as complete

This is step 1 and 2 of my [proposal](https://github.com/rust-lang/rust/issues/119612#issuecomment-1918097361) to move `min_exhaustive_patterns` forward. The vast majority of in-tree use cases of `exhaustive_patterns` are covered by `min_exhaustive_patterns`. There are a few cases that still require `exhaustive_patterns` in tests and they're all behind references.

r? ``@ghost``
2024-02-23 17:02:03 +01:00
许杰友 Jieyou Xu (Joe) ec2cc761bc [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
Nadrieril 8e83d0cd75 Prefer min_exhaustive_patterns in tests 2024-02-13 16:45:53 +01:00
Nadrieril 61d6443467 Unmark the feature gate as incomplete 2024-02-13 16:45:29 +01:00
Nadrieril 4733b1bba5 Test min_exhaustive_patterns in more cases 2024-02-08 11:48:38 +01:00
Nadrieril ddef5b61f1 Don't warn an empty pattern unreachable if we're not sure the data is valid 2023-12-09 00:44:49 +01:00
Nadrieril 4e376cc104 Test empty types better 2023-12-09 00:39:59 +01:00
Nilstrieb 41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Camille GILLOT 687659f33f Add diverging match guard test. 2023-10-24 15:30:17 +00:00
Camille GILLOT 6f3f878351 Normalize types when applying uninhabited predicate. 2023-06-27 17:10:14 +00:00
Camille GILLOT 9a7ed3625f Emit diagnostic for privately uninhabited uncovered witnesses. 2023-05-24 19:16:07 +00:00
Michael Goulet 2c23c7f0cd Erase regions before uninhabited check 2023-02-01 01:14:34 +00:00
mejrs 8476c517c0 Don't recommend if let if let else works 2023-01-11 14:40:07 -08:00
mejrs 31c20210b9 Migrate pattern matching 2023-01-11 14:40:02 -08:00
Albert Larsan cf2dff2b1e Move /src/test to /tests 2023-01-11 09:32:08 +00:00