diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-06-28 07:17:43 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-07-15 15:56:17 +0000 |
| commit | 6b33d5bfa94f0005c2ae7136f4cda14a396e42bc (patch) | |
| tree | 120dcddd97c6d211fce3b95891ce987d6237d26f | |
| parent | 728c7e8bda215dc0ef055a817964f199427512e0 (diff) | |
| download | rust-6b33d5bfa94f0005c2ae7136f4cda14a396e42bc.tar.gz rust-6b33d5bfa94f0005c2ae7136f4cda14a396e42bc.zip | |
Make destructuring a defining use
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/mod.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-only-pattern.rs | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index e139a73efc5..8e763a02af3 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -793,6 +793,14 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { ProjectionElem::OpaqueCast(ty) => { let ty = self.sanitize_type(place, ty); let ty = self.cx.normalize(ty, location); + self.cx + .eq_types( + base.ty, + ty, + location.to_locations(), + ConstraintCategory::TypeAnnotation, + ) + .unwrap(); PlaceTy::from_ty(ty) } } diff --git a/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-only-pattern.rs b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-only-pattern.rs new file mode 100644 index 00000000000..3f0445f5037 --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-only-pattern.rs @@ -0,0 +1,12 @@ +#![feature(type_alias_impl_trait)] +// check-pass + +type T = impl Copy; + +fn foo(foo: T) { + let (mut x, mut y) = foo; + x = 42; + y = "foo"; +} + +fn main() {} |
