Skip to content

Commit 904c18c

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 <david.wood@huawei.com>
1 parent 6d22d4c commit 904c18c

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
@@ -25,7 +25,7 @@ use rustc_span::RealFileName;
2525
use rustc_span::SourceFileHashAlgorithm;
2626

2727
use rustc_errors::emitter::HumanReadableErrorType;
28-
use rustc_errors::{ColorConfig, HandlerFlags};
28+
use rustc_errors::{ColorConfig, DiagnosticArgValue, HandlerFlags, IntoDiagnosticArg};
2929

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

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

0 commit comments

Comments
 (0)