Closed
Description
It is hard (maybe impossible) to compile certain combinations of cfg flags.
E.g.: I believe the following should always compile, for any choice of a
and b
cfg switches:
#[cfg(and(not(a),not(b)))]
fn f() { println!("Got it"); }
#[cfg(a)]
fn f() { println!("in a"); }
#[cfg(b)]
fn f() { println!("in b"); }
fn main() {
f();
}
But currently you get:
% rustc d.rs
d.rs:11:4: 11:5 error: unresolved name `f`.
d.rs:11 f();
^
error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /Users/fklock/Dev/Mozilla/rust.git/src/libsyntax/diagnostic.rs:101
task '<main>' failed at 'explicit failure', /Users/fklock/Dev/Mozilla/rust.git/src/librustc/lib.rs:396
I believe this is because our current cfg
implementation is largely just a hack, rather than a proper expression evaluator. See also #2119.