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

#[deriving(Encodable)] crashes rustc --pretty expanded #12685

Closed
lifthrasiir opened this issue Mar 4, 2014 · 1 comment · Fixed by #13544
Closed

#[deriving(Encodable)] crashes rustc --pretty expanded #12685

lifthrasiir opened this issue Mar 4, 2014 · 1 comment · Fixed by #13544
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@lifthrasiir
Copy link
Contributor

extern crate serialize;
#[deriving(Encodable)] struct A;
#[deriving(Encodable)] struct B(int);
#[deriving(Encodable)] struct C { x: int } 
#[deriving(Encodable)] enum D {}
#[deriving(Encodable)] enum E { y } 
#[deriving(Encodable)] enum F { z(int) }

While this code compiles fine and works well against the encoder, rustc --pretty expanded gives this ICE:

use std::prelude::*;
extern crate std = "std#0.10-pre";
extern crate green = "green#0.10-pre";
extern crate rustuv = "rustuv#0.10-pre";
extern crate serialize;
#[deriving(Encodable)]
struct A;
#[doc = "Automatically derived."]
impl <__E: ::serialize::Encoder> ::serialize::Encodable<__E> for A {
    fn encode(&self, __arg_0: &mut __E) {
error: internal compiler error: unexpected failure
This message reflects a bug in the Rust compiler. 
We would appreciate a bug report: http://static.rust-lang.org/doc/master/complement-bugreport.html
note: the compiler hit an unexpected failure path. this is a bug
Ok(task 'rustc' failed at 'assertion failed: body.expr.is_some()', <rust>/src/libsyntax/print/pprust.rs:1400
)

Deriving is certainly generating an AST which is fine for trans but not fine for the pretty printer. It turns out that #[deriving(Encodable)] creates an FnBlockExpr node with a multi-statement Block (normally expected to contain a single ExprBlock node), which triggers a couple of assertions.

@pnkfelix
Copy link
Member

\o/ maybe now I'll be able to pretty-print rustc!

flip1995 pushed a commit to flip1995/rust that referenced this issue May 2, 2024
Threadlocal_initializer_can_be_made_const will not trigger for unreachable initializers

This commit introduces a check to ensure that the lint won't trigger when the initializer is unreachable, such as:

```
thread_local! {
    static STATE: Cell<usize> = panic!();
}
```

This is achieved by looking at the unpeeled initializer expression and ensuring that the parent macro is not `panic!()`, `todo!()`, `unreachable!()`, `unimplemented!()`.

fixes rust-lang#12637

changelog: [`threadlocal_initializer_can_be_made_const`] will no longer trigger on `unreachable` macros.
Zalathar added a commit to Zalathar/rust that referenced this issue Jun 4, 2024
This was an ancient regression test for rust-lang#12685, caused by `-Zunpretty=expanded`
crashing on certain code produced by `#[derive(RustcEncodable)]`.
Zalathar added a commit to Zalathar/rust that referenced this issue Jun 4, 2024
This was an ancient regression test for rust-lang#12685, caused by `-Zunpretty=expanded`
crashing on certain code produced by `#[derive(RustcEncodable)]`.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 4, 2024
Remove `tests/run-make-fulldeps/pretty-expanded`

This was an ancient regression test for rust-lang#12685, caused by `-Zunpretty=expanded` crashing on certain code produced by `#[derive(RustcEncodable)]`.

Given that this test predates `//@ pretty-expanded` tests, and was tied to ancient implementation details of the pretty-printer and `#[derive(RustcEncodable)]` (which the test no longer even uses), I think we can safely delete it.

---

Spotted via rust-lang#125948.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 4, 2024
Rollup merge of rust-lang#125973 - Zalathar:pretty, r=lqd

Remove `tests/run-make-fulldeps/pretty-expanded`

This was an ancient regression test for rust-lang#12685, caused by `-Zunpretty=expanded` crashing on certain code produced by `#[derive(RustcEncodable)]`.

Given that this test predates `//@ pretty-expanded` tests, and was tied to ancient implementation details of the pretty-printer and `#[derive(RustcEncodable)]` (which the test no longer even uses), I think we can safely delete it.

---

Spotted via rust-lang#125948.
lcnr pushed a commit to lcnr/rust that referenced this issue Jun 12, 2024
This was an ancient regression test for rust-lang#12685, caused by `-Zunpretty=expanded`
crashing on certain code produced by `#[derive(RustcEncodable)]`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pretty Area: Pretty printing (including `-Z unpretty`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants