Skip to content

Commit ae51741

Browse files
committed
session: impl IntoDiagnosticArg for CrateType
Forward the `Display` implementation for `CrateType` to `IntoDiagnosticArg` so that it can be used in diagnostic structs. Signed-off-by: David Wood <[email protected]>
1 parent 8a2f9c3 commit ae51741

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_span::RealFileName;
2424
use rustc_span::SourceFileHashAlgorithm;
2525

2626
use rustc_errors::emitter::HumanReadableErrorType;
27-
use rustc_errors::{ColorConfig, HandlerFlags};
27+
use rustc_errors::{ColorConfig, DiagnosticArgValue, HandlerFlags, IntoDiagnosticArg};
2828

2929
use std::collections::btree_map::{
3030
Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter,
@@ -2637,6 +2637,12 @@ impl fmt::Display for CrateType {
26372637
}
26382638
}
26392639

2640+
impl IntoDiagnosticArg for CrateType {
2641+
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
2642+
self.to_string().into_diagnostic_arg()
2643+
}
2644+
}
2645+
26402646
#[derive(Copy, Clone, PartialEq, Debug)]
26412647
pub enum PpSourceMode {
26422648
/// `-Zunpretty=normal`

0 commit comments

Comments
 (0)