Skip to content

Commit ec31591

Browse files
committed
Cleanly error out when building without the alloc feature
1 parent 8101840 commit ec31591

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ script:
1111
- if [[ "$TRAVIS_NIGHTLY" == "true" ]]; then cargo test --verbose --all-features; fi
1212
- if [[ "$TRAVIS_NIGHTLY" == "true" ]]; then cargo bench --verbose --all-features --no-run; fi
1313
- if [[ "$TRAVIS_NIGHTLY" == "true" ]]; then rustup target add thumbv7m-none-eabi; fi
14-
- if [[ "$TRAVIS_NIGHTLY" == "true" ]]; then cargo build --verbose --no-default-features --target thumbv7m-none-eabi; fi
14+
- if [[ "$TRAVIS_NIGHTLY" == "true" ]]; then cargo build --verbose --no-default-features --features=alloc --target thumbv7m-none-eabi; fi
1515
- if [[ "$TRAVIS_NIGHTLY" != "true" ]]; then cargo test --verbose; fi
1616

1717
cache: cargo

src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
//! ```
5050
#![cfg_attr(not(test), no_std)]
5151

52+
#[cfg(not(feature = "alloc"))]
53+
compile_error!("This crate does not yet support environments without liballoc. See https://github.com/RustCrypto/RSA/issues/51.");
54+
5255
#[cfg(feature = "alloc")]
5356
extern crate alloc;
5457
#[cfg(feature = "std")]
@@ -67,40 +70,55 @@ extern crate hex;
6770
#[cfg(all(test, feature = "serde"))]
6871
extern crate serde_test;
6972

73+
#[cfg(feature = "alloc")]
7074
pub use num_bigint::BigUint;
7175

7276
/// Useful algorithms.
77+
#[cfg(feature = "alloc")]
7378
pub mod algorithms;
7479

7580
/// Error types.
81+
#[cfg(feature = "alloc")]
7682
pub mod errors;
7783

7884
/// Supported hash functions.
85+
#[cfg(feature = "alloc")]
7986
pub mod hash;
8087

8188
/// Supported padding schemes.
89+
#[cfg(feature = "alloc")]
8290
pub mod padding;
8391

8492
#[cfg(feature = "pem")]
8593
pub use pem;
8694

95+
#[cfg(feature = "alloc")]
8796
mod key;
97+
#[cfg(feature = "alloc")]
8898
mod oaep;
8999
#[cfg(feature = "std")]
90100
mod parse;
101+
#[cfg(feature = "alloc")]
91102
mod pkcs1v15;
103+
#[cfg(feature = "alloc")]
92104
mod pss;
105+
#[cfg(feature = "alloc")]
93106
mod raw;
94107

108+
#[cfg(feature = "alloc")]
95109
pub use self::hash::Hash;
110+
#[cfg(feature = "alloc")]
96111
pub use self::key::{PublicKey, PublicKeyParts, RSAPrivateKey, RSAPublicKey};
112+
#[cfg(feature = "alloc")]
97113
pub use self::padding::PaddingScheme;
98114

99115
// Optionally expose internals if requested via feature-flag.
100116

101117
#[cfg(not(feature = "expose-internals"))]
118+
#[cfg(feature = "alloc")]
102119
mod internals;
103120

104121
/// Internal raw RSA functions.
105122
#[cfg(feature = "expose-internals")]
123+
#[cfg(feature = "alloc")]
106124
pub mod internals;

0 commit comments

Comments
 (0)