resolve: derive diag for undetermined macro resolution
This commit is contained in:
parent
abfc6c4438
commit
7bad066f82
@ -58,6 +58,10 @@ resolve_cannot_determine_import_resolution =
|
||||
cannot determine resolution for the import
|
||||
.note = import resolution is stuck, try simplifying other imports
|
||||
|
||||
resolve_cannot_determine_macro_resolution =
|
||||
cannot determine resolution for the {$kind} `{$path}`
|
||||
.note = import resolution is stuck, try simplifying macro imports
|
||||
|
||||
resolve_cannot_find_ident_in_this_scope =
|
||||
cannot find {$expected} `{$ident}` in this scope
|
||||
|
||||
|
@ -654,6 +654,16 @@ pub(crate) struct CannotDetermineImportResolution {
|
||||
pub(crate) span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(resolve_cannot_determine_macro_resolution)]
|
||||
#[note]
|
||||
pub(crate) struct CannotDetermineMacroResolution {
|
||||
#[primary_span]
|
||||
pub(crate) span: Span,
|
||||
pub(crate) kind: &'static str,
|
||||
pub(crate) path: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(resolve_cannot_be_reexported_private, code = "E0364")]
|
||||
pub(crate) struct CannotBeReexportedPrivate {
|
||||
|
@ -2,7 +2,8 @@
|
||||
//! interface provided by `Resolver` to macro expander.
|
||||
|
||||
use crate::errors::{
|
||||
self, AddAsNonDerive, CannotFindIdentInThisScope, MacroExpectedFound, RemoveSurroundingDerive,
|
||||
self, AddAsNonDerive, CannotDetermineMacroResolution, CannotFindIdentInThisScope,
|
||||
MacroExpectedFound, RemoveSurroundingDerive,
|
||||
};
|
||||
use crate::Namespace::*;
|
||||
use crate::{BuiltinMacroState, Determinacy};
|
||||
@ -719,13 +720,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
// even if speculative `resolve_path` returned nothing previously, so we skip this
|
||||
// less informative error if the privacy error is reported elsewhere.
|
||||
if this.privacy_errors.is_empty() {
|
||||
let msg = format!(
|
||||
"cannot determine resolution for the {} `{}`",
|
||||
kind.descr(),
|
||||
Segment::names_to_string(path)
|
||||
);
|
||||
let msg_note = "import resolution is stuck, try simplifying macro imports";
|
||||
this.tcx.sess.struct_span_err(span, msg).note(msg_note).emit();
|
||||
this.tcx.sess.emit_err(CannotDetermineMacroResolution {
|
||||
span,
|
||||
kind: kind.descr(),
|
||||
path: Segment::names_to_string(path),
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user