Skip to content

change method resolution to constrain hidden types instead of rejecting method candidates - #123962

Merged
bors merged 3 commits into
rust-lang:masterfrom
oli-obk:define_opaque_types5
Jun 14, 2024
Merged

bors merged 3 commits into
rust-lang:masterfrom
oli-obk:define_opaque_types5

Conversation

@oli-obk

@oli-obk oli-obk commented Apr 15, 2024

Copy link
Copy Markdown
Contributor

Some of these are in probes and may affect inference. This is therefore a breaking change.

This allows new code to compile on stable:

trait Trait {}

impl Trait for u32 {}

struct Bar<T>(T);

impl Bar<u32> {
    fn foo(self) {}
}

fn foo(x: bool) -> Bar<impl Sized> {
    if x {
        let x = foo(false);
        x.foo();
        //^ this used to not find the `foo` method, because while we did equate `x`'s type with possible candidates, we didn't allow opaque type inference while doing so
    }
    todo!()
}

r? @compiler-errors

fixes #121404

cc #116652

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-types Relevant to the types team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DefineOpaqueTypes::No in UFC Self resolution