Skip to content

DefineOpaqueTypes::No in UFC Self resolution #121404

Closed
@oli-obk

Description

@oli-obk

in

DefineOpaqueTypes::No,
we disable hidden type registration. I have been unable to craft a test case for this, as either the self_ty arg of instantiate_value_path is None, or there are no generic parameters on the self type, so it gets inference variables which end up working out fine.

As an example:

#![feature(type_alias_impl_trait)]
struct Foo<T>(T);

impl Foo<u32> {
    fn method() {}
    fn method2(self) {}
}

type Bar = impl Sized;

fn bar() -> Bar {
    42_u32
}

impl Foo<Bar> {
    fn foo() -> Bar {
        Self::method();
        //~^ ERROR: no function or associated item named `method` found for struct `Foo<Bar>`
        Foo::<Bar>::method();
        //~^ ERROR: no function or associated item named `method` found for struct `Foo<Bar>`
        let x = Foo(bar());
        Foo::method2(x);
        let x = Self(bar());
        Self::method2(x);
        //~^ ERROR: no function or associated item named `method2` found for struct `Foo<Bar>`
        todo!()
    }
}

fn main() {}

the Foo::method2(x); works fine, none of the others do, and none of them have a self_ty set here either.

Wrapping the types in <> does not have an effect, even if the code seems to hint at that:

// `<T>::assoc` will end up here, and so

any ideas @compiler-errors

cc #121394

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-cleanupCategory: PRs that clean code up or issues documenting cleanup.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions