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

proc-macro derive panicked #44523

Closed
alanhkarp opened this issue Sep 12, 2017 · 6 comments
Closed

proc-macro derive panicked #44523

alanhkarp opened this issue Sep 12, 2017 · 6 comments

Comments

@alanhkarp
Copy link

The following compiles without the Serialize or Deserialize in derive. Note that all variables are Copy. I am running macOS Sierra Version 10.12.16 on a MacBook Pro with a 2.2 Ghz Intel Core i7.

cargo run
Compiling multicell v0.1.0 (file:///Users/alan/Documents/Eclipse/multicell)
error: proc-macro derive panicked
--> src/routing_table_entry.rs:9:41
|
9 | #[derive(Debug, Copy, Clone, Serialize, Deserialize)]
| ^^^^^^^^^^^
|
= help: message: called Result::unwrap() on an Err value: "failed to parse derive input: "pub struct RoutingTableEntry {\n index: TableIndex,\n uuid: Uuid,\n may_send: bool,\n inuse: bool,\n parent: PortNo,\n mask: Mask,\n other_indices: [TableIndex; MAX_PORTS.v as usize],\n}""

error: Could not compile multicell.

To learn more, run the command again with --verbose.

rustc --version --verbose routing_table_entry.rs
rustc 1.15.1 (021bd29 2017-02-08)
binary: rustc
commit-hash: 021bd29
commit-date: 2017-02-08
host: x86_64-apple-darwin
release: 1.15.1
LLVM version: 3.9

cargo run --verbose
Fresh cfg-if v0.1.1
Fresh itoa v0.3.1
Fresh unicode-xid v0.0.4
Fresh serde v0.9.11
Fresh dtoa v0.4.1
Fresh num-traits v0.1.37
Fresh libc v0.2.21
Fresh rustc-demangle v0.1.4
Fresh crossbeam v0.2.10
Fresh quick-error v1.2.0
Fresh quote v0.3.15
Fresh synom v0.11.3
Fresh serde_json v0.9.9
Fresh rand v0.3.15
Fresh backtrace v0.3.2
Fresh syn v0.11.9
Fresh eval v0.4.0
Fresh uuid v0.4.0
Fresh error-chain v0.10.0
Fresh serde_codegen_internals v0.14.1
Fresh serde_derive v0.9.11
Compiling multicell v0.1.0 (file:///Users/alan/Documents/Eclipse/multicell)
Running rustc --crate-name multicell src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=c3754c3b59b444a8 -C extra-filename=-c3754c3b59b444a8 --out-dir /Users/alan/Documents/Eclipse/multicell/target/debug/deps -L dependency=/Users/alan/Documents/Eclipse/multicell/target/debug/deps --extern serde_json=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libserde_json-3d75a8ee8aa27a6a.rlib --extern eval=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libeval-19007993aba8ae97.rlib --extern error_chain=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/liberror_chain-dc31d088e7e1eb1e.rlib --extern crossbeam=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libcrossbeam-49604b5af8766723.rlib --extern serde_derive=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libserde_derive-c205a175c33019f9.dylib --extern rand=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/librand-e7e80d6f8d47bbec.rlib --extern uuid=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libuuid-461871f5c8ab3856.rlib --extern serde=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libserde-0dc9e96503d8d5e9.rlib --extern multicell=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libmulticell-cd67f32b1d3caf8c.rlib
error: proc-macro derive panicked
--> src/routing_table_entry.rs:9:41
|
9 | #[derive(Debug, Copy, Clone, Serialize, Deserialize)]
| ^^^^^^^^^^^
|
= help: message: called Result::unwrap() on an Err value: "failed to parse derive input: "pub struct RoutingTableEntry {\n index: TableIndex,\n uuid: Uuid,\n may_send: bool,\n inuse: bool,\n parent: PortNo,\n mask: Mask,\n other_indices: [TableIndex; MAX_PORTS.v as usize],\n}""

error: Could not compile multicell.

Caused by:
process didn't exit successfully: rustc --crate-name multicell src/main.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=c3754c3b59b444a8 -C extra-filename=-c3754c3b59b444a8 --out-dir /Users/alan/Documents/Eclipse/multicell/target/debug/deps -L dependency=/Users/alan/Documents/Eclipse/multicell/target/debug/deps --extern serde_json=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libserde_json-3d75a8ee8aa27a6a.rlib --extern eval=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libeval-19007993aba8ae97.rlib --extern error_chain=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/liberror_chain-dc31d088e7e1eb1e.rlib --extern crossbeam=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libcrossbeam-49604b5af8766723.rlib --extern serde_derive=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libserde_derive-c205a175c33019f9.dylib --extern rand=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/librand-e7e80d6f8d47bbec.rlib --extern uuid=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libuuid-461871f5c8ab3856.rlib --extern serde=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libserde-0dc9e96503d8d5e9.rlib --extern multicell=/Users/alan/Documents/Eclipse/multicell/target/debug/deps/libmulticell-cd67f32b1d3caf8c.rlib (exit code: 101)

@est31
Copy link
Member

est31 commented Sep 12, 2017

cc @dtolnay -- maybe a serde bug?

@alanhkarp
Copy link
Author

I have no idea how to tell. On 11/17/2016 serde-rs/serde#623 says that "This is #37788 for which a fix has merged into Rust and will be in tomorrow's nightly." I am using stable, but a change from last November should have made it into stable by now.

@dtolnay
Copy link
Member

dtolnay commented Sep 12, 2017

pub struct RoutingTableEntry {
    index: TableIndex,
    uuid: Uuid,
    may_send: bool,
    inuse: bool,
    parent: PortNo,
    mask: Mask,
    other_indices: [TableIndex; MAX_PORTS.v as usize],
}

The array length expression here requires you to enable the full feature of syn. See https://github.com/dtolnay/syn#optional-features. By default it will only parse very basic length expressions because the full expression grammar is so complicated that it would take 3 times longer to compile for something that almost nobody ever uses.

You can get this to work as is by enabling the relevant feature in Cargo.toml:

syn = { version = "0.11", features = ["full"] }

Or without that, you can factor the length expression into a standalone constant:

const OTHER_INDICES_LEN: usize = MAX_PORTS.v as usize;

pub struct RoutingTableEntry {
    other_indices: [TableIndex; OTHER_INDICES_LEN],
}

Or factor out the entire array type:

type OtherIndices = [TableIndex; MAX_PORTS.v as usize];

pub struct RoutingTableEntry {
    other_indices: OtherIndices,
}

@alanhkarp
Copy link
Author

Thanks for the prompt response. I never would have figured that out.

In the spirit of Rust's excellent compiler errors, I wonder if the error message include something like

  Try syn = { version = "0.11", features = ["full"] } in Cargo.toml

@Mark-Simulacrum
Copy link
Member

I don't believe this is a rust compiler bug; I don't think we can make that suggestion on our side (since this is a failure on serde's side). Closing. It's possible Serde can make that suggestion in the panic! call, but that's something you'd have to request on their issue tracker.

@nidhinmahesh
Copy link

Facing a similar issue as above but I am not using this package. Issue might be caused by some other package but I am finding it difficult to find the error:

[dependencies]
actix = "0.10.0"
actix-web = "3.3.2"
actix-cors = "0.5.3"
actix-service = "1.0.6"
actix-http = "2.2.0"
blob-uuid = "0.4.0"
chrono = "0.4.6"
diesel = { version = "1.4.5", features = ["chrono", "postgres", "r2d2", "uuidv07", "serde_json"] }
uuid = { version = "0.8.1", features = ["serde", "v4"] }
dotenv = "0.15.0"
env_logger = "0.8.2"
failure = "0.1.8"
futures = "0.3.8"
http = "0.2.2"
jsonwebtoken = "7.2.0"
lazy_static = "1.4.0"
libreauth = "0.14.0"
log = "0.4.11"
num_cpus = "1.13.0"
regex = "1.4.2"
serde = "1.0.118"
serde_derive = "1.0.118"
serde_json = "1.0.60"
slug = "0.1.4"
validator = { version = "0.12", features = ["derive"] }
validator_derive = "0.12.0"

Error messsage : Same as @alanhkarp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants