rust/compiler
bors 8327047b23 Auto merge of #113393 - compiler-errors:next-solver-unsize-rhs, r=lcnr
Normalize the RHS of an `Unsize` goal in the new solver

`Unsize` goals are... tricky. Not only do they structurally match on their self type, but they're also structural on their other type parameter. I'm pretty certain that it is both incomplete and also just plain undesirable to not consider normalizing the RHS of an unsize goal. More practically, I'd like for this code to work:

```rust
trait A {}
trait B: A {}

impl A for usize {}
impl B for usize {}

trait Mirror {
    type Assoc: ?Sized;
}

impl<T: ?Sized> Mirror for T {
    type Assoc = T;
}

fn main() {
    // usize: Unsize<dyn B>
    let x = Box::new(1usize) as Box<<dyn B as Mirror>::Assoc>;
    // dyn A: Unsize<dyn B>
    let y = x as Box<<dyn A as Mirror>::Assoc>;
}
```

---

In order to achieve this, we add `EvalCtxt::normalize_non_self_ty` (naming modulo bikeshedding), which *must* be used for all non-self type arguments that are structurally matched in candidate assembly. Currently this is only necessary for `Unsize`'s argument, but I could see future traits requiring this (hopefully rarely) in the future. It uses `repeat_while_none` to limit infinite looping, and normalizes the self type until it is no longer an alias.

Also, we need to fix feature gate detection for `trait_upcasting` and `unsized_tuple_coercion` when HIR typeck has unnormalized types. We can do that by checking the `ImplSource` returned by selection, which necessitates adding a new impl source for tuple upcasting.
2023-07-25 17:10:31 +00:00
..
rustc
rustc_abi interpret: refactor projection code to work on a common trait, and use that for visitors 2023-07-25 14:30:58 +02:00
rustc_apfloat
rustc_arena
rustc_ast more clippy::style fixes: 2023-07-23 23:39:04 +02:00
rustc_ast_lowering more clippy::style fixes: 2023-07-23 23:39:04 +02:00
rustc_ast_passes
rustc_ast_pretty more clippy::style fixes: 2023-07-23 23:39:04 +02:00
rustc_attr
rustc_baked_icu_data
rustc_borrowck
rustc_builtin_macros fix couple of clippy findings: 2023-07-23 10:50:14 +02:00
rustc_codegen_cranelift
rustc_codegen_gcc Auto merge of #113877 - JhonnyBillM:reuse-codegen-ssa-monomorphization-errors-in-gcc, r=davidtwco 2023-07-24 11:29:59 +00:00
rustc_codegen_llvm
rustc_codegen_ssa remove redundant clones 2023-07-23 09:48:07 +02:00
rustc_const_eval Auto merge of #113393 - compiler-errors:next-solver-unsize-rhs, r=lcnr 2023-07-25 17:10:31 +00:00
rustc_data_structures more clippy::style fixes: 2023-07-23 23:39:04 +02:00
rustc_driver
rustc_driver_impl
rustc_error_codes
rustc_error_messages
rustc_errors Optimize format usage 2023-07-24 00:08:09 -04:00
rustc_expand
rustc_feature
rustc_fluent_macro
rustc_fs_util
rustc_graphviz
rustc_hir more clippy::style fixes: 2023-07-23 23:39:04 +02:00
rustc_hir_analysis fix clippy::useless_format 2023-07-23 11:14:52 +02:00
rustc_hir_pretty
rustc_hir_typeck Make everything builtin! 2023-07-25 16:08:58 +00:00
rustc_incremental
rustc_index
rustc_infer fix some clippy::style findings 2023-07-23 23:36:56 +02:00
rustc_interface
rustc_lexer Auto merge of #113476 - fee1-dead-contrib:c-str-lit, r=petrochenkov 2023-07-25 12:04:34 +00:00
rustc_lint
rustc_lint_defs
rustc_llvm
rustc_log
rustc_macros
rustc_metadata Auto merge of #113958 - lukas-code:doc-links, r=GuillaumeGomez,petrochenkov 2023-07-25 01:35:53 +00:00
rustc_middle Auto merge of #113393 - compiler-errors:next-solver-unsize-rhs, r=lcnr 2023-07-25 17:10:31 +00:00
rustc_mir_build
rustc_mir_dataflow
rustc_mir_transform
rustc_monomorphize more clippy::style fixes: 2023-07-23 23:39:04 +02:00
rustc_parse Auto merge of #113476 - fee1-dead-contrib:c-str-lit, r=petrochenkov 2023-07-25 12:04:34 +00:00
rustc_parse_format
rustc_passes validate doc(masked) 2023-07-24 18:04:35 +02:00
rustc_plugin_impl
rustc_privacy
rustc_query_impl fix couple of clippy findings: 2023-07-23 10:50:14 +02:00
rustc_query_system
rustc_resolve Auto merge of #113980 - bvanjoi:fix-113953, r=petrochenkov 2023-07-25 05:25:11 +00:00
rustc_serialize
rustc_session Add missing documentation for Session::time 2023-07-24 16:50:25 +02:00
rustc_smir Dynamic for smir 2023-07-24 00:17:45 -04:00
rustc_span
rustc_symbol_mangling more clippy::style fixes: 2023-07-23 23:39:04 +02:00
rustc_target Auto merge of #113411 - unikraft:unikraft, r=wesleywiser 2023-07-25 03:41:56 +00:00
rustc_trait_selection Make everything builtin! 2023-07-25 16:08:58 +00:00
rustc_traits
rustc_transmute
rustc_ty_utils Make everything builtin! 2023-07-25 16:08:58 +00:00
rustc_type_ir add docs for AliasKind::Inherent 2023-07-22 15:38:41 -04:00