Merge pull request #117 from torfmaster/feature/cargo_test

Fix some old toolchain problems
diff --git a/.cargo/config b/.cargo/config
index 973dfb5..818ce68 100644
--- a/.cargo/config
+++ b/.cargo/config
@@ -12,3 +12,15 @@
   "-C", "relocation-model=static",
   "-D", "warnings",
 ]
+
+# Target configuration for the travis CI Linux build
+[target.x86_64-unknown-linux-gnu]
+rustflags = [
+  "-D", "warnings",
+]
+
+# Target configuration for the travis CI OS-X build
+[target.x86_64-apple-darwin]
+rustflags = [
+  "-D", "warnings",
+]
diff --git a/.travis.yml b/.travis.yml
index b3eadc1..55492aa 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,5 +15,5 @@
 
 script:
   - cargo fmt --all -- --check
-  - cargo test --lib --all
+  - cargo test --workspace
   - ./build_examples.sh
diff --git a/.vscode/settings.json b/.vscode/settings.json
index a2d71f6..d14867b 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,5 +1,4 @@
 {
     "editor.formatOnSave": true,
-    "rust.target": "thumbv7em-none-eabi",
-    "rust.all_targets": false,
+    "rust.all_targets": true,
 }
\ No newline at end of file
diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs
index c346eab..c97ae32 100644
--- a/codegen/src/lib.rs
+++ b/codegen/src/lib.rs
@@ -12,10 +12,18 @@
 /// Procedural attribute macro. This is meant to be applied to a binary's async
 /// `main()`, transforming into a function that returns a type acceptable for
 /// `main()`. In other words, this will not compile with libtock-rs:
-///     async fn main() {}
+/// ```ignore
+/// async fn main() {
+///     // async code
+/// }
+/// ```
 /// and this will:
-///     #[libtock::main]
-///     async fn main() {}
+/// ```ignore
+/// #[libtock::main]
+/// async fn main() {
+///     // async code
+/// }
+/// ```
 #[proc_macro_attribute]
 pub fn main(_: TokenStream, input: TokenStream) -> TokenStream {
     generate_main_wrapped(input.into()).into()
diff --git a/src/ble_composer.rs b/src/ble_composer.rs
index 33780b6..1701ec5 100644
--- a/src/ble_composer.rs
+++ b/src/ble_composer.rs
@@ -78,7 +78,7 @@
     #[test]
     fn test_add() {
         let mut pld = BlePayload::new();
-        pld.add(1, &[2]);
+        pld.add(1, &[2]).unwrap();
         assert_eq!(pld.as_ref().len(), 3);
         assert_eq!(pld.as_ref(), &mut [2, 1, 2])
     }
@@ -86,15 +86,15 @@
     #[test]
     fn test_add_service_payload() {
         let mut pld = BlePayload::new();
-        pld.add_service_payload([1, 2], &[2]);
+        pld.add_service_payload([1, 2], &[2]).unwrap();
         assert_eq!(pld.as_ref(), &[4, 0x16, 1, 2, 2])
     }
 
     #[test]
     fn test_add_service_payload_two_times() {
         let mut pld = BlePayload::new();
-        pld.add_service_payload([1, 2], &[2]);
-        pld.add_service_payload([1, 2], &[2, 3]);
+        pld.add_service_payload([1, 2], &[2]).unwrap();
+        pld.add_service_payload([1, 2], &[2, 3]).unwrap();
 
         assert_eq!(pld.as_ref(), &[4, 0x16, 1, 2, 2, 5, 0x16, 1, 2, 2, 3])
     }
diff --git a/src/lib.rs b/src/lib.rs
index 6d49e29..ae46436 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,9 +6,7 @@
     naked_functions,
     ptr_offset_from
 )]
-#![no_std]
-
-extern crate alloc;
+#![cfg_attr(any(target_arch = "arm", target_arch = "riscv32"), no_std)]
 
 mod callback;
 
@@ -31,7 +29,6 @@
 pub mod temperature;
 pub mod timer;
 pub mod unwind_symbols;
-pub use libtock_codegen::main;
 
 #[cfg(any(target_arch = "arm", target_arch = "riscv32"))]
 pub mod entry_point;
@@ -41,6 +38,8 @@
 
 pub mod syscalls;
 
+pub use libtock_codegen::main;
+
 // Dummy structure to force importing the panic_handler and other no_std elements when nothing else
 // is imported.
 pub struct LibTock;
diff --git a/src/result.rs b/src/result.rs
index a7f40e1..9b26c31 100644
--- a/src/result.rs
+++ b/src/result.rs
@@ -11,6 +11,13 @@
     Other(OtherError),
 }
 
+#[cfg(not(any(target_arch = "arm", target_arch = "riscv32")))]
+impl core::fmt::Debug for TockError {
+    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
+        writeln!(f, "impl Debug only for test builds")
+    }
+}
+
 #[derive(Copy, Clone)]
 pub struct SubscribeError {
     pub driver_number: usize,
diff --git a/src/temperature.rs b/src/temperature.rs
index e50cbe2..28e366f 100644
--- a/src/temperature.rs
+++ b/src/temperature.rs
@@ -51,8 +51,6 @@
 #[cfg(test)]
 mod test {
     use super::*;
-    use alloc::string::String;
-    use alloc::string::ToString;
 
     #[test]
     fn render_temperature() {