about summary refs log tree commit diff
path: root/compiler/rustc_ast_passes/src/ast_validation.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2025-03-21 15:25:30 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2025-04-01 13:42:00 +1100
commit43018eacb61da96b718f70b7719bf5e51207df61 (patch)
tree024a6539f9881d2e2a148f26c9a406ce1d403058 /compiler/rustc_ast_passes/src/ast_validation.rs
parentdeed0f2480c507f7a3979ea814ade54685c5c45a (diff)
downloadrust-43018eacb61da96b718f70b7719bf5e51207df61.tar.gz
rust-43018eacb61da96b718f70b7719bf5e51207df61.zip
Ignore `#[test_case]` on anything other than `fn`/`const`/`static`.
`expand_test_case` looks for any item with a `#[test_case]` attribute
and adds a `test_path_symbol` attribute to it while also fiddling with
the item's ident's span.

This is pretty weird, because `#[test_case]` is only valid on
`fn`/`const`/`static` items, as far as I can tell. But you don't
currently get an error or warning if you use it on other kinds of items.

This commit changes things so that a `#[test_case]` item is modified
only if it is `fn`/`const`/`static`. This is relevant for moving idents
from `Item` to `ItemKind`, because some item kinds don't have an ident,
e.g. `impl` blocks.

The commit also does the following.
- Renames a local variable `test_id` as `test_ident`.
- Changes a `const` to `static` in
  `tests/ui/custom_test_frameworks/full.rs` to give the `static` case
  some test coverage.
- Adds a `struct` and `impl` to the same test to give some test coverage
  to the non-affected item kinds. These have a `FIXME` comment
  identifying the weirdness here. Hopefully this will be useful
  breadcrumbs for somebody else in the future.
Diffstat (limited to 'compiler/rustc_ast_passes/src/ast_validation.rs')
0 files changed, 0 insertions, 0 deletions