diff options
| author | bohan <bohan-zhang@foxmail.com> | 2023-09-04 00:52:17 +0800 |
|---|---|---|
| committer | bohan <bohan-zhang@foxmail.com> | 2023-09-04 09:29:26 +0800 |
| commit | 7bad066f82f65781864804f674ee9c31c1ad68a7 (patch) | |
| tree | 7b832bbb4028f0ce745fdf86a7765016b7b6c300 /compiler/rustc_resolve | |
| parent | abfc6c44381fb033c6b3b0a6bfb804a799f39afd (diff) | |
| download | rust-7bad066f82f65781864804f674ee9c31c1ad68a7.tar.gz rust-7bad066f82f65781864804f674ee9c31c1ad68a7.zip | |
resolve: derive diag for undetermined macro resolution
Diffstat (limited to 'compiler/rustc_resolve')
| -rw-r--r-- | compiler/rustc_resolve/messages.ftl | 4 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/errors.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/macros.rs | 15 |
3 files changed, 21 insertions, 8 deletions
diff --git a/compiler/rustc_resolve/messages.ftl b/compiler/rustc_resolve/messages.ftl index f98918cba88..33fde285524 100644 --- a/compiler/rustc_resolve/messages.ftl +++ b/compiler/rustc_resolve/messages.ftl @@ -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 diff --git a/compiler/rustc_resolve/src/errors.rs b/compiler/rustc_resolve/src/errors.rs index e4b89c65853..85c9171e78a 100644 --- a/compiler/rustc_resolve/src/errors.rs +++ b/compiler/rustc_resolve/src/errors.rs @@ -655,6 +655,16 @@ pub(crate) struct CannotDetermineImportResolution { } #[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 { #[primary_span] diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 1199290a4d1..82060716575 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -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), + }); } } }; |
