about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-09-17 06:47:35 +0000
committerbors <bors@rust-lang.org>2021-09-17 06:47:35 +0000
commit1c03f0d0ba4fee54b7aa458f4d3ad989d8bf7b34 (patch)
tree535fc47baf233bb1a844d22916a3c086d6daab11 /compiler/rustc_errors/src
parent38e576423dc56a006ccf0b72e106f09bdea6efc2 (diff)
parent4d5bcbe957fa2f9b47aba81484d47206de742f3d (diff)
downloadrust-1c03f0d0ba4fee54b7aa458f4d3ad989d8bf7b34.tar.gz
rust-1c03f0d0ba4fee54b7aa458f4d3ad989d8bf7b34.zip
Auto merge of #89037 - JohnTitor:rollup-rd9btbs, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #86382 (Make diagnostics clearer for `?` operators)
 - #87529 (Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types)
 - #88339 (Add TcpListener::into_incoming and IntoIncoming)
 - #88735 (Don't lint about missing code examples in derived traits)
 - #88751 (Couple of changes to FileSearch and SearchPath)
 - #88883 (Move some tests to more reasonable directories - 7)
 - #88887 (Const Deref)
 - #88911 (Improve error message for type mismatch in generator arguments)
 - #89014 (PassWrapper: handle separate Module*SanitizerPass)
 - #89033 (Set the library path in sysroot-crates-are-unstable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index 232cf4bdb7f..41a73268f46 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -74,6 +74,10 @@ impl DiagnosticStyledString {
     pub fn highlighted<S: Into<String>>(t: S) -> DiagnosticStyledString {
         DiagnosticStyledString(vec![StringPart::Highlighted(t.into())])
     }
+
+    pub fn content(&self) -> String {
+        self.0.iter().map(|x| x.content()).collect::<String>()
+    }
 }
 
 #[derive(Debug, PartialEq, Eq)]
@@ -82,6 +86,14 @@ pub enum StringPart {
     Highlighted(String),
 }
 
+impl StringPart {
+    pub fn content(&self) -> &str {
+        match self {
+            &StringPart::Normal(ref s) | &StringPart::Highlighted(ref s) => s,
+        }
+    }
+}
+
 impl Diagnostic {
     pub fn new(level: Level, message: &str) -> Self {
         Diagnostic::new_with_code(level, None, message)