Repository: paritytech/ink
Pull request #285 (2019-11-28 18:51:36)

Use ink_prelude crate in the rest of ink!

codecov-io: # [Codecov](https://codecov.io/gh/paritytech/ink/pull/285?src=pr&el=h1) Report
> Merging [#285](https://codecov.io/gh/paritytech/ink/pull/285?src=pr&el=desc) into [master](https://codecov.io/gh/paritytech/ink/commit/19fe1917b49483b1138c90264f8dedf9403136aa?src=pr&el=desc) will **decrease** coverage by `27.61%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/paritytech/ink/pull/285/graphs/tree.svg?width=650&token=tYyVaCZb7o&height=150&src=pr)](https://codecov.io/gh/paritytech/ink/pull/285?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##           master     #285       +/-   ##
===========================================
- Coverage   41.73%   14.12%   -27.62%     
===========================================
  Files          55        7       -48     
  Lines        3680      354     -3326     
===========================================
- Hits         1536       50     -1486     
+ Misses       2144      304     -1840
```


| [Impacted Files](https://codecov.io/gh/paritytech/ink/pull/285?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [utils/src/hash.rs](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree#diff-dXRpbHMvc3JjL2hhc2gucnM=) | `0% <0%> (-51.52%)` | :arrow_down: |
| [core/src/env2/test/typed\_encoded.rs](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree#diff-Y29yZS9zcmMvZW52Mi90ZXN0L3R5cGVkX2VuY29kZWQucnM=) | | |
| [lang/src/gen/test.rs](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree#diff-bGFuZy9zcmMvZ2VuL3Rlc3QucnM=) | | |
| [core/src/storage/collections/bitvec/block.rs](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree#diff-Y29yZS9zcmMvc3RvcmFnZS9jb2xsZWN0aW9ucy9iaXR2ZWMvYmxvY2sucnM=) | | |
| [lang/src/tests/mod.rs](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree#diff-bGFuZy9zcmMvdGVzdHMvbW9kLnJz) | | |
| [lang/src/parser.rs](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree#diff-bGFuZy9zcmMvcGFyc2VyLnJz) | | |
| [lang/src/hir.rs](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree#diff-bGFuZy9zcmMvaGlyLnJz) | | |
| [core/src/storage/collections/bitvec/pack.rs](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree#diff-Y29yZS9zcmMvc3RvcmFnZS9jb2xsZWN0aW9ucy9iaXR2ZWMvcGFjay5ycw==) | | |
| [core/src/byte\_utils.rs](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree#diff-Y29yZS9zcmMvYnl0ZV91dGlscy5ycw==) | | |
| [core/derive/tests/compile\_tests.rs](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree#diff-Y29yZS9kZXJpdmUvdGVzdHMvY29tcGlsZV90ZXN0cy5ycw==) | | |
| ... and [36 more](https://codecov.io/gh/paritytech/ink/pull/285/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/paritytech/ink/pull/285?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/paritytech/ink/pull/285?src=pr&el=footer). Last update [19fe191...06659ae](https://codecov.io/gh/paritytech/ink/pull/285?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/abi/Cargo.toml b/abi/Cargo.toml
index e2751aacbc..e768b2b622 100644
--- a/abi/Cargo.toml
+++ b/abi/Cargo.toml
@@ -17,7 +17,8 @@ include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
 [dependencies]
 serde = { version = "1.0", default-features = false, features = ["derive", "alloc"] }
 derive_more = { version = "0.99.2", default-features = false, features = ["from"] }
-ink_abi_derive = { version = "0.1.0", path = "derive", default-features = false, optional = true }
+ink_abi_derive = { path = "derive", default-features = false, optional = true }
+ink_prelude = { path = "../prelude/", default-features = false }
 type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"] }
 
 [dev-dependencies]
@@ -30,6 +31,7 @@ default = [
 ]
 std = [
     "ink_abi_derive/std",
+    "ink_prelude/std",
     "serde/std",
     "type-metadata/std",
 ]
diff --git a/core/Cargo.toml b/core/Cargo.toml
index c7c2bd1496..027992c873 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -18,7 +18,8 @@ include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
 ink_abi = { path = "../abi/", default-features = false, features = ["derive"], optional = true }
 ink_alloc = { path = "../alloc/", default-features = false }
 ink_utils = { path = "../utils/" }
-ink_core_derive = { version = "0.1.0", path = "derive", default-features = false }
+ink_core_derive = { path = "derive", default-features = false }
+ink_prelude = { path = "../prelude/", default-features = false }
 
 scale = { package = "parity-scale-codec", version = "1.1", default-features = false, features = ["derive", "full"] }
 type-metadata = { git = "https://github.com/type-metadata/type-metadata.git", default-features = false, features = ["derive"], optional = true }
@@ -34,6 +35,7 @@ test-env = [
 std = [
     "ink_abi/std",
     "ink_alloc/std",
+    "ink_prelude/std",
     "scale/std",
     "type-metadata/std",
 ]
diff --git a/core/src/env/api.rs b/core/src/env/api.rs
index 7bdf51ddd5..377bb78bd4 100644
--- a/core/src/env/api.rs
+++ b/core/src/env/api.rs
@@ -28,9 +28,9 @@ use crate::{
         CreateError,
         EnvStorage as _,
     },
-    memory::vec::Vec,
     storage::Key,
 };
+use ink_prelude::vec::Vec;
 
 /// Stores the given value under the specified key in the contract storage.
 ///
diff --git a/core/src/env/calls.rs b/core/src/env/calls.rs
index e54f38402d..ba42cd33c8 100644
--- a/core/src/env/calls.rs
+++ b/core/src/env/calls.rs
@@ -16,18 +16,16 @@ use core::marker::PhantomData;
 
 use scale::Decode;
 
-use crate::{
-    env::{
-        self,
-        CallError,
-        CreateError,
-        Env,
-        EnvTypes,
-    },
-    memory::{
-        vec,
-        vec::Vec,
-    },
+use crate::env::{
+    self,
+    CallError,
+    CreateError,
+    Env,
+    EnvTypes,
+};
+use ink_prelude::{
+    vec,
+    vec::Vec,
 };
 
 /// Consists of the input data to a call.
diff --git a/core/src/env/srml/srml_only/impls.rs b/core/src/env/srml/srml_only/impls.rs
index 49d1d5d268..38253cb765 100644
--- a/core/src/env/srml/srml_only/impls.rs
+++ b/core/src/env/srml/srml_only/impls.rs
@@ -28,9 +28,9 @@ use crate::{
         EnvStorage,
         EnvTypes,
     },
-    memory::vec::Vec,
     storage::Key,
 };
+use ink_prelude::vec::Vec;
 
 /// Load the contents of the scratch buffer
 fn read_scratch_buffer() -> Vec<u8> {
diff --git a/core/src/env/traits.rs b/core/src/env/traits.rs
index 3eadb68161..aa26e35026 100644
--- a/core/src/env/traits.rs
+++ b/core/src/env/traits.rs
@@ -17,10 +17,8 @@ use scale::{
     Decode,
 };
 
-use crate::{
-    memory::vec::Vec,
-    storage::Key,
-};
+use crate::storage::Key;
+use ink_prelude::vec::Vec;
 
 /// Error encountered by calling a remote contract.
 ///
diff --git a/core/src/env2/buffer_arena.rs b/core/src/env2/buffer_arena.rs
index 1de3a1622c..1aeff4ae01 100644
--- a/core/src/env2/buffer_arena.rs
+++ b/core/src/env2/buffer_arena.rs
@@ -23,18 +23,16 @@
 //! Users and systems are advised to share a common set of allocated buffers
 //! provided by the global buffer arena.
 
-use crate::{
-    env2::utils::{
-        EnlargeTo,
-        Reset,
-    },
-    memory::vec::Vec,
+use crate::env2::utils::{
+    EnlargeTo,
+    Reset,
 };
 use cfg_if::cfg_if;
 use core::cell::{
     Cell,
     RefCell,
 };
+use ink_prelude::vec::Vec;
 
 /// The maximum amount of used byte buffers at the same time.
 ///
diff --git a/core/src/env2/call/builder.rs b/core/src/env2/call/builder.rs
index 34dbd63837..f4ba0453f5 100644
--- a/core/src/env2/call/builder.rs
+++ b/core/src/env2/call/builder.rs
@@ -14,20 +14,18 @@
 
 use core::marker::PhantomData;
 
-use crate::{
-    env2::{
-        call::{
-            state,
-            CallData,
-            Selector,
-        },
-        errors::CallError,
-        Env,
-        EnvAccessMut,
-        EnvTypes,
+use crate::env2::{
+    call::{
+        state,
+        CallData,
+        Selector,
     },
-    memory::vec::Vec,
+    errors::CallError,
+    Env,
+    EnvAccessMut,
+    EnvTypes,
 };
+use ink_prelude::vec::Vec;
 
 /// Represents a return type.
 ///
diff --git a/core/src/env2/call/create.rs b/core/src/env2/call/create.rs
index e0458d8c54..4857c1a588 100644
--- a/core/src/env2/call/create.rs
+++ b/core/src/env2/call/create.rs
@@ -14,19 +14,17 @@
 
 use core::marker::PhantomData;
 
-use crate::{
-    env2::{
-        call::{
-            CallData,
-            Selector,
-        },
-        errors::CreateError,
-        Env,
-        EnvAccessMut,
-        EnvTypes,
+use crate::env2::{
+    call::{
+        CallData,
+        Selector,
     },
-    memory::vec::Vec,
+    errors::CreateError,
+    Env,
+    EnvAccessMut,
+    EnvTypes,
 };
+use ink_prelude::vec::Vec;
 
 pub mod state {
     pub use crate::env2::call::state::{
diff --git a/core/src/env2/call/utils.rs b/core/src/env2/call/utils.rs
index f8249baa8f..edcf8344b9 100644
--- a/core/src/env2/call/utils.rs
+++ b/core/src/env2/call/utils.rs
@@ -13,8 +13,7 @@
 // limitations under the License.
 
 use derive_more::From;
-
-use crate::memory::{
+use ink_prelude::{
     vec,
     vec::Vec,
 };
diff --git a/core/src/env2/env_access/mutable.rs b/core/src/env2/env_access/mutable.rs
index eabcfa0f56..cdee00312c 100644
--- a/core/src/env2/env_access/mutable.rs
+++ b/core/src/env2/env_access/mutable.rs
@@ -30,7 +30,6 @@ use crate::{
         SetProperty,
         Topics,
     },
-    memory::vec::Vec,
     storage::{
         alloc::{
             Allocate,
@@ -41,6 +40,7 @@ use crate::{
         Key,
     },
 };
+use ink_prelude::vec::Vec;
 
 #[cfg_attr(feature = "ink-generate-abi", derive(type_metadata::Metadata))]
 #[derive(Debug)]
diff --git a/core/src/env2/types.rs b/core/src/env2/types.rs
index ffb55ca252..b21205e02e 100644
--- a/core/src/env2/types.rs
+++ b/core/src/env2/types.rs
@@ -35,9 +35,9 @@ use type_metadata::Metadata;
 
 use crate::{
     env2::EnvTypes,
-    memory::vec::Vec,
     storage::Flush,
 };
+use ink_prelude::vec::Vec;
 
 /// The fundamental types of the SRML default configuration.
 #[cfg_attr(feature = "test-env", derive(Debug, Clone, PartialEq, Eq))]
diff --git a/core/src/env2/utils.rs b/core/src/env2/utils.rs
index 069e357278..c0d8ee0b4c 100644
--- a/core/src/env2/utils.rs
+++ b/core/src/env2/utils.rs
@@ -14,13 +14,12 @@
 
 //! Utility definitions used for environmental access.
 
+use ink_prelude::vec::Vec;
 use smallvec::{
     Array,
     SmallVec,
 };
 
-use crate::memory::vec::Vec;
-
 /// Buffers that allow to reset themselves.
 ///
 /// # Note
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 4ee56a2981..6421b9156e 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -47,16 +47,12 @@
 #[cfg(not(feature = "std"))]
 extern crate ink_alloc;
 
-#[cfg(not(feature = "std"))]
-extern crate alloc;
-
 #[cfg(all(test, feature = "std"))]
 mod test_utils;
 
 mod byte_utils;
 pub mod env;
 pub mod env2;
-pub mod memory;
 pub mod storage;
 
 // Needed for derive macros of `core/derive` sub crate.
diff --git a/core/src/memory.rs b/core/src/memory.rs
deleted file mode 100644
index 003b618571..0000000000
--- a/core/src/memory.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2018-2019 Parity Technologies (UK) Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-//! Data structures to operate on main memory.
-//!
-//! These definitions are useful since we are operating in a `no_std` environment.
-
-#[cfg(not(feature = "std"))]
-mod no_std_defs {
-    pub use alloc::{
-        borrow,
-        boxed,
-        format,
-        string,
-        vec,
-    };
-
-    /// Collection types.
-    pub mod collections {
-        pub use self::{
-            BTreeMap,
-            BTreeSet,
-            BinaryHeap,
-            LinkedList,
-            VecDeque,
-        };
-        pub use alloc::collections::*;
-        pub use core::ops::Bound;
-    }
-}
-
-#[cfg(feature = "std")]
-mod std_defs {
-    pub use std::{
-        borrow,
-        boxed,
-        format,
-        string,
-        vec,
-    };
-
-    /// Collection types.
-    pub mod collections {
-        pub use self::{
-            binary_heap::BinaryHeap,
-            btree_map::BTreeMap,
-            btree_set::BTreeSet,
-            linked_list::LinkedList,
-            vec_deque::VecDeque,
-            Bound,
-        };
-        pub use std::collections::*;
-    }
-}
-
-#[cfg(not(feature = "std"))]
-#[doc(inline)]
-pub use self::no_std_defs::*;
-
-#[cfg(feature = "std")]
-#[doc(inline)]
-pub use self::std_defs::*;
diff --git a/core/src/storage/cell/raw_cell.rs b/core/src/storage/cell/raw_cell.rs
index 9fd8178f81..0fd548487b 100644
--- a/core/src/storage/cell/raw_cell.rs
+++ b/core/src/storage/cell/raw_cell.rs
@@ -12,14 +12,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-use scale::{
-    Decode,
-    Encode,
-};
-
 use crate::{
     env,
-    memory::vec::Vec,
     storage::{
         alloc::{
             Allocate,
@@ -29,6 +23,11 @@ use crate::{
         NonCloneMarker,
     },
 };
+use ink_prelude::vec::Vec;
+use scale::{
+    Decode,
+    Encode,
+};
 
 /// A raw cell.
 ///
diff --git a/core/src/storage/cell/sync_cell.rs b/core/src/storage/cell/sync_cell.rs
index 605ced25b4..640cfe688f 100644
--- a/core/src/storage/cell/sync_cell.rs
+++ b/core/src/storage/cell/sync_cell.rs
@@ -30,18 +30,16 @@ use type_metadata::{
     TypeId,
 };
 
-use crate::{
-    memory::boxed::Box,
-    storage::{
-        alloc::{
-            Allocate,
-            AllocateUsing,
-        },
-        cell::TypedCell,
-        Flush,
-        Key,
+use crate::storage::{
+    alloc::{
+        Allocate,
+        AllocateUsing,
     },
+    cell::TypedCell,
+    Flush,
+    Key,
 };
+use ink_prelude::boxed::Box;
 
 /// A synchronized cell.
 ///
diff --git a/core/src/storage/chunk/raw_chunk.rs b/core/src/storage/chunk/raw_chunk.rs
index 78a4c339d1..cbafe82ca3 100644
--- a/core/src/storage/chunk/raw_chunk.rs
+++ b/core/src/storage/chunk/raw_chunk.rs
@@ -14,7 +14,6 @@
 
 use crate::{
     env,
-    memory::vec::Vec,
     storage::{
         alloc::{
             Allocate,
@@ -24,6 +23,7 @@ use crate::{
         NonCloneMarker,
     },
 };
+use ink_prelude::vec::Vec;
 
 /// A chunk of raw cells.
 ///
diff --git a/core/src/storage/chunk/sync_chunk/cache.rs b/core/src/storage/chunk/sync_chunk/cache.rs
index dd919150b1..0b55cf423b 100644
--- a/core/src/storage/chunk/sync_chunk/cache.rs
+++ b/core/src/storage/chunk/sync_chunk/cache.rs
@@ -13,8 +13,7 @@
 // limitations under the License.
 
 use core::cell::RefCell;
-
-use crate::memory::collections::btree_map::{
+use ink_prelude::collections::btree_map::{
     BTreeMap,
     Entry,
 };
diff --git a/core/src/storage/flush.rs b/core/src/storage/flush.rs
index 72525d60ea..daa9b67b1f 100644
--- a/core/src/storage/flush.rs
+++ b/core/src/storage/flush.rs
@@ -154,7 +154,7 @@ where
     }
 }
 
-impl<T> Flush for crate::memory::vec::Vec<T>
+impl<T> Flush for ink_prelude::vec::Vec<T>
 where
     T: Flush,
 {
@@ -165,9 +165,9 @@ where
     }
 }
 
-impl Flush for crate::memory::string::String {}
+impl Flush for ink_prelude::string::String {}
 
-impl<K, V> Flush for crate::memory::collections::btree_map::BTreeMap<K, V>
+impl<K, V> Flush for ink_prelude::collections::btree_map::BTreeMap<K, V>
 where
     V: Flush,
 {
@@ -179,9 +179,9 @@ where
     }
 }
 
-impl<T> Flush for crate::memory::collections::btree_set::BTreeSet<T> {}
+impl<T> Flush for ink_prelude::collections::btree_set::BTreeSet<T> {}
 
-impl<T> Flush for crate::memory::collections::linked_list::LinkedList<T>
+impl<T> Flush for ink_prelude::collections::linked_list::LinkedList<T>
 where
     T: Flush,
 {
@@ -192,7 +192,7 @@ where
     }
 }
 
-impl<T> Flush for crate::memory::collections::vec_deque::VecDeque<T>
+impl<T> Flush for ink_prelude::collections::vec_deque::VecDeque<T>
 where
     T: Flush,
 {
@@ -203,4 +203,4 @@ where
     }
 }
 
-impl<T> Flush for crate::memory::collections::binary_heap::BinaryHeap<T> {}
+impl<T> Flush for ink_prelude::collections::binary_heap::BinaryHeap<T> {}
diff --git a/examples/lang/delegator/accumulator/src/lib.rs b/examples/lang/delegator/accumulator/src/lib.rs
index 096428ae14..a40628ba06 100644
--- a/examples/lang/delegator/accumulator/src/lib.rs
+++ b/examples/lang/delegator/accumulator/src/lib.rs
@@ -14,11 +14,9 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use ink_core::{
-    memory::format,
-    storage,
-};
+use ink_core::storage;
 use ink_lang::contract;
+use ink_prelude::format;
 
 contract! {
     #![env = ink_core::env::DefaultSrmlTypes]
diff --git a/examples/lang/delegator/adder/src/lib.rs b/examples/lang/delegator/adder/src/lib.rs
index 9a1d69e5ea..75121fb6a1 100644
--- a/examples/lang/delegator/adder/src/lib.rs
+++ b/examples/lang/delegator/adder/src/lib.rs
@@ -14,11 +14,9 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use ink_core::{
-    memory::format,
-    storage,
-};
+use ink_core::storage;
 use ink_lang::contract;
+use ink_prelude::format;
 
 contract! {
     #![env = ink_core::env::DefaultSrmlTypes]
diff --git a/examples/lang/delegator/src/lib.rs b/examples/lang/delegator/src/lib.rs
index 800f377df0..2c252aa818 100644
--- a/examples/lang/delegator/src/lib.rs
+++ b/examples/lang/delegator/src/lib.rs
@@ -14,11 +14,9 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use ink_core::{
-    memory::format,
-    storage,
-};
+use ink_core::storage;
 use ink_lang::contract;
+use ink_prelude::format;
 
 #[derive(Debug, Copy, Clone, PartialEq, Eq, scale::Encode, scale::Decode)]
 #[cfg_attr(feature = "ink-generate-abi", derive(type_metadata::Metadata))]
diff --git a/examples/lang/delegator/subber/src/lib.rs b/examples/lang/delegator/subber/src/lib.rs
index 660c0b9439..0aced33363 100644
--- a/examples/lang/delegator/subber/src/lib.rs
+++ b/examples/lang/delegator/subber/src/lib.rs
@@ -14,11 +14,9 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use ink_core::{
-    memory::format,
-    storage,
-};
+use ink_core::storage;
 use ink_lang::contract;
+use ink_prelude::format;
 
 contract! {
     #![env = ink_core::env::DefaultSrmlTypes]
diff --git a/examples/lang/erc20/src/lib.rs b/examples/lang/erc20/src/lib.rs
index 4110755d0b..a10495c203 100644
--- a/examples/lang/erc20/src/lib.rs
+++ b/examples/lang/erc20/src/lib.rs
@@ -16,11 +16,11 @@
 
 use ink_core::{
     env::DefaultSrmlTypes,
-    memory::format,
     storage,
 };
 use ink_lang::contract;
 use ink_model::EnvHandler;
+use ink_prelude::format;
 
 contract! {
     #![env = DefaultSrmlTypes]
diff --git a/examples/lang/erc721/src/lib.rs b/examples/lang/erc721/src/lib.rs
index 9970524cd0..d3a698a316 100644
--- a/examples/lang/erc721/src/lib.rs
+++ b/examples/lang/erc721/src/lib.rs
@@ -17,11 +17,11 @@
 use core::result::Result;
 use ink_core::{
     env::DefaultSrmlTypes,
-    memory::format,
     storage,
 };
 use ink_lang::contract;
 use ink_model;
+use ink_prelude::format;
 use scale::{
     Decode,
     Encode,
diff --git a/examples/lang/flipper/src/lib.rs b/examples/lang/flipper/src/lib.rs
index ae90c00069..e03172695d 100644
--- a/examples/lang/flipper/src/lib.rs
+++ b/examples/lang/flipper/src/lib.rs
@@ -16,10 +16,10 @@
 
 use ink_core::{
     env::DefaultSrmlTypes,
-    memory::format,
     storage,
 };
 use ink_lang::contract;
+use ink_prelude::format;
 
 contract! {
     #![env = DefaultSrmlTypes]
diff --git a/examples/lang/incrementer/src/lib.rs b/examples/lang/incrementer/src/lib.rs
index dcf2052823..d09c659171 100644
--- a/examples/lang/incrementer/src/lib.rs
+++ b/examples/lang/incrementer/src/lib.rs
@@ -14,11 +14,9 @@
 
 #![cfg_attr(not(feature = "std"), no_std)]
 
-use ink_core::{
-    memory::format,
-    storage,
-};
+use ink_core::storage;
 use ink_lang::contract;
+use ink_prelude::format;
 
 contract! {
     #![env = ink_core::env::DefaultSrmlTypes]
diff --git a/lang/Cargo.toml b/lang/Cargo.toml
index 7ab086d049..f05713e600 100644
--- a/lang/Cargo.toml
+++ b/lang/Cargo.toml
@@ -17,6 +17,7 @@ include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
 [dependencies]
 ink_utils = { path = "../utils/" }
 ink_model = { path = "../model/", default-features = false }
+ink_prelude = { path = "../prelude/", default-features = false }
 scale = { package = "parity-scale-codec", version = "1.1", default-features = false, features = ["derive"] }
 
 quote = "1.0"
@@ -43,6 +44,7 @@ test-env = [
 ]
 std = [
     "ink_model/std",
+    "ink_prelude/std",
     "scale/std",
     "itertools/use_std",
     "either/use_std",
diff --git a/lang2/Cargo.toml b/lang2/Cargo.toml
index db7386dcce..dc9c7a45de 100644
--- a/lang2/Cargo.toml
+++ b/lang2/Cargo.toml
@@ -15,9 +15,10 @@ categories = ["no-std", "embedded"]
 include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
 
 [dependencies]
-ink_core = { version = "0.1", path = "../core", default-features = false }
-ink_abi = { version = "0.1", path = "../abi", default-features = false, optional = true }
-ink_lang2_macro = { version = "0.1.0", path = "macro", default-features = false }
+ink_core = { path = "../core", default-features = false }
+ink_abi = { path = "../abi", default-features = false, optional = true }
+ink_prelude = { path = "../prelude/", default-features = false }
+ink_lang2_macro = { path = "macro", default-features = false }
 
 scale = { package = "parity-scale-codec", version = "1.1", default-features = false, features = ["derive", "full"] }
 derive_more = { version = "0.99.2", default-features = false, features = ["from"] }
@@ -31,6 +32,7 @@ test-env = [
 ]
 std = [
     "ink_abi/std",
+    "ink_prelude/std",
     "ink_core/std",
     "ink_lang2_macro/std",
     "scale/std",
diff --git a/model/Cargo.toml b/model/Cargo.toml
index 1c85a77f2e..4a29b1cf25 100644
--- a/model/Cargo.toml
+++ b/model/Cargo.toml
@@ -15,15 +15,17 @@ include = ["Cargo.toml", "src/**/*.rs", "README.md", "LICENSE"]
 
 [dependencies]
 ink_core = { path = "../core", default-features = false }
+ink_prelude = { path = "../prelude/", default-features = false }
 scale = { package = "parity-scale-codec", version = "1.1", default-features = false, features = ["derive", "full"] }
 
 [features]
 default = ["test-env"]
 test-env = [
-	"std",
-	"ink_core/test-env",
+    "std",
+    "ink_core/test-env",
 ]
 std = [
-	"ink_core/std",
-	"scale/std",
+    "ink_core/std",
+    "ink_prelude/std",
+    "scale/std",
 ]
diff --git a/model/src/contract.rs b/model/src/contract.rs
index cf1b4ab4fb..be35355caf 100644
--- a/model/src/contract.rs
+++ b/model/src/contract.rs
@@ -14,10 +14,8 @@
 
 use core::marker::PhantomData;
 
-use ink_core::{
-    env,
-    memory::vec::Vec,
-};
+use ink_core::env;
+use ink_prelude::vec::Vec;
 
 use crate::{
     exec_env::ExecutionEnv,
diff --git a/model/src/msg_handler.rs b/model/src/msg_handler.rs
index 0c7f5a082c..55876431a8 100644
--- a/model/src/msg_handler.rs
+++ b/model/src/msg_handler.rs
@@ -17,10 +17,8 @@ use core::{
     result::Result as CoreResult,
 };
 
-use ink_core::{
-    env,
-    memory::vec::Vec,
-};
+use ink_core::env;
+use ink_prelude::vec::Vec;
 use scale::Decode;
 
 use crate::{
diff --git a/prelude/lib.rs b/prelude/lib.rs
index 09368c1291..623a32c0ac 100644
--- a/prelude/lib.rs
+++ b/prelude/lib.rs
@@ -20,6 +20,8 @@
 //!
 //! The `ink_prelude` crate guarantees a stable interface between `std` and `no_std` mode.
 
+#![cfg_attr(not(feature = "std"), no_std)]
+
 #[cfg(not(feature = "std"))]
 extern crate alloc;
 


Test patch:
diff --git a/core/src/env/test_env.rs b/core/src/env/test_env.rs
index bdd3ee5458..d5e4bdfe26 100644
--- a/core/src/env/test_env.rs
+++ b/core/src/env/test_env.rs
@@ -29,12 +29,12 @@ use crate::{
         CallError,
         EnvTypes,
     },
-    memory::collections::hash_map::{
-        Entry,
-        HashMap,
-    },
     storage::Key,
 };
+use ink_prelude::collections::hash_map::{
+    Entry,
+    HashMap,
+};
 
 /// A wrapper for the generic bytearray used for data in contract events.
 #[derive(Debug, Clone, PartialEq, Eq)]
diff --git a/core/src/env2/test/account.rs b/core/src/env2/test/account.rs
index 788a3fc13c..d59ca75ee2 100644
--- a/core/src/env2/test/account.rs
+++ b/core/src/env2/test/account.rs
@@ -23,14 +23,12 @@
 
 use core::borrow::Borrow;
 
-use crate::{
-    env2::test::{
-        storage::Storage,
-        types::*,
-        TypedEncoded,
-    },
-    memory::collections::btree_map::BTreeMap,
+use crate::env2::test::{
+    storage::Storage,
+    types::*,
+    TypedEncoded,
 };
+use ink_prelude::collections::btree_map::BTreeMap;
 
 /// The on-chain registered accounts.
 ///
diff --git a/core/src/env2/test/record.rs b/core/src/env2/test/record.rs
index 71f561b201..61d0dec82e 100644
--- a/core/src/env2/test/record.rs
+++ b/core/src/env2/test/record.rs
@@ -39,9 +39,9 @@ use crate::{
         EnvTypes,
         Topics,
     },
-    memory::vec::Vec,
     storage::Key,
 };
+use ink_prelude::vec::Vec;
 
 /// A record of an event happening on the off-chain test environment.
 ///
diff --git a/core/src/env2/test/storage.rs b/core/src/env2/test/storage.rs
index 53223b56ec..b8a8c4464f 100644
--- a/core/src/env2/test/storage.rs
+++ b/core/src/env2/test/storage.rs
@@ -20,12 +20,10 @@
 
 use core::cell::Cell;
 
-use crate::{
-    memory::collections::btree_map::{
-        self,
-        BTreeMap,
-    },
-    storage::Key,
+use crate::storage::Key;
+use ink_prelude::collections::btree_map::{
+    self,
+    BTreeMap,
 };
 
 /// An entry in the storage of the test environment.