-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Compiler bug while serializing enum to JSON value #137823
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
C-bug
Category: This is a bug.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
|
reduction: trait Convert {
fn convert<S>(&self, serializer: S) -> S::Out
where
S: Converter;
}
trait Converter {
type Out;
}
struct Foo;
impl Convert for Foo {
fn convert<S>(&self, ser: S) -> S::Out
where
S: Converter,
{
let value = Box::new(Foo);
value.convert(ConvertWrap { _d: ser })
}
}
fn main() {
Foo.convert(Ser);
}
struct Ser;
impl Converter for Ser {
type Out = ();
}
impl Convert for Box<Foo> {
fn convert<S>(&self, serializer: S) -> S::Out
where
S: Converter,
{
(**self).convert(serializer)
}
}
struct ConvertWrap<S> {
_d: S,
}
impl<S> Converter for ConvertWrap<S>
where
S: Converter,
{
type Out = S::Out;
} |
Slightly reduced fn convert<S: Converter>() -> S::Out {
convert2::<ConvertWrap<S>>()
}
fn convert2<S: Converter>() -> S::Out {
convert::<S>()
}
fn main() {
convert::<Ser>();
}
trait Converter {
type Out;
}
struct Ser;
impl Converter for Ser {
type Out = ();
}
struct ConvertWrap<S> {
_d: S,
}
impl<S> Converter for ConvertWrap<S>
where
S: Converter,
{
type Out = S::Out;
} |
As per cargo-bisect-rustc, this used to produce a regular (non-internal) error until #132173 / nightly-2024-11-11 error: reached the recursion limit while instantiating `convert::<ConvertWrap<ConvertWrap<ConvertWrap<ConvertWrap<ConvertWrap<...>>>>>>`
--> <source>:5:5
|
5 | convert::<S>()
| ^^^^^^^^^^^^^^
| |
huh, I guess it leaks monomorphizing...? |
Note: cyrgani's reproducer and my reproducer give the same ICE, but the original code gave a different ICE. Error output of my reproducer
|
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
C-bug
Category: This is a bug.
I-ICE
Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
S-has-mcve
Status: A Minimal Complete and Verifiable Example has been found for this issue
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Error reliably occurs when trying to serialize a tuple-like variant to a JSON value while also using the serde tag macro.
Code
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: