Skip to content

Instantly share code, notes, and snippets.

@radare
Created June 21, 2015 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radare/36d2f7df5bc19ef8063f to your computer and use it in GitHub Desktop.
Save radare/36d2f7df5bc19ef8063f to your computer and use it in GitHub Desktop.
rust main
// this file is included when compiling src/bin/*.rs or tests
// maybe we shouldn't define 'main' here
extern crate radeco;
use std::env;
use radeco::frontend::esil;
fn parse_verbose<'a> (p: &mut esil::Parser, expression: &'a String) {
let expstr = expression.as_str();
println!("< {}", expression);
if let Err(e) = p.parse(expstr) {
panic!("Error: {:?}", e)
}
for inst in &p.emit_insts() {
println!("> {}", inst);
}
}
// attribute to ignore unused 'main' when running tests
#[cfg_attr(test, allow(dead_code))]
fn main() {
let mut p = esil::Parser::new();
let expression: String;
if env::args().count() > 1 {
expression = env::args().nth(1).unwrap();
} else {
expression = String::from_str("rax,rbx,+");
}
parse_verbose(&mut p, &expression);
}
@radare
Copy link
Author

radare commented Jun 21, 2015

$ make
cargo run
   Compiling radeco v0.1.0 (file:///Users/pancake/prg/radeco)
src/main.rs:9:29: 9:37 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements
src/main.rs:9     let expstr = expression.as_str();
                                          ^~~~~~~~
src/main.rs:8:1: 17:2 help: consider using an explicit lifetime parameter as shown: fn parse_verbose<'a>(p: &mut esil::Parser<'a>, expression: &'a String)
src/main.rs:8 fn parse_verbose<'a> (p: &mut esil::Parser, expression: &'a String) {
src/main.rs:9     let expstr = expression.as_str();
src/main.rs:10     println!("< {}", expression);
src/main.rs:11     if let Err(e) = p.parse(expstr) {
src/main.rs:12         panic!("Error: {:?}", e)
src/main.rs:13     }
               ...
error: aborting due to previous error
Could not compile `radeco`.

To learn more, run the command again with --verbose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment