Closed
Description
STR
// main.rs
extern crate libc;
#[cfg(error)]
mod trigger;
const CSTOPB_: u32 = 64;
const CREAD_: u32 = 128;
const CSTOPB: u32 = CSTOPB_;
// This cast to `c_uint` is necessary
const CREAD: u32 = CREAD_ as ::libc::c_uint;
#[cfg(not(error))]
mod trigger;
fn main() {}
// trigger.rs
#[repr(u32)]
enum Bit {
CSTOPB = super::CSTOPB,
CREAD = super::CREAD,
}
Output
rustc --cfg error main.rs
generates the following compiler error:
main.rs:12:30: 12:44 error: target type not found for const cast
main.rs:12 const CREAD: u32 = CREAD_ as ::libc::c_uint;
rustc main.rs
compiles successfully.
Version
rustc 0.13.0-dev (93e589c87 2014-10-17 09:22:14 +0000)
I can trace this behavior back to 0.11
I thought that the position of the items in a crate (except for use
imports and extern crate
s which must go at the beginning) didn't affect the compiler output. That makes me think this is a bug.