rust/compiler/rustc_middle/src
bors e52e7115c7 Auto merge of #96515 - lcnr:user-types-in-pat, r=nikomatsakis
correctly deal with user type ascriptions in pat

supersedes #93856

`thir::PatKind::AscribeUserType` previously resulted in `CanonicalUserTypeAnnotations` where the inferred type already had a subtyping relation according to `variance` to the `user_ty`.

The bug can pretty much be summarized as follows:

- during mir building
  - `user_ty -> inferred_ty`: considers variance
  - `StatementKind::AscribeUserType`: `inferred_ty` is the type of the place, so no variance needed
- during mir borrowck
  - `user_ty -> inferred_ty`: does not consider variance
  - `StatementKind::AscribeUserType`: applies variance

This mostly worked fine. The lifetimes in `inferred_ty` were only bound by its relation to `user_ty` and to the `place` of `StatementKind::AscribeUserType`, so it doesn't matter where exactly the subtyping happens.

It does however matter when having higher ranked subtying. At this point the place where the subtyping happens is forced, causing this mismatch between building and borrowck to result in unintended errors.

cc #96514 which is pretty much the same issue

r? `@nikomatsakis`
2022-05-21 23:34:30 +00:00
..
dep_graph Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
hir Auto merge of #95418 - cjgillot:more-disk, r=davidtwco 2022-05-20 20:49:55 +00:00
infer fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
middle Cache more queries on disk. 2022-05-13 08:06:48 +02:00
mir Auto merge of #96515 - lcnr:user-types-in-pat, r=nikomatsakis 2022-05-21 23:34:30 +00:00
query Auto merge of #95418 - cjgillot:more-disk, r=davidtwco 2022-05-20 20:49:55 +00:00
thir Reimplement lowering of sym operands for asm! so that it also works with global_asm! 2022-04-14 15:32:03 +01:00
traits Rollup merge of #95979 - lcnr:coherence-docs, r=compiler-errors 2022-05-18 08:41:14 +02:00
ty Auto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplett 2022-05-21 06:38:49 +00:00
util span: move MultiSpan 2022-04-05 07:01:00 +01:00
arena.rs Cache more queries on disk. 2022-05-13 08:06:48 +02:00
lib.rs Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
lint.rs Move lint expectation checking into a separate query (RFC 2383) 2022-05-08 14:37:14 +02:00
macros.rs Rename TypeFolderFallible to FallibleTypeFolder 2021-12-02 16:14:18 +00:00
metadata.rs resolve/metadata: Stop encoding macros as reexports 2022-02-24 22:55:40 +03:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
thir.rs correctly deal with user type ascriptions in pat 2022-05-21 08:13:17 +02:00