Skip to content

Commit d450048

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 f7b4210 commit d450048

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/rustc_session/src/config.rs

+7-1
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,
@@ -2694,6 +2694,12 @@ impl fmt::Display for CrateType {
26942694
}
26952695
}
26962696

2697+
impl IntoDiagnosticArg for CrateType {
2698+
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
2699+
self.to_string().into_diagnostic_arg()
2700+
}
2701+
}
2702+
26972703
#[derive(Copy, Clone, PartialEq, Debug)]
26982704
pub enum PpSourceMode {
26992705
/// `-Zunpretty=normal`

0 commit comments

Comments
 (0)