diff options
| author | bors <bors@rust-lang.org> | 2025-03-11 18:13:31 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-03-11 18:13:31 +0000 | 
| commit | 6650252439d4e03368b305c42a10006e36f1545e (patch) | |
| tree | 143473174f128998c2f0665dd2802ce459dadedd /compiler/rustc_builtin_macros/src/lib.rs | |
| parent | f2d69d5a7c04617d122facd0a7a5bdde0af928ae (diff) | |
| parent | 69a1bb8bdba5ccb76a72e35a69fde1937c287386 (diff) | |
| download | rust-6650252439d4e03368b305c42a10006e36f1545e.tar.gz rust-6650252439d4e03368b305c42a10006e36f1545e.zip | |
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
Diffstat (limited to 'compiler/rustc_builtin_macros/src/lib.rs')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/lib.rs | 2 | 
1 files changed, 2 insertions, 0 deletions
| diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index ca16583a45d..c5d2a84fba4 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -39,6 +39,7 @@ mod compile_error; mod concat; mod concat_bytes; mod concat_idents; +mod define_opaque; mod derive; mod deriving; mod edition_panic; @@ -114,6 +115,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { bench: test::expand_bench, cfg_accessible: cfg_accessible::Expander, cfg_eval: cfg_eval::expand, + define_opaque: define_opaque::expand, derive: derive::Expander { is_const: false }, derive_const: derive::Expander { is_const: true }, global_allocator: global_allocator::expand, | 
