Closed cole-miller closed 3 years ago
This seems to work:
fn main() {
let ac = autocfg::new();
ac.emit_expression_cfg(
r#"{ struct A<const N: usize>([(); N]); A([]) }"#,
"have_const_generics",
);
}
But if there's a nicer way I'd love to know about it! (Otherwise feel free to close this.)
There's no direct support for item definitions, which is what you'd need to test this, but I think a block expression is reasonable. You could also do that with emit_constant_cfg
, but the constraints there are really about constant evaluation.
Did you add A([])
to avoid unused warning spew? I might change it to start hiding output by default for #30.
Did you add A([]) to avoid unused warning spew?
No, it was just a reflex :P (I wasn't thinking about implicit ()
return). The unused warning doesn't bother me especially since it only shows up with -vv
and this is the only thing in my build.rs
currently.
I'd like to probe support for (minimal) const generics by checking this code:
But this can't be done with
probe_type
and I'm not sure how else to do it (other than maybeprobe_rustc_version
which seems kind of awkward). Any workarounds?