Repository navigation
TAIT: "unconstrained opaque type" error even if it's constrained #96572
Description
Activity
- addedA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.F-type_alias_impl_trait`#[feature(type_alias_impl_trait)]``#[feature(type_alias_impl_trait)]`
on Apr 30, 2022 UPDATE: the below ICE is fixed now!
I don't think we can really allow this. No pattern but a straight up binding is a valid pattern for an opaque type. If you actually give that pattern a type
#![feature(type_alias_impl_trait)] fn main() { type T = impl Copy; let foo: T = (1u32, 2u32); let (a, b): (u32, u32) = foo; }
then we get a lot of ICEs from borrowck. The interesting ones are
error: internal compiler error: broken MIR in DefId(0:3 ~ inference[4f8b]::main) ((_1.0: u32)): can't project out of PlaceTy { ty: main::T, variant_index: None } --> /home/ubuntu/rust5/src/test/ui/type-alias-impl-trait/inference.rs:6:10 | LL | let (a, b): (u32, u32) = foo; | ^ | = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:855:31 error: internal compiler error: broken MIR in DefId(0:3 ~ inference[4f8b]::main) ((_1.1: u32)): can't project out of PlaceTy { ty: main::T, variant_index: None } --> /home/ubuntu/rust5/src/test/ui/type-alias-impl-trait/inference.rs:6:13 | LL | let (a, b): (u32, u32) = foo; | ^ | = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:855:31These happen because we assume that if a pattern type checks, that we can actually destructure the thing that was moved into the pattern. Unfortunately for opaque types that isn't true.
I guess the simple solution would be to just forbid it. We could try to allow it, but I'm not sure how to do that in general without just throwing more logic into match checking and mir building. Just patching the type of
fooas seen in the pattern logic could work though... basically only touch mir typeck and verification/sanitation to teach them about the types inferred from patterns- addedI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️I-needs-decisionIssue: In need of a decision.Issue: In need of a decision.
on May 3, 2022 - addedglacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.
on May 3, 2022 UPDATE: the below ICE is fixed now!
Other examples:
#![feature(type_alias_impl_trait)] fn main() { type T = impl Copy; let foo: T = (1u32, 2u32); match foo { (a, b) => (), } }
also gives an error (playground)
- removedI-needs-decisionIssue: In need of a decision.Issue: In need of a decision.
on May 12, 2022 Also ICEs (playground):
#![feature(type_alias_impl_trait)] fn main() { type T = impl Copy; let foo: T = Some((1u32, 2u32)); match foo { None => (), Some((a, b)) => (), } }
triage:
Implement a "opaque type downcast projection" in mir and insert appropriately
Triage: #96572 (comment) and #96572 (comment) are fixed by #96515. The last one (#96572 (comment)) is still ICE.
- addedC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
on May 28, 2022 6 remaining items
- Repository owner moved this from In Progress to Done in type alias impl trait stabilization
on Sep 20, 2022 - added a commit that references this issue
on Oct 6, 2022 - added a commit that references this issue
on Oct 23, 2022
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
This is allowed:
But this isn't:
It seems strange to me that adding code causes a type that was previously properly constrained to not longer be so. I'm not sure if it's a diagnostics issue, or if it should indeed be allowed...
See playground
rustc 1.62.0-nightly (a707f40 2022-04-29)
@rustbot label A-impl-trait F-type_alias_impl_trait