-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Rust can't infer appropriate generics for function when it should #89242
Comments
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=aaa115e139635787f9b033a1418c7f06 is failing on beta but working on stable, so tagging as a beta regression. |
Looking into this. From what I can tell, the version of this without the where clause doesn't compile on stable nor nightly (though the error is slightly different). However, while the version with the where clauses does compile on stable, it's actually not callable (because we can prove the where clause). On nightly, we just get a more eager error. This is still a bug (and I'm looking into it), but I don't think it's strictly a regression. You can't actually use any less code than before. |
I think this certainly mitigates the likely impact of the regression, but it wouldn't surprise me too much if there exists "real world" code that is just uncallable (and not tested, so not discovered yet). I think if we can fix the regression on nightly and backport it, that would be ideal. |
Okay, so I investigated this a bit. It's kind of rough. My work-through
Basically, are potentially four ways forward
|
Stumbled across this again. This is basically #89196, because we try to prove the bound before we complete function resolution. It's a little different though, so I'll mark this to get included as a known-bug. |
triage: closing, the linked MCVE now compiles properly on stable and nightly |
I was working on some generic code when I hit this bug, so I made this MRE:
(playground link: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=ce2ea68678f61b329a6cec59310c1aea)
I'd expect both calls to
takes_trait_b
to succeed, but the second call doesn't as rust seemingly tries to uphold the where clause for any possibleT
This has been observed on
rustc 1.57.0-nightly (aa8f2d432 2021-09-18)
Adding two extra where clauses makes both calls compile on stable, but this example still fails on nightly: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=aaa115e139635787f9b033a1418c7f06
Seems like a regression.
The text was updated successfully, but these errors were encountered: