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

Overflow on double nested container types #34137

Closed
pedrohjordao opened this issue Jun 7, 2016 · 4 comments
Closed

Overflow on double nested container types #34137

pedrohjordao opened this issue Jun 7, 2016 · 4 comments
Labels
A-typesystem Area: The type 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

@pedrohjordao
Copy link

pedrohjordao commented Jun 7, 2016

I have the following code:

https://play.rust-lang.org/?gist=b8c78d5084a9b9ab7c53a2a9faa022af&version=stable&backtrace=0

As it can be seen the #[test] works fine, but if I try to run a cargo test on it I get the following error on the doc_test:

failures:

---- vec::<&'a Vector>::add_0 stdout ----
error: overflow evaluating the requirement <&_ as std::ops::Add<_>>::Output [E0275]
:1:1: 1:1 note: consider adding a #![recursion_limit="128"] attribute to your crate
error: aborting due to previous error

It seems like which function will fail depends on the compiler. I have the impression that at home both implemententions of Add for &Vector will fail, but I might be mistaken and will update this issue when I get home.

This is the rust version I'm using here:

rustc 1.10.0-dev (14f61c8 2016-04-18)
binary: rustc
commit-hash: 14f61c8
commit-date: 2016-04-18
host: x86_64-unknown-linux-gnu
release: 1.10.0-dev

The discussion on the rust forums can be found here:
https://users.rust-lang.org/t/weird-problems-with-recursion-in-type-bounds-in-tests-on-libs/6101/4

update: I was mistaken, at home I get the same behavior. But like @mbrubeck said on the forum discussion, if I remove the last two Add impls everything works.

@apt1002
Copy link

apt1002 commented Nov 22, 2016

In case it is useful, this much shorter program gives similar behaviour:
https://play.rust-lang.org/?gist=2f793999729aec2cd8274157f7012e5d&version=stable&backtrace=0

Compare this version, which compiles and runs just fine:
https://play.rust-lang.org/?gist=6ff433c8cc94c22985180210cc3a8e7d&version=stable&backtrace=0

@goertzenator
Copy link

Here's a further minimization of @apt1002 's program:

https://play.rust-lang.org/?gist=0a77e1bd0f8e539d8a85ee30ed63b1f6&version=stable&backtrace=0

A common thread on all these failing programs is that there are 2 layers of "containerization", whether that be &, Vector, or a wrapper struct.

@apt1002
Copy link

apt1002 commented Feb 14, 2017

Good idea to remove the lifetime nonsense. Much clearer.

I think we've both made errors! Mine was that "where Target: From<&'m T>" should have been "where Target: for<'a> From<&'a T>". I only just learned about this. Yours is that "(a.0).0" should be "C((a.0).0)".

The error message is unchanged in both cases, i.e. it still looks like a compiler bug. I think these examples should work, but at the very least the compiler is not giving the right error message.

@Mark-Simulacrum Mark-Simulacrum changed the title Problem with recursion in Trait bounds in some contexts Overflow on double nested container types Jun 23, 2017
@Mark-Simulacrum Mark-Simulacrum added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-typesystem Area: The type system labels Jun 23, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 25, 2017
@Enselic
Copy link
Member

Enselic commented Sep 17, 2023

Triage: Let's close this because

  • this issue has had no updates in several years and is unlikely to ever get fixed
  • as pointed out in Overflow on double nested container types #34137 (comment) the code can't be expected to compile in the first place
  • there are over one hundred other issues reported with "error: overflow evaluating the requirement" and it is very unlikely this particular issue needs to be kept open

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type 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

5 participants