Fix some warnings in no_std builds.

The dbg! macro expands to nothing in no_std mode, so variables that are
only used for debugging prompt unused variable warnings.

Also, allow unstable_features in no_std builds, since they use
feature(alloc), which is an unstable feature.
This commit is contained in:
Dan Gohman
2018-04-30 13:56:29 -07:00
parent 94a883abae
commit 9c87f3ac87
7 changed files with 22 additions and 14 deletions

View File

@@ -1,7 +1,8 @@
//! Cretonne code generation library. //! Cretonne code generation library.
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces, unstable_features)] #![warn(unused_import_braces)]
#![cfg_attr(feature = "std", warn(unstable_features))]
#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
#![cfg_attr(feature="cargo-clippy", allow( #![cfg_attr(feature="cargo-clippy", allow(
// Rustfmt 0.9.0 is at odds with this lint: // Rustfmt 0.9.0 is at odds with this lint:

View File

@@ -6,6 +6,7 @@
//! parameter will belong to the same virtual register as the EBB parameter value itself. //! parameter will belong to the same virtual register as the EBB parameter value itself.
use cursor::{Cursor, EncCursor}; use cursor::{Cursor, EncCursor};
#[cfg(feature = "std")]
use dbg::DisplayList; use dbg::DisplayList;
use dominator_tree::{DominatorTree, DominatorTreePreorder}; use dominator_tree::{DominatorTree, DominatorTreePreorder};
use flowgraph::ControlFlowGraph; use flowgraph::ControlFlowGraph;
@@ -546,8 +547,8 @@ impl<'a> Context<'a> {
return false; return false;
} }
let vreg = self.virtregs.unify(self.values); let _vreg = self.virtregs.unify(self.values);
dbg!("-> merged into {} = {}", vreg, DisplayList(self.values)); dbg!("-> merged into {} = {}", _vreg, DisplayList(self.values));
true true
} }

View File

@@ -857,8 +857,11 @@ impl<'a> Context<'a> {
let added = self.try_add_var(rc, throughs); let added = self.try_add_var(rc, throughs);
debug_assert!(added, "Ran out of registers in {}", rc); debug_assert!(added, "Ran out of registers in {}", rc);
} }
Err(SolverError::Global(value)) => { Err(SolverError::Global(_value)) => {
dbg!("Not enough global registers for {}, trying as local", value); dbg!(
"Not enough global registers for {}, trying as local",
_value
);
// We'll clear the `is_global` flag on all solver variables and instead make a // We'll clear the `is_global` flag on all solver variables and instead make a
// note to replace all global defines with local defines followed by a copy. // note to replace all global defines with local defines followed by a copy.
*replace_global_defines = true; *replace_global_defines = true;

View File

@@ -30,7 +30,8 @@
//! `Vec`. //! `Vec`.
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces, unstable_features)] #![warn(unused_import_braces)]
#![cfg_attr(feature = "std", warn(unstable_features))]
#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
#![cfg_attr(feature = "cargo-clippy", #![cfg_attr(feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive))] allow(new_without_default, new_without_default_derive))]

View File

@@ -128,7 +128,8 @@
//! ``` //! ```
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces, unstable_features)] #![warn(unused_import_braces)]
#![cfg_attr(feature = "std", warn(unstable_features))]
#![cfg_attr(feature = "cargo-clippy", allow(new_without_default))] #![cfg_attr(feature = "cargo-clippy", allow(new_without_default))]
#![cfg_attr(feature="cargo-clippy", warn( #![cfg_attr(feature="cargo-clippy", warn(
float_arithmetic, float_arithmetic,

View File

@@ -1024,9 +1024,9 @@ mod tests {
let flags = settings::Flags::new(settings::builder()); let flags = settings::Flags::new(settings::builder());
match verify_function(&func, &flags) { match verify_function(&func, &flags) {
Ok(()) => {} Ok(()) => {}
Err(err) => { Err(_err) => {
#[cfg(feature = "std")] #[cfg(feature = "std")]
panic!(err.message); panic!(_err.message);
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
panic!("function failed to verify"); panic!("function failed to verify");
} }
@@ -1203,9 +1203,9 @@ mod tests {
let flags = settings::Flags::new(settings::builder()); let flags = settings::Flags::new(settings::builder());
match verify_function(&func, &flags) { match verify_function(&func, &flags) {
Ok(()) => {} Ok(()) => {}
Err(err) => { Err(_err) => {
#[cfg(feature = "std")] #[cfg(feature = "std")]
panic!(err.message); panic!(_err.message);
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
panic!("function failed to verify"); panic!("function failed to verify");
} }
@@ -1254,9 +1254,9 @@ mod tests {
let flags = settings::Flags::new(settings::builder()); let flags = settings::Flags::new(settings::builder());
match verify_function(&func, &flags) { match verify_function(&func, &flags) {
Ok(()) => {} Ok(()) => {}
Err(err) => { Err(_err) => {
#[cfg(feature = "std")] #[cfg(feature = "std")]
panic!(err.message); panic!(_err.message);
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
panic!("function failed to verify"); panic!("function failed to verify");
} }

View File

@@ -10,7 +10,8 @@
//! The main function of this module is [`translate_module`](fn.translate_module.html). //! The main function of this module is [`translate_module`](fn.translate_module.html).
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)] #![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
#![warn(unused_import_braces, unstable_features)] #![warn(unused_import_braces)]
#![cfg_attr(feature = "std", warn(unstable_features))]
#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))] #![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
#![cfg_attr(feature = "cargo-clippy", #![cfg_attr(feature = "cargo-clippy",
allow(new_without_default, new_without_default_derive))] allow(new_without_default, new_without_default_derive))]