-
Notifications
You must be signed in to change notification settings - Fork 2.6k
refactor Target serialization #2219
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
Conversation
Remove obscure `metadata` field and implement proper Encodable for TargetKind becase default one is not used.
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
I'm not sure what fields of dependency should I serialize: pub struct DependencyInner {
name: String, // already included
source_id: SourceId, // should be included, but is `source_id` a good name? Maybe just `source`?
req: VersionReq, // already included
specified_req: Option<String>, // no sure about this one
kind: Kind, // should be included?
only_match_name: bool, // should be omitted
optional: bool, // should be included
default_features: bool, // should be omitted
features: Vec<String>, // should be omitted
// This dependency should be used only for this platform.
// `None` means *all platforms*.
only_for_platform: Option<String>, // should be omitted
} Otherwise I'm ready to merge this |
use support::{project, execs, main_file, basic_bin_manifest}; | ||
use hamcrest::{assert_that}; | ||
|
||
fn setup() {} | ||
|
||
fn remove_all_whitespace(s: &str) -> String { | ||
let re = Regex::new(r"\s+").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using a regex for this, could this use .split_whitespace().collect()
?
I think it's ok to leave out the other For dependency information, here's what I think should happen: pub struct DependencyInner {
name: String, // include
source_id: SourceId, // include (naming 'source' is fine)
req: VersionReq, // include
specified_req: Option<String>, // omit
kind: Kind, // include
only_match_name: bool, // omit
optional: bool, // include
default_features: bool, // include
features: Vec<String>, // include
only_for_platform: Option<String>, // include, probably call 'target'
}
`` |
290a403
to
0b00794
Compare
Should I make a custom encodable for this? Or |
fa03386
to
9646ed6
Compare
Ok, I think this is done. It has about 0 tests, but I hope to improve this situation in the metadata PR =) |
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { | ||
match *self { | ||
Kind::Normal => "normal", | ||
Kind::Development => "development", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may want to just be called "dev" as that's what it's called in the manifest
target encoding as |
9646ed6
to
77e7273
Compare
@alexcrichton updated |
@alexcrichton another preparation PR for #2196 I've removed obscure `metadata` field from `Target`. It is a breaking change (for read-manifest), but the field seemed cryptic, useless and untested :) `Target` has a bunch of boolean fields: ``` tested: bool, benched: bool, doc: bool, doctest: bool, harness: bool, // whether to use the test harness (--test) for_host: bool, ``` I guess they should not be included in serialized representation? I will push commits for other `Encodable`s here.
☀️ Test successful - cargo-linux-32, cargo-linux-64, cargo-mac-32, cargo-mac-64, cargo-win-gnu-32, cargo-win-gnu-64, cargo-win-msvc-32, cargo-win-msvc-64 |
@alexcrichton another preparation PR for #2196
I've removed obscure
metadata
field fromTarget
. It is a breaking change (for read-manifest), but the field seemed cryptic, useless and untested :)Target
has a bunch of boolean fields:I guess they should not be included in serialized representation?
I will push commits for other
Encodable
s here.