Fix warnings (causing CI failures) with new Rust beta.

- Panic messages must now be string literals (we used `format!()` in
  many places; `panic!()` can take format strings directly).
- Some dead enum options with EVEX encoding stuff in old x86 backend.
  This will go away soon and/or be moved to the new backend anyway, so
  let's silence the warning for now.
- A few other misc warnings.
This commit is contained in:
Chris Fallin
2021-02-16 08:34:00 -08:00
committed by Dan Gohman
parent d0e5d347b1
commit 8cd64e3ec6
5 changed files with 8 additions and 13 deletions

View File

@@ -277,6 +277,7 @@ impl EvexContext {
} }
/// The EVEX format allows choosing a vector length in the `L'` and `L` bits; see `EvexContext`. /// The EVEX format allows choosing a vector length in the `L'` and `L` bits; see `EvexContext`.
#[allow(dead_code)]
enum EvexVectorLength { enum EvexVectorLength {
V128, V128,
V256, V256,
@@ -296,6 +297,7 @@ impl EvexVectorLength {
} }
/// The EVEX format allows defining rounding control in the `L'` and `L` bits; see `EvexContext`. /// The EVEX format allows defining rounding control in the `L'` and `L` bits; see `EvexContext`.
#[allow(dead_code)]
enum EvexRoundingControl { enum EvexRoundingControl {
RNE, RNE,
RD, RD,

View File

@@ -2064,10 +2064,7 @@ mod tests {
Some(&VerifierError { ref message, .. }) => { Some(&VerifierError { ref message, .. }) => {
if !message.contains($msg) { if !message.contains($msg) {
#[cfg(feature = "std")] #[cfg(feature = "std")]
panic!(format!( panic!("'{}' did not contain the substring '{}'", message, $msg);
"'{}' did not contain the substring '{}'",
message, $msg
));
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
panic!("error message did not contain the expected substring"); panic!("error message did not contain the expected substring");
} }

View File

@@ -31,7 +31,6 @@ pub fn subtest(parsed: &TestCommand) -> anyhow::Result<Box<dyn SubTest>> {
/// Code sink that generates text. /// Code sink that generates text.
struct TextSink { struct TextSink {
code_size: binemit::CodeOffset,
offset: binemit::CodeOffset, offset: binemit::CodeOffset,
text: String, text: String,
} }
@@ -40,7 +39,6 @@ impl TextSink {
/// Create a new empty TextSink. /// Create a new empty TextSink.
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
code_size: 0,
offset: 0, offset: 0,
text: String::new(), text: String::new(),
} }
@@ -98,9 +96,7 @@ impl binemit::CodeSink for TextSink {
write!(self.text, "{} ", code).unwrap(); write!(self.text, "{} ", code).unwrap();
} }
fn begin_jumptables(&mut self) { fn begin_jumptables(&mut self) {}
self.code_size = self.offset
}
fn begin_rodata(&mut self) {} fn begin_rodata(&mut self) {}
fn end_codegen(&mut self) {} fn end_codegen(&mut self) {}
fn add_stack_map( fn add_stack_map(

View File

@@ -1098,7 +1098,7 @@ mod tests {
Ok(()) => {} Ok(()) => {}
Err(_errors) => { Err(_errors) => {
#[cfg(feature = "std")] #[cfg(feature = "std")]
panic!(_errors); panic!("{}", _errors);
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
panic!("function failed to verify"); panic!("function failed to verify");
} }
@@ -1291,7 +1291,7 @@ mod tests {
Ok(()) => {} Ok(()) => {}
Err(_errors) => { Err(_errors) => {
#[cfg(feature = "std")] #[cfg(feature = "std")]
panic!(_errors); panic!("{}", _errors);
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
panic!("function failed to verify"); panic!("function failed to verify");
} }
@@ -1357,7 +1357,7 @@ mod tests {
Ok(()) => {} Ok(()) => {}
Err(_errors) => { Err(_errors) => {
#[cfg(feature = "std")] #[cfg(feature = "std")]
panic!(_errors); panic!("{}", _errors);
#[cfg(not(feature = "std"))] #[cfg(not(feature = "std"))]
panic!("function failed to verify"); panic!("function failed to verify");
} }

View File

@@ -90,7 +90,7 @@ fn handle_module(data: Vec<u8>, flags: &Flags, return_mode: ReturnMode) {
for func in dummy_environ.info.function_bodies.values() { for func in dummy_environ.info.function_bodies.values() {
verifier::verify_function(func, &*isa) verifier::verify_function(func, &*isa)
.map_err(|errors| panic!(pretty_verifier_error(func, Some(&*isa), None, errors))) .map_err(|errors| panic!("{}", pretty_verifier_error(func, Some(&*isa), None, errors)))
.unwrap(); .unwrap();
} }
} }