Skip to content

Commit 527db0f

Browse files
committed
Stop supporting no_alloc
1 parent d6c9467 commit 527db0f

File tree

12 files changed

+22
-84
lines changed

12 files changed

+22
-84
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
run: cargo test --all-features
2121
- name: Test with no features
2222
run: cargo test --tests --no-default-features
23-
- name: Test with feature alloc
24-
run: cargo test --tests --no-default-features -F alloc
2523
- name: Test with feature impl-error
2624
run: cargo test --tests --no-default-features -F impl-error
2725
- name: Test with feature net

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ categories = ["encoding", "parser-implementations"]
1313

1414
[features]
1515
default = ["std"]
16-
std = ["alloc", "impl-error"]
17-
alloc = ["borrow-or-share/alloc", "serde?/alloc"]
16+
std = ["impl-error"]
1817
impl-error = []
1918
net = []
2019

2120
[dependencies]
22-
borrow-or-share = { version = "0.2.4", default-features = false }
21+
borrow-or-share = "0.2"
2322
ref-cast = "1.0"
2423

2524
[dependencies.serde]
2625
version = "1.0"
2726
default-features = false
27+
features = ["alloc"]
2828
optional = true
2929

3030
[package.metadata.docs.rs]

src/component.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ impl<'a, UserinfoE: Encoder, RegNameE: Encoder> Authority<'a, UserinfoE, RegName
227227
/// An empty authority component.
228228
pub const EMPTY: Authority<'static, UserinfoE, RegNameE> = Authority::new("", AuthMeta::EMPTY);
229229

230-
#[cfg(feature = "alloc")]
231230
pub(crate) fn meta(&self) -> AuthMeta {
232231
self.inner.meta
233232
}

src/convert.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
use crate::{imp::RiMaybeRef, Iri, IriRef, Uri, UriRef};
2-
use borrow_or_share::Bos;
3-
use core::str;
4-
5-
#[cfg(feature = "alloc")]
61
use crate::{
7-
imp::{HostMeta, Meta, RmrRef},
8-
pct_enc,
2+
imp::{HostMeta, Meta, RiMaybeRef, RmrRef},
3+
pct_enc, Iri, IriRef, Uri, UriRef,
94
};
10-
#[cfg(feature = "alloc")]
115
use alloc::string::String;
12-
#[cfg(feature = "alloc")]
13-
use core::num::NonZeroUsize;
6+
use borrow_or_share::Bos;
7+
use core::{num::NonZeroUsize, str};
148

159
macro_rules! impl_from {
1610
($($x:ident => $($y:ident),+)*) => {
@@ -60,7 +54,6 @@ macro_rules! impl_try_from {
6054
}
6155
}
6256

63-
#[cfg(feature = "alloc")]
6457
impl TryFrom<$x<String>> for $y<String> {
6558
type Error = (ConvertError, $x<String>);
6659

@@ -92,7 +85,6 @@ impl_try_from! {
9285
IriRef if ensure_has_scheme => Iri
9386
}
9487

95-
#[cfg(feature = "alloc")]
9688
impl<T: Bos<str>> Iri<T> {
9789
/// Converts the IRI to a URI by percent-encoding non-ASCII characters.
9890
///
@@ -114,7 +106,6 @@ impl<T: Bos<str>> Iri<T> {
114106
}
115107
}
116108

117-
#[cfg(feature = "alloc")]
118109
impl<T: Bos<str>> IriRef<T> {
119110
/// Converts the IRI reference to a URI reference by percent-encoding non-ASCII characters.
120111
///
@@ -136,7 +127,6 @@ impl<T: Bos<str>> IriRef<T> {
136127
}
137128
}
138129

139-
#[cfg(feature = "alloc")]
140130
fn encode_non_ascii(r: RmrRef<'_, '_>) -> (String, Meta) {
141131
let len = r
142132
.as_str()
@@ -196,7 +186,6 @@ fn encode_non_ascii(r: RmrRef<'_, '_>) -> (String, Meta) {
196186
(buf, meta)
197187
}
198188

199-
#[cfg(feature = "alloc")]
200189
fn encode_non_ascii_str(buf: &mut String, s: &str) {
201190
if s.is_ascii() {
202191
buf.push_str(s);

src/imp.rs

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
#![allow(missing_debug_implementations)]
22

3-
use crate::{
4-
component::{Authority, IAuthority, Scheme},
5-
convert::ConvertError,
6-
parse::{self, ParseError},
7-
pct_enc::{encoder::*, EStr, Encoder},
8-
};
9-
use borrow_or_share::{BorrowOrShare, Bos};
10-
use core::{borrow::Borrow, cmp::Ordering, fmt, hash, num::NonZeroUsize, str};
11-
12-
#[cfg(feature = "alloc")]
133
use crate::{
144
build::{
155
state::{NonRefStart, Start},
166
Builder,
177
},
8+
component::{Authority, IAuthority, Scheme},
9+
convert::ConvertError,
1810
normalize::Normalizer,
11+
parse::{self, ParseError},
12+
pct_enc::{encoder::*, EStr, Encoder},
1913
resolve::{self, ResolveError},
2014
};
21-
#[cfg(feature = "alloc")]
2215
use alloc::{borrow::ToOwned, string::String};
23-
#[cfg(feature = "alloc")]
24-
use core::str::FromStr;
16+
use borrow_or_share::{BorrowOrShare, Bos};
17+
use core::{
18+
borrow::Borrow,
19+
cmp::Ordering,
20+
fmt, hash,
21+
num::NonZeroUsize,
22+
str::{self, FromStr},
23+
};
2524

2625
#[cfg(feature = "net")]
2726
use crate::net::{Ipv4Addr, Ipv6Addr};
@@ -33,7 +32,6 @@ pub trait Value: Default {}
3332

3433
impl Value for &str {}
3534

36-
#[cfg(feature = "alloc")]
3735
impl Value for String {}
3836

3937
pub struct Constraints {
@@ -64,7 +62,6 @@ pub trait RiMaybeRef: Sized {
6462
Self::Val: BorrowOrShare<'i, 'o, str>;
6563
}
6664

67-
#[cfg(feature = "alloc")]
6865
pub trait Ri: RiMaybeRef {
6966
type Ref<T>: RiMaybeRef<Val = T>;
7067
}
@@ -85,7 +82,6 @@ impl<'a> Parse for &'a str {
8582
}
8683
}
8784

88-
#[cfg(feature = "alloc")]
8985
impl Parse for String {
9086
type Val = Self;
9187
type Err = (ParseError, Self);
@@ -296,7 +292,6 @@ macro_rules! ri_maybe_ref {
296292
}
297293

298294
$(
299-
#[cfg(feature = "alloc")]
300295
impl<T: Bos<str>> Ri for $Ty<T> {
301296
type Ref<U> = $RefTy<U>;
302297
}
@@ -324,7 +319,6 @@ macro_rules! ri_maybe_ref {
324319
}
325320
}
326321

327-
#[cfg(feature = "alloc")]
328322
impl $Ty<String> {
329323
#[doc = concat!("Creates a new builder for ", $name, ".")]
330324
#[inline]
@@ -351,7 +345,6 @@ macro_rules! ri_maybe_ref {
351345
}
352346
}
353347

354-
#[cfg(feature = "alloc")]
355348
impl $Ty<&str> {
356349
#[doc = concat!("Creates a new `", $ty, "<String>` by cloning the contents of this `", $ty, "<&str>`.")]
357350
#[inline]
@@ -593,7 +586,6 @@ macro_rules! ri_maybe_ref {
593586
#[doc = concat!("assert_eq!(", $var, ".resolve_against(&base).unwrap(), \"http://example.com/foo/bar?baz\");")]
594587
/// # Ok::<_, fluent_uri::ParseError>(())
595588
/// ```
596-
#[cfg(feature = "alloc")]
597589
pub fn resolve_against<U: Bos<str>>(
598590
&self,
599591
base: &$NonRefTy<U>,
@@ -639,7 +631,6 @@ macro_rules! ri_maybe_ref {
639631
#[doc = concat!("assert_eq!(", $var, ".normalize(), \"example://a/b/c/%7Bfoo%7D\");")]
640632
/// # Ok::<_, fluent_uri::ParseError>(())
641633
/// ```
642-
#[cfg(feature = "alloc")]
643634
#[must_use]
644635
pub fn normalize(&self) -> $Ty<String> {
645636
Normalizer::new().normalize(self).unwrap()
@@ -749,15 +740,13 @@ macro_rules! ri_maybe_ref {
749740
#[doc = concat!("assert_eq!(", $var, ".with_fragment(None), \"http://example.com/\");")]
750741
/// # Ok::<_, fluent_uri::ParseError>(())
751742
/// ```
752-
#[cfg(feature = "alloc")]
753743
#[must_use]
754744
pub fn with_fragment(&self, opt: Option<&EStr<$FragmentE>>) -> $Ty<String> {
755745
// Altering only the fragment does not change the metadata.
756746
RiMaybeRef::new(self.make_ref().with_fragment(opt.map(EStr::as_str)), self.meta)
757747
}
758748
}
759749

760-
#[cfg(feature = "alloc")]
761750
impl $Ty<String> {
762751
/// Replaces the fragment component of `self` with the given one.
763752
///
@@ -865,7 +854,6 @@ macro_rules! ri_maybe_ref {
865854
}
866855
}
867856

868-
#[cfg(feature = "alloc")]
869857
impl TryFrom<String> for $Ty<String> {
870858
type Error = (ParseError, String);
871859

@@ -884,7 +872,6 @@ macro_rules! ri_maybe_ref {
884872
}
885873
}
886874

887-
#[cfg(feature = "alloc")]
888875
impl<'a> From<$Ty<String>> for String {
889876
#[doc = concat!("Equivalent to [`into_string`](", $ty, "::into_string).")]
890877
#[inline]
@@ -893,7 +880,6 @@ macro_rules! ri_maybe_ref {
893880
}
894881
}
895882

896-
#[cfg(feature = "alloc")]
897883
impl From<$Ty<&str>> for $Ty<String> {
898884
/// Equivalent to [`to_owned`](Self::to_owned).
899885
#[inline]
@@ -902,7 +888,6 @@ macro_rules! ri_maybe_ref {
902888
}
903889
}
904890

905-
#[cfg(feature = "alloc")]
906891
impl FromStr for $Ty<String> {
907892
type Err = ParseError;
908893

@@ -1043,7 +1028,6 @@ impl<'v, 'm> RmrRef<'v, 'm> {
10431028
.map(|i| self.eslice(i, self.val.len()))
10441029
}
10451030

1046-
#[cfg(feature = "alloc")]
10471031
pub fn set_fragment(buf: &mut String, meta: &Meta, opt: Option<&str>) {
10481032
buf.truncate(meta.query_or_path_end());
10491033
if let Some(s) = opt {
@@ -1057,7 +1041,6 @@ impl<'v, 'm> RmrRef<'v, 'm> {
10571041
&self.val[..self.meta.query_or_path_end()]
10581042
}
10591043

1060-
#[cfg(feature = "alloc")]
10611044
pub fn with_fragment(self, opt: Option<&str>) -> String {
10621045
let stripped = self.strip_fragment();
10631046
if let Some(s) = opt {

src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,14 @@
8383
//! [`Serialize`]: serde::Serialize
8484
//! [`Deserialize`]: serde::Deserialize
8585
86-
#[cfg(feature = "alloc")]
8786
pub mod build;
8887
pub mod component;
8988
mod convert;
9089
mod fmt;
9190
mod imp;
92-
#[cfg(feature = "alloc")]
9391
pub mod normalize;
9492
mod parse;
9593
pub mod pct_enc;
96-
#[cfg(feature = "alloc")]
9794
pub mod resolve;
9895
mod utf8;
9996

@@ -104,7 +101,6 @@ pub use parse::{ParseError, ParseErrorKind};
104101
#[cfg(feature = "std")]
105102
extern crate std;
106103

107-
#[cfg(feature = "alloc")]
108104
extern crate alloc;
109105

110106
#[cfg(all(feature = "net", not(feature = "std")))]

src/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ pub(crate) fn parse_v4_or_reg_name(bytes: &[u8]) -> HostMeta {
423423
}
424424
}
425425

426-
#[cfg(all(feature = "alloc", not(feature = "net")))]
426+
#[cfg(not(feature = "net"))]
427427
pub(crate) fn parse_v6(bytes: &[u8]) -> [u16; 8] {
428428
Reader::new(bytes).read_v6().unwrap()
429429
}

0 commit comments

Comments
 (0)