mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
internal: Implement module_path
macro
This commit is contained in:
parent
9b7b93e031
commit
d44a3ab30c
20 changed files with 279 additions and 71 deletions
|
@ -116,7 +116,6 @@ register_builtin! {
|
|||
(column, Column) => line_expand,
|
||||
(file, File) => file_expand,
|
||||
(line, Line) => line_expand,
|
||||
(module_path, ModulePath) => module_path_expand,
|
||||
(assert, Assert) => assert_expand,
|
||||
(stringify, Stringify) => stringify_expand,
|
||||
(llvm_asm, LlvmAsm) => asm_expand,
|
||||
|
@ -142,7 +141,10 @@ register_builtin! {
|
|||
(include_bytes, IncludeBytes) => include_bytes_expand,
|
||||
(include_str, IncludeStr) => include_str_expand,
|
||||
(env, Env) => env_expand,
|
||||
(option_env, OptionEnv) => option_env_expand
|
||||
(option_env, OptionEnv) => option_env_expand,
|
||||
// This isn't really eager, we have no inputs, but we abuse the fact how eager macros are
|
||||
// handled in r-a to be able to thread the module path through.
|
||||
(module_path, ModulePath) => module_path_expand
|
||||
}
|
||||
|
||||
fn mk_pound(span: Span) -> tt::Subtree {
|
||||
|
@ -157,18 +159,6 @@ fn mk_pound(span: Span) -> tt::Subtree {
|
|||
)
|
||||
}
|
||||
|
||||
fn module_path_expand(
|
||||
_db: &dyn ExpandDatabase,
|
||||
_id: MacroCallId,
|
||||
_tt: &tt::Subtree,
|
||||
span: Span,
|
||||
) -> ExpandResult<tt::Subtree> {
|
||||
// Just return a dummy result.
|
||||
ExpandResult::ok(quote! {span =>
|
||||
"module::path"
|
||||
})
|
||||
}
|
||||
|
||||
fn line_expand(
|
||||
_db: &dyn ExpandDatabase,
|
||||
_id: MacroCallId,
|
||||
|
@ -904,6 +894,18 @@ fn option_env_expand(
|
|||
ExpandResult::ok(expanded)
|
||||
}
|
||||
|
||||
fn module_path_expand(
|
||||
_db: &dyn ExpandDatabase,
|
||||
_id: MacroCallId,
|
||||
tt: &tt::Subtree,
|
||||
span: Span,
|
||||
) -> ExpandResult<tt::Subtree> {
|
||||
// Note: The actual implementation of this is in crates\hir-expand\src\eager.rs
|
||||
ExpandResult::ok(quote! {span =>
|
||||
#tt
|
||||
})
|
||||
}
|
||||
|
||||
fn quote_expand(
|
||||
_db: &dyn ExpandDatabase,
|
||||
_arg_id: MacroCallId,
|
||||
|
|
|
@ -128,7 +128,7 @@ macro_rules! quote_impl__ {
|
|||
}
|
||||
};
|
||||
}
|
||||
pub(super) use quote_impl__ as __quote;
|
||||
pub(crate) use quote_impl__ as __quote;
|
||||
|
||||
/// FIXME:
|
||||
/// It probably should implement in proc-macro
|
||||
|
@ -137,7 +137,7 @@ macro_rules! quote_impl {
|
|||
$crate::builtin::quote::IntoTt::to_subtree($crate::builtin::quote::__quote!($span $($tt)*), $span)
|
||||
}
|
||||
}
|
||||
pub(super) use quote_impl as quote;
|
||||
pub(crate) use quote_impl as quote;
|
||||
|
||||
pub(crate) trait IntoTt {
|
||||
fn to_subtree(self, span: Span) -> crate::tt::Subtree;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue