Skip to content

Commit

Permalink
Implement IntoDiagArg for hir Namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiretza committed Apr 17, 2024
1 parent d83d20c commit a1d7d38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
use rustc_data_structures::fx::FxIndexMap;
use rustc_error_messages::fluent_value_from_str_list_sep_by_and;
use rustc_error_messages::FluentValue;
use rustc_hir::def::Namespace;
use rustc_lint_defs::{Applicability, LintExpectationId};
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Symbol;
Expand Down Expand Up @@ -158,6 +159,12 @@ impl IntoDiagArg for DiagArgValue {
}
}

impl IntoDiagArg for Namespace {
fn into_diag_arg(self) -> DiagArgValue {
DiagArgValue::Str(Cow::Borrowed(self.descr()))
}
}

impl Into<FluentValue<'static>> for DiagArgValue {
fn into(self) -> FluentValue<'static> {
match self {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_errors::{
codes::*, Applicability, Diag, DiagArgValue, DiagMessage, DiagStyledString, EmissionGuarantee,
LintDiagnostic, SubdiagMessageOp, Subdiagnostic, SuggestionStyle,
};
use rustc_hir::def_id::DefId;
use rustc_hir::{def::Namespace, def_id::DefId};
use rustc_macros::{LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{
inhabitedness::InhabitedPredicate, Clause, PolyExistentialTraitRef, Ty, TyCtxt,
Expand Down

0 comments on commit a1d7d38

Please sign in to comment.