Clone API docs
It would be nice for the missing docs to not complain when compiling multiversion. I.e. we could make following compile by also cloning the docs:
#![deny(missing_docs)]
use multiversion::multiversion;
/// Sums values
#[multiversion]
#[clone(target = "x86_64+aes+sse3+ssse3+avx+avx2")]
/// Sums values
pub fn sum(array: &[i32]) -> i32 {
let mut sum = 0;
for i in array {
sum += i;
}
sum
}
fn main() {
let _ = sum(&[1, 2]);
}
cargo build yields
error: missing documentation for the crate
--> examples/bla.rs:1:1
|
1 | / #![deny(missing_docs)]
2 | |
3 | | use multiversion::multiversion;
4 | |
... |
18 | | let _ = sum(&[1, 2]);
19 | | }
| |_^
|
note: the lint level is defined here
--> examples/bla.rs:1:9
|
1 | #![deny(missing_docs)]
| ^^^^^^^^^^^^
error: missing documentation for a function
--> examples/bla.rs:6:1
|
6 | #[multiversion]
| ^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `multiversion` (in Nightly builds, run with -Z macro-backtrace for more info)
I'm working on a change that should place the clones within the scope of the multiversioned function, which I think should incidentally solve this as well.
More broadly, though, I'm unsure how to handle attributes on the multiversioned function vs on the clones. Copying all attributes doesn't quite make sense, for example:
#[multiversion(...)]
#[export_name = "foo"]
pub fn some_multiversioned_function() { ... }
However sometimes you might want it copied, like the tracing::instrument macro. Maybe the default should be to not copy, and provide a mechanism to copy particular attributes.
On master, the clones are now completely contained within the multiversioned function, which solves this issue. It also helps some more peculiar cases, like multiversioned trait implementations.