diff options
| author | Michael Goulet <michael@errs.io> | 2023-03-07 22:26:52 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-03-08 01:58:15 +0000 |
| commit | 64eea3c47a883a5544f97e656807009a7eb99c00 (patch) | |
| tree | 7198c696ee022872628217e2549eac943f4553f3 /compiler/rustc_hir_analysis/src/errors.rs | |
| parent | 08e5a77b069dc55481fef6a415c5bb8f056c00c9 (diff) | |
| download | rust-64eea3c47a883a5544f97e656807009a7eb99c00.tar.gz rust-64eea3c47a883a5544f97e656807009a7eb99c00.zip | |
Tweak E0740
Diffstat (limited to 'compiler/rustc_hir_analysis/src/errors.rs')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/errors.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 74fec93d91e..dd40706f1d3 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -5,7 +5,7 @@ use rustc_errors::{ error_code, Applicability, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, MultiSpan, }; -use rustc_macros::Diagnostic; +use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::Ty; use rustc_span::{symbol::Ident, Span, Symbol}; @@ -430,3 +430,23 @@ pub(crate) struct CastThinPointerToFatPointer<'tcx> { pub expr_ty: Ty<'tcx>, pub cast_ty: String, } + +#[derive(Diagnostic)] +#[diag(hir_analysis_invalid_union_field, code = "E0740")] +pub(crate) struct InvalidUnionField { + #[primary_span] + pub field_span: Span, + #[subdiagnostic] + pub sugg: InvalidUnionFieldSuggestion, + #[note] + pub note: (), +} + +#[derive(Subdiagnostic)] +#[multipart_suggestion(hir_analysis_invalid_union_field_sugg, applicability = "machine-applicable")] +pub(crate) struct InvalidUnionFieldSuggestion { + #[suggestion_part(code = "std::mem::ManuallyDrop<")] + pub lo: Span, + #[suggestion_part(code = ">")] + pub hi: Span, +} |
