/*
See <https://github.com/rust-lang/rust/issues/26448#issuecomment-173794570>.
*/
if version_matches("< 1.7.0") {
println!("cargo:rustc-cfg=str_into_output_extra_broken");
}
Also, you're dangerously close to a strawman argument: I never said the only way to do this should be compiler-defined feature flags. Even if that was a thing, you're quite right, it's still helpful to define your own, which is what you can already do.
I mean, yeah, but that just changes the optics of those errors (if it won't compile, it won't compile, just with a different message). It doesn't make code that wouldn't have otherwise compiled work (which adding this to Cargo could). Also, this is coming from someone who previously proposed more or less exactly what you're proposing now, so it's not like I think it's a bad idea... just a possible misapplication of effort.
Also, you're dangerously close to a strawman argument: I never said the only way to do this should be compiler-defined feature flags
Sorry, I did not meant to convey that you did, just that while feature flags look nicer, they are not enough anyways.
here's a snippet from scan-rules' current build.rs:
This is basically what I've been doing as well and it works, but I don't think it is nice. I thought that adding a way to do this (or something that covers 99% of the use cases) outside build.rs (in normal rust files) would make this nicer, but thinking twice about it, this kind of compiler-version-dependent conditional compilation is never nice, so maybe it is a pointless effort.
I’d like a nicer, more convenient syntax for it, too.
That’s partly why I’m arguing against it, here. Having to use build.rsis clunky, but maybe imposing a bit of separation and inconvenience isn’t a bad thing. I’ve seen some really horrific codebases using conditional compilation.
Plus, every time I try to imagine how to introduce named custom cfgs directly in Rust source, it starts to smell of Inner Platform Effect, at which point I go think about something else.