Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6650252

Browse files
committedMar 11, 2025
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
2 parents f2d69d5 + 69a1bb8 commit 6650252

File tree

666 files changed

+2912
-2469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

666 files changed

+2912
-2469
lines changed
 

‎compiler/rustc_builtin_macros/src/alloc_error_handler.rs

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ fn generate_handler(cx: &ExtCtxt<'_>, handler: Ident, span: Span, sig_span: Span
8888
generics: Generics::default(),
8989
contract: None,
9090
body,
91+
define_opaque: None,
9192
}));
9293

9394
let attrs = thin_vec![cx.attr_word(sym::rustc_std_internal_symbol, span)];

‎compiler/rustc_builtin_macros/src/autodiff.rs

+1
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ mod llvm_enzyme {
247247
generics: Generics::default(),
248248
contract: None,
249249
body: Some(d_body),
250+
define_opaque: None,
250251
});
251252
let mut rustc_ad_attr =
252253
P(ast::NormalAttr::from_ident(Ident::with_dummy_span(sym::rustc_autodiff)));
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.