rust/compiler/rustc_typeck
Dylan DPC f1412a665f
Rollup merge of #101614 - compiler-errors:rpitit-eq, r=jackh726
Equate fn outputs when inferring RPITIT hidden types

When we are trying to infer the hidden types for RPITITs, we need to equate the output tys instead of just subtyping them. For example:

```rust
trait Foo { fn bar() -> impl Sized {} }

impl Foo for () { fn bar() -> &'static str { "" } }
```

If we just subtype the signatures `fn() -> &'static str <: fn() -> _#1t` (where `_#1t` is the variable we've used to infer `impl Sized`), we'll end up `&'static str <: _#1t`, which causes us to infer `_#1t = #'_#2r str`, where `'_#2r` is unconstrained, which gets fixed up to `ReEmpty`, and which is certainly not what we want.

I can't actually think of a way to make this fail to compile, because during borrowck we've already done the method probe, and so we just look at the `impl` method signature and see the `&'static str` any time we call `<() as Foo>::bar()`. But this _does_ cause the ICE [here](https://github.com/rust-lang/rust/pull/98559#issuecomment-1241891994) in `@jackh726's` "Remove ReEmpty" PR (#98559) to stop ICEing, because after that PR we were leaking unconstrained region variables into the typeck results.

r? types
2022-09-10 18:56:08 +05:30
..
src Rollup merge of #101614 - compiler-errors:rpitit-eq, r=jackh726 2022-09-10 18:56:08 +05:30
Cargo.toml Improve error message for unstable default body 2022-07-26 15:40:04 +04:00
README.md

For high-level intro to how type checking works in rustc, see the type checking chapter of the rustc dev guide.