mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Resolve macro-error
diagnostics on asm & llvm_asm
We currently stub these out as returning unit. This fixes spurious RA diagnostics in the following: ```rust unsafe { asm!(""); llvm_asm!(""); } ```
This commit is contained in:
parent
34f7b5383a
commit
090a59970d
2 changed files with 17 additions and 0 deletions
|
@ -95,6 +95,8 @@ register_builtin! {
|
||||||
// format_args_nl only differs in that it adds a newline in the end,
|
// format_args_nl only differs in that it adds a newline in the end,
|
||||||
// so we use the same stub expansion for now
|
// so we use the same stub expansion for now
|
||||||
(format_args_nl, FormatArgsNl) => format_args_expand,
|
(format_args_nl, FormatArgsNl) => format_args_expand,
|
||||||
|
(llvm_asm, LlvmAsm) => asm_expand,
|
||||||
|
(asm, Asm) => asm_expand,
|
||||||
|
|
||||||
EAGER:
|
EAGER:
|
||||||
(compile_error, CompileError) => compile_error_expand,
|
(compile_error, CompileError) => compile_error_expand,
|
||||||
|
@ -271,6 +273,19 @@ fn format_args_expand(
|
||||||
ExpandResult::ok(expanded)
|
ExpandResult::ok(expanded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn asm_expand(
|
||||||
|
_db: &dyn AstDatabase,
|
||||||
|
_id: LazyMacroId,
|
||||||
|
_tt: &tt::Subtree,
|
||||||
|
) -> ExpandResult<tt::Subtree> {
|
||||||
|
// both asm and llvm_asm don't return anything, so we can expand them to nothing,
|
||||||
|
// for now
|
||||||
|
let expanded = quote! {
|
||||||
|
()
|
||||||
|
};
|
||||||
|
ExpandResult::ok(expanded)
|
||||||
|
}
|
||||||
|
|
||||||
fn unquote_str(lit: &tt::Literal) -> Option<String> {
|
fn unquote_str(lit: &tt::Literal) -> Option<String> {
|
||||||
let lit = ast::make::tokens::literal(&lit.to_string());
|
let lit = ast::make::tokens::literal(&lit.to_string());
|
||||||
let token = ast::String::cast(lit)?;
|
let token = ast::String::cast(lit)?;
|
||||||
|
|
|
@ -199,6 +199,8 @@ pub mod known {
|
||||||
format_args_nl,
|
format_args_nl,
|
||||||
env,
|
env,
|
||||||
option_env,
|
option_env,
|
||||||
|
llvm_asm,
|
||||||
|
asm,
|
||||||
// Builtin derives
|
// Builtin derives
|
||||||
Copy,
|
Copy,
|
||||||
Clone,
|
Clone,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue