Skip to content

Incorrect error for overflow in bound evaluation #29446

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

Closed
wthrowe opened this issue Oct 29, 2015 · 3 comments
Closed

Incorrect error for overflow in bound evaluation #29446

wthrowe opened this issue Oct 29, 2015 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@wthrowe
Copy link
Contributor

wthrowe commented Oct 29, 2015

#![allow(unconditional_recursion)]

struct X<T>(T);

trait A {
    fn foo(self);
}

impl<T> A for T {
    fn foo(self) {
        X(self).foo() // <-- error points here
    }
}

fn main() {
    1.foo();
}

reports error: overflow evaluating the requirement i32 : core::marker::Sized [E0275]. While this code certainly shouldn't work, I would not expect proving i32: Sized to be the problematic part.

(This is similar to #23714, but I think that's about the example failing to compile rather than the nonsense error.)

@arielb1
Copy link
Contributor

arielb1 commented Oct 29, 2015

The note in the error message correctly tells you that the problem involves the type X<X<X<X<X<X<X<X<i32>>>>>>>>.

@arielb1
Copy link
Contributor

arielb1 commented Oct 29, 2015

The error here is a recursive monomorphization (<T as A>::foo requiring <X<T> as A>::foo) that bails out in trait selection. The error message sucks.

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Oct 29, 2015
@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum
Copy link
Member

Today's error message is quite a bit more clear, I think, since it indicates that the problem is with this piece of code and with what expansion. As such, I'm going to go ahead and close this.

error: reached the recursion limit while instantiating `<T as A><X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<i32>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>::foo`
  --> test.rs:10:5
   |
10 | /     fn foo(self) {
11 | |         X(self).foo() // <-- error points here
12 | |     }
   | |_____^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

4 participants