Remove unreachable and untested suggestion for invalid span enum derive(Default)

This commit is contained in:
Tom Martin 2023-06-19 16:22:21 +01:00
parent db613750a9
commit 2027e989bc
No known key found for this signature in database
GPG Key ID: 73A733F9629F5AC5
4 changed files with 6 additions and 20 deletions

View File

@ -60,9 +60,6 @@ resolve_change_import_binding =
resolve_consider_adding_a_derive =
consider adding a derive
resolve_consider_adding_a_derive_enum =
consider adding `#[derive(Default)]` to this enum
resolve_const_not_member_of_trait =
const `{$const_}` is not a member of trait `{$trait_}`
.label = not a member of trait `{$trait_}`

View File

@ -32,7 +32,7 @@
use crate::errors::{
AddedMacroUse, ChangeImportBinding, ChangeImportBindingSuggestion, ConsiderAddingADerive,
ConsiderAddingADeriveEnum, ExplicitUnsafeTraits,
ExplicitUnsafeTraits,
};
use crate::imports::{Import, ImportKind};
use crate::late::{PatternSource, Rib};
@ -1393,14 +1393,10 @@ pub(crate) fn unresolved_macro_suggestions(
let span = self.def_span(def_id);
let source_map = self.tcx.sess.source_map();
let head_span = source_map.guess_head_span(span);
if let Ok(head) = source_map.span_to_snippet(head_span) {
err.subdiagnostic(ConsiderAddingADerive {
span: head_span,
suggestion: format!("#[derive(Default)]\n{head}")
});
} else {
err.subdiagnostic(ConsiderAddingADeriveEnum { span: head_span });
}
err.subdiagnostic(ConsiderAddingADerive {
span: head_span.shrink_to_lo(),
suggestion: format!("#[derive(Default)]\n")
});
}
for ns in [Namespace::MacroNS, Namespace::TypeNS, Namespace::ValueNS] {
if let Ok(binding) = self.early_resolve_ident_in_lexical_scope(

View File

@ -646,10 +646,3 @@ pub(crate) struct ConsiderAddingADerive {
pub(crate) span: Span,
pub(crate) suggestion: String,
}
#[derive(Subdiagnostic)]
#[help(resolve_consider_adding_a_derive_enum)]
pub(crate) struct ConsiderAddingADeriveEnum {
#[primary_span]
pub(crate) span: Span,
}

View File

@ -7,7 +7,7 @@ LL | #[default]
help: consider adding a derive
|
LL + #[derive(Default)]
LL ~ pub enum Test {
LL | pub enum Test {
|
error: aborting due to previous error