|
1 | 1 | //! Errors emitted by ast_passes.
|
2 | 2 |
|
3 |
| -use rustc_ast::ParamKindOrd; |
| 3 | +use rustc_ast::{visit::FnKind, ParamKindOrd}; |
4 | 4 | use rustc_errors::{fluent, AddToDiagnostic, Applicability, Diagnostic, SubdiagnosticMessage};
|
5 | 5 | use rustc_macros::{Diagnostic, Subdiagnostic};
|
6 | 6 | use rustc_span::{Span, Symbol};
|
7 | 7 |
|
8 |
| -use crate::ast_validation::ForbiddenLetReason; |
| 8 | +use crate::ast_validation::{DisallowTildeConstContext, ForbiddenLetReason}; |
9 | 9 |
|
10 | 10 | #[derive(Diagnostic)]
|
11 | 11 | #[diag(ast_passes_forbidden_let)]
|
@@ -584,26 +584,26 @@ pub struct TraitObjectWithMaybe {
|
584 | 584 | #[derive(Diagnostic)]
|
585 | 585 | #[diag(ast_passes::forbidden_maybe_const)]
|
586 | 586 | #[note]
|
587 |
| -pub struct ForbiddenMaybeConst { |
| 587 | +pub struct ForbiddenMaybeConst<'a, 'b> { |
588 | 588 | #[primary_span]
|
589 | 589 | pub span: Span,
|
590 | 590 | #[subdiagnostic]
|
591 |
| - pub reason: DisallowTildeConstContext, |
| 591 | + pub(crate) reason: &'a DisallowTildeConstContext<'b>, |
592 | 592 | }
|
593 | 593 |
|
594 |
| -impl AddToDiagnostic for DisallowTildeConstContext { |
| 594 | +impl<'a> AddToDiagnostic for &'a DisallowTildeConstContext<'_> { |
595 | 595 | fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
|
596 | 596 | where
|
597 | 597 | F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
|
598 | 598 | {
|
599 | 599 | match self {
|
600 |
| - Self::TraitObject => { |
| 600 | + DisallowTildeConstContext::TraitObject => { |
601 | 601 | diag.note(fluent::ast_passes::trait_object);
|
602 | 602 | }
|
603 |
| - Self::Fn(FnKind::Closure(..)) => { |
| 603 | + DisallowTildeConstContext::Fn(FnKind::Closure(..)) => { |
604 | 604 | diag.note(fluent::ast_passes::closure);
|
605 | 605 | }
|
606 |
| - Self::Fn(FnKind::Fn(_, ident, ..)) => { |
| 606 | + DisallowTildeConstContext::Fn(FnKind::Fn(_, ident, ..)) => { |
607 | 607 | diag.span_note(ident.span, fluent::ast_passes::fn_not_const);
|
608 | 608 | }
|
609 | 609 | }
|
|
0 commit comments