about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-02-01 19:17:39 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-02-03 09:02:50 +1100
commita9a2e1565abbeae741d6d715224194caf500099b (patch)
tree0eed2a91e690488feac06a519c64230857ecc980 /compiler/rustc_errors/src
parent585367f15f9fe7f4b169f6a157d087c0586c4ee1 (diff)
downloadrust-a9a2e1565abbeae741d6d715224194caf500099b.tar.gz
rust-a9a2e1565abbeae741d6d715224194caf500099b.zip
`Diagnostic` cleanups
- `emitted_at` isn't used outside the crate.
- `code` and `messages` are public fields, so there's no point have
  trivial getters/setters for them.
- `suggestions` is public, so the comment about "functionality on
  `Diagnostic`" isn't needed.
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/diagnostic.rs18
-rw-r--r--compiler/rustc_errors/src/lib.rs2
2 files changed, 2 insertions, 18 deletions
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index 6deaaef780d..789889973e2 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -116,7 +116,7 @@ pub struct Diagnostic {
 
     /// With `-Ztrack_diagnostics` enabled,
     /// we print where in rustc this error was emitted.
-    pub emitted_at: DiagnosticLocation,
+    pub(crate) emitted_at: DiagnosticLocation,
 }
 
 #[derive(Clone, Debug, Encodable, Decodable)]
@@ -206,9 +206,6 @@ impl StringPart {
     }
 }
 
-// Note: most of these methods are setters that return `&mut Self`. The small
-// number of simple getter functions all have `get_` prefixes to distinguish
-// them from the setters.
 impl Diagnostic {
     #[track_caller]
     pub fn new<M: Into<DiagnosticMessage>>(level: Level, message: M) -> Self {
@@ -889,15 +886,6 @@ impl Diagnostic {
         self
     }
 
-    pub fn clear_code(&mut self) -> &mut Self {
-        self.code = None;
-        self
-    }
-
-    pub fn get_code(&self) -> Option<ErrCode> {
-        self.code
-    }
-
     pub fn primary_message(&mut self, msg: impl Into<DiagnosticMessage>) -> &mut Self {
         self.messages[0] = (msg.into(), Style::NoStyle);
         self
@@ -923,10 +911,6 @@ impl Diagnostic {
         self.args = args;
     }
 
-    pub fn messages(&self) -> &[(DiagnosticMessage, Style)] {
-        &self.messages
-    }
-
     /// Helper function that takes a `SubdiagnosticMessage` and returns a `DiagnosticMessage` by
     /// combining it with the primary message of the diagnostic (if translatable, otherwise it just
     /// passes the user's string along).
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index 668c10bc4b6..61fe0040863 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -1422,7 +1422,7 @@ impl DiagCtxtInner {
                     &mut out,
                     "delayed span bug: {}\n{}\n",
                     bug.inner
-                        .messages()
+                        .messages
                         .iter()
                         .filter_map(|(msg, _)| msg.as_str())
                         .collect::<String>(),