diff options
| author | David Wood <david.wood@huawei.com> | 2022-03-31 09:02:31 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2022-04-05 07:01:03 +0100 |
| commit | 70ee0c96fc29c57f64a6ccfeb66cccf6fac951f7 (patch) | |
| tree | 01a686fcd042f264200076fb73abc167b90bbc3d /src/test/ui-fulldeps | |
| parent | 8100541d5496e087ca214df4e599a67a91f25983 (diff) | |
| download | rust-70ee0c96fc29c57f64a6ccfeb66cccf6fac951f7.tar.gz rust-70ee0c96fc29c57f64a6ccfeb66cccf6fac951f7.zip | |
macros: add `#[no_arg]` to skip `set_arg` call
A call to `set_arg` is generated for every field of a `SessionDiagnostic` struct without attributes, but not all types support being an argument, so `#[no_arg]` is introduced to skip these fields. Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'src/test/ui-fulldeps')
| -rw-r--r-- | src/test/ui-fulldeps/session-derive-errors.rs | 20 | ||||
| -rw-r--r-- | src/test/ui-fulldeps/session-derive-errors.stderr | 14 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/test/ui-fulldeps/session-derive-errors.rs b/src/test/ui-fulldeps/session-derive-errors.rs index 422f3894991..96d78c2d00e 100644 --- a/src/test/ui-fulldeps/session-derive-errors.rs +++ b/src/test/ui-fulldeps/session-derive-errors.rs @@ -311,3 +311,23 @@ struct ErrorWithLifetime<'a> { span: Span, name: &'a str, } + +#[derive(SessionDiagnostic)] +//~^ ERROR no method named `into_diagnostic_arg` found for struct `Hello` in the current scope +#[error(code = "E0123", slug = "foo")] +struct ArgFieldWithoutSkip { + #[primary_span] + span: Span, + other: Hello, +} + +#[derive(SessionDiagnostic)] +#[error(code = "E0123", slug = "foo")] +struct ArgFieldWithSkip { + #[primary_span] + span: Span, + // `Hello` does not implement `IntoDiagnosticArg` so this would result in an error if + // not for `#[skip_arg]`. + #[skip_arg] + other: Hello, +} diff --git a/src/test/ui-fulldeps/session-derive-errors.stderr b/src/test/ui-fulldeps/session-derive-errors.stderr index 78ed255523f..21bf8e060ba 100644 --- a/src/test/ui-fulldeps/session-derive-errors.stderr +++ b/src/test/ui-fulldeps/session-derive-errors.stderr @@ -274,5 +274,17 @@ error: cannot find attribute `nonsense` in this scope LL | #[nonsense] | ^^^^^^^^ -error: aborting due to 34 previous errors +error[E0599]: no method named `into_diagnostic_arg` found for struct `Hello` in the current scope + --> $DIR/session-derive-errors.rs:315:10 + | +LL | struct Hello {} + | ------------ method `into_diagnostic_arg` not found for this +... +LL | #[derive(SessionDiagnostic)] + | ^^^^^^^^^^^^^^^^^ method not found in `Hello` + | + = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 35 previous errors +For more information about this error, try `rustc --explain E0599`. |
