Allow defining opaques in statics and consts

This commit is contained in:
Michael Goulet 2025-03-24 23:19:18 +00:00
parent 2bf0c2df14
commit f8df298d74
17 changed files with 314 additions and 162 deletions

View file

@ -11,15 +11,20 @@ pub(crate) fn expand(
let define_opaque = match &mut item {
Annotatable::Item(p) => match &mut p.kind {
ast::ItemKind::Fn(f) => Some(&mut f.define_opaque),
ast::ItemKind::Const(ct) => Some(&mut ct.define_opaque),
ast::ItemKind::Static(si) => Some(&mut si.define_opaque),
_ => None,
},
Annotatable::AssocItem(i, _assoc_ctxt) => match &mut i.kind {
ast::AssocItemKind::Fn(func) => Some(&mut func.define_opaque),
ast::AssocItemKind::Const(ct) => Some(&mut ct.define_opaque),
_ => None,
},
Annotatable::Stmt(s) => match &mut s.kind {
ast::StmtKind::Item(p) => match &mut p.kind {
ast::ItemKind::Fn(f) => Some(&mut f.define_opaque),
ast::ItemKind::Const(ct) => Some(&mut ct.define_opaque),
ast::ItemKind::Static(si) => Some(&mut si.define_opaque),
_ => None,
},
_ => None,

View file

@ -285,6 +285,7 @@ pub(crate) fn expand_test_or_bench(
defaultness: ast::Defaultness::Final,
generics: ast::Generics::default(),
ty: cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))),
define_opaque: None,
// test::TestDescAndFn {
expr: Some(
cx.expr_struct(