-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Recursive function call generates confusing overflow message #72577
Comments
&mut bytes::bytes_mut::BytesMut: bytes::buf::buf_impl::Buf
@o0Ignition0o: You can make this compile by changing Minimized: struct BytesMut;
trait Buf {}
impl Buf for BytesMut {}
impl<'a, T: Buf> Buf for &'a mut T {}
fn do_more<B>(mut buf: B)
where
B: Buf,
{
do_more(&mut buf);
}
fn main() {
do_more(&mut BytesMut)
} Trying to monomorphize We should be able to detect this kind of recursive monomorphization in simple cases (when the function directly calls itself rather than going through a helper function). |
Oh thanks a lot! So long story short I should try to avoid recursion in this kind of scenario ? (the real life use case is a bit more complicated, but i was willing about to use recursion to solve it ^^') thanks again :D |
This improves the output for issue rust-lang#72577, but there's still more work to be done. Currently, an overflow error during monomorphization results in an error that points at the function we were unable to monomorphize. However, we don't point at the call that caused the monomorphization to happen. In the overflow occurs in a large recursive function, it may be difficult to determine where the issue is. This commit tracks and `Span` information during collection of `MonoItem`s, which is used when emitting an overflow error. `MonoItem` itself is unchanged, so this only affects `src/librustc_mir/monomorphize/collector.rs`
…err, r=ecstatic-morse Point at the call span when overflow occurs during monomorphization This improves the output for issue rust-lang#72577, but there's still more work to be done. Currently, an overflow error during monomorphization results in an error that points at the function we were unable to monomorphize. However, we don't point at the call that caused the monomorphization to happen. In the overflow occurs in a large recursive function, it may be difficult to determine where the issue is. This commit tracks and `Span` information during collection of `MonoItem`s, which is used when emitting an overflow error. `MonoItem` itself is unchanged, so this only affects `src/librustc_mir/monomorphize/collector.rs`
…err, r=ecstatic-morse Point at the call span when overflow occurs during monomorphization This improves the output for issue rust-lang#72577, but there's still more work to be done. Currently, an overflow error during monomorphization results in an error that points at the function we were unable to monomorphize. However, we don't point at the call that caused the monomorphization to happen. In the overflow occurs in a large recursive function, it may be difficult to determine where the issue is. This commit tracks and `Span` information during collection of `MonoItem`s, which is used when emitting an overflow error. `MonoItem` itself is unchanged, so this only affects `src/librustc_mir/monomorphize/collector.rs`
Current output:
|
error[E0275]: overflow evaluating the requirement
&mut bytes::bytes_mut::BytesMut: bytes::buf::buf_impl::Buf
Here's a link to the playground : https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=e0d226183c371b79d9a234ccebdeafd0
I tried this code:
I expected to see this happen: Nothing really, but I would love to see an error message that would help me out here ^^.
Instead, this happened:
Meta
rustc --version --verbose
:Link to the twitter discussion https://twitter.com/ekuber/status/1264962969206525952?s=20
Paging @estebank who might be interested <3
The text was updated successfully, but these errors were encountered: