since and before for stable versions do not consider the date of nightly build

未关闭
#42 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
rust
领域
compilers

调研方向

先阅读 README 中对 since 和 before 的定义,然后使用报告中所示的 nightly cargo 命令复现该行为,并检查版本检测的入口点。使用 stable 1.74.0 的发布日期和带日期的 nightly 示例进行检查。完成的标准是,before 和 since 代码片段能针对这些编译器日期选择预期的代码。

由索引模型根据 Issue 内容生成。

描述

According to the README, #[rustversion::since(1.74)] should be

True on that stable release and any later compiler, including beta and nightly.

The key word in this sentence is later. Stable Rust 1.74.0 was released on 2023-11-16, but nightly-2023-09-14 is a nightly that came out more than 2 months before. The following snippet succeeds to compile when it should fail because the nightly is older than 1.74:

#[rustversion::since(1.74)]
fn main() {
   println!("Hello, world!");
}
cargo +nightly-2023-09-13 b
   Compiling rustversion v1.0.14
   Compiling rust-version-test v0.1.0 (D:\git-repos\github\rust-version-test)
    Finished dev [unoptimized + debuginfo] target(s) in 2.26s

Similarly, the below snippet fails to compile on nightly-2023-09-14:

#[rustversion::before(1.74)]
fn main() {
    println!("Hello, world!");
}
cargo +nightly-2023-09-14 b
   Compiling rustversion v1.0.14
   Compiling rust-version-test v0.1.0 (D:\git-repos\github\rust-version-test)
error[E0601]: `main` function not found in crate `rust_version_test`
 --> src\main.rs:4:2
  |
4 | }
  |  ^ consider adding a `main` function to `src\main.rs`

For more information about this error, try `rustc --explain E0601`.
error: could not compile `rust-version-test` (bin "rust-version-test") due to previous error
主要语言
Rust
星标
397
派生
22
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dtolnay/rustversion 的其他 Issue

查看 dtolnay/rustversion 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。