X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_lint%2Fsrc%2Flints.rs;h=2e447b900e1174b79ed142bb3c1cbf0d664e34ba;hb=00efb0cb960e4b89a80cad7d44fa0eefd223f513;hp=c3782a496891db3797bab13879bc32e54f024d02;hpb=44a500c8c187b245638684748f54bd6ec67e0b25;p=rust.git diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index c3782a49689..2e447b900e1 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -277,7 +277,7 @@ fn add_to_diagnostic_with(self, diag: &mut rustc_errors::Diagnostic, _: F) ) -> rustc_errors::SubdiagnosticMessage, { // Access to associates types should use `::Assoc`, which does not need a - // bound. Let's see if this type does that. + // bound. Let's see if this type does that. // We use a HIR visitor to walk the type. use rustc_hir::intravisit::{self, Visitor}; @@ -917,6 +917,13 @@ pub struct CStringPtr { pub unwrap: Span, } +// multiple_supertrait_upcastable.rs +#[derive(LintDiagnostic)] +#[diag(lint_multple_supertrait_upcastable)] +pub struct MultipleSupertraitUpcastable { + pub ident: Ident, +} + // non_ascii_idents.rs #[derive(LintDiagnostic)] #[diag(lint_identifier_non_ascii_char)] @@ -1395,6 +1402,21 @@ pub struct UnusedDef<'a, 'b> { pub cx: &'a LateContext<'b>, pub def_id: DefId, pub note: Option, + pub suggestion: Option, +} + +#[derive(Subdiagnostic)] +pub enum UnusedDefSuggestion { + #[suggestion( + suggestion, + style = "verbose", + code = "let _ = ", + applicability = "machine-applicable" + )] + Default { + #[primary_span] + span: Span, + }, } // Needed because of def_path_str @@ -1410,6 +1432,9 @@ fn decorate_lint<'b>( if let Some(note) = self.note { diag.note(note.as_str()); } + if let Some(sugg) = self.suggestion { + diag.subdiagnostic(sugg); + } diag }