Add translatable diagnostic for cannot find in this scope
This commit is contained in:
parent
50c971a0b7
commit
355a689542
3 changed files with 23 additions and 4 deletions
|
@ -267,4 +267,7 @@ resolve_change_import_binding =
|
||||||
you can use `as` to change the binding name of the import
|
you can use `as` to change the binding name of the import
|
||||||
|
|
||||||
resolve_imports_cannot_refer_to =
|
resolve_imports_cannot_refer_to =
|
||||||
imports cannot refer to {$what}
|
imports cannot refer to {$what}
|
||||||
|
|
||||||
|
resolve_cannot_find_ident_in_this_scope =
|
||||||
|
cannot find {$expected} `{$ident}` in this scope
|
||||||
|
|
|
@ -613,3 +613,12 @@ pub(crate) struct ImportsCannotReferTo<'a> {
|
||||||
pub(crate) span: Span,
|
pub(crate) span: Span,
|
||||||
pub(crate) what: &'a str,
|
pub(crate) what: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Diagnostic)]
|
||||||
|
#[diag(resolve_cannot_find_ident_in_this_scope)]
|
||||||
|
pub(crate) struct CannotFindIdentInThisScope<'a> {
|
||||||
|
#[primary_span]
|
||||||
|
pub(crate) span: Span,
|
||||||
|
pub(crate) expected: &'a str,
|
||||||
|
pub(crate) ident: Ident,
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
//! A bunch of methods and structures more or less related to resolving macros and
|
//! A bunch of methods and structures more or less related to resolving macros and
|
||||||
//! interface provided by `Resolver` to macro expander.
|
//! interface provided by `Resolver` to macro expander.
|
||||||
|
|
||||||
use crate::errors::{self, AddAsNonDerive, MacroExpectedFound, RemoveSurroundingDerive};
|
use crate::errors::{
|
||||||
|
self, AddAsNonDerive, CannotFindIdentInThisScope, MacroExpectedFound, RemoveSurroundingDerive,
|
||||||
|
};
|
||||||
use crate::Namespace::*;
|
use crate::Namespace::*;
|
||||||
use crate::{BuiltinMacroState, Determinacy};
|
use crate::{BuiltinMacroState, Determinacy};
|
||||||
use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet};
|
use crate::{DeriveData, Finalize, ParentScope, ResolutionError, Resolver, ScopeSet};
|
||||||
|
@ -793,8 +795,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
Err(..) => {
|
Err(..) => {
|
||||||
let expected = kind.descr_expected();
|
let expected = kind.descr_expected();
|
||||||
let msg = format!("cannot find {} `{}` in this scope", expected, ident);
|
|
||||||
let mut err = self.tcx.sess.struct_span_err(ident.span, msg);
|
let mut err = self.tcx.sess.create_err(CannotFindIdentInThisScope {
|
||||||
|
span: ident.span,
|
||||||
|
expected,
|
||||||
|
ident,
|
||||||
|
});
|
||||||
|
|
||||||
self.unresolved_macro_suggestions(&mut err, kind, &parent_scope, ident, krate);
|
self.unresolved_macro_suggestions(&mut err, kind, &parent_scope, ident, krate);
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue