Skip to content

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

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

When compiling without a specified --edition, emit a note#158102
estebank wants to merge 5 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

This comment has been minimized.

@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

@estebank
estebank force-pushed the note-default-edition branch from a1d6de2 to a25876f Compare September 13, 2026 23:31
@rustbot

rustbot commented Sep 13, 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.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-aarch64-gnu-llvm-21-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Finished `release` profile [optimized] target(s) in 2.45s
     Running `/checkout/obj/build/aarch64-unknown-linux-gnu/stage3-codegen/aarch64-unknown-linux-gnu/release/y test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot`
##[group]Build sysroot
[BUILD] sysroot None
note: `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

[RUSTC-TIMING] ____ test:false 0.020
note: `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

note: `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

note: `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

##[endgroup]
##[group][BUILD] mini_core
[BUILD] mini_core
##[endgroup]
---

##[endgroup]
##[group]Build sysroot
[BUILD] sysroot Llvm
note: `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

[RUSTC-TIMING] ____ test:false 0.021
note: `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

note: `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

note: `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

##[endgroup]
##[group][AOT] arbitrary_self_types_pointers_and_wrappers
[AOT] arbitrary_self_types_pointers_and_wrappers
##[endgroup]
---
[AOT] issue-59326
##[endgroup]
##[group][AOT] neon
[AOT] neon
note: `--edition` is unspecified, defaulting to `2015` while the latest is `2024`; it must be one of: <2015|2018|2021|2024|future>

##[endgroup]
##[group][AOT] gen_block_iterate
[AOT] gen_block_iterate
##[endgroup]
---
   Compiling rustc_interface v0.0.0 (/checkout/compiler/rustc_interface)
error[E0061]: this function takes 3 arguments but 2 arguments were supplied
    --> compiler/rustc_interface/src/tests.rs:952:16
     |
 952 |     let opts = build_session_options(&mut early_dcx, &matches);
     |                ^^^^^^^^^^^^^^^^^^^^^-------------------------- argument #3 of type `bool` is missing
     |
note: function defined here
    --> compiler/rustc_session/src/config.rs:2692:8
     |
2692 | pub fn build_session_options(
     |        ^^^^^^^^^^^^^^^^^^^^^
help: provide the argument
     |
 952 |     let opts = build_session_options(&mut early_dcx, &matches, /* bool */);
     |                                                              ++++++++++++

error[E0061]: this function takes 3 arguments but 2 arguments were supplied
    --> compiler/rustc_interface/src/tests.rs:963:20
     |
 963 |         let opts = build_session_options(&mut early_dcx, &matches);
     |                    ^^^^^^^^^^^^^^^^^^^^^-------------------------- argument #3 of type `bool` is missing
     |
note: function defined here
    --> compiler/rustc_session/src/config.rs:2692:8
     |
2692 | pub fn build_session_options(
     |        ^^^^^^^^^^^^^^^^^^^^^
help: provide the argument
     |
 963 |         let opts = build_session_options(&mut early_dcx, &matches, /* bool */);
     |                                                                  ++++++++++++

error[E0061]: this function takes 3 arguments but 2 arguments were supplied
    --> compiler/rustc_interface/src/tests.rs:976:20
     |
 976 |         let opts = build_session_options(&mut early_dcx, &matches);
     |                    ^^^^^^^^^^^^^^^^^^^^^-------------------------- argument #3 of type `bool` is missing
     |
note: function defined here
    --> compiler/rustc_session/src/config.rs:2692:8
     |
2692 | pub fn build_session_options(
     |        ^^^^^^^^^^^^^^^^^^^^^
help: provide the argument
     |
 976 |         let opts = build_session_options(&mut early_dcx, &matches, /* bool */);
     |                                                                  ++++++++++++

[RUSTC-TIMING] rustc_driver_impl test:true 2.320
   Compiling rustc_public v0.1.0-preview (/checkout/compiler/rustc_public)
For more information about this error, try `rustc --explain E0061`.

pull Bot pushed a commit to quansat775-ux/cargo that referenced this pull request Sep 14, 2026
As part of notifying users calling bare `rustc` without an explicit
edition that they should likely be using the 2024 edition, update cargo
tests to not trigger the new user facing note. This change will let
rust-lang/rust#158102 to land.
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