Other crates may wish to document their long term development across versions.
Seems like a very small change to allow any crate to use the attribute, and rustdoc already know how to process it.
And please also a lint that warns you if you are using stuff from a library with a "since version" more recent than the version requirement you specify in Cargo.toml. That's what's breaking the min-version feature of Cargo as well as cargo update -p.
Could you give an example of that? I'm not sure I follow.
If you have a library foo:
#[since(version="0.17.4")]
pub struct Bar;
#[since(version="0.12.0")]
pub struct Foo;
And the foo="0.17.3" entry in Cargo.toml of your project, then this code in your project should give a warning:
use foo;
let _b = foo::Bar; // Warning: using an item added in a later version than specified minimum
// Note: Version 0.17.3 specified, but `foo::Bar` was added in version `0.17.4`.
let _f = foo::Foo; // No warning
The key here is, you can have the 0.17.3 version in Cargo.toml yet still use 0.17.4 because you recently cloned the library or because you ran cargo update or something.
ah, right.
Doesn't cargo update alter the Cargo.toml file to match what you updated to?
@Lokathor No, it only updates the Cargo.lock, the Cargo.toml is unchanged.
The "version" specified in Cargo.toml can be a complicated requirement expression (e.g. >0.15.8,<0.20.29). If the warning is to be generated from rustc this means the compiler needs to know how to compute the lower bound from the version range (warn if since is > the lower bound). This feels like out-of-scope for rustc, but perhaps suitable for clippy.
Semver compatibility is a big influence for many of Rust's language design choices. Think of the orphan rule. Not there to annoy people but to allow for safe & painless semver compliant upgrades. rustc implements the Rust language together with the orphan rule. Should the orphan rule be put into clippy?
Maybe the implementation of the "is this version the lowest possible match for the version range" check is better put into the semver crate and not rustc which then would use it, but that's a detail.
Most helpful comment
The "version" specified in
Cargo.tomlcan be a complicated requirement expression (e.g.>0.15.8,<0.20.29). If the warning is to be generated fromrustcthis means the compiler needs to know how to compute the lower bound from the version range (warn ifsinceis > the lower bound). This feels like out-of-scope forrustc, but perhaps suitable for clippy.