Skip to content

normalizing an opaque while proving its item bounds causes overflow errors #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lcnr opened this issue Jan 21, 2025 · 1 comment
Open

Comments

@lcnr
Copy link
Contributor

lcnr commented Jan 21, 2025

#![feature(type_alias_impl_trait)]

type Foo = impl PartialEq<(Foo, i32)>;

struct Bar;

impl PartialEq<(Bar, i32)> for Bar {
    fn eq(&self, _other: &(Bar, i32)) -> bool {
        true
    }
}

fn foo() -> Foo {
    //~^ ERROR can't compare `Bar` with `(Foo, i32)`
    Bar
}

fn main() {}
error[E0275]: overflow evaluating the requirement `Foo == Bar`
  --> <source>:15:5
   |
15 |     Bar
   |     ^^^

error[E0275]: overflow evaluating the requirement `Bar <: Foo`
  --> <source>:13:17
   |
13 |   fn foo() -> Foo {
   |  _________________^
14 | |     //~^ ERROR can't compare `Bar` with `(Foo, i32)`
15 | |     Bar
16 | | }
   | |_^

error[E0275]: overflow evaluating the requirement `Foo: Sized`
  --> <source>:13:13
   |
13 | fn foo() -> Foo {
   |             ^^^
14 |     //~^ ERROR can't compare `Bar` with `(Foo, i32)`
15 |     Bar
   |     --- this returned value is of type `Bar`
   |
   = note: the return type of a function must have a statically known size

error[E0275]: overflow evaluating the requirement `Foo == _`
  --> <source>:13:1
   |
13 | fn foo() -> Foo {
   | ^^^^^^^^^^^^^^^

affected test

  • tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration.rs
  • tests/ui/impl-trait/failed-to-resolve-instance-ice-123145.rs (indirectly when proving its item bounds)
  • tests/ui/impl-trait/recursive-type-alias-impl-trait-declaration-too-subtle-2.rs
@lcnr lcnr changed the title opaque referencing itself in its item bounds overflows normalizing an opaque while proving its item bounds causes overflow errors Jan 21, 2025
@lcnr
Copy link
Contributor Author

lcnr commented Jan 21, 2025

likely requires changes to our cycle semantics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant