Skip to content

Conversation

@clubby789
Copy link
Contributor

@clubby789 clubby789 commented Dec 11, 2025

Split out from #149791

Currently duplicates a custom simple version parser, could instead add a dep on semver to do parsing.

  • Adds an optional msrv field to DiagCtxtInner, parsed from CARGO_PKG_RUST_VERSION if present
  • Adds an optional rust_version field to DiagInner, controlled by adding , msrv = "1.xx.0" to a #[diag]
  • Avoid emitting diagnostics for if their rust_version is > msrv

@rustbot
Copy link
Collaborator

rustbot commented Dec 11, 2025

rustc_macros::diagnostics was changed

cc @davidtwco, @compiler-errors, @TaKO8Ki

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

@rustbot
Copy link
Collaborator

rustbot commented Dec 11, 2025

r? @mati865

rustbot has assigned @mati865.
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-attributes Area: Attributes (`#[…]`, `#![…]`) A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 11, 2025
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Dec 11, 2025

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
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- [ui] tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui-fulldeps/session-diagnostic/diagnostic-derive/diagnostic-derive.stderr`
diff of stderr:

62 LL | #[diag(nonsense = "...", code = E0123, slug = "foo")]
63    |        ^^^^^^^^
64    |
-    = note: only the `code` parameter is valid after the slug
+    = note: only `code` or `msrv`are valid after the slug
66 
67 error: derive(Diagnostic): diagnostic slug not specified
68   --> $DIR/diagnostic-derive.rs:86:1

78 LL | #[diag(nonsense = 4, code = E0123, slug = "foo")]
79    |        ^^^^^^^^
80    |
-    = note: only the `code` parameter is valid after the slug
+    = note: only `code` or `msrv`are valid after the slug
82 
83 error: derive(Diagnostic): diagnostic slug not specified
84   --> $DIR/diagnostic-derive.rs:92:1

94 LL | #[diag(no_crate_example, code = E0123, slug = "foo")]
95    |                                        ^^^^
96    |
-    = note: only the `code` parameter is valid after the slug
+    = note: only `code` or `msrv`are valid after the slug
98 
99 error: derive(Diagnostic): `#[suggestion = ...]` is not a valid attribute
100   --> $DIR/diagnostic-derive.rs:105:5


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args session-diagnostic/diagnostic-derive.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui-fulldeps/session-diagnostic/diagnostic-derive" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0"
stdout: none
--- stderr -------------------------------
error: derive(Diagnostic): unsupported type attribute for diagnostic derive enum
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:47:1
   |
LL | #[diag(no_crate_example, code = E0123)]
   | ^

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:50:5
   |
LL |     Foo,
   |     ^^^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:52:5
   |
LL |     Bar,
   |     ^^^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): `#[nonsense(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:63:1
   |
LL | #[nonsense(no_crate_example, code = E0123)]
   | ^

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:63:1
   |
LL | #[nonsense(no_crate_example, code = E0123)]
   | ^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:70:1
   |
LL | #[diag(code = E0123)]
   | ^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): diagnostic slug must be the first argument
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:80:16
   |
LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")]
   |                ^

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:80:1
   |
LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")]
   | ^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): unknown argument
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:86:8
   |
LL | #[diag(nonsense = "...", code = E0123, slug = "foo")]
   |        ^^^^^^^^
   |
   = note: only `code` or `msrv`are valid after the slug

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:86:1
   |
LL | #[diag(nonsense = "...", code = E0123, slug = "foo")]
   | ^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): unknown argument
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:92:8
   |
LL | #[diag(nonsense = 4, code = E0123, slug = "foo")]
   |        ^^^^^^^^
   |
   = note: only `code` or `msrv`are valid after the slug

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:92:1
   |
LL | #[diag(nonsense = 4, code = E0123, slug = "foo")]
   | ^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): unknown argument
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:98:40
   |
LL | #[diag(no_crate_example, code = E0123, slug = "foo")]
   |                                        ^^^^
   |
   = note: only `code` or `msrv`are valid after the slug

error: derive(Diagnostic): `#[suggestion = ...]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:105:5
   |
LL |     #[suggestion = "bar"]
   |     ^

---

error: derive(Diagnostic): attribute specified multiple times
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:118:40
   |
LL | #[diag(no_crate_example, code = E0123, code = E0456)]
   |                                        ^^^^
   |
note: previously specified here
  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:118:26
   |
LL | #[diag(no_crate_example, code = E0123, code = E0456)]
   |                          ^^^^

error: derive(Diagnostic): diagnostic slug must be the first argument
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:123:43
   |
LL | #[diag(no_crate_example, no_crate::example, code = E0123)]
   |                                           ^

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:128:1
   |
LL | struct KindNotProvided {} //~ ERROR diagnostic slug not specified
   | ^^^^^^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:131:1
   |
LL | #[diag(code = E0123)]
   | ^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:142:5
   |
LL |     #[primary_span]
   |     ^

error: derive(Diagnostic): `#[nonsense]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:150:5
   |
LL |     #[nonsense]
   |     ^

error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:167:5
   |
LL |     #[label(no_crate_label)]
   |     ^

error: derive(Diagnostic): `name` doesn't refer to a field on this type
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:175:46
   |
LL |     #[suggestion(no_crate_suggestion, code = "{name}")]
   |                                              ^^^^^^^^

error: invalid format string: expected `}` but string was terminated
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:180:10
   |
LL | #[derive(Diagnostic)]
   |          ^^^^^^^^^^ expected `}` in format string
   |
   = note: if you intended to print `{`, you can escape it using `{{`
   = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)

error: invalid format string: unmatched `}` found
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:190:10
   |
LL | #[derive(Diagnostic)]
   |          ^^^^^^^^^^ unmatched `}` in format string
   |
   = note: if you intended to print `}`, you can escape it using `}}`
   = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)

error: derive(Diagnostic): the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:210:5
   |
LL |     #[label(no_crate_label)]
   |     ^

error: derive(Diagnostic): suggestion without `code = "..."`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:229:5
   |
LL |     #[suggestion(no_crate_suggestion)]
   |     ^

---
   |                  ^^^^^^^^
   |
   = help: only `no_span`, `style`, `code` and `applicability` are valid nested attributes

error: derive(Diagnostic): suggestion without `code = "..."`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:237:5
   |
LL |     #[suggestion(nonsense = "bar")]
   |     ^

error: derive(Diagnostic): invalid nested attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:246:18
   |
LL |     #[suggestion(msg = "bar")]
   |                  ^^^
   |
   = help: only `no_span`, `style`, `code` and `applicability` are valid nested attributes

error: derive(Diagnostic): suggestion without `code = "..."`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:246:5
   |
LL |     #[suggestion(msg = "bar")]
   |     ^

error: derive(Diagnostic): wrong field type for suggestion
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:269:5
   |
LL |     #[suggestion(no_crate_suggestion, code = "This is suggested code")]
   |     ^
   |
   = help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)`

error: derive(Diagnostic): attribute specified multiple times
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:285:24
   |
LL |     suggestion: (Span, Span, Applicability),
---
   |
LL |     suggestion: (Applicability, Applicability, Span),
   |                  ^^^^^^^^^^^^^

error: derive(Diagnostic): `#[label = ...]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:300:5
   |
LL |     #[label = "bar"]
   |     ^

error: derive(Diagnostic): attribute specified multiple times
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:451:5
   |
LL |     #[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")]
   |     ^
   |
note: previously specified here
  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:453:24
   |
LL |     suggestion: (Span, Applicability),
   |                        ^^^^^^^^^^^^^

error: derive(Diagnostic): invalid applicability
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:459:69
   |
LL |     #[suggestion(no_crate_suggestion, code = "...", applicability = "batman")]
   |                                                                     ^^^^^^^^

error: derive(Diagnostic): the `#[help(...)]` attribute can only be applied to fields of type `Span`, `MultiSpan`, `bool` or `()`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:526:5
   |
LL |     #[help(no_crate_help)]
   |     ^

error: derive(Diagnostic): a diagnostic slug must be the first argument to the attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:535:32
   |
LL |     #[label(no_crate_label, foo)]
   |                                ^

error: derive(Diagnostic): only `no_span` is a valid nested attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:543:29
   |
LL |     #[label(no_crate_label, foo = "...")]
   |                             ^^^

error: derive(Diagnostic): only `no_span` is a valid nested attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:551:29
   |
LL |     #[label(no_crate_label, foo("..."))]
   |                             ^^^

error: derive(Diagnostic): `#[primary_span]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:563:5
   |
LL |     #[primary_span]
   |     ^
   |
   = help: the `primary_span` field attribute is not valid for lint diagnostics

error: derive(Diagnostic): `#[error(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:583:1
   |
LL | #[error(no_crate_example, code = E0123)]
   | ^

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:583:1
   |
LL | #[error(no_crate_example, code = E0123)]
   | ^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): `#[warn_(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:590:1
   |
LL | #[warn_(no_crate_example, code = E0123)]
   | ^

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:590:1
   |
LL | #[warn_(no_crate_example, code = E0123)]
   | ^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:597:1
   |
LL | #[lint(no_crate_example, code = E0123)]
   | ^

error: derive(Diagnostic): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:597:1
   |
LL | #[lint(no_crate_example, code = E0123)]
   | ^
   |
   = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]`

error: derive(Diagnostic): `#[lint(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:604:1
   |
LL | #[lint(no_crate_example, code = E0123)]
   | ^

---

error: derive(Diagnostic): attribute specified multiple times
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:613:53
   |
LL |     #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
   |                                                     ^^^^
   |
note: previously specified here
  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:613:39
   |
LL |     #[suggestion(no_crate_suggestion, code = "...", code = ",,,")]
   |                                       ^^^^

error: derive(Diagnostic): wrong types for suggestion
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:622:24
   |
LL |     suggestion: (Span, usize),
   |                        ^^^^^
   |
   = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`

error: derive(Diagnostic): wrong types for suggestion
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:630:17
   |
LL |     suggestion: (Span,),
   |                 ^^^^^^^
   |
   = help: `#[suggestion(...)]` on a tuple field must be applied to fields of type `(Span, Applicability)`

error: derive(Diagnostic): suggestion without `code = "..."`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:637:5
   |
LL |     #[suggestion(no_crate_suggestion)]
   |     ^

error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:644:1
   |
LL | #[multipart_suggestion(no_crate_suggestion)]
   | ^
   |
   = help: consider creating a `Subdiagnostic` instead

error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:647:1
   |
LL | #[multipart_suggestion()]
   | ^
   |
   = help: consider creating a `Subdiagnostic` instead

error: derive(Diagnostic): `#[multipart_suggestion(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:651:5
   |
LL |     #[multipart_suggestion(no_crate_suggestion)]
   |     ^
   |
   = help: consider creating a `Subdiagnostic` instead

error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:659:1
   |
LL | #[suggestion(no_crate_suggestion, code = "...")]
   | ^
   |
   = help: `#[label]` and `#[suggestion]` can only be applied to fields

error: derive(Diagnostic): `#[label]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:668:1
   |
LL | #[label]
   | ^
   |
   = help: `#[label]` and `#[suggestion]` can only be applied to fields

error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:702:5
   |
LL |     #[subdiagnostic(bad)]
   |     ^

error: derive(Diagnostic): `#[subdiagnostic = ...]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:710:5
   |
LL |     #[subdiagnostic = "bad"]
   |     ^

error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:718:5
   |
LL |     #[subdiagnostic(bad, bad)]
   |     ^

error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:726:5
   |
LL |     #[subdiagnostic("bad")]
   |     ^

error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:734:5
   |
LL |     #[subdiagnostic(eager)]
   |     ^

error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:742:5
   |
LL |     #[subdiagnostic(eager)]
   |     ^

error: derive(Diagnostic): `#[subdiagnostic(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:763:5
   |
LL |     #[subdiagnostic(eager)]
   |     ^

error: derive(Diagnostic): expected at least one string literal for `code(...)`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:794:23
   |
LL |     #[suggestion(code())]
   |                       ^

error: derive(Diagnostic): `code(...)` must contain only string literals
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:802:23
   |
LL |     #[suggestion(code(foo))]
   |                       ^^^

error: derive(Diagnostic): `#[suggestion(...)]` is not a valid attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:826:5
   |
LL |     #[suggestion(no_crate_suggestion, code = "")]
   |     ^
   |
   = note: `#[suggestion(...)]` applied to `Vec` field is ambiguous
   = help: to show a suggestion consisting of multiple parts, use a `Subdiagnostic` annotated with `#[multipart_suggestion(...)]`
   = help: to show a variable set of suggestions, use a `Vec` of `Subdiagnostic`s annotated with `#[suggestion(...)]`

error[E0433]: failed to resolve: you might be missing crate `core`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:58:8
   |
LL | #[diag = "E0123"]
   |        ^ you might be missing crate `core`

error[E0433]: failed to resolve: you might be missing crate `core`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:802:23
   |
LL |     #[suggestion(code(foo))]
   |                       ^^^ you might be missing crate `core`

error[E0433]: failed to resolve: you might be missing crate `core`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:811:25
   |
LL |     #[suggestion(code = 3)]
   |                         ^ you might be missing crate `core`

error: cannot find attribute `nonsense` in this scope
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:63:3
   |
LL | #[nonsense(no_crate_example, code = E0123)]
   |   ^^^^^^^^

error: cannot find attribute `nonsense` in this scope
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:150:7
   |
LL |     #[nonsense]
   |       ^^^^^^^^

error: cannot find attribute `error` in this scope
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:583:3
   |
LL | #[error(no_crate_example, code = E0123)]
   |   ^^^^^
   |
help: `error` is an attribute that can be used by the derive macro `Error`, you might be missing a `derive` attribute
   |
LL + #[derive(Error)]
LL | struct ErrorAttribute {}
   |

error: cannot find attribute `warn_` in this scope
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:590:3
   |
LL | #[warn_(no_crate_example, code = E0123)]
   |   ^^^^^
   |
help: a built-in attribute with a similar name exists
   |
LL - #[warn_(no_crate_example, code = E0123)]
LL + #[warn(no_crate_example, code = E0123)]
   |

error: cannot find attribute `lint` in this scope
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:597:3
   |
LL | #[lint(no_crate_example, code = E0123)]
   |   ^^^^
   |
help: a built-in attribute with a similar name exists
   |
LL - #[lint(no_crate_example, code = E0123)]
LL + #[link(no_crate_example, code = E0123)]
   |

error: cannot find attribute `lint` in this scope
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:604:3
   |
LL | #[lint(no_crate_example, code = E0123)]
   |   ^^^^
   |
help: a built-in attribute with a similar name exists
   |
LL - #[lint(no_crate_example, code = E0123)]
LL + #[link(no_crate_example, code = E0123)]
   |

error: cannot find attribute `multipart_suggestion` in this scope
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:644:3
   |
---

error[E0425]: cannot find value `nonsense` in module `crate::fluent_generated`
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:75:8
   |
LL | #[diag(nonsense, code = E0123)]
   |        ^^^^^^^^ not found in `crate::fluent_generated`

error[E0425]: cannot find value `__code_34` in this scope
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:808:10
   |
LL | #[derive(Diagnostic)] //~ ERROR cannot find value `__code_34` in this scope
   |          ^^^^^^^^^^ not found in this scope
   |
   = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `Hello: IntoDiagArg` is not satisfied
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:349:12
   |
LL | #[derive(Diagnostic)]
   |          ---------- required by a bound introduced by this call
...
---
             AllocRange
             Backtrace
             Binder<I, T>
           and 75 others
note: required by a bound in `Diag::<'a, G>::arg`
  --> /rustc/FAKE_PREFIX/compiler/rustc_errors/src/diagnostic.rs:1332:4
   = note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 85 previous errors

@RalfJung
Copy link
Member

Adds an optional msrv field to DiagCtxtInner, parsed from CARGO_PKG_RUST_VERSION if present

That's an odd way to pass information from cargo to rustc. Usually we use command-line flags for that. Is there any precedent for rustc parsing a CARGO_* env var?

@mati865
Copy link
Member

mati865 commented Dec 11, 2025

@rustbot reroll

I don't have experience with lint system.

@rustbot rustbot assigned SparrowLii and unassigned mati865 Dec 11, 2025
@clubby789
Copy link
Contributor Author

clubby789 commented Dec 11, 2025

There's

if name.as_str() == "wasm_bindgen" {
let major = env::var("CARGO_PKG_VERSION_MAJOR")
as well as some Fluent translation infrastructure that use it.

If an --msrv flag or similar is preferred, I can open an MCP for that.

@RalfJung
Copy link
Member

RalfJung commented Dec 11, 2025

There's [...] as well as some Fluent translation infrastructure that use it.

Those are ad-hoc workarounds and largely only affect diagnostics. We can remove it any time, it's not part of the stable API of rustc.

(The use in compiler/rustc_fluent_macro/src/fluent.rs is a proc macro used in the compiler. So this happens at compiler build time, not at compiler run time.)

If an --msrv flag or similar is preferred, I can open an MCP for that.

I think that would be much more in line with the existing interface of rustc, yes. (This IMO needs an MCP either way since it's a new API no matter which shape it takes.)

@clubby789
Copy link
Contributor Author

MCP: rust-lang/compiler-team#950

@bors
Copy link
Collaborator

bors commented Dec 12, 2025

☔ The latest upstream changes (presumably #149645) made this pull request unmergeable. Please resolve the merge conflicts.

@jdonszelmann
Copy link
Contributor

@rustbot blocked on mcp

(and ci failing hehe)

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 15, 2025
@rustbot rustbot added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Dec 15, 2025
@clubby789 clubby789 added the S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-blocked Status: Blocked on something else such as an RFC or other implementation work. S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants