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

Macros 1.1 #530

Merged
merged 8 commits into from
Sep 2, 2016
Merged

Macros 1.1 #530

merged 8 commits into from
Sep 2, 2016

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Aug 29, 2016

@dtolnay dtolnay added the wip label Aug 29, 2016
@dtolnay
Copy link
Member Author

dtolnay commented Aug 29, 2016

Some limitations:

  • #[derive(Deserialize)] always panics. I have not debugged this yet.
  • #[derive(Serialize)] for ordinary structs always panics. Newtype structs, unit structs, and enums not containing ordinary struct variants all seem to work.

Both panics are this:

thread 'rustc' panicked at 'fold_mac disabled by default', src/libsyntax/fold.rs:171

EDIT: it is a rustc bug.

@dtolnay dtolnay removed the wip label Sep 1, 2016
@@ -36,51 +36,67 @@ include!(concat!(env!("OUT_DIR"), "/lib.rs"));
include!("lib.rs.in");

#[cfg(feature = "with-syntex")]
pub fn expand<S, D>(src: S, dst: D) -> Result<(), syntex::Error>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusing diff - this is just splitting expand into expand and expand_str with common code in syntex_registry.

@erickt
Copy link
Member

erickt commented Sep 1, 2016

Looks good to me!

@dtolnay
Copy link
Member Author

dtolnay commented Sep 2, 2016

I added a test suite but we need to fix rust-lang/rust#36211 before it will pass.

@dtolnay dtolnay merged commit ffa2f80 into master Sep 2, 2016
@dtolnay dtolnay deleted the derive branch September 2, 2016 04:59
bors added a commit to rust-lang/cargo that referenced this pull request Sep 6, 2016
Macros 1.1

Tested with serde-rs/serde#530. This should be able to merge independently of rust-lang/rust#35957.

r? @alexcrichton
@tikue
Copy link

tikue commented Sep 6, 2016

Trying to use this, I get

error: the `#[rustc_macro_derive]` attribute is only usable with crates of the `rustc-macro` crate type

@dtolnay
Copy link
Member Author

dtolnay commented Sep 6, 2016

@tikue you need a version of Cargo that supports rustc-macro crates. My Cargo PR merged a few hours ago so it will be in the next nightly. If you need it now you can build cargo yourself from the master branch. It should be as simple as cloning and running cargo install.

@tikue
Copy link

tikue commented Sep 6, 2016

@dtolnay cool, thanks!

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

Successfully merging this pull request may close these issues.

3 participants