Skip to content

Commit 24a4b1b

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

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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)