about summary refs log tree commit diff
path: root/tests/ui/pattern/deref-patterns
AgeCommit message (Collapse)AuthorLines
2025-08-26fix: Add col separator before secondary messages with no sourceScott Schafer-0/+1
2025-08-22On E0277, point at type that doesn't implement boundEsteban Küber-2/+14
When encountering an unmet trait bound, point at local type that doesn't implement the trait: ``` error[E0277]: the trait bound `Bar<T>: Foo` is not satisfied --> $DIR/issue-64855.rs:9:19 | LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ; | ^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound | help: the trait `Foo` is not implemented for `Bar<T>` --> $DIR/issue-64855.rs:9:1 | LL | pub struct Bar<T>(<Self as Foo>::Type) where Self: ; | ^^^^^^^^^^^^^^^^^ ```
2025-07-28In rustc_pattern_analysis, put `true` witnesses before `false` witnessesChayim Refael Friedman-4/+4
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-05-06error early when mixing deref patterns with normal constructorsdianne-0/+91
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-06add exhaustiveness/usefulness tests for deref patternsdianne-0/+269
2025-05-06let deref patterns participate in usefulness/exhaustivenessdianne-15/+9
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-05always peel `&mut`, to allow matching on `&mut str`dianne-3/+143
2025-05-05match ergonomics for string and byte string literal patternsdianne-41/+156
2025-04-30compiletest: Make diagnostic kind mandatory on line annotationsVadim Petrochenkov-11/+13
2025-04-27Test partial moves via deref patsNadrieril-0/+8
2025-04-24lower deref patterns on boxes using built-in derefsdianne-0/+47
This allows deref patterns to move out of boxes. Implementation-wise, I've opted to put the information of whether a deref pattern uses a built-in deref or a method call in the THIR. It'd be a bit less code to check `.is_box()` everywhere, but I think this way feels more robust (and we don't have a `mutability` field in the THIR that we ignore when the smart pointer's a box). I'm not sure about the naming (or using `ByRef`), though.
2025-04-24move existing tests away from using boxesdianne-50/+96
Since deref patterns on boxes will be lowered differently, I'll be making a separate test file for them. This makes sure we're still testing the generic `Deref(Mut)::deref(_mut)`-based lowering.
2025-04-22make `[u8]` and `[u8;N]` literal patterns usable in deref patternsdianne-1/+147
Specifically, this allows byte string literal patterns to be used where a `[u8]` or `[u8;N]` is expected when `deref_patterns` is enabled.
2025-04-22make `str` literal patterns usable in deref patternsdianne-29/+54
Specifically, this allows string literal patterns to be used where a `str` is expected when `deref_patterns` is enabled.
2025-04-16Make cow_of_cow test a teeny bit more explicitNadrieril-1/+2
2025-04-16add a feature gate testdianne-0/+44
Implicit deref patterns allow previously ill-typed programs. Make sure they're still ill-typed without the feature gate. I've thrown in a test for `deref!(_)` too, though it seems it refers to `deref_patterns` as a library feature.
2025-04-16upvar inference for implicit deref patternsdianne-0/+27
2025-04-16respect the tcx's recursion limit when peelingdianne-0/+41
2025-04-16don't peel ADTs the pattern could matchdianne-0/+79
This is the use for the previous commits' refactors; see the messages there for more information.
2025-04-16register `DerefMut` bounds for implicit mutable derefsdianne-3/+62
2025-04-16pattern typing for immutable implicit deref patternsdianne-3/+183
2025-03-13EUV: fix place of deref pattern's interior's scrutineedianne-0/+15
The place previously used here was that of the temporary holding the reference returned by `Deref::deref` or `DerefMut::deref_mut`. However, since the inner pattern of `deref!(inner)` expects the deref-target type itself, this would ICE when that type was inspected (e.g. by the EUV case for slice patterns). This adds a deref projection to fix that. Since current in-tree consumers of EUV (upvar inference and clippy) don't care about Rvalues, the place could be simplified to `self.cat_rvalue(pat.hir_id, self.pat_ty_adjusted(subpat)?)` to save some cycles. I personally find EUV to be a bit fragile, so I've opted for pedantic correctness. Maybe a `HACK` comment would suffice though?
2024-11-25`add_move_error_suggestions`: use a HIR visitor rather than `SourceMap`dianne-0/+10
2024-04-20Test or-patterns inside deref patternsNadrieril-1/+13
2024-04-20Use deep fake borrows for deref patternsNadrieril-0/+26
2024-04-20Address closure-related reviewNadrieril-0/+21
2024-04-20Allow mutable bindings inside deref patternsNadrieril-0/+15
2024-04-20Don't fake borrow inside a deref patternNadrieril-2/+2
2024-04-20Lower deref patterns to MIRNadrieril-6/+174
This handles using deref patterns to choose the correct match arm. This does not handle bindings or guards. Co-authored-by: Deadbeef <ent3rm4n@gmail.com>
2024-03-25Require DerefMut if deref pattern has nested ref mut bindingMichael Goulet-0/+37
2024-03-21Implement macro-based deref!() syntax for deref patternsMichael Goulet-4/+4
Stop using `box PAT` syntax for deref patterns, as it's misleading and also causes their semantics being tangled up.
2024-03-20Add barest-bones deref patternsNadrieril-0/+31
Co-authored-by: Deadbeef <ent3rm4n@gmail.com>