mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Show proc-macro loading errors in unresolved-proc-macro diagnostics
This commit is contained in:
parent
15c63c4119
commit
7d51fc4640
14 changed files with 149 additions and 114 deletions
|
@ -29,19 +29,23 @@ pub(crate) fn unresolved_proc_macro(
|
|||
Some(name) => format!("proc macro `{}` not expanded", name),
|
||||
None => "proc macro not expanded".to_string(),
|
||||
};
|
||||
let (message, severity) = if config_enabled {
|
||||
(message, Severity::Error)
|
||||
} else {
|
||||
let message = match d.kind {
|
||||
hir::MacroKind::Attr if proc_macros_enabled => {
|
||||
format!("{message}{}", " (attribute macro expansion is disabled)")
|
||||
let severity = if config_enabled { Severity::Error } else { Severity::WeakWarning };
|
||||
let message = format!(
|
||||
"{message}: {}",
|
||||
if config_enabled {
|
||||
match &d.proc_macro_err {
|
||||
Some(e) => e,
|
||||
None => "proc macro not found",
|
||||
}
|
||||
_ => {
|
||||
format!("{message}{}", " (proc-macro expansion is disabled)")
|
||||
} else {
|
||||
match d.kind {
|
||||
hir::MacroKind::Attr if proc_macros_enabled => {
|
||||
"attribute macro expansion is disabled"
|
||||
}
|
||||
_ => "proc-macro expansion is disabled",
|
||||
}
|
||||
};
|
||||
(message, Severity::WeakWarning)
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
Diagnostic::new("unresolved-proc-macro", message, display_range).severity(severity)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue