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

Implement playground-specific custom metadata to control enabled features #326

Merged
merged 3 commits into from
May 12, 2018
Merged

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented May 12, 2018

This is based on the custom metadata configurable for docs.rs -- see https://docs.rs/about. Ours looks like:

# Cargo.toml
[package]
name = "test"

[package.metadata.playground]
default-features = true
features = ["std", "extra-traits"]
all-features = false

This PR includes a bump of the Cargo dependency to pick up rust-lang/cargo#5360 which has not been included in a release yet.

Motivation

I want the "extra-traits" feature of Syn so that people can debug print a syntax tree. This comes up often in IRC.

extern crate syn;

fn main() {
    println!("{:#?}", syn::parse_str::<syn::Type>("u8").unwrap());
}

Using cargo from git because the developers are in the process of
figuring out how to align their version numbers with rustc and may need
to skip the next one or two releases. The Manifest::custom_metadata
method is new in master and will be required for supporting
playground-specific custom metadata.
}
}

fn is_true(b: &bool) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

heh

@shepmaster
Copy link
Member

As when you added the original feature support: wow, thanks!

Do you think the metadata should completely replace the playground feature in time?

@dtolnay
Copy link
Member Author

dtolnay commented May 12, 2018

Yes I think custom metadata completely replaces our earlier scheme of looking for a "playground" feature. That was implemented in #100 in February 2017 and custom metadata only became available for published crates in rust-lang/cargo#4167 in June 2017. If it had been available earlier we would have used that. (I think preserving custom metadata for published crates was blocked on upgrading Cargo from rustc-serialize to Serde because rustc-serialize cannot handle deserializing data of unspecified structure.)

For now the uuid crate still uses a playground feature: https://github.com/uuid-rs/uuid/blob/0.6.3/Cargo.toml#L46. If you are on board with the approach in this PR, I would land this, then send a PR to uuid to switch to custom metadata, cut a uuid release, and finally remove the playground feature here.

@shepmaster
Copy link
Member

Yeah, I agree with everything you said. I'll wait just a while to see what the UUID devs have to say; I think they added that comparatively recently.

@dtolnay
Copy link
Member Author

dtolnay commented May 12, 2018

In uuid-rs/uuid#224 it looks like they are good with it. That person reviewed the original change in uuid-rs/uuid#189.

@kinggoesgaming
Copy link

Yes, I would love this change...

Just a note: the original uuid PR for this was uuid-rs/uuid#155

@shepmaster shepmaster merged commit 17d83ac into rust-lang:master May 12, 2018
@shepmaster
Copy link
Member

Forward to the future!

@dtolnay dtolnay deleted the metadata branch May 12, 2018 19:22
bors bot added a commit to uuid-rs/uuid that referenced this pull request May 13, 2018
224: Use custom metadata to specify playground features r=kinggoesgaming a=dtolnay

Fixes #223.

Marking WIP until rust-lang/rust-playground#326 has landed.

Co-authored-by: David Tolnay <dtolnay@gmail.com>
@shepmaster shepmaster added the enhancement Something new the playground could do label May 14, 2018
masklinn added a commit to masklinn/either that referenced this pull request Apr 4, 2024
Playground metadata is explicitly inspired by docs.rs so looks very similar, was implemented at rust-lang/rust-playground#326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something new the playground could do
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants