Skip to content

Commit

Permalink
Require explicit usage of alloc and std
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Aug 31, 2021
1 parent 7680b64 commit 26562e5
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions objc/src/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ decl.register();
```
*/

use alloc::format;
use alloc::string::ToString;
use core::mem;
use core::ptr;
use std::ffi::CString;
Expand Down
1 change: 1 addition & 0 deletions objc/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ encode_args_impl!(A, B, C, D, E, F, G, H, I, J, K, L);
#[cfg(test)]
mod tests {
use crate::runtime::{Class, Object, Sel};
use alloc::string::ToString;
use objc_encode::Encode;

#[test]
Expand Down
6 changes: 4 additions & 2 deletions objc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ The bindings can be used on Linux or *BSD utilizing the
[GNUstep Objective-C runtime](https://www.github.com/gnustep/libobjc2).
*/

#![crate_name = "objc"]
#![crate_type = "lib"]
#![no_std]
#![warn(missing_docs)]
#![allow(clippy::missing_safety_doc)]

extern crate alloc;
extern crate std;

pub use objc_encode::{Encode, Encoding};

pub use crate::encode::EncodeArguments;
Expand Down
1 change: 1 addition & 0 deletions objc/src/message/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloc::string::{String, ToString};
use core::any::Any;
use core::fmt;
use core::mem;
Expand Down
1 change: 1 addition & 0 deletions objc/src/rc/weak.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloc::boxed::Box;
use core::cell::UnsafeCell;
use core::ptr;

Expand Down
4 changes: 4 additions & 0 deletions objc_foundation/src/array.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloc::vec::Vec;
use core::cmp::Ordering;
use core::ffi::c_void;
use core::marker::PhantomData;
Expand Down Expand Up @@ -406,6 +407,9 @@ pub type NSMutableSharedArray<T> = NSMutableArray<T, Shared>;

#[cfg(test)]
mod tests {
use alloc::vec;
use alloc::vec::Vec;

use super::{INSArray, INSMutableArray, NSArray, NSMutableArray};
use crate::{INSObject, INSString, NSObject, NSString};
use objc_id::Id;
Expand Down
3 changes: 3 additions & 0 deletions objc_foundation/src/data.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[cfg(feature = "block")]
use alloc::vec::Vec;
use core::ffi::c_void;
use core::ops::Range;
use core::slice;
Expand Down Expand Up @@ -135,6 +137,7 @@ impl INSMutableCopying for NSMutableData {
mod tests {
use super::{INSData, INSMutableData, NSData, NSMutableData};
use crate::INSObject;
use alloc::vec;

#[test]
fn test_bytes() {
Expand Down
5 changes: 4 additions & 1 deletion objc_foundation/src/dictionary.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloc::vec::Vec;
use core::cmp::min;
use core::marker::PhantomData;
use core::ops::Index;
Expand Down Expand Up @@ -164,9 +165,11 @@ where

#[cfg(test)]
mod tests {
use alloc::vec;
use objc_id::Id;

use super::{INSDictionary, NSDictionary};
use crate::{INSArray, INSObject, INSString, NSObject, NSString};
use objc_id::Id;

fn sample_dict(key: &str) -> Id<NSDictionary<NSString, NSObject>> {
let string = NSString::from_str(key);
Expand Down
4 changes: 4 additions & 0 deletions objc_foundation/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#![no_std]
#![crate_name = "objc_foundation"]

extern crate alloc;
extern crate std;

pub use self::array::{
INSArray, INSMutableArray, NSArray, NSComparisonResult, NSMutableArray, NSMutableSharedArray,
NSRange, NSSharedArray,
Expand Down
1 change: 1 addition & 0 deletions objc_foundation/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ object_struct!(NSObject);
mod tests {
use super::{INSObject, NSObject};
use crate::{INSString, NSString};
use alloc::format;

#[test]
fn test_is_equal() {
Expand Down
1 change: 1 addition & 0 deletions objc_foundation/src/value.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use alloc::string::ToString;
use core::any::Any;
use core::ffi::c_void;
use core::marker::PhantomData;
Expand Down
3 changes: 3 additions & 0 deletions objc_id/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ assert!(weak.load().is_none());
```
*/

// This crate is, but its dependencies are not
#![no_std]

pub use id::{Id, Owned, Ownership, ShareId, Shared, WeakId};

mod id;
Expand Down

0 comments on commit 26562e5

Please sign in to comment.