rust/compiler
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
..
rustc
rustc_apfloat
rustc_arena
rustc_ast Rollup merge of #97232 - tshepang:typo, r=Dylan-DPC 2022-05-21 11:39:52 +02:00
rustc_ast_lowering Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_ast_passes Introduce LifetimeCtxt. 2022-05-20 12:25:05 +02:00
rustc_ast_pretty Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_attr
rustc_borrowck Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_builtin_macros Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_codegen_cranelift
rustc_codegen_gcc Handle tmm_reg in rustc_codegen_gcc 2022-05-17 06:34:58 -04:00
rustc_codegen_llvm Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_codegen_ssa Rollup merge of #97062 - bjorn3:cg_ssa_driver_refactor, r=compiler-errors 2022-05-19 08:22:42 +09:00
rustc_const_eval Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_data_structures
rustc_driver
rustc_error_codes
rustc_error_messages migrate maybe_recover_from_bad_type_plus diagnostic 2022-05-16 17:16:27 -05:00
rustc_errors Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_expand Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_feature
rustc_fs_util
rustc_graphviz
rustc_hir Rollup merge of #97223 - cjgillot:linear-hir-tree, r=jackh726 2022-05-21 11:39:51 +02:00
rustc_hir_pretty
rustc_incremental
rustc_index Auto merge of #95418 - cjgillot:more-disk, r=davidtwco 2022-05-20 20:49:55 +00:00
rustc_infer Rollup merge of #97109 - TaKO8Ki:fix-misleading-cannot-infer-type-for-type-parameter-error, r=oli-obk 2022-05-20 19:54:39 +02:00
rustc_interface
rustc_lexer
rustc_lint Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_lint_defs Lint single-use-lifetimes on the AST. 2022-05-20 12:26:37 +02:00
rustc_llvm
rustc_log
rustc_macros
rustc_metadata Auto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplett 2022-05-21 06:38:49 +00:00
rustc_middle Auto merge of #96515 - lcnr:user-types-in-pat, r=nikomatsakis 2022-05-21 23:34:30 +00:00
rustc_mir_build Auto merge of #96515 - lcnr:user-types-in-pat, r=nikomatsakis 2022-05-21 23:34:30 +00:00
rustc_mir_dataflow Auto merge of #97111 - JohnTitor:rollup-x3vjf6u, r=JohnTitor 2022-05-17 12:01:12 +00:00
rustc_mir_transform Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_monomorphize Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_parse Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_parse_format
rustc_passes Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_plugin_impl
rustc_privacy Rollup merge of #97096 - tmiasko:reachable-constructor, r=petrochenkov 2022-05-18 07:40:58 +09:00
rustc_query_impl Auto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplett 2022-05-21 06:38:49 +00:00
rustc_query_system
rustc_resolve Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_save_analysis
rustc_serialize
rustc_session Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_span Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_symbol_mangling
rustc_target Add ABI clobbers 2022-05-17 06:48:03 -04:00
rustc_trait_selection Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_traits Remove crate visibility usage in compiler 2022-05-20 20:04:54 -04:00
rustc_ty_utils Auto merge of #97012 - oli-obk:🦀_intrinsics, r=davidtwco 2022-05-17 09:39:26 +00:00
rustc_type_ir
rustc_typeck Auto merge of #97239 - jhpratt:remove-crate-vis, r=joshtriplett 2022-05-21 06:38:49 +00:00