Setting cfg(nightly) on nightly by default

In theory it would be nice to have standard feature macros for testing whether a rust compiler implements a particular feature (instead of every project having to define their own).

If you believe stating a version number is clearer than that, then we'll just have to agree to disagree.

The problem is that a feature flag will never be enough: even if a compiler version implements a feature, that implementation might contain a bug that makes the feature unusable for a particular purpose / context. So one needs to easily be able to test for a compiler version.

C++ has both, and while C++ feature testing macros are nice in theory, they have actually made things worse in practice. Before, libraries used to test whether a particular compiler version or higher was available. Now libraries test whether a particular feature flag is available but if it is available, they still need to test against compiler versions to work around bugs in the reporting of the flags or in the implementations of the feature... (range-v3 config file is a wonderful example of the current situation).

You're seriously going to vet every nightly? And publish updates on a regular basis? And document which ones contain the performance gains and which don't?

Most open source C++ libraries that I've worked on do this without problems :confused: range-v3 is one example: when clang trunk/gcc trunk hits a bug, they workaround the bug for the range of trunk versions that contain the bug (because a lot of their users use tip-of-trunk compiler versions). The workarounds are disabled but not removed after new compiler versions with the fix are released because, what's the point, the work has already been done. I find it really hacky to have to do things like these in build.rs.

By the time you get to this check, Cargo has already decided what version of a crate it's going to try and use. We want this check in Cargo, not the compiler. That way, Cargo can exclude incompatible versions from selection entirely.

Yes, putting this check in cargo makes more sense, but a rust compiler should still reject compiling something that it cannot compile. Having this information at the top-level of a crate would allow the rust compiler to emit a better diagnostic, like "rustc version 1.4.0 is not enogh to compile this crate which requires version >=1.6.0".