-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #61825 - Centril:tauv-infer-fix, r=<try>
type_alias_enum_variants: fix #61801; allow a path pattern to infer Fix #61801. Given a type-relative path pattern referring to an enum variant through a type alias, allow inferring the generic argument applied in the expectation set by the scrutinee of a `match` expression. Similar issues may exist for `let` statements but I don't know how to test for that since `PhantomData<T>` is necessary...) The gist of the problem here was that `resolve_ty_and_res_ufcs` was called twice which is apparently no good... It is possible that this PR is papering over some deeper problem, but that is beyond my knowledge of the compiler. r? @petrochenkov cc @eddyb @alexreg cc #61682 cc #49683
- Loading branch information
Showing
2 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/ui/type-alias-enum-variants/issue-61801-path-pattern-can-infer.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// In this regression test we check that a path pattern referring to a unit variant | ||
// through a type alias is successful in inferring the generic argument. | ||
|
||
// compile-pass | ||
|
||
#![feature(type_alias_enum_variants)] | ||
|
||
enum Opt<T> { | ||
N, | ||
S(T), | ||
} | ||
|
||
type OptAlias<T> = Opt<T>; | ||
|
||
fn f1(x: OptAlias<u8>) { | ||
match x { | ||
OptAlias::N // We previously failed to infer `T` to `u8`. | ||
=> (), | ||
_ => (), | ||
} | ||
|
||
match x { | ||
< | ||
OptAlias<_> // And we failed to infer this type also. | ||
>::N => (), | ||
_ => (), | ||
} | ||
} | ||
|
||
fn main() {} |