Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@radare 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