rust/tests/ui/attributes
bors 6650252439 Auto merge of #128440 - oli-obk:defines, r=lcnr
Add `#[define_opaques]` attribute and require it for all type-alias-impl-trait sites that register a hidden type

Instead of relying on the signature of items to decide whether they are constraining an opaque type, the opaque types that the item constrains must be explicitly listed.

A previous version of this PR used an actual attribute, but had to keep the resolved `DefId`s in a side table.

Now we just lower to fields in the AST that have no surface syntax, instead a builtin attribute macro fills in those fields where applicable.

Note that for convenience referencing opaque types in associated types from associated methods on the same impl will not require an attribute. If that causes problems `#[defines()]` can be used to overwrite the default of searching for opaques in the signature.

One wart of this design is that closures and static items do not have generics. So since I stored the opaques in the generics of functions, consts and methods, I would need to add a custom field to closures and statics to track this information. During a T-types discussion we decided to just not do this for now.

fixes #131298
2025-03-11 18:13:31 +00:00
..
auxiliary qnx: avoid test failure 2025-02-28 16:10:41 +02:00
inline Adjust tests/ui/attr-usage-inline.rs 2024-12-17 19:57:42 +08:00
main-removed-2 Update tests to use new proc-macro header 2024-11-27 07:18:25 -08:00
unsafe Stabilize the 2024 edition 2024-11-22 11:12:15 -08:00
z-crate-attr add more -Z crate-attr tests 2025-03-11 00:13:17 -04:00
arg-error-issue-121425.rs fix spans of arguments in diagnostic 2024-03-03 10:48:40 +08:00
arg-error-issue-121425.stderr Fix test output expectations 2025-02-24 14:31:19 +01:00
assoc-expr.rs Overhaul token collection. 2024-08-16 09:07:55 +10:00
attr-bad-crate-attr.rs Adjust tests/ui/attr-bad-crate-attr.rs 2024-12-17 19:18:30 +08:00
attr-bad-crate-attr.stderr Adjust tests/ui/attr-bad-crate-attr.rs 2024-12-17 19:18:30 +08:00
attr-before-view-item2.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
attr-before-view-item.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
attr-eq-token-tree.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
attr-eq-token-tree.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
attr-mix-new.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
attr-shebang.rs Adjust tests/ui/attr-shebang.rs 2024-12-17 19:22:21 +08:00
attrs-on-params.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
attrs-on-params.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
attrs-with-no-formal-in-generics-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
attrs-with-no-formal-in-generics-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
attrs-with-no-formal-in-generics-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
attrs-with-no-formal-in-generics-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
attrs-with-no-formal-in-generics-3.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
attrs-with-no-formal-in-generics-3.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
check-builtin-attr-ice.rs tests: add regression test for incorrect "builtin attribute is checked" assertion ICE 2024-08-04 01:50:55 +00:00
check-builtin-attr-ice.stderr Reword "crate not found" resolve message 2025-01-24 01:19:50 +00:00
check-cfg_attr-ice.rs tests: add regression test to make sure cfg_attr isn't considered unhandled 2024-08-06 06:12:10 +00:00
check-cfg_attr-ice.stderr Reword "crate not found" resolve message 2025-01-24 01:19:50 +00:00
class-attributes-1.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
class-attributes-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
collapse-debuginfo-invalid.rs Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
collapse-debuginfo-invalid.stderr Implement #[define_opaque] attribute for functions. 2025-03-11 12:05:02 +00:00
const-stability-on-macro.rs Update since stability attributes in tests 2023-10-23 13:04:47 -07:00
const-stability-on-macro.stderr Update since stability attributes in tests 2023-10-23 13:04:47 -07:00
crate-name-macro-call.rs Reject macro calls inside of #![crate_name] 2025-02-15 16:47:30 +01:00
crate-name-macro-call.stderr Reject macro calls inside of #![crate_name] 2025-02-15 16:47:30 +01:00
crate-type-delimited.rs Move #![crate_type] UI tests into attributes directory 2025-02-15 03:41:07 +01:00
crate-type-delimited.stderr Move #![crate_type] UI tests into attributes directory 2025-02-15 03:41:07 +01:00
crate-type-empty.rs Move #![crate_type] UI tests into attributes directory 2025-02-15 03:41:07 +01:00
crate-type-empty.stderr Move #![crate_type] UI tests into attributes directory 2025-02-15 03:41:07 +01:00
crate-type-macro-call.rs Move #![crate_type] UI tests into attributes directory 2025-02-15 03:41:07 +01:00
crate-type-macro-call.stderr Move #![crate_type] UI tests into attributes directory 2025-02-15 03:41:07 +01:00
crate-type-macro-empty.rs fix #137589 2025-02-25 18:17:32 +01:00
crate-type-macro-empty.stderr fix #137589 2025-02-25 18:17:32 +01:00
crate-type-macro-not-crate.rs fix #137589 2025-02-25 18:17:32 +01:00
crate-type-macro-not-crate.stderr fix #137589 2025-02-25 18:17:32 +01:00
crate-type-macro-not-found.rs fix #137589 2025-02-25 18:17:32 +01:00
crate-type-macro-not-found.stderr fix #137589 2025-02-25 18:17:32 +01:00
decl_macro_ty_in_attr_macro.rs add test to reproduce #137662 (using ty decl macro fragment in an attr) and fix it 2025-02-28 09:43:46 +01:00
doc-attr.rs Update ui tests 2024-02-29 14:43:43 +01:00
doc-attr.stderr Update ui tests 2024-02-29 14:43:43 +01:00
doc-test-literal.rs Update ui tests 2024-02-29 14:43:43 +01:00
doc-test-literal.stderr Update ui tests 2024-02-29 14:43:43 +01:00
dump_def_parents.rs Remove the -test suffix from normalize directives 2024-12-27 19:58:16 +11:00
dump_def_parents.stderr Filter empty lines, comments and delimiters from previous to last multiline span rendering 2024-12-12 23:36:27 +00:00
dump-preds.rs Remove the -test suffix from normalize directives 2024-12-27 19:58:16 +11:00
dump-preds.stderr rustc_type_ir: derivative -> derive-where 2024-07-12 21:52:04 +03:00
duplicated-attributes.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
duplicated-attributes.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
extented-attribute-macro-error.rs Remove the -test suffix from normalize directives 2024-12-27 19:58:16 +11:00
extented-attribute-macro-error.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
field-attributes-vis-unresolved.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
field-attributes-vis-unresolved.stderr Reword "crate not found" resolve message 2025-01-24 01:19:50 +00:00
invalid_macro_export_argument.deny.stderr Add invalid_macro_export_arguments to built-in macro list 2023-04-27 18:33:39 +00:00
invalid_macro_export_argument.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
invalid-repr.rs add test for invalid places of repr align 2023-04-17 12:42:02 +00:00
invalid-repr.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-40962.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-90873.rs Improve an error involving attribute values. 2023-12-12 15:54:25 +11:00
issue-90873.stderr Make parse error suggestions verbose and fix spans 2024-07-12 03:02:57 +00:00
issue-100631.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-100631.stderr Fix test output expectations 2025-02-24 14:31:19 +01:00
issue-105594-invalid-attr-validation.rs remove #[cmse_nonsecure_entry] 2024-09-21 13:05:21 +02:00
issue-105594-invalid-attr-validation.stderr remove #[cmse_nonsecure_entry] 2024-09-21 13:05:21 +02:00
issue-115264-expr-field.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-115264-pat-field.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
item-attributes.rs Remove libc from rust_get_test_int uses 2024-04-17 09:18:14 -04:00
key-value-expansion-on-mac.rs Improve an error involving attribute values. 2023-12-12 15:54:25 +11:00
key-value-expansion-on-mac.stderr Improve an error involving attribute values. 2023-12-12 15:54:25 +11:00
key-value-expansion-scope-pass.rs resolve: Implement a lint for out-of-scope use of macro_rules 2024-06-24 17:12:08 +03:00
key-value-expansion-scope.rs Specify scope in out_of_scope_macro_calls lint 2025-02-19 18:29:00 +00:00
key-value-expansion-scope.stderr Reword message 2025-02-20 17:55:31 +00:00
key-value-expansion.rs Update tests. 2025-01-07 16:04:14 +01:00
key-value-expansion.stderr Improve an error involving attribute values. 2023-12-12 15:54:25 +11:00
key-value-non-ascii.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
key-value-non-ascii.stderr Show diff suggestion format on verbose replacement 2025-02-10 20:21:39 +00:00
linkage.rs Emit an error for invalid use of the linkage attribute 2024-08-17 15:03:20 +09:00
linkage.stderr Emit an error for invalid use of the linkage attribute 2024-08-17 15:03:20 +09:00
log-backtrace.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
macro_export_on_decl_macro.rs check_attrs: Warn when #[macro_export] is used on macros 2.0 2023-08-07 21:14:28 +02:00
macro_export_on_decl_macro.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
main-removed-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
main-removed-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
malformed-fn-align.rs add test to verify that #132391 can be closed 2025-02-24 14:31:19 +01:00
malformed-fn-align.stderr add test to verify that #132391 can be closed 2025-02-24 14:31:19 +01:00
may_dangle.rs Check that #[may_dangle] is properly applied 2024-08-18 20:32:00 +03:00
may_dangle.stderr Check that #[may_dangle] is properly applied 2024-08-18 20:32:00 +03:00
method-attributes.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
mixed_export_name_and_no_mangle.fixed Fix test output expectations 2025-02-24 14:31:19 +01:00
mixed_export_name_and_no_mangle.rs Fix test output expectations 2025-02-24 14:31:19 +01:00
mixed_export_name_and_no_mangle.stderr Fix test output expectations 2025-02-24 14:31:19 +01:00
multiple-invalid.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
multiple-invalid.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
no-mangle-closure.rs Skip no_mangle if the item has no name. 2023-03-28 18:05:12 +00:00
no-mangle-closure.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
no-sanitize.rs Allow disabling ASan instrumentation for globals 2024-11-02 22:35:34 +01:00
no-sanitize.stderr Allow disabling ASan instrumentation for globals 2024-11-02 22:35:34 +01:00
nonterminal-expansion.rs Remove NtMeta. 2025-02-28 08:42:06 +11:00
nonterminal-expansion.stderr Remove NtMeta. 2025-02-28 08:42:06 +11:00
obsolete-attr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
obsolete-attr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
optimize.rs misapplied optimize attribute throws a compilation error (#128488) 2024-10-20 08:34:15 -06:00
optimize.stderr misapplied optimize attribute throws a compilation error (#128488) 2024-10-20 08:34:15 -06:00
repr-align-in-trait-issue-132391.rs Fix test output expectations 2025-02-24 14:31:19 +01:00
repr-align-in-trait-issue-132391.stderr Fix test output expectations 2025-02-24 14:31:19 +01:00
rustc_confusables_std_cases.rs Add get_line confusable to Stdin::read_line() 2024-10-02 23:19:26 -05:00
rustc_confusables_std_cases.stderr Trim suggestion parts to the subset that is purely additive 2025-02-14 00:44:10 -08:00
rustc_confusables.rs Deduplicate some logic and reword output 2024-02-22 18:05:28 +00:00
rustc_confusables.stderr Fix test output expectations 2025-02-24 14:31:19 +01:00
rustc_pub_transparent.rs New #[rustc_pub_transparent] attribute 2024-08-24 23:05:37 +03:00
rustc_pub_transparent.stderr New #[rustc_pub_transparent] attribute 2024-08-24 23:05:37 +03:00
statement-attribute-validation.rs Add regression test for #117058 2023-10-24 08:21:52 +00:00
statement-attribute-validation.stderr Add regression test for #117058 2023-10-24 08:21:52 +00:00
suffixed-literal-meta.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
suffixed-literal-meta.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
tool_attributes.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unknown-attr.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unknown-attr.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unnamed-field-attributes-dup.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unnamed-field-attributes-vis.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unnamed-field-attributes.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unrestricted-attribute-tokens.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unused-item-in-attr.rs Improve an error involving attribute values. 2023-12-12 15:54:25 +11:00
unused-item-in-attr.stderr Improve an error involving attribute values. 2023-12-12 15:54:25 +11:00
used_with_archive.rs Make #[used] work when linking with ld64 2025-02-24 04:04:59 +01:00
used_with_archive.run.stdout Make #[used] work when linking with ld64 2025-02-24 04:04:59 +01:00
used_with_arg_no_mangle.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
used_with_arg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
used_with_arg.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
used_with_multi_args.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
used_with_multi_args.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
used-issue-126789.rs Show used attribute's kind for user when find it isn't applied to a static variable. 2024-06-29 19:39:09 +08:00
used-issue-126789.stderr Show used attribute's kind for user when find it isn't applied to a static variable. 2024-06-29 19:39:09 +08:00
validation-on-associated-items-issue-121537.rs fix attribute validation on associated items in traits 2024-02-24 08:14:38 -05:00
validation-on-associated-items-issue-121537.stderr fix attribute validation on associated items in traits 2024-02-24 08:14:38 -05:00
variant-attributes.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00