Use identifiers in diagnostics more often
This commit is contained in:
parent
f85c6de552
commit
ac1c6c50f4
21 changed files with 83 additions and 72 deletions
|
@ -677,7 +677,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
}
|
||||
if could_be_path {
|
||||
let import_suggestions = self.lookup_import_candidates(
|
||||
Ident::with_dummy_span(name),
|
||||
name,
|
||||
Namespace::ValueNS,
|
||||
&parent_scope,
|
||||
&|res: Res| {
|
||||
|
|
|
@ -59,7 +59,7 @@ pub(crate) struct NameAlreadyUsedInParameterList {
|
|||
pub(crate) span: Span,
|
||||
#[label(resolve_first_use_of_name)]
|
||||
pub(crate) first_use_span: Span,
|
||||
pub(crate) name: Symbol,
|
||||
pub(crate) name: Ident,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -142,7 +142,7 @@ pub(crate) struct VariableBoundWithDifferentMode {
|
|||
pub(crate) span: Span,
|
||||
#[label(resolve_first_binding_span)]
|
||||
pub(crate) first_binding_span: Span,
|
||||
pub(crate) variable_name: Symbol,
|
||||
pub(crate) variable_name: Ident,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -151,7 +151,7 @@ pub(crate) struct IdentifierBoundMoreThanOnceInParameterList {
|
|||
#[primary_span]
|
||||
#[label]
|
||||
pub(crate) span: Span,
|
||||
pub(crate) identifier: Symbol,
|
||||
pub(crate) identifier: Ident,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -160,7 +160,7 @@ pub(crate) struct IdentifierBoundMoreThanOnceInSamePattern {
|
|||
#[primary_span]
|
||||
#[label]
|
||||
pub(crate) span: Span,
|
||||
pub(crate) identifier: Symbol,
|
||||
pub(crate) identifier: Ident,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -478,7 +478,7 @@ pub(crate) struct TraitImplDuplicate {
|
|||
pub(crate) old_span: Span,
|
||||
#[label(resolve_trait_item_span)]
|
||||
pub(crate) trait_item_span: Span,
|
||||
pub(crate) name: Symbol,
|
||||
pub(crate) name: Ident,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -976,7 +976,7 @@ pub(crate) struct AttemptToDefineBuiltinMacroTwice {
|
|||
pub(crate) struct VariableIsNotBoundInAllPatterns {
|
||||
#[primary_span]
|
||||
pub(crate) multispan: MultiSpan,
|
||||
pub(crate) name: Symbol,
|
||||
pub(crate) name: Ident,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic, Debug, Clone)]
|
||||
|
@ -984,7 +984,7 @@ pub(crate) struct VariableIsNotBoundInAllPatterns {
|
|||
pub(crate) struct PatternDoesntBindName {
|
||||
#[primary_span]
|
||||
pub(crate) span: Span,
|
||||
pub(crate) name: Symbol,
|
||||
pub(crate) name: Ident,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic, Debug, Clone)]
|
||||
|
@ -1260,7 +1260,7 @@ pub(crate) struct TraitImplMismatch {
|
|||
#[primary_span]
|
||||
#[label]
|
||||
pub(crate) span: Span,
|
||||
pub(crate) name: Symbol,
|
||||
pub(crate) name: Ident,
|
||||
pub(crate) kind: &'static str,
|
||||
pub(crate) trait_path: String,
|
||||
#[label(resolve_trait_impl_mismatch_label_item)]
|
||||
|
|
|
@ -2835,7 +2835,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
match seen_bindings.entry(ident) {
|
||||
Entry::Occupied(entry) => {
|
||||
let span = *entry.get();
|
||||
let err = ResolutionError::NameAlreadyUsedInParameterList(ident.name, span);
|
||||
let err = ResolutionError::NameAlreadyUsedInParameterList(ident, span);
|
||||
self.report_error(param.ident.span, err);
|
||||
let rib = match param.kind {
|
||||
GenericParamKind::Lifetime => {
|
||||
|
@ -3422,7 +3422,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
match seen_trait_items.entry(id_in_trait) {
|
||||
Entry::Occupied(entry) => {
|
||||
self.report_error(span, ResolutionError::TraitImplDuplicate {
|
||||
name: ident.name,
|
||||
name: ident,
|
||||
old_span: *entry.get(),
|
||||
trait_item_span: binding.span,
|
||||
});
|
||||
|
@ -3457,7 +3457,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
};
|
||||
let trait_path = path_names_to_string(path);
|
||||
self.report_error(span, ResolutionError::TraitImplMismatch {
|
||||
name: ident.name,
|
||||
name: ident,
|
||||
kind,
|
||||
code,
|
||||
trait_path,
|
||||
|
@ -3640,9 +3640,8 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
.filter(|(_, pat)| pat.id != pat_outer.id)
|
||||
.flat_map(|(map, _)| map);
|
||||
|
||||
for (key, binding_inner) in inners {
|
||||
let name = key.name;
|
||||
match map_outer.get(key) {
|
||||
for (&name, binding_inner) in inners {
|
||||
match map_outer.get(&name) {
|
||||
None => {
|
||||
// The inner binding is missing in the outer.
|
||||
let binding_error =
|
||||
|
@ -3880,7 +3879,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
// `Variant(a, a)`:
|
||||
_ => IdentifierBoundMoreThanOnceInSamePattern,
|
||||
};
|
||||
self.report_error(ident.span, error(ident.name));
|
||||
self.report_error(ident.span, error(ident));
|
||||
}
|
||||
|
||||
// Record as bound if it's valid:
|
||||
|
|
|
@ -214,7 +214,7 @@ enum Used {
|
|||
|
||||
#[derive(Debug)]
|
||||
struct BindingError {
|
||||
name: Symbol,
|
||||
name: Ident,
|
||||
origin: BTreeSet<Span>,
|
||||
target: BTreeSet<Span>,
|
||||
could_be_path: bool,
|
||||
|
@ -226,7 +226,7 @@ enum ResolutionError<'ra> {
|
|||
GenericParamsFromOuterItem(Res, HasGenericParams, DefKind),
|
||||
/// Error E0403: the name is already used for a type or const parameter in this generic
|
||||
/// parameter list.
|
||||
NameAlreadyUsedInParameterList(Symbol, Span),
|
||||
NameAlreadyUsedInParameterList(Ident, Span),
|
||||
/// Error E0407: method is not a member of trait.
|
||||
MethodNotMemberOfTrait(Ident, String, Option<Symbol>),
|
||||
/// Error E0437: type is not a member of trait.
|
||||
|
@ -236,11 +236,11 @@ enum ResolutionError<'ra> {
|
|||
/// Error E0408: variable `{}` is not bound in all patterns.
|
||||
VariableNotBoundInPattern(BindingError, ParentScope<'ra>),
|
||||
/// Error E0409: variable `{}` is bound in inconsistent ways within the same match arm.
|
||||
VariableBoundWithDifferentMode(Symbol, Span),
|
||||
VariableBoundWithDifferentMode(Ident, Span),
|
||||
/// Error E0415: identifier is bound more than once in this parameter list.
|
||||
IdentifierBoundMoreThanOnceInParameterList(Symbol),
|
||||
IdentifierBoundMoreThanOnceInParameterList(Ident),
|
||||
/// Error E0416: identifier is bound more than once in the same pattern.
|
||||
IdentifierBoundMoreThanOnceInSamePattern(Symbol),
|
||||
IdentifierBoundMoreThanOnceInSamePattern(Ident),
|
||||
/// Error E0426: use of undeclared label.
|
||||
UndeclaredLabel { name: Symbol, suggestion: Option<LabelSuggestion> },
|
||||
/// Error E0429: `self` imports are only allowed within a `{ }` list.
|
||||
|
@ -292,14 +292,14 @@ enum ResolutionError<'ra> {
|
|||
UnreachableLabel { name: Symbol, definition_span: Span, suggestion: Option<LabelSuggestion> },
|
||||
/// Error E0323, E0324, E0325: mismatch between trait item and impl item.
|
||||
TraitImplMismatch {
|
||||
name: Symbol,
|
||||
name: Ident,
|
||||
kind: &'static str,
|
||||
trait_path: String,
|
||||
trait_item_span: Span,
|
||||
code: ErrCode,
|
||||
},
|
||||
/// Error E0201: multiple impl items for the same trait item.
|
||||
TraitImplDuplicate { name: Symbol, trait_item_span: Span, old_span: Span },
|
||||
TraitImplDuplicate { name: Ident, trait_item_span: Span, old_span: Span },
|
||||
/// Inline asm `sym` operand must refer to a `fn` or `static`.
|
||||
InvalidAsmSym,
|
||||
/// `self` used instead of `Self` in a generic parameter
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue