Skip to content

[beta-1.95] Add missing truncate when writing .crate files#16713

Merged
epage merged 1 commit intorust-lang:rust-1.95.0from
weihanglo:beta-backport
Mar 6, 2026
Merged

[beta-1.95] Add missing truncate when writing .crate files#16713
epage merged 1 commit intorust-lang:rust-1.95.0from
weihanglo:beta-backport

Conversation

@weihanglo
Copy link
Member

Beta backports

In order to make CI pass, the following PRs are also cherry-picked:

@rustbot rustbot added Command-package S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2026

r? @ehuss

rustbot has assigned @ehuss.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage

@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2026

⚠️ Warning ⚠️

  • Pull requests are usually filed against the master branch for this repo, but this one is against rust-1.95.0. Please double check that you specified the right target!

@weihanglo
Copy link
Member Author

The failure was due to rust-lang/rust#152164, which worked correctly as ECHO_SCRIPT doesn't have any frontmatter.

thread 'script::cargo::test_no_build_rs' (9804054) panicked at tests/testsuite/script/cargo.rs:998:10:

---- expected: tests/testsuite/script/cargo.rs:991:27
++++ actual:   stderr
   1    1 | [WARNING] `package.edition` is unspecified, defaulting to the latest edition (currently `[..]`)
   2    2 | [COMPILING] script v0.0.0 ([ROOT]/foo/script.rs)
        3 + [WARNING] feature `frontmatter` is declared but not used
        4 +  --> <crate attribute>:1:12
        5 +   |
        6 + 1 | #![feature(frontmatter)]
        7 +   |            ^^^^^^^^^^^
        8 +   |
        9 +   = [NOTE] `#[warn(unused_features)]` (part of `#[warn(unused)]`) on by default
       10 +
       11 + [WARNING] `script` (bin "script") generated 1 warning
   3   12 | [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
   4      - [RUNNING] `[ROOT]/home/.cargo/build/[HASH]/target/debug/script[EXE] --help`
       13 + [RUNNING] `[ROOT]/home/.cargo/build/[HASH]/target/debug/script --help`

Update with SNAPSHOTS=overwrite

A quick fix for our test suite can be adding empty frontmatter to ECHO_SCRIPT, but that won't help user's Cargo script.

Another quick fix is adding allow(unused_features) along with frontmatter. Since the stabilization FCP is complete, I guess we'll soon have no need of this feature.

@weihanglo
Copy link
Member Author

BTW the fix should be ported to both master and rust-1.95.0 branch.

github-merge-queue bot pushed a commit that referenced this pull request Mar 6, 2026
### What does this PR try to resolve?

rust-lang/rust#152164 added a warn-by-default
`unused_features` lint.
Cargo injects  `#![feature(frontmatter)]` for all embedded scripts,
but scripts without frontmatter syntax never trigger feature gate check,
and causes causing the lint warning.

Given the stabilization FCP of frontmatter [is
complete](rust-lang/rust#148051 (comment))
already,
we could expect it will soon be stabilized (?).

It should be fine we suppress this new unstable lint.

### How to test and review this PR?

Test suite passes.
See
<#16713 (comment)>
for more.
ehuss pushed a commit to ehuss/cargo that referenced this pull request Mar 6, 2026
…16714)

### What does this PR try to resolve?

rust-lang/rust#152164 added a warn-by-default
`unused_features` lint.
Cargo injects  `#![feature(frontmatter)]` for all embedded scripts,
but scripts without frontmatter syntax never trigger feature gate check,
and causes causing the lint warning.

Given the stabilization FCP of frontmatter [is
complete](rust-lang/rust#148051 (comment))
already,
we could expect it will soon be stabilized (?).

It should be fine we suppress this new unstable lint.

### How to test and review this PR?

Test suite passes.
See
<rust-lang#16713 (comment)>
for more.
@ehuss
Copy link
Contributor

ehuss commented Mar 6, 2026

Posted #16715 to update the tests.

<!--
_Thanks for the pull request 🎉!_
_Please read the contribution guide: <https://doc.crates.io/contrib/>._
-->

### What does this PR try to resolve?

Fixes rust-lang#16683 by adding manuall truncate.
<!--
_Explain the motivation behind this change._
_A clear overview along with an in-depth explanation are helpful._
-->

### How to test and review this PR?

See the original issue for mCVE.
<!--
_Demonstrate how you test this change and guide reviewers through your
PR._
_With a smooth review process, a pull request usually gets reviewed
quicker._
-->
@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2026

This PR was rebased onto a different rust-1.95.0 commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@epage epage merged commit e8eb843 into rust-lang:rust-1.95.0 Mar 6, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 6, 2026
@weihanglo weihanglo deleted the beta-backport branch March 6, 2026 18:52
rust-bors bot pushed a commit to rust-lang/rust that referenced this pull request Mar 7, 2026
[beta] update stage0 and cargo

Update stage0 to 1.94.0

<https://forge.rust-lang.org/release/process.html#beta-stage0-update-friday>

---

Update cargo submodule #153515

2 commits in f298b8c82da0cba538516b45b04a480fc501d4c0..e8eb8435d5cad936237a1ee798c2f983624d0825
2026-02-24 21:59:20 +0000 to 2026-03-06 12:51:00 -0600
- [beta-1.95] Add missing truncate when writing .crate files (rust-lang/cargo#16713)
- [beta 1.95] backport test fixes (rust-lang/cargo#16715)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants