• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use crate::fluent_generated as fluent;
2 use rustc_errors::{ErrorGuaranteed, Handler, IntoDiagnostic};
3 use rustc_macros::Diagnostic;
4 use rustc_middle::ty::{self, PolyTraitRef, Ty};
5 use rustc_span::{Span, Symbol};
6 
7 #[derive(Diagnostic)]
8 #[diag(trait_selection_dump_vtable_entries)]
9 pub struct DumpVTableEntries<'a> {
10     #[primary_span]
11     pub span: Span,
12     pub trait_ref: PolyTraitRef<'a>,
13     pub entries: String,
14 }
15 
16 #[derive(Diagnostic)]
17 #[diag(trait_selection_unable_to_construct_constant_value)]
18 pub struct UnableToConstructConstantValue<'a> {
19     #[primary_span]
20     pub span: Span,
21     pub unevaluated: ty::UnevaluatedConst<'a>,
22 }
23 
24 #[derive(Diagnostic)]
25 #[diag(trait_selection_empty_on_clause_in_rustc_on_unimplemented, code = "E0232")]
26 pub struct EmptyOnClauseInOnUnimplemented {
27     #[primary_span]
28     #[label]
29     pub span: Span,
30 }
31 
32 #[derive(Diagnostic)]
33 #[diag(trait_selection_invalid_on_clause_in_rustc_on_unimplemented, code = "E0232")]
34 pub struct InvalidOnClauseInOnUnimplemented {
35     #[primary_span]
36     #[label]
37     pub span: Span,
38 }
39 
40 #[derive(Diagnostic)]
41 #[diag(trait_selection_no_value_in_rustc_on_unimplemented, code = "E0232")]
42 #[note]
43 pub struct NoValueInOnUnimplemented {
44     #[primary_span]
45     #[label]
46     pub span: Span,
47 }
48 
49 pub struct NegativePositiveConflict<'tcx> {
50     pub impl_span: Span,
51     pub trait_desc: ty::TraitRef<'tcx>,
52     pub self_ty: Option<Ty<'tcx>>,
53     pub negative_impl_span: Result<Span, Symbol>,
54     pub positive_impl_span: Result<Span, Symbol>,
55 }
56 
57 impl IntoDiagnostic<'_> for NegativePositiveConflict<'_> {
58     #[track_caller]
into_diagnostic( self, handler: &Handler, ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed>59     fn into_diagnostic(
60         self,
61         handler: &Handler,
62     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
63         let mut diag = handler.struct_err(fluent::trait_selection_negative_positive_conflict);
64         diag.set_arg("trait_desc", self.trait_desc.print_only_trait_path().to_string());
65         diag.set_arg(
66             "self_desc",
67             self.self_ty.map_or_else(|| "none".to_string(), |ty| ty.to_string()),
68         );
69         diag.set_span(self.impl_span);
70         diag.code(rustc_errors::error_code!(E0751));
71         match self.negative_impl_span {
72             Ok(span) => {
73                 diag.span_label(span, fluent::trait_selection_negative_implementation_here);
74             }
75             Err(cname) => {
76                 diag.note(fluent::trait_selection_negative_implementation_in_crate);
77                 diag.set_arg("negative_impl_cname", cname.to_string());
78             }
79         }
80         match self.positive_impl_span {
81             Ok(span) => {
82                 diag.span_label(span, fluent::trait_selection_positive_implementation_here);
83             }
84             Err(cname) => {
85                 diag.note(fluent::trait_selection_positive_implementation_in_crate);
86                 diag.set_arg("positive_impl_cname", cname.to_string());
87             }
88         }
89         diag
90     }
91 }
92 
93 #[derive(Diagnostic)]
94 #[diag(trait_selection_inherent_projection_normalization_overflow)]
95 pub struct InherentProjectionNormalizationOverflow {
96     #[primary_span]
97     pub span: Span,
98     pub ty: String,
99 }
100