Skip to content

fix(rustc): Always pass --edition to rustc #13499

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Feb 29, 2024
Merged

Conversation

epage
Copy link
Contributor

@epage epage commented Feb 28, 2024

On Internals, the idea came up for warning on unset Edition.
I am working on the cargo warning but if rustc ever wants to do so, they'd be blocked on cargo ensuring --edition is always set. Hence this change.

On [Internals](https://internals.rust-lang.org/t/idea-rustc-cargo-should-warn-on-unspecified-edition/20309),
the idea came up for warning on unset Edition.
I am working on the cargo warning but if rustc ever wants to do so,
they'd be blocked on cargo ensuring `--edition` is always set.
Hence this change.
@rustbot
Copy link
Collaborator

rustbot commented Feb 28, 2024

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

@rustbot rustbot added A-unstable Area: nightly unstable support S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 28, 2024
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty reasonable, with only a small cost of 14 more characters passed to rustc. Packages using new editions should also outnumber those still in edition 2015.

@weihanglo
Copy link
Member

I believe we'll see a PR adding edition="2015" to every Cargo.toml in every test case 😈

Anyway,
@bors r+

@bors
Copy link
Contributor

bors commented Feb 28, 2024

📌 Commit 831847e has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 28, 2024
bors added a commit that referenced this pull request Feb 28, 2024
fix(rustc): Always pass --edition to rustc

On [Internals](https://internals.rust-lang.org/t/idea-rustc-cargo-should-warn-on-unspecified-edition/20309), the idea came up for warning on unset Edition.
I am working on the cargo warning but if rustc ever wants to do so, they'd be blocked on cargo ensuring `--edition` is always set. Hence this change.
@bors
Copy link
Contributor

bors commented Feb 28, 2024

⌛ Testing commit 831847e with merge 2bdaed6...

@bors
Copy link
Contributor

bors commented Feb 28, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 28, 2024
@weihanglo
Copy link
Member

This is something I didn't heard of (or I forget)

thread 'lto::test_all' panicked at tests/testsuite/lto.rs:326:10:

test failed running `/Users/runner/work/cargo/cargo/target/debug/cargo test --release -v`
error: process exited with code 101 (expected 0)
--- stdout

--- stderr
   Compiling foo v0.0.0 (/Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo)
     Running `rustc --crate-name a --edition=2015 tests/a.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C opt-level=3 -C lto --test -C metadata=32dbe2f9e5f2635b -C extra-filename=-32dbe2f9e5f2635b --out-dir /Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps -C strip=debuginfo -L dependency=/Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps`
     Running `rustc --crate-name foo --edition=2015 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C opt-level=3 -C lto --test -C metadata=e21a1c78a933506e -C extra-filename=-e21a1c78a933506e --out-dir /Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps -C strip=debuginfo -L dependency=/Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps`
     Running `rustc --crate-name foo --edition=2015 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C lto -C metadata=f92f3902d0319166 -C extra-filename=-f92f3902d0319166 --out-dir /Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps -C strip=debuginfo -L dependency=/Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps`
     Running `rustc --crate-name b --edition=2015 tests/b.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C opt-level=3 -C lto --test -C metadata=0981e9e08983757b -C extra-filename=-0981e9e08983757b --out-dir /Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps -C strip=debuginfo -L dependency=/Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps`
error: could not compile `foo` (test "b")

Caused by:
  process didn't exit successfully: `rustc --crate-name b --edition=2015 tests/b.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C opt-level=3 -C lto --test -C metadata=0981e9e08983757b -C extra-filename=-0981e9e08983757b --out-dir /Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps -C strip=debuginfo -L dependency=/Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps` (signal: 11, SIGSEGV: invalid memory reference)
warning: build failed, waiting for other jobs to finish...
error: could not compile `foo` (bin "foo" test)

Caused by:
  process didn't exit successfully: `rustc --crate-name foo --edition=2015 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --emit=dep-info,link -C opt-level=3 -C lto --test -C metadata=e21a1c78a933506e -C extra-filename=-e21a1c78a933506e --out-dir /Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps -C strip=debuginfo -L dependency=/Users/runner/work/cargo/cargo/target/tmp/cit/t1910/foo/target/release/deps` (signal: 4, SIGILL: illegal instruction)

Let's
@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 29, 2024
@bors
Copy link
Contributor

bors commented Feb 29, 2024

⌛ Testing commit 831847e with merge 5a5ee9a...

@bors
Copy link
Contributor

bors commented Feb 29, 2024

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 5a5ee9a to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Feb 29, 2024

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 5a5ee9a to master...

@bors bors merged commit 5a5ee9a into rust-lang:master Feb 29, 2024
@bors
Copy link
Contributor

bors commented Feb 29, 2024

👀 Test was successful, but fast-forwarding failed: 422 Changes must be made through a pull request.

@epage epage deleted the always-edition branch February 29, 2024 16:36
bors added a commit that referenced this pull request Mar 1, 2024
feat(toml): Warn on unset Edition

### What does this PR try to resolve?

On [Internals](https://internals.rust-lang.org/t/idea-rustc-cargo-should-warn-on-unspecified-edition/20309), the idea came up for warning on unset Edition.

Besides helping people who forget to set the Edition, this creates symmetry between `Cargo.toml` and cargo scripts (#12207).  While the default is different in each case, we are making the default obvious and guiding people away from it.

### How should we test and review this PR?

There are separate commits for adding tests (and refactors) so the changes in behavior will be more obvious

### Additional information

This builds on
- #13499
- #13504
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 2, 2024
Update cargo

12 commits in 8964c8ccff6e420e2a38b8696d178d69fab84d9d..f772ec0224d3755ce52ac5128a80319fb2eb45d0
2024-02-27 19:22:46 +0000 to 2024-03-01 22:57:35 +0000
- feat(toml): Warn on unset Edition (rust-lang/cargo#13505)
- fix(msrv): Report all incompatible packages, not just a random one (rust-lang/cargo#13514)
- refactor: abstract `std::fs` away from on-disk index cache (rust-lang/cargo#13515)
- chore(deps): update compatible (rust-lang/cargo#13507)
- chore(deps): update rust crate rusqlite to 0.31.0 (rust-lang/cargo#13510)
- [docs]: Clarify vendored sources as read-only and way to modify (rust-lang/cargo#13512)
- chore(deps): update rust crate supports-hyperlinks to v3 (rust-lang/cargo#13511)
- refactor: Clarify more Config -> Context (rust-lang/cargo#13506)
- test: Make `edition` explicit in packages (rust-lang/cargo#13504)
- Add all unit's children recursively for `doc.extern-map` option (rust-lang/cargo#13481)
- fix(rustc): Always pass --edition to rustc (rust-lang/cargo#13499)
- Silently ignore `cargo::rustc-check-cfg` to avoid MSRV annoyance when stabilizing `-Zcheck-cfg` (rust-lang/cargo#13438)

r? ghost
@ehuss ehuss added this to the 1.78.0 milestone Mar 2, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-unstable Area: nightly unstable support S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants