migrate: expect.rs
This commit is contained in:
parent
6ffecd2059
commit
3c1a1f3643
2 changed files with 41 additions and 30 deletions
|
@ -3,7 +3,10 @@ use std::num::NonZeroU32;
|
|||
use rustc_errors::{fluent, AddToDiagnostic, Applicability, DecorateLint, DiagnosticMessage};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_macros::{LintDiagnostic, Subdiagnostic};
|
||||
use rustc_middle::ty::{Predicate, Ty, TyCtxt};
|
||||
use rustc_middle::{
|
||||
lint::LintExpectation,
|
||||
ty::{Predicate, Ty, TyCtxt},
|
||||
};
|
||||
use rustc_span::{edition::Edition, symbol::Ident, Span, Symbol};
|
||||
|
||||
use crate::{errors::OverruledAttributeSub, LateContext};
|
||||
|
@ -304,6 +307,32 @@ pub struct EnumIntrinsicsMemVariant<'a> {
|
|||
pub ty_param: Ty<'a>,
|
||||
}
|
||||
|
||||
// expect.rs
|
||||
pub struct Expectation<'a> {
|
||||
pub expectation: &'a LintExpectation,
|
||||
}
|
||||
|
||||
impl<'a> DecorateLint<'a, ()> for Expectation<'_> {
|
||||
fn decorate_lint<'b>(
|
||||
self,
|
||||
diag: &'b mut rustc_errors::DiagnosticBuilder<'a, ()>,
|
||||
) -> &'b mut rustc_errors::DiagnosticBuilder<'a, ()> {
|
||||
if let Some(rationale) = self.expectation.reason {
|
||||
diag.note(rationale.as_str());
|
||||
}
|
||||
|
||||
if self.expectation.is_unfulfilled_lint_expectations {
|
||||
diag.note(fluent::note);
|
||||
}
|
||||
|
||||
diag
|
||||
}
|
||||
|
||||
fn msg(&self) -> DiagnosticMessage {
|
||||
fluent::lint_expectation
|
||||
}
|
||||
}
|
||||
|
||||
// internal.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_default_hash_types)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue