Skip to content

When compiling without a specified --edition, emit a note - #158102

Open
estebank wants to merge 4 commits into
rust-lang:mainfrom
estebank:note-default-edition
Open

When compiling without a specified --edition, emit a note#158102
estebank wants to merge 4 commits into
rust-lang:mainfrom
estebank:note-default-edition

Conversation

@estebank

Copy link
Copy Markdown
Contributor

No description provided.

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jun 18, 2026
@rust-log-analyzer

This comment was marked as resolved.

@estebank

Copy link
Copy Markdown
Contributor Author

I'll try to write an MCP later (unless someone does it for me). This change was motivated after seeing https://internals.rust-lang.org/t/code-compiles-on-playground-but-fails-when-passed-via-stdin-to-rustc/24393 where the different defaults between cargo, playground and rustc caused people to get confused.

@estebank
estebank force-pushed the note-default-edition branch from b923a75 to 2a486d3 Compare June 18, 2026 20:41
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@estebank
estebank force-pushed the note-default-edition branch from 4241536 to d71c2fa Compare July 21, 2026 02:17
@estebank estebank added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Jul 21, 2026
@estebank
estebank marked this pull request as ready for review July 21, 2026 02:25
@rustbot

rustbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 21, 2026
@rustbot

rustbot commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
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: compiler
  • compiler expanded to 74 candidates
  • Random selection from 18 candidates

@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 25, 2026
@estebank
estebank force-pushed the note-default-edition branch from d71c2fa to a1d6de2 Compare July 27, 2026 06:56
@rustbot

rustbot commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main 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.

@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Aug 3, 2026

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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


fn main() {
rustc().input("foo-prev.rs").run();
rustc().edition("2015").input("foo-prev.rs").run();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remark: we could consider default setting edition but allow overriding, but explicit is fine

@rust-bors

rust-bors Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📌 Commit a1d6de2 has been approved by jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Aug 4, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 4, 2026
…ieyouxu

When compiling without a specified `--edition`, emit a note
@jhpratt

jhpratt commented Aug 4, 2026

Copy link
Copy Markdown
Member

@bors r- #160481 (comment)

---- messages::deduplicate_errors stdout ----
running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/cargo test -j1`

thread 'messages::deduplicate_errors' (114996) panicked at src/tools/cargo/tests/testsuite/messages.rs:163:10:

--- Expected
++++ actual:   stderr
   1    1 | [COMPILING] foo v0.0.1 ([ROOT]/foo)
   2      - [NOTE] `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>
   3      - 
   4    2 | [ERROR] expected one of `!` or `::`, found `should`
   5    3 |  --> src/lib.rs:2:22
   6    4 |   |
   7    5 | 2 |                 this should not compile
   8    6 |   |                      ^^^^^^ expected one of `!` or `::`
   9    7 | 
  10    8 | [ERROR] could not compile `foo` (lib) due to 1 previous error



---- messages::deduplicate_errors stdout end ----
---- messages::deduplicate_messages_basic stdout ----
running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/cargo test --no-run -j1`

thread 'messages::deduplicate_messages_basic' (115030) panicked at src/tools/cargo/tests/testsuite/messages.rs:87:10:

--- Expected
++++ actual:   stderr
   1    1 | [COMPILING] foo v0.0.1 ([ROOT]/foo)
   2      - [NOTE] `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>
   3      - 
   4    2 | [WARNING] unused variable: `x`
   5    3 |  --> src/lib.rs:3:25
   6    4 |   |
   7    5 | 3 |                     let x = 1;
   8    6 |   |                         ^ [HELP] if this is intentional, prefix it with an underscore: `_x`
   9    7 |   |
  10    8 |   = [NOTE] `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default
  11    9 | 
  12      - [WARNING] `foo` (lib) generated 1 warning[..]
       10 + [WARNING] `foo` (lib) generated 1 warning (run `cargo fix --lib -p foo` to apply 1 suggestion)
  13   11 | [WARNING] `foo` (lib test) generated 1 warning (1 duplicate)
  14   12 | [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
  15      - [EXECUTABLE] unittests src/lib.rs (target/debug/deps/foo-[HASH][EXE])
       13 + [EXECUTABLE] unittests src/lib.rs (target/debug/deps/foo-[HASH])



---- messages::deduplicate_messages_basic stdout end ----

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 4, 2026
@rust-bors

rust-bors Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#160481), which was unapproved.

View changes since this unapproval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-run-make Area: port run-make Makefiles to rmake.rs A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants