Public bug reported: [ Impact ]
`rustc` 1.80 introduced a minor breaking change in [1][2], causing crate `time<0.3.35` to fail to compile when crate features `formatting` or `parsing` are enabled. A fix for `time` was merged prior to the release of 1.80 [3]. Noble ships a version of `time` that is broken with the newer compilers available in universe: rust-time | 0.3.31-1 | noble/universe | source At this time, Noble also ships rustc 1.80 thru 1.85: rustc-1.80 | 1.80.1+dfsg0ubuntu1-0ubuntu0.24.04 | noble-updates/universe | source, amd64, arm64, armhf, ppc64el, riscv64, s390x rustc-1.81 | 1.81.0+dfsg0ubuntu1-0ubuntu0.24.04 | noble-updates/universe | source, amd64, arm64, armhf, ppc64el, riscv64, s390x rustc-1.82 | 1.82.0+dfsg0ubuntu0-0ubuntu0.24.04 | noble-updates/universe | source, amd64, arm64, armhf, ppc64el, riscv64, s390x rustc-1.83 | 1.83.0+dfsg0ubuntu1~bpo2-0ubuntu0.24.04 | noble-updates/universe | source, amd64, arm64, armhf, ppc64el, riscv64, s390x rustc-1.84 | 1.84.1+dfsg0ubuntu1~bpo2-0ubuntu2.24.04 | noble-updates/universe | source, amd64, arm64, armhf, ppc64el, riscv64, s390x rustc-1.85 | 1.85.1+dfsg0ubuntu2~bpo0-0ubuntu0.24.04 | noble-updates/universe | source, amd64, arm64, armhf, ppc64el, riscv64, s390x This prevents users of the newer compilers from compiling any crate with a direct or indirect dependency on the Noble sources for `time` when crate features `formatting` or `parsing` are enabled: error[E0282]: type annotations needed for `Box<_>` --> /usr/share/cargo/registry/time-0.3.31/src/format_description/parse/mod.rs:84:9 | 84 | let items = format_items | ^^^^^ ... 87 | Ok(items.into()) | ---- type must be known at this point | help: consider giving `items` an explicit type, where the placeholders `_` are specified | 84 | let items: Box<_> = format_items | ++++++++ The user who reported this was compiling sqlx [5]. [1] https://github.com/rust-lang/libs-team/issues/196 [2] https://github.com/rust-lang/rust/pull/99969/ [3] https://github.com/time-rs/time/pull/671 [4] https://github.com/time-rs/time/pull/671/commits/42682db317cc014a759d57bf088fb39f3c71b4bb [5] https://launchpad.net/ubuntu/+source/rust-sqlx [ Test Plan ] Compile-check with all available compiler versions in Noble: ``` sudo apt install cargo cargo-1.{76..85} cat > ~/.cargo/config <<EOF [source] [source.debian-packages] directory = "/usr/share/cargo/registry" [source.crates-io] replace-with = "debian-packages" EOF cargo new time-test cd time-test echo 'time = { version = ">=0.3.31", features = ["formatting"] }' >> Cargo.toml cat > do-build <<EOF #!/bin/bash set -ex for cargo in cargo cargo-1.{76..85}; do "\${cargo}" clean "\${cargo}" check --verbose done EOF chmod 755 do-build ./do-build echo $? ``` Expected result: Successful compilation with all compiler versions, `do-build` returns 0 Actual result: error[E0282]: type annotations needed for `Box<_>` --> /usr/share/cargo/registry/time-0.3.31/src/format_description/parse/mod.rs:83:9 | 83 | let items = format_items | ^^^^^ ... 86 | Ok(items.into()) | ---- type must be known at this point | help: consider giving `items` an explicit type, where the placeholders `_` are specified | 83 | let items: Box<_> = format_items | ++++++++ For more information about this error, try `rustc --explain E0282`. error: could not compile `time` (lib) due to 1 previous error Regression check: Run the unittest suite in the git-ubuntu sources, as it is not run on binary builds. Skip the doctests as they already fail on `0.3.31-1`: ``` git-ubuntu clone rust-time git switch applied/ubuntu/noble-devel sudo apt build-dep ./ sudo apt install librust-quickcheck-macros-dev librust-rstest-dev librust-trybuild-dev cat > do-test <<EOF #!/bin/bash set -ex for cargo in cargo cargo-1.{76..85}; do "\${cargo}" clean "\${cargo}" test --verbose --all-features --lib --bins --tests done EOF chmod 755 do-test ./do-test ``` Expected Result: All Pass [ Where problems could occur ] The affected code deals with runtime parsing of the `format_description` DSL [1][2]; if the code is wrong we would expect to see failures where a timestamp's format description is passed to a program at runtime. If problems occur but are not caught in the initial upload & autopkgtest run, rebuilds of Rust packages that transitively depend on rust-time could experience breakage, as Rust libraries/crates are statically linked. [1] https://docs.rs/time/0.3.31/time/macros/macro.format_description.html [2] https://time-rs.github.io/book/api/format-description.html [ Other Info ] The regression occurs because `collect` can no longer determine which `FromIterator` implementation to use, as `Box<_>` could mean `Box<[_]>` or `Box<str>` [1][2][3]. However, in this context, the extra `map` is taking advantage of the identity implementation of the `From` trait [4] (`Into` has a blanket implementation for any type implementing `From` [5]). Without the extra `From`, the compiler can correctly infer that `collect` should produce a `Box<[Item<'_>]>`, as `Item` does not implement `From` for any of the types implementing `FromIterator` for `Box<str>`. See the upstream pull request for a more concise description [6]. [1] https://doc.rust-lang.org/1.80.0/std/iter/trait.Iterator.html#method.collect [2] https://doc.rust-lang.org/1.80.0/std/iter/trait.FromIterator.html#implementors [3] https://doc.rust-lang.org/1.80.0/std/iter/trait.FromIterator.html#impl-FromIterator%3CI%3E-for-Box%3C%5BI%5D%3E [4] https://doc.rust-lang.org/1.80.0/std/convert/trait.From.html#impl-From%3CT%3E-for-T [5] https://doc.rust-lang.org/1.80.0/std/convert/trait.Into.html [6] https://github.com/time-rs/time/pull/671 ** Affects: rust-time (Ubuntu) Importance: Undecided Status: Fix Released ** Affects: rust-time (Ubuntu Noble) Importance: Medium Assignee: Wesley Hershberger (whershberger) Status: In Progress ** Tags: sts ** Also affects: rust-time (Ubuntu Noble) Importance: Undecided Status: New ** Changed in: rust-time (Ubuntu) Status: In Progress => Fix Released ** Changed in: rust-time (Ubuntu Noble) Status: New => In Progress ** Changed in: rust-time (Ubuntu Noble) Importance: Undecided => Medium ** Changed in: rust-time (Ubuntu Noble) Assignee: (unassigned) => Wesley Hershberger (whershberger) ** Changed in: rust-time (Ubuntu) Assignee: Wesley Hershberger (whershberger) => (unassigned) ** Changed in: rust-time (Ubuntu) Importance: Medium => Undecided -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2136226 Title: [SRU] Fails to compile on rustc>=1.80 with features `formatting` or `parsing` To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/rust-time/+bug/2136226/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
