From 61db54c44705488188340e97a0d3f8e785d6e767 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 18 Jan 2018 22:05:51 -0800 Subject: [PATCH] Add support for running tests in `no_std` mode. --- README.rst | 10 ++++--- cranelift/test-no_std.sh | 28 ++++++++++++++++++++ lib/cretonne/src/bforest/map.rs | 7 +++-- lib/cretonne/src/bforest/node.rs | 1 + lib/cretonne/src/bforest/pool.rs | 1 + lib/cretonne/src/bforest/set.rs | 4 ++- lib/cretonne/src/dbg.rs | 2 ++ lib/cretonne/src/flowgraph.rs | 1 + lib/cretonne/src/ir/condcodes.rs | 1 + lib/cretonne/src/ir/dfg.rs | 1 + lib/cretonne/src/ir/entities.rs | 1 + lib/cretonne/src/ir/extfunc.rs | 1 + lib/cretonne/src/ir/extname.rs | 1 + lib/cretonne/src/ir/immediates.rs | 1 + lib/cretonne/src/ir/instructions.rs | 1 + lib/cretonne/src/ir/jumptable.rs | 2 ++ lib/cretonne/src/ir/layout.rs | 1 + lib/cretonne/src/ir/libcall.rs | 1 + lib/cretonne/src/ir/progpoint.rs | 1 + lib/cretonne/src/ir/sourceloc.rs | 1 + lib/cretonne/src/ir/stackslot.rs | 1 + lib/cretonne/src/ir/trapcode.rs | 1 + lib/cretonne/src/ir/types.rs | 1 + lib/cretonne/src/isa/arm32/registers.rs | 1 + lib/cretonne/src/isa/arm64/registers.rs | 1 + lib/cretonne/src/isa/intel/registers.rs | 1 + lib/cretonne/src/isa/riscv/mod.rs | 1 + lib/cretonne/src/isa/riscv/registers.rs | 1 + lib/cretonne/src/isa/riscv/settings.rs | 1 + lib/cretonne/src/iterators.rs | 2 ++ lib/cretonne/src/lib.rs | 1 - lib/cretonne/src/loop_analysis.rs | 1 + lib/cretonne/src/partition_slice.rs | 1 + lib/cretonne/src/regalloc/allocatable_set.rs | 1 + lib/cretonne/src/regalloc/coalescing.rs | 2 -- lib/cretonne/src/regalloc/liverange.rs | 1 + lib/cretonne/src/regalloc/pressure.rs | 1 + lib/cretonne/src/regalloc/solver.rs | 1 + lib/cretonne/src/settings.rs | 1 + lib/cretonne/src/timing.rs | 1 + lib/cretonne/src/verifier/mod.rs | 3 +++ lib/cretonne/src/write.rs | 1 + lib/frontend/src/ssa.rs | 21 ++++++++++++--- 43 files changed, 101 insertions(+), 13 deletions(-) create mode 100755 cranelift/test-no_std.sh diff --git a/README.rst b/README.rst index e9c9b568d9..690472578b 100644 --- a/README.rst +++ b/README.rst @@ -74,11 +74,13 @@ Or, when using `cretonne` as a dependency (in Cargo.toml): path = "..." features = ["no_std"] -Currently, tests don't test the `no_std` feature: +`no_std` is currently "best effort". We won't try to break it, and we'll +accept patches fixing problems, however we don't expect all developers to +build and test with `no_std` when submitting patches. Accordingly, the +`./test-all.sh` script does not test `no_std`. -1. `cargo test --features no_std` won't compile. - -2. `./test-all.sh` doesn't test the `no_std` feature. +There is a separate `./test-no_std.sh` script that tests the `no_std` +feature in packages which support it. It's important to note that cretonne still needs liballoc to compile. Thus, whatever environment is used must implement an allocator. diff --git a/cranelift/test-no_std.sh b/cranelift/test-no_std.sh new file mode 100755 index 0000000000..c9d3fe38f7 --- /dev/null +++ b/cranelift/test-no_std.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# This is the test script for testing the no_std configuration of +# packages which support it. + +# Exit immediately on errors. +set -e + +# Repository top-level directory. +cd $(dirname "$0") +topdir=$(pwd) + +function banner() { + echo "====== $@ ======" +} + +# Test those packages which have no_std support. +LIBS="cretonne frontend wasm native" +cd "$topdir" +for LIB in $LIBS +do + banner "Rust unit tests in $LIB" + cd "lib/$LIB" + cargo test --features no_std + cd "$topdir" +done + +banner "OK" diff --git a/lib/cretonne/src/bforest/map.rs b/lib/cretonne/src/bforest/map.rs index 5aa19bceda..073f27529b 100644 --- a/lib/cretonne/src/bforest/map.rs +++ b/lib/cretonne/src/bforest/map.rs @@ -222,7 +222,8 @@ where } /// Get a text version of the path to `key`. - fn tpath(&self, key: K, forest: &MapForest, comp: &C) -> String { + fn tpath(&self, key: K, forest: &MapForest, comp: &C) -> ::std::string::String { + use std::string::ToString; match self.root.expand() { None => "map(empty)".to_string(), Some(root) => { @@ -415,7 +416,8 @@ where } /// Get a text version of the path to the current position. - fn tpath(&self) -> String { + fn tpath(&self) -> ::std::string::String { + use std::string::ToString; self.path.to_string() } } @@ -423,6 +425,7 @@ where #[cfg(test)] mod test { use std::mem; + use std::vec::Vec; use super::*; use super::super::NodeData; diff --git a/lib/cretonne/src/bforest/node.rs b/lib/cretonne/src/bforest/node.rs index 53a96f9b14..779554f0c8 100644 --- a/lib/cretonne/src/bforest/node.rs +++ b/lib/cretonne/src/bforest/node.rs @@ -580,6 +580,7 @@ where #[cfg(test)] mod test { use std::mem; + use std::string::ToString; use super::*; // Forest impl for a set implementation. diff --git a/lib/cretonne/src/bforest/pool.rs b/lib/cretonne/src/bforest/pool.rs index 37801ee4ab..18c455fdd1 100644 --- a/lib/cretonne/src/bforest/pool.rs +++ b/lib/cretonne/src/bforest/pool.rs @@ -78,6 +78,7 @@ impl NodePool { { use std::borrow::Borrow; use std::cmp::Ordering; + use std::vec::Vec; use super::Comparator; use entity::SparseSet; diff --git a/lib/cretonne/src/bforest/set.rs b/lib/cretonne/src/bforest/set.rs index 6992265773..22f5122c7c 100644 --- a/lib/cretonne/src/bforest/set.rs +++ b/lib/cretonne/src/bforest/set.rs @@ -314,7 +314,8 @@ where } /// Get a text version of the path to the current position. - fn tpath(&self) -> String { + fn tpath(&self) -> ::std::string::String { + use std::string::ToString; self.path.to_string() } } @@ -351,6 +352,7 @@ where #[cfg(test)] mod test { use std::mem; + use std::vec::Vec; use super::*; use super::super::NodeData; diff --git a/lib/cretonne/src/dbg.rs b/lib/cretonne/src/dbg.rs index ace22b6c47..8f949f00e1 100644 --- a/lib/cretonne/src/dbg.rs +++ b/lib/cretonne/src/dbg.rs @@ -19,10 +19,12 @@ use std::fmt; use std::fs::File; #[cfg(not(feature = "no_std"))] use std::io::{self, Write}; +#[cfg(not(feature = "no_std"))] use std::sync::atomic; #[cfg(not(feature = "no_std"))] use std::thread; +#[cfg(not(feature = "no_std"))] static STATE: atomic::AtomicIsize = atomic::ATOMIC_ISIZE_INIT; /// Is debug tracing enabled? diff --git a/lib/cretonne/src/flowgraph.rs b/lib/cretonne/src/flowgraph.rs index d1e45312ac..9c0fa09f26 100644 --- a/lib/cretonne/src/flowgraph.rs +++ b/lib/cretonne/src/flowgraph.rs @@ -204,6 +204,7 @@ mod tests { use super::*; use cursor::{Cursor, FuncCursor}; use ir::{Function, InstBuilder, types}; + use std::vec::Vec; #[test] fn empty() { diff --git a/lib/cretonne/src/ir/condcodes.rs b/lib/cretonne/src/ir/condcodes.rs index 4bbf82cb6f..11c438b10a 100644 --- a/lib/cretonne/src/ir/condcodes.rs +++ b/lib/cretonne/src/ir/condcodes.rs @@ -266,6 +266,7 @@ impl FromStr for FloatCC { #[cfg(test)] mod tests { use super::*; + use std::string::ToString; static INT_ALL: [IntCC; 10] = [ IntCC::Equal, diff --git a/lib/cretonne/src/ir/dfg.rs b/lib/cretonne/src/ir/dfg.rs index 023d8751b6..2f1cc8763b 100644 --- a/lib/cretonne/src/ir/dfg.rs +++ b/lib/cretonne/src/ir/dfg.rs @@ -944,6 +944,7 @@ mod tests { use cursor::{Cursor, FuncCursor}; use ir::types; use ir::{Function, Opcode, InstructionData, TrapCode}; + use std::string::ToString; #[test] fn make_inst() { diff --git a/lib/cretonne/src/ir/entities.rs b/lib/cretonne/src/ir/entities.rs index a9e6705d98..1a4e772be4 100644 --- a/lib/cretonne/src/ir/entities.rs +++ b/lib/cretonne/src/ir/entities.rs @@ -262,6 +262,7 @@ impl From for AnyEntity { mod tests { use super::*; use std::u32; + use std::string::ToString; #[test] fn value_with_number() { diff --git a/lib/cretonne/src/ir/extfunc.rs b/lib/cretonne/src/ir/extfunc.rs index 0aa87fa60e..f8fe767970 100644 --- a/lib/cretonne/src/ir/extfunc.rs +++ b/lib/cretonne/src/ir/extfunc.rs @@ -379,6 +379,7 @@ impl FromStr for CallConv { mod tests { use super::*; use ir::types::{I32, F32, B8}; + use std::string::ToString; #[test] fn argument_type() { diff --git a/lib/cretonne/src/ir/extname.rs b/lib/cretonne/src/ir/extname.rs index f58f8d24ec..b7bcc7d94f 100644 --- a/lib/cretonne/src/ir/extname.rs +++ b/lib/cretonne/src/ir/extname.rs @@ -122,6 +122,7 @@ impl FromStr for ExternalName { mod tests { use super::ExternalName; use ir::LibCall; + use std::string::ToString; #[test] fn display_testcase() { diff --git a/lib/cretonne/src/ir/immediates.rs b/lib/cretonne/src/ir/immediates.rs index 69607754a2..0dca3144cb 100644 --- a/lib/cretonne/src/ir/immediates.rs +++ b/lib/cretonne/src/ir/immediates.rs @@ -630,6 +630,7 @@ mod tests { use std::{f32, f64}; use std::str::FromStr; use std::fmt::Display; + use std::string::ToString; #[test] fn format_imm64() { diff --git a/lib/cretonne/src/ir/instructions.rs b/lib/cretonne/src/ir/instructions.rs index 1340c14055..22800ac634 100644 --- a/lib/cretonne/src/ir/instructions.rs +++ b/lib/cretonne/src/ir/instructions.rs @@ -724,6 +724,7 @@ pub enum ResolvedConstraint { #[cfg(test)] mod tests { use super::*; + use std::string::ToString; #[test] fn opcodes() { diff --git a/lib/cretonne/src/ir/jumptable.rs b/lib/cretonne/src/ir/jumptable.rs index 4f6e117b64..1c7bf79157 100644 --- a/lib/cretonne/src/ir/jumptable.rs +++ b/lib/cretonne/src/ir/jumptable.rs @@ -142,6 +142,8 @@ mod tests { use super::JumpTableData; use ir::Ebb; use entity::EntityRef; + use std::vec::Vec; + use std::string::ToString; #[test] fn empty() { diff --git a/lib/cretonne/src/ir/layout.rs b/lib/cretonne/src/ir/layout.rs index e18ffd7a33..1fc1c048fb 100644 --- a/lib/cretonne/src/ir/layout.rs +++ b/lib/cretonne/src/ir/layout.rs @@ -743,6 +743,7 @@ mod tests { use entity::EntityRef; use ir::{Ebb, Inst, ProgramOrder, SourceLoc}; use std::cmp::Ordering; + use std::vec::Vec; struct LayoutCursor<'f> { /// Borrowed function layout. Public so it can be re-borrowed from this cursor. diff --git a/lib/cretonne/src/ir/libcall.rs b/lib/cretonne/src/ir/libcall.rs index e8c848f71d..85133611be 100644 --- a/lib/cretonne/src/ir/libcall.rs +++ b/lib/cretonne/src/ir/libcall.rs @@ -100,6 +100,7 @@ impl LibCall { #[cfg(test)] mod test { use super::*; + use std::string::ToString; #[test] fn display() { diff --git a/lib/cretonne/src/ir/progpoint.rs b/lib/cretonne/src/ir/progpoint.rs index 480160ea96..72a00602ee 100644 --- a/lib/cretonne/src/ir/progpoint.rs +++ b/lib/cretonne/src/ir/progpoint.rs @@ -148,6 +148,7 @@ mod tests { use super::*; use entity::EntityRef; use ir::{Inst, Ebb}; + use std::string::ToString; #[test] fn convert() { diff --git a/lib/cretonne/src/ir/sourceloc.rs b/lib/cretonne/src/ir/sourceloc.rs index ffcf0db943..36e5247488 100644 --- a/lib/cretonne/src/ir/sourceloc.rs +++ b/lib/cretonne/src/ir/sourceloc.rs @@ -51,6 +51,7 @@ impl fmt::Display for SourceLoc { #[cfg(test)] mod tests { use ir::SourceLoc; + use std::string::ToString; #[test] fn display() { diff --git a/lib/cretonne/src/ir/stackslot.rs b/lib/cretonne/src/ir/stackslot.rs index 744bd06ac3..7baadde636 100644 --- a/lib/cretonne/src/ir/stackslot.rs +++ b/lib/cretonne/src/ir/stackslot.rs @@ -320,6 +320,7 @@ mod tests { use ir::Function; use ir::types; use super::*; + use std::string::ToString; #[test] fn stack_slot() { diff --git a/lib/cretonne/src/ir/trapcode.rs b/lib/cretonne/src/ir/trapcode.rs index 2374c206f3..1487a63aad 100644 --- a/lib/cretonne/src/ir/trapcode.rs +++ b/lib/cretonne/src/ir/trapcode.rs @@ -83,6 +83,7 @@ impl FromStr for TrapCode { #[cfg(test)] mod tests { use super::*; + use std::string::ToString; // Everything but user-defined codes. const CODES: [TrapCode; 8] = [ diff --git a/lib/cretonne/src/ir/types.rs b/lib/cretonne/src/ir/types.rs index f8774250ec..07cf97aefa 100644 --- a/lib/cretonne/src/ir/types.rs +++ b/lib/cretonne/src/ir/types.rs @@ -324,6 +324,7 @@ impl Default for Type { #[cfg(test)] mod tests { use super::*; + use std::string::ToString; #[test] fn basic_scalars() { diff --git a/lib/cretonne/src/isa/arm32/registers.rs b/lib/cretonne/src/isa/arm32/registers.rs index 7c6ac406e1..e2c4813bdd 100644 --- a/lib/cretonne/src/isa/arm32/registers.rs +++ b/lib/cretonne/src/isa/arm32/registers.rs @@ -8,6 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/registers-arm32.rs")); mod tests { use super::{INFO, GPR, S, D}; use isa::RegUnit; + use std::string::{String, ToString}; #[test] fn unit_encodings() { diff --git a/lib/cretonne/src/isa/arm64/registers.rs b/lib/cretonne/src/isa/arm64/registers.rs index 62311aaebe..2c1d85e091 100644 --- a/lib/cretonne/src/isa/arm64/registers.rs +++ b/lib/cretonne/src/isa/arm64/registers.rs @@ -8,6 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/registers-arm64.rs")); mod tests { use super::INFO; use isa::RegUnit; + use std::string::{String, ToString}; #[test] fn unit_encodings() { diff --git a/lib/cretonne/src/isa/intel/registers.rs b/lib/cretonne/src/isa/intel/registers.rs index c2b96f77d3..c972c10a13 100644 --- a/lib/cretonne/src/isa/intel/registers.rs +++ b/lib/cretonne/src/isa/intel/registers.rs @@ -8,6 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/registers-intel.rs")); mod tests { use super::*; use isa::RegUnit; + use std::string::{String, ToString}; #[test] fn unit_encodings() { diff --git a/lib/cretonne/src/isa/riscv/mod.rs b/lib/cretonne/src/isa/riscv/mod.rs index 8efae74af7..6fc976686b 100644 --- a/lib/cretonne/src/isa/riscv/mod.rs +++ b/lib/cretonne/src/isa/riscv/mod.rs @@ -117,6 +117,7 @@ mod tests { use isa; use ir::{DataFlowGraph, InstructionData, Opcode}; use ir::{types, immediates}; + use std::string::{String, ToString}; fn encstr(isa: &isa::TargetIsa, enc: Result) -> String { match enc { diff --git a/lib/cretonne/src/isa/riscv/registers.rs b/lib/cretonne/src/isa/riscv/registers.rs index 3cce8c4988..e2073899b6 100644 --- a/lib/cretonne/src/isa/riscv/registers.rs +++ b/lib/cretonne/src/isa/riscv/registers.rs @@ -8,6 +8,7 @@ include!(concat!(env!("OUT_DIR"), "/registers-riscv.rs")); mod tests { use super::{INFO, GPR, FPR}; use isa::RegUnit; + use std::string::{String, ToString}; #[test] fn unit_encodings() { diff --git a/lib/cretonne/src/isa/riscv/settings.rs b/lib/cretonne/src/isa/riscv/settings.rs index 8cb376e5da..7b609acf20 100644 --- a/lib/cretonne/src/isa/riscv/settings.rs +++ b/lib/cretonne/src/isa/riscv/settings.rs @@ -12,6 +12,7 @@ include!(concat!(env!("OUT_DIR"), "/settings-riscv.rs")); mod tests { use super::{builder, Flags}; use settings::{self, Configurable}; + use std::string::ToString; #[test] fn display_default() { diff --git a/lib/cretonne/src/iterators.rs b/lib/cretonne/src/iterators.rs index 08866717e8..0524343028 100644 --- a/lib/cretonne/src/iterators.rs +++ b/lib/cretonne/src/iterators.rs @@ -48,6 +48,8 @@ where #[cfg(test)] mod tests { + use std::vec::Vec; + #[test] fn adjpairs() { use super::IteratorExtras; diff --git a/lib/cretonne/src/lib.rs b/lib/cretonne/src/lib.rs index 8302095998..95868a6933 100644 --- a/lib/cretonne/src/lib.rs +++ b/lib/cretonne/src/lib.rs @@ -63,7 +63,6 @@ mod write; #[cfg(feature = "no_std")] mod std { pub use core::*; - #[macro_use] pub use alloc::{boxed, vec, string}; pub mod collections { pub use hashmap_core::{HashMap, HashSet}; diff --git a/lib/cretonne/src/loop_analysis.rs b/lib/cretonne/src/loop_analysis.rs index dfd5cf135a..431496b6e4 100644 --- a/lib/cretonne/src/loop_analysis.rs +++ b/lib/cretonne/src/loop_analysis.rs @@ -231,6 +231,7 @@ mod test { use loop_analysis::{Loop, LoopAnalysis}; use flowgraph::ControlFlowGraph; use dominator_tree::DominatorTree; + use std::vec::Vec; #[test] fn nested_loops_detection() { diff --git a/lib/cretonne/src/partition_slice.rs b/lib/cretonne/src/partition_slice.rs index 6f106e5bfc..7a94a9fe0d 100644 --- a/lib/cretonne/src/partition_slice.rs +++ b/lib/cretonne/src/partition_slice.rs @@ -33,6 +33,7 @@ where #[cfg(test)] mod tests { use super::partition_slice; + use std::vec::Vec; fn check(x: &[u32], want: &[u32]) { assert_eq!(x.len(), want.len()); diff --git a/lib/cretonne/src/regalloc/allocatable_set.rs b/lib/cretonne/src/regalloc/allocatable_set.rs index cc72066b5d..e0abf76d37 100644 --- a/lib/cretonne/src/regalloc/allocatable_set.rs +++ b/lib/cretonne/src/regalloc/allocatable_set.rs @@ -221,6 +221,7 @@ impl fmt::Display for AllocatableSet { mod tests { use super::*; use isa::registers::{RegClass, RegClassData}; + use std::vec::Vec; // Register classes for testing. const GPR: RegClass = &RegClassData { diff --git a/lib/cretonne/src/regalloc/coalescing.rs b/lib/cretonne/src/regalloc/coalescing.rs index 225aa8e9d8..5933170e33 100644 --- a/lib/cretonne/src/regalloc/coalescing.rs +++ b/lib/cretonne/src/regalloc/coalescing.rs @@ -18,8 +18,6 @@ use std::cmp; use std::iter; use std::fmt; use std::slice; -use std::iter::Peekable; -use std::mem; use std::vec::Vec; use isa::{TargetIsa, EncInfo}; use timing; diff --git a/lib/cretonne/src/regalloc/liverange.rs b/lib/cretonne/src/regalloc/liverange.rs index 7d7d6a8775..93d5b0c244 100644 --- a/lib/cretonne/src/regalloc/liverange.rs +++ b/lib/cretonne/src/regalloc/liverange.rs @@ -463,6 +463,7 @@ mod tests { use entity::EntityRef; use ir::{ProgramOrder, ExpandedProgramPoint}; use std::cmp::Ordering; + use std::vec::Vec; // Dummy program order which simply compares indexes. // It is assumed that EBBs have indexes that are multiples of 10, and instructions have indexes diff --git a/lib/cretonne/src/regalloc/pressure.rs b/lib/cretonne/src/regalloc/pressure.rs index c71037efdd..67e0e99b70 100644 --- a/lib/cretonne/src/regalloc/pressure.rs +++ b/lib/cretonne/src/regalloc/pressure.rs @@ -273,6 +273,7 @@ mod tests { use regalloc::AllocatableSet; use std::borrow::Borrow; use super::Pressure; + use std::boxed::Box; // Make an arm32 `TargetIsa`, if possible. fn arm32() -> Option> { diff --git a/lib/cretonne/src/regalloc/solver.rs b/lib/cretonne/src/regalloc/solver.rs index c2f8017c3a..db5efcab06 100644 --- a/lib/cretonne/src/regalloc/solver.rs +++ b/lib/cretonne/src/regalloc/solver.rs @@ -1163,6 +1163,7 @@ mod tests { use isa::{TargetIsa, RegClass, RegUnit, RegInfo}; use regalloc::AllocatableSet; use super::{Solver, Move}; + use std::boxed::Box; // Make an arm32 `TargetIsa`, if possible. fn arm32() -> Option> { diff --git a/lib/cretonne/src/settings.rs b/lib/cretonne/src/settings.rs index a7da8d6f17..b6ef9eae30 100644 --- a/lib/cretonne/src/settings.rs +++ b/lib/cretonne/src/settings.rs @@ -348,6 +348,7 @@ mod tests { use super::{builder, Flags}; use super::Error::*; use super::Configurable; + use std::string::ToString; #[test] fn display_default() { diff --git a/lib/cretonne/src/timing.rs b/lib/cretonne/src/timing.rs index c05ee93004..15496ed9ce 100644 --- a/lib/cretonne/src/timing.rs +++ b/lib/cretonne/src/timing.rs @@ -238,6 +238,7 @@ mod details { #[cfg(test)] mod test { use super::*; + use std::string::ToString; #[test] fn display() { diff --git a/lib/cretonne/src/verifier/mod.rs b/lib/cretonne/src/verifier/mod.rs index c3bebc5ae6..117de2f38b 100644 --- a/lib/cretonne/src/verifier/mod.rs +++ b/lib/cretonne/src/verifier/mod.rs @@ -1132,7 +1132,10 @@ mod tests { Ok(_) => { panic!("Expected an error!") }, Err(Error { message, .. } ) => { if !message.contains($msg) { + #[cfg(not(feature = "no_std"))] panic!(format!("'{}' did not contain the substring '{}'", message, $msg)); + #[cfg(feature = "no_std")] + panic!("error message did not contain the expected substring"); } } } diff --git a/lib/cretonne/src/write.rs b/lib/cretonne/src/write.rs index 4ca8ddaadb..ff60033af2 100644 --- a/lib/cretonne/src/write.rs +++ b/lib/cretonne/src/write.rs @@ -467,6 +467,7 @@ impl<'a> fmt::Display for DisplayValues<'a> { mod tests { use ir::{Function, ExternalName, StackSlotData, StackSlotKind}; use ir::types; + use std::string::ToString; #[test] fn basic() { diff --git a/lib/frontend/src/ssa.rs b/lib/frontend/src/ssa.rs index f99ff5e179..fc2ebcca08 100644 --- a/lib/frontend/src/ssa.rs +++ b/lib/frontend/src/ssa.rs @@ -1039,7 +1039,12 @@ mod tests { let flags = settings::Flags::new(&settings::builder()); match verify_function(&func, &flags) { Ok(()) => {} - Err(err) => panic!(err.message), + Err(err) => { + #[cfg(not(feature = "no_std"))] + panic!(err.message); + #[cfg(feature = "no_std")] + panic!("function failed to verify"); + } } } @@ -1213,7 +1218,12 @@ mod tests { let flags = settings::Flags::new(&settings::builder()); match verify_function(&func, &flags) { Ok(()) => {} - Err(err) => panic!(err.message), + Err(err) => { + #[cfg(not(feature = "no_std"))] + panic!(err.message); + #[cfg(feature = "no_std")] + panic!("function failed to verify"); + } } } @@ -1259,7 +1269,12 @@ mod tests { let flags = settings::Flags::new(&settings::builder()); match verify_function(&func, &flags) { Ok(()) => {} - Err(err) => panic!(err.message), + Err(err) => { + #[cfg(not(feature = "no_std"))] + panic!(err.message); + #[cfg(feature = "no_std")] + panic!("function failed to verify"); + } } } }