about summary refs log tree commit diff
path: root/compiler/rustc_errors/src/diagnostic_builder.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-01-05 17:35:54 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2024-01-08 12:05:40 +1100
commitca2fc426a9b30a4fd4442512cec312ce8f8ce870 (patch)
tree4c9fa0072c0fdb679220864bc70f0ad18b20849a /compiler/rustc_errors/src/diagnostic_builder.rs
parent75c68cfd2b9870f2953b62d250bd7d0564a7b56d (diff)
downloadrust-ca2fc426a9b30a4fd4442512cec312ce8f8ce870.tar.gz
rust-ca2fc426a9b30a4fd4442512cec312ce8f8ce870.zip
Remove `Clone` impl for `DiagnosticBuilder`.
It seems like a bad idea, just asking for diagnostics to be emitted
multiple times.
Diffstat (limited to 'compiler/rustc_errors/src/diagnostic_builder.rs')
-rw-r--r--compiler/rustc_errors/src/diagnostic_builder.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs
index e018c14a4a5..fab5affbad1 100644
--- a/compiler/rustc_errors/src/diagnostic_builder.rs
+++ b/compiler/rustc_errors/src/diagnostic_builder.rs
@@ -42,7 +42,6 @@ where
 /// access in the methods of `DiagnosticBuilder` here, consider
 /// extending `DiagCtxtFlags`.
 #[must_use]
-#[derive(Clone)]
 pub struct DiagnosticBuilder<'a, G: EmissionGuarantee = ErrorGuaranteed> {
     state: DiagnosticBuilderState<'a>,
 
@@ -55,6 +54,10 @@ pub struct DiagnosticBuilder<'a, G: EmissionGuarantee = ErrorGuaranteed> {
     _marker: PhantomData<G>,
 }
 
+// Cloning a `DiagnosticBuilder` is a recipe for a diagnostic being emitted
+// twice, which would be bad.
+impl<G> !Clone for DiagnosticBuilder<'_, G> {}
+
 #[derive(Clone)]
 enum DiagnosticBuilderState<'a> {
     /// Initial state of a `DiagnosticBuilder`, before `.emit()` or `.cancel()`.