mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
parse_macro_expansion_error
almost never contains values so Option
it
This commit is contained in:
parent
56552f4839
commit
caddcccea5
3 changed files with 14 additions and 8 deletions
|
@ -129,11 +129,10 @@ pub trait ExpandDatabase: SourceDatabase {
|
||||||
/// user wrote in the file that defines the proc-macro.
|
/// user wrote in the file that defines the proc-macro.
|
||||||
fn proc_macro_span(&self, fun: AstId<ast::Fn>) -> Span;
|
fn proc_macro_span(&self, fun: AstId<ast::Fn>) -> Span;
|
||||||
/// Firewall query that returns the errors from the `parse_macro_expansion` query.
|
/// Firewall query that returns the errors from the `parse_macro_expansion` query.
|
||||||
// FIXME: Option<Arc<...>>
|
|
||||||
fn parse_macro_expansion_error(
|
fn parse_macro_expansion_error(
|
||||||
&self,
|
&self,
|
||||||
macro_call: MacroCallId,
|
macro_call: MacroCallId,
|
||||||
) -> ExpandResult<Arc<[SyntaxError]>>;
|
) -> Option<Arc<ExpandResult<Arc<[SyntaxError]>>>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This expands the given macro call, but with different arguments. This is
|
/// This expands the given macro call, but with different arguments. This is
|
||||||
|
@ -358,8 +357,14 @@ fn parse_macro_expansion(
|
||||||
fn parse_macro_expansion_error(
|
fn parse_macro_expansion_error(
|
||||||
db: &dyn ExpandDatabase,
|
db: &dyn ExpandDatabase,
|
||||||
macro_call_id: MacroCallId,
|
macro_call_id: MacroCallId,
|
||||||
) -> ExpandResult<Arc<[SyntaxError]>> {
|
) -> Option<Arc<ExpandResult<Arc<[SyntaxError]>>>> {
|
||||||
db.parse_macro_expansion(MacroFileId { macro_call_id }).map(|it| it.0.errors().into())
|
let e: ExpandResult<Arc<[SyntaxError]>> =
|
||||||
|
db.parse_macro_expansion(MacroFileId { macro_call_id }).map(|it| Arc::from(it.0.errors()));
|
||||||
|
if e.value.is_empty() && e.err.is_none() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(Arc::new(e))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn parse_with_map(
|
pub(crate) fn parse_with_map(
|
||||||
|
|
|
@ -831,13 +831,15 @@ fn macro_call_diagnostics(
|
||||||
macro_call_id: MacroCallId,
|
macro_call_id: MacroCallId,
|
||||||
acc: &mut Vec<AnyDiagnostic>,
|
acc: &mut Vec<AnyDiagnostic>,
|
||||||
) {
|
) {
|
||||||
let ValueResult { value: parse_errors, err } = db.parse_macro_expansion_error(macro_call_id);
|
let Some(e) = db.parse_macro_expansion_error(macro_call_id) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let ValueResult { value: parse_errors, err } = &*e;
|
||||||
if let Some(err) = err {
|
if let Some(err) = err {
|
||||||
let loc = db.lookup_intern_macro_call(macro_call_id);
|
let loc = db.lookup_intern_macro_call(macro_call_id);
|
||||||
let (node, precise_location, macro_name, kind) = precise_macro_call_location(&loc.kind, db);
|
let (node, precise_location, macro_name, kind) = precise_macro_call_location(&loc.kind, db);
|
||||||
let diag = match err {
|
let diag = match err {
|
||||||
hir_expand::ExpandError::UnresolvedProcMacro(krate) => {
|
&hir_expand::ExpandError::UnresolvedProcMacro(krate) => {
|
||||||
UnresolvedProcMacro { node, precise_location, macro_name, kind, krate }.into()
|
UnresolvedProcMacro { node, precise_location, macro_name, kind, krate }.into()
|
||||||
}
|
}
|
||||||
err => MacroError { node, precise_location, message: err.to_string() }.into(),
|
err => MacroError { node, precise_location, message: err.to_string() }.into(),
|
||||||
|
|
|
@ -246,7 +246,6 @@ pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixtur
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
dbg!(&actual);
|
|
||||||
let fneg = expected
|
let fneg = expected
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|x| !actual.contains(x))
|
.filter(|x| !actual.contains(x))
|
||||||
|
|
Loading…
Reference in a new issue