Skip to content

Conversation

@BoxyUwU
Copy link
Member

@BoxyUwU BoxyUwU commented Oct 1, 2025

Fixes rust-lang/trait-system-refactor-initiative#233

fn peculiar() -> impl Fn(u8) -> u8 {
    return |x| x + 1
}

the |x| x + 1 expr has a type of Closure(?31t) which we wind up inferring the RPIT to. The CoerceMany ret_coercion for the whole peculiar typeck has an expected type of RPIT (unnormalized). When we type check the return |x| x + 1 expr we go from the never type to Closure(?31t) which then participates in the ret_coercion giving us a coerce-lub(RPIT, Closure(?31t)).

Normalizing RPIT gives us some Closure(?50t) where ?31t and ?50t have been unified with ?31t as the root var. resolve_vars_if_possible doesn't resolve infer vars to their roots so these wind up with different structural identities so the fast path doesn't apply and we fall back to coercing to a fn ptr. cc #147193 which also fixes this

New solver probably just gets more inference variables here because canonicalization + generally different approach to normalization of opaques. Idk :3

In theory I feel like using a lub here ought to cause other code to work that currently doesn't 🤔 E.g. if the two types only differ in normalization. I'm not certain about how to construct such an example though :3

r? lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 1, 2025
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling stable_deref_trait v1.2.0
error[E0277]: the trait bound `!: FromStr` is not satisfied
    --> /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.174/build.rs:242:36
     |
 242 |     let minor = otry!(otry!(minor).parse().ok());
     |                                    ^^^^^ the trait `FromStr` is not implemented for `!`
     |
     = help: the following other types implement trait `FromStr`:
               ByteString
               CString
---
             and 32 others
note: required by a bound in `core::str::<impl str>::parse`
    --> /checkout/library/core/src/str/mod.rs:2701:21
     |
2701 |     pub fn parse<F: FromStr>(&self) -> Result<F, F::Err> {
     |                     ^^^^^^^ required by this bound in `core::str::<impl str>::parse`

[RUSTC-TIMING] stable_deref_trait test:false 0.043
   Compiling memchr v2.7.5
For more information about this error, try `rustc --explain E0277`.

@BoxyUwU
Copy link
Member Author

BoxyUwU commented Oct 1, 2025

hell yeah

@bors
Copy link
Collaborator

bors commented Oct 8, 2025

☔ The latest upstream changes (presumably #147111) made this pull request unmergeable. Please resolve the merge conflicts.

@BoxyUwU
Copy link
Member Author

BoxyUwU commented Oct 30, 2025

gonna close this because either it'll wind up fixed by my other PR or i'll wind up splitting my other PR into pieces and probably still wind up usurping this one

@BoxyUwU BoxyUwU closed this Oct 30, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FulfillmentErrorCode::Project ICE for opaques

5 participants