Skip to content
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

Removing bound from generic type causes an "overflow evaluating a requirement" error. #65836

Open
rodrimati1992 opened this issue Oct 25, 2019 · 2 comments
Labels
A-traits Area: Trait system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@rodrimati1992
Copy link
Contributor

With the following code:

pub trait Frogg<W: ?Sized> {
    fn frogg(&self, _with: &W){}
}

impl <T, W> Frogg<[W]> for T
where
    T: Frogg<W>
{}

impl <T, W> Frogg<[W]> for [T]
where
    T: Frogg<W>
{}

fn bar<T, W>(slice: &[T], other: &[W]) 
where
    T:Frogg<W>
{
    slice.frogg(other)
}

If I remove the where clause for bar,it prints this error:

error[E0275]: overflow evaluating the requirement `_: std::marker::Sized`
  --> src/lib.rs:16:11
   |
16 |     slice.frogg(other)
   |           ^^^^^
   |
   = help: consider adding a `#![recursion_limit="256"]` attribute to your crate
   = note: required because of the requirements on the impl of `Frogg<[_]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[_]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[_]]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[[_]]]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[[[_]]]]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[[[[_]]]]]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[[[[[_]]]]]]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[[[[[[_]]]]]]]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[[[[[[[_]]]]]]]]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[[[[[[[[_]]]]]]]]]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[[[[[[[[[_]]]]]]]]]]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[[[[[[[[[[_]]]]]]]]]]]]>` for `T`
   = note: required because of the requirements on the impl of `Frogg<[[[[[[[[[[[[[_]]]]]]]]]]]]]>` for `T`
   [Ommited identical errors for length]

error: aborting due to previous error

I expected to get an error mentioning how slice does not implement the Frogg trait instead.

@rodrimati1992 rodrimati1992 changed the title Removing bound from generic type causes and "overflow evaluating a requirement" error. Removing bound from generic type causes an "overflow evaluating a requirement" error. Oct 25, 2019
@jonas-schievink jonas-schievink added A-traits Area: Trait system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 26, 2019
@Centril
Copy link
Contributor

Centril commented Oct 26, 2019

cc @rust-lang/wg-traits

@istankovic
Copy link
Contributor

I think this can be closed since the error is much better now:

   Compiling playground v0.0.1 (/playground)
error[E0275]: overflow evaluating the requirement `_: Sized`
  --> src/lib.rs:18:11
   |
18 |     slice.frogg(other)
   |           ^^^^^
   |
   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`playground`)
note: required for `T` to implement `Frogg<[_]>`
  --> src/lib.rs:5:13
   |
5  | impl <T, W> Frogg<[W]> for T
   |          -  ^^^^^^^^^^     ^
   |          |
   |          unsatisfied trait bound introduced here
   = note: 128 redundant requirements hidden
   = note: required for `[T]` to implement `Frogg<[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[_]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]>`

For more information about this error, try `rustc --explain E0275`.
error: could not compile `playground` (lib) due to previous error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants