Skip to content

Commit 51d17bd

Browse files
author
bors-servo
authored
Auto merge of #216 - nox:serde, r=SimonSapin
Allow serde 0.8 and remove use of compiler plugins <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/216) <!-- Reviewable:end -->
2 parents 25e7098 + 9f2f582 commit 51d17bd

File tree

5 files changed

+47
-17
lines changed

5 files changed

+47
-17
lines changed

Cargo.toml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "url"
4-
version = "1.1.1"
4+
version = "1.2.0"
55
authors = ["The rust-url developers"]
66

77
description = "URL library for Rust, based on the WHATWG URL Standard"
@@ -27,13 +27,12 @@ rustc-serialize = "0.3"
2727

2828
[features]
2929
query_encoding = ["encoding"]
30-
heap_size = ["heapsize", "heapsize_plugin"]
30+
heap_size = ["heapsize"]
3131

3232
[dependencies]
33-
idna = { version = "0.1.0", path = "./idna" }
34-
heapsize = {version = ">=0.1.1, <0.4", optional = true}
35-
heapsize_plugin = {version = "0.1.0", optional = true}
3633
encoding = {version = "0.2", optional = true}
37-
serde = {version = ">=0.6.1, <0.8", optional = true}
38-
rustc-serialize = {version = "0.3", optional = true}
34+
heapsize = {version = ">=0.1.1, <0.4", optional = true}
35+
idna = { version = "0.1.0", path = "./idna" }
3936
matches = "0.1"
37+
rustc-serialize = {version = "0.3", optional = true}
38+
serde = {version = ">=0.6.1, <0.9", optional = true}

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
test:
22
cargo test --features "query_encoding serde rustc-serialize"
3-
[ x$$TRAVIS_RUST_VERSION != xnightly ] || cargo test --features heap_size
3+
[ x$$TRAVIS_RUST_VERSION != xnightly ] || cargo test --features heapsize
44

55
doc:
66
cargo doc --features "query_encoding serde rustc-serialize"

src/host.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9+
#[cfg(feature = "heapsize")] use heapsize::HeapSizeOf;
910
use std::cmp;
1011
use std::fmt::{self, Formatter};
1112
use std::io;
@@ -16,14 +17,16 @@ use percent_encoding::percent_decode;
1617
use idna;
1718

1819
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
19-
#[cfg_attr(feature="heap_size", derive(HeapSizeOf))]
2020
pub enum HostInternal {
2121
None,
2222
Domain,
2323
Ipv4(Ipv4Addr),
2424
Ipv6(Ipv6Addr),
2525
}
2626

27+
#[cfg(feature = "heapsize")]
28+
known_heap_size!(0, HostInternal);
29+
2730
impl<S> From<Host<S>> for HostInternal {
2831
fn from(host: Host<S>) -> HostInternal {
2932
match host {
@@ -36,7 +39,6 @@ impl<S> From<Host<S>> for HostInternal {
3639

3740
/// The host name of an URL.
3841
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
39-
#[cfg_attr(feature="heap_size", derive(HeapSizeOf))]
4042
pub enum Host<S=String> {
4143
/// A DNS domain name, as '.' dot-separated labels.
4244
/// Non-ASCII labels are encoded in punycode per IDNA.
@@ -55,6 +57,16 @@ pub enum Host<S=String> {
5557
Ipv6(Ipv6Addr),
5658
}
5759

60+
#[cfg(feature = "heapsize")]
61+
impl<S: HeapSizeOf> HeapSizeOf for Host<S> {
62+
fn heap_size_of_children(&self) -> usize {
63+
match *self {
64+
Host::Domain(ref s) => s.heap_size_of_children(),
65+
_ => 0,
66+
}
67+
}
68+
}
69+
5870
impl<'a> Host<&'a str> {
5971
/// Return a copy of `self` that owns an allocated `String` but does not borrow an `&Url`.
6072
pub fn to_owned(&self) -> Host<String> {

src/lib.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,15 @@ let css_url = this_document.join("../main.css").unwrap();
112112
assert_eq!(css_url.as_str(), "http://servo.github.io/rust-url/main.css")
113113
*/
114114

115-
#![cfg_attr(feature="heap_size", feature(plugin, custom_derive))]
116-
#![cfg_attr(feature="heap_size", plugin(heapsize_plugin))]
117-
118115
#[cfg(feature="rustc-serialize")] extern crate rustc_serialize;
119116
#[macro_use] extern crate matches;
120117
#[cfg(feature="serde")] extern crate serde;
121-
#[cfg(feature="heap_size")] #[macro_use] extern crate heapsize;
118+
#[cfg(feature="heapsize")] #[macro_use] extern crate heapsize;
122119

123120
pub extern crate idna;
124121

125122
use encoding::EncodingOverride;
123+
#[cfg(feature = "heapsize")] use heapsize::HeapSizeOf;
126124
use host::HostInternal;
127125
use parser::{Parser, Context, SchemeType, to_u32};
128126
use percent_encoding::{PATH_SEGMENT_ENCODE_SET, USERINFO_ENCODE_SET,
@@ -156,7 +154,6 @@ pub mod quirks;
156154

157155
/// A parsed URL record.
158156
#[derive(Clone)]
159-
#[cfg_attr(feature="heap_size", derive(HeapSizeOf))]
160157
pub struct Url {
161158
/// Syntax in pseudo-BNF:
162159
///
@@ -181,6 +178,13 @@ pub struct Url {
181178
fragment_start: Option<u32>, // Before '#', unlike Position::FragmentStart
182179
}
183180

181+
#[cfg(feature = "heapsize")]
182+
impl HeapSizeOf for Url {
183+
fn heap_size_of_children(&self) -> usize {
184+
self.serialization.heap_size_of_children()
185+
}
186+
}
187+
184188
/// Full configuration for the URL parser.
185189
#[derive(Copy, Clone)]
186190
pub struct ParseOptions<'a> {

src/origin.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9+
#[cfg(feature = "heapsize")] use heapsize::HeapSizeOf;
910
use host::Host;
1011
use idna::domain_to_unicode;
1112
use parser::default_port;
@@ -34,7 +35,6 @@ pub fn url_origin(url: &Url) -> Origin {
3435

3536
/// The origin of an URL
3637
#[derive(PartialEq, Eq, Clone, Debug)]
37-
#[cfg_attr(feature="heap_size", derive(HeapSizeOf))]
3838
pub enum Origin {
3939
/// A globally unique identifier
4040
Opaque(OpaqueOrigin),
@@ -43,6 +43,19 @@ pub enum Origin {
4343
Tuple(String, Host<String>, u16)
4444
}
4545

46+
#[cfg(feature = "heapsize")]
47+
impl HeapSizeOf for Origin {
48+
fn heap_size_of_children(&self) -> usize {
49+
match *self {
50+
Origin::Tuple(ref scheme, ref host, _) => {
51+
scheme.heap_size_of_children() +
52+
host.heap_size_of_children()
53+
},
54+
_ => 0,
55+
}
56+
}
57+
}
58+
4659

4760
impl Origin {
4861
/// Creates a new opaque origin that is only equal to itself.
@@ -95,5 +108,7 @@ impl Origin {
95108

96109
/// Opaque identifier for URLs that have file or other schemes
97110
#[derive(Eq, PartialEq, Clone, Debug)]
98-
#[cfg_attr(feature="heap_size", derive(HeapSizeOf))]
99111
pub struct OpaqueOrigin(usize);
112+
113+
#[cfg(feature = "heapsize")]
114+
known_heap_size!(0, OpaqueOrigin);

0 commit comments

Comments
 (0)