rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.96k stars 12.68k forks source link

Recusion limit (selection ambiguity) reached quickly in monomorphization #40003

Closed alexcrichton closed 7 years ago

alexcrichton commented 7 years ago

Originally reported at https://github.com/alexcrichton/futures-rs/issues/393 I've minimized this example to a one-file reproduction.

I'm not really sure why it's hitting the limit so quickly, but is this a bug in the compiler or perhaps a bug in the futures crate?

alexcrichton commented 7 years ago

cc @rust-lang/compiler

Mark-Simulacrum commented 7 years ago

Captured a debug log from rustc_trans: https://gist.github.com/Mark-Simulacrum/55341cf99db2ab2c0739ead0533b7f28

nikomatsakis commented 7 years ago

Nominating for discussion. @alexcrichton how serious of a problem is this? (i.e., is it occurring a lot?)

alexcrichton commented 7 years ago

@nikomatsakis I haven't myself run into this much, but maybe @conradev (reporter of the original issue) has run into it more?

conradev commented 7 years ago

I have only run into it in the situation from the original ticket (alexcrichton/futures-rs#393).

That said, @dwrensha also ran into the same error, but in a different situation: alexcrichton/futures-rs/issues/367 (I'm not sure how related it is, if at all)

dwrensha commented 7 years ago

I was able to shuffle things around a bit in my code to avoid the problem: https://github.com/dwrensha/zillions/commit/da6e69c87b1b28e817b2b4d13920e5ef333f70ee. Still, this is a very surprising and unhelpful error message to see, and I can imagine beginners getting quite confused upon seeing it.

nikomatsakis commented 7 years ago

triage: P-medium

cetra3 commented 7 years ago

Just going to plug my code here. It is a bit more of an elaborate example: https://github.com/cetra3/apache_log/tree/recursion_limit

Are there any settings we can set to bump up this so-called recursion limit? Or is it hard set in the compiler.

goffrie commented 7 years ago

Ran into this as well... For what it's worth, it seems like the error message is a red herring - it doesn't look like it's a recursion depth problem, it just ends up with two ambiguous trait impls.

goffrie commented 7 years ago

It appears that this was fixed by #45065.

alexcrichton commented 7 years ago

Nice! I'll tag this as needstest so we can check in the test above

cetra3 commented 7 years ago

How would I test it out against my code? Has this landed in nightly?

goffrie commented 7 years ago

Yes - at least, the reduced test case compiles fine with the latest nightly.

cetra3 commented 7 years ago

I've tested my code on the latest nightly. Compiles fine now!