Skip to content

Detect missing derive on unresolved attribute even when not imported #142487

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jun 14, 2025

When encountering unresolved attributes, ensure the proc-macros for every crate in scope are added to the macro_map so that typos and missing derives are properly detected.

error: cannot find attribute `sede` in this scope
  --> $DIR/missing-derive-3.rs:20:7
   |
LL |     #[sede(untagged)]
   |       ^^^^
   |
help: the derive macros `Deserialize` and `Serialize` accept the similarly named `serde` attribute
   |
LL |     #[serde(untagged)]
   |         +

error: cannot find attribute `serde` in this scope
  --> $DIR/missing-derive-3.rs:14:7
   |
LL |     #[serde(untagged)]
   |       ^^^^^
   |
note: `serde` is imported here, but it is a crate, not an attribute
  --> $DIR/missing-derive-3.rs:4:1
   |
LL | extern crate serde;
   | ^^^^^^^^^^^^^^^^^^^
help: `serde` is an attribute that can be used by the derive macros `Deserialize` and `Serialize`, you might be missing a `derive` attribute
   |
LL + #[derive(Deserialize, Serialize)]
LL | enum B {
   |

Follow up to #134841.

```
error: cannot find attribute `sede` in this scope
  --> $DIR/missing-derive-3.rs:20:7
   |
LL |     #[sede(untagged)]
   |       ^^^^
   |
help: the derive macros `Deserialize` and `Serialize` accept the similarly named `serde` attribute
   |
LL |     #[serde(untagged)]
   |         +

error: cannot find attribute `serde` in this scope
  --> $DIR/missing-derive-3.rs:14:7
   |
LL |     #[serde(untagged)]
   |       ^^^^^
   |
note: `serde` is imported here, but it is a crate, not an attribute
  --> $DIR/missing-derive-3.rs:4:1
   |
LL | extern crate serde;
   | ^^^^^^^^^^^^^^^^^^^
help: `serde` is an attribute that can be used by the derive macros `Deserialize` and `Serialize`, you might be missing a `derive` attribute
   |
LL + #[derive(Deserialize, Serialize)]
LL | enum B {
   |
```
@rustbot
Copy link
Collaborator

rustbot commented Jun 14, 2025

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 14, 2025
Comment on lines +172 to +179
/// Add every proc macro accessible from the current crate to the `macro_map` so diagnostics can
/// find them for suggestions.
pub(crate) fn register_macros_for_all_crates(&mut self) {
let def_ids = self.cstore().all_proc_macro_def_ids();
for def_id in def_ids {
self.get_macro_by_def_id(def_id);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should memoize this, but the Resolver doesn't use queries, so we should likely do that "manually" by adding a signal field to the Resolver to skip this logic after the first call.

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
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:

559    |
560 LL | #[error(no_crate_example, code = E0123)]
561    |   ^^^^^
+    |
+ help: `error` is an attribute that can be used by the derive macro `Error`, you might be missing a `derive` attribute
+    |
+ LL + #[derive(Error)]
---
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" "-A" "internal_features" "-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 the `code` parameter is 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 the `code` parameter is 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 the `code` parameter is 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:112:8
   |
---

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)]
   |     ^

error: derive(Diagnostic): invalid nested attribute
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:237:18
   |
LL |     #[suggestion(nonsense = "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: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): diagnostic slug not specified
##[error]  --> /checkout/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs:604:1
   |
LL | #[lint(no_crate_example, code = E0123)]
   | ^
   |
   = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]`

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: `warn`

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)]
---

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
...
LL |     other: Hello,
   |            ^^^^^ the trait `IntoDiagArg` is not implemented for `Hello`
   |
   = help: the following other types implement trait `IntoDiagArg`:
             &'a T
             &'a std::path::Path
             &'a str
             &rustc_target::spec::TargetTuple
             AllocId
             AllocRange
             Backtrace
             Binder<I, T>
           and 71 others
note: required by a bound in `Diag::<'a, G>::arg`
  --> /rustc/FAKE_PREFIX/compiler/rustc_errors/src/diagnostic.rs:1276:5
   = 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

@jieyouxu

This comment was marked as off-topic.

@rustbot

This comment was marked as off-topic.

@jieyouxu
Copy link
Member

r? compiler

@rustbot rustbot assigned compiler-errors and unassigned jieyouxu Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler 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