rust/tests/ui/binding
Guillaume Boisseau cc7edbc1e4
Rollup merge of #120479 - estebank:issue-61788, r=wesleywiser
Suggest turning `if let` into irrefutable `let` if appropriate

When encountering an `if let` tail expression without an `else` arm for an enum with a single variant, suggest writing an irrefutable `let` binding instead.

```
error[E0317]: `if` may be missing an `else` clause
  --> $DIR/irrefutable-if-let-without-else.rs:8:5
   |
LL |   fn foo(x: Enum) -> i32 {
   |                      --- expected `i32` because of this return type
LL | /     if let Enum::Variant(value) = x {
LL | |         value
LL | |     }
   | |_____^ expected `i32`, found `()`
   |
   = note: `if` expressions without `else` evaluate to `()`
   = help: consider adding an `else` block that evaluates to the expected type
help: consider using an irrefutable `let` binding instead
   |
LL ~     let Enum::Variant(value) = x;
LL ~         value
   |
```

Fix #61788.
2024-02-07 18:24:43 +01:00
..
ambiguity-item.rs
ambiguity-item.stderr
bind-field-short-with-modifiers.rs
borrowed-ptr-pattern-2.rs
borrowed-ptr-pattern-3.rs
borrowed-ptr-pattern-infallible.rs
borrowed-ptr-pattern-option.rs
borrowed-ptr-pattern.rs
const-param.rs
const-param.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
empty-types-in-patterns.rs
exhaustive-bool-match-sanity.rs
expr-match-generic-unique1.rs
expr-match-generic-unique2.rs
expr-match-generic.rs
expr-match-panic-all.rs
expr-match-panic.rs
expr-match-unique.rs
expr-match.rs
fat-arrow-match.rs
fn-arg-incomplete-pattern-drop-order.rs
fn-pattern-expected-type-2.rs
fn-pattern-expected-type.rs
func-arg-incomplete-pattern.rs
func-arg-ref-pattern.rs
func-arg-wild-pattern.rs
if-let.rs
inconsistent-lifetime-mismatch.rs
inferred-suffix-in-pattern-range.rs
irrefutable-if-let-without-else.fixed Suggest turnging if let into irrefutable let if appropriate 2024-02-06 03:53:06 +00:00
irrefutable-if-let-without-else.rs Suggest turnging if let into irrefutable let if appropriate 2024-02-06 03:53:06 +00:00
irrefutable-if-let-without-else.stderr Suggest turnging if let into irrefutable let if appropriate 2024-02-06 03:53:06 +00:00
irrefutable-slice-patterns.rs
issue-53114-borrow-checks.rs Add diverging match guard test. 2023-10-24 15:30:17 +00:00
issue-53114-safety-checks.rs Ignore AscribeUserType in unsafeck to avoid duplicate diagnostics. 2023-03-09 17:45:13 +00:00
issue-53114-safety-checks.stderr Stabilize THIR unsafeck 2024-01-05 10:00:59 +00:00
let-assignability.rs
let-destruct-ref.rs
let-var-hygiene.rs
match-arm-statics.rs Remove asmjs from tests 2023-10-28 23:11:03 -07:00
match-beginning-vert.rs Add more if let guard tests 2023-09-19 12:48:40 +00:00
match-borrowed_str.rs
match-bot-2.rs
match-bot.rs
match-byte-array-patterns.rs
match-enum-struct-0.rs
match-enum-struct-1.rs
match-implicit-copy-unique.rs
match-in-macro.rs
match-join.rs
match-larger-const.rs
match-naked-record-expr.rs
match-naked-record.rs
match-path.rs
match-pattern-bindings.rs
match-pattern-lit.rs
match-pattern-no-type-params.rs
match-pattern-simple.rs
match-phi.rs
match-pipe-binding.rs
match-range-infer.rs
match-range-static.rs
match-range.rs remove illegal_floating_point_literal_pattern lint 2024-01-26 17:25:02 +01:00
match-reassign.rs
match-ref-binding-in-guard-3256.rs
match-ref-binding-mut-option.rs
match-ref-binding-mut.rs
match-ref-binding.rs
match-ref-unsized.rs
match-str.rs
match-struct-0.rs
match-tag.rs Adjust compiler tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
match-unique-bind.rs
match-unsized.rs
match-value-binding-in-guard-3291.rs
match-var-hygiene.rs
match-vec-alternatives.rs
match-vec-rvalue.rs
match-with-ret-arm.rs
multi-let.rs
mut-in-ident-patterns.rs
nested-matchs.rs
nested-pattern.rs
nil-pattern.rs
nullary-or-pattern.rs
optional_comma_in_match_arm.rs remove invalid ignore-pretty 2023-04-03 09:24:11 +02:00
or-pattern.rs Adjust compiler tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
order-drop-with-match.rs
pat-ranges.rs
pat-tuple-1.rs
pat-tuple-2.rs
pat-tuple-3.rs
pat-tuple-4.rs
pat-tuple-5.rs
pat-tuple-6.rs
pat-tuple-7.rs
pattern-bound-var-in-for-each.rs
pattern-in-closure.rs
range-inclusive-pattern-precedence.rs
shadow.rs
simple-generic-match.rs Adjust compiler tests for unused_tuple_struct_fields -> dead_code 2024-01-02 15:34:37 -05:00
use-uninit-match2.rs
use-uninit-match.rs
zero_sized_subslice_match.rs