mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-27 16:07:46 +00:00
Register define_opaque builtin attribute macro
So that we'll correctly treat it as an attribute. I don't like that we have to register every builtin macro even if we don't need it, but that's what we got.
This commit is contained in:
parent
2d3f2e516f
commit
a4612ce527
@ -7,7 +7,7 @@ use crate::{ExpandResult, MacroCallId, MacroCallKind, db::ExpandDatabase, name,
|
||||
use super::quote;
|
||||
|
||||
macro_rules! register_builtin {
|
||||
($(($name:ident, $variant:ident) => $expand:ident),* ) => {
|
||||
($(($name:ident, $variant:ident) => $expand:ident),* $(,)? ) => {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum BuiltinAttrExpander {
|
||||
$($variant),*
|
||||
@ -65,7 +65,8 @@ register_builtin! {
|
||||
(derive_const, DeriveConst) => derive_expand,
|
||||
(global_allocator, GlobalAllocator) => dummy_attr_expand,
|
||||
(test, Test) => dummy_gate_test_expand,
|
||||
(test_case, TestCase) => dummy_gate_test_expand
|
||||
(test_case, TestCase) => dummy_gate_test_expand,
|
||||
(define_opaque, DefineOpaque) => dummy_attr_expand,
|
||||
}
|
||||
|
||||
pub fn find_builtin_attr(ident: &name::Name) -> Option<BuiltinAttrExpander> {
|
||||
|
||||
@ -1508,3 +1508,55 @@ extern crate dep;
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builtin_macro_completed_only_as_its_kind() {
|
||||
check(
|
||||
r#"
|
||||
#[rustc_builtin_macro]
|
||||
pub macro define_opaque($($tt:tt)*) {
|
||||
/* compiler built-in */
|
||||
}
|
||||
|
||||
fn foo() {
|
||||
def$0
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
fn foo() fn()
|
||||
bt u32 u32
|
||||
kw async
|
||||
kw const
|
||||
kw crate::
|
||||
kw enum
|
||||
kw extern
|
||||
kw false
|
||||
kw fn
|
||||
kw for
|
||||
kw if
|
||||
kw if let
|
||||
kw impl
|
||||
kw impl for
|
||||
kw let
|
||||
kw letm
|
||||
kw loop
|
||||
kw match
|
||||
kw mod
|
||||
kw return
|
||||
kw self::
|
||||
kw static
|
||||
kw struct
|
||||
kw trait
|
||||
kw true
|
||||
kw type
|
||||
kw union
|
||||
kw unsafe
|
||||
kw use
|
||||
kw while
|
||||
kw while let
|
||||
sn macro_rules
|
||||
sn pd
|
||||
sn ppd
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
@ -524,4 +524,5 @@ define_symbols! {
|
||||
arbitrary_self_types,
|
||||
arbitrary_self_types_pointers,
|
||||
supertrait_item_shadowing,
|
||||
define_opaque,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user