corrode icon indicating copy to clipboard operation
corrode copied to clipboard

box, true and false are not renamed

Open skade opened this issue 8 years ago • 2 comments

The following two programs are translated, but don't compile for the same reason: they use variable and variant names that are keywords in Rust.

void foo(int box) {
    box++;
}

void bar() {
    foo(1);
}
typedef enum
{
    false,
    true
} boolean;

void foo(boolean bar) {

}

void bar() {
    foo(false);
}

skade avatar Jul 04 '17 20:07 skade

It looks like as is also not renamed:

// example.c
int main() {
	int as = 23;
	return 0;
}

// example.rs 
fn main() {
    let ret = unsafe { _c_main() };
    ::std::process::exit(ret);
}

#[no_mangle]
pub unsafe extern fn _c_main() -> i32 {
    let mut as : i32 = 23i32;
    0i32
}

The rust snippet will not compile, fails with:

expected identifier, found keyword `as`

willmurphyscode avatar Dec 26 '17 22:12 willmurphyscode

The patch I PR'd should work fine. I tested as_ and it was good to go, so I assume the rest of them would be too.

phase avatar Dec 26 '17 23:12 phase