Skip to content

Commit ca2fc42

Browse files
committedJan 8, 2024
Remove Clone impl for DiagnosticBuilder.
It seems like a bad idea, just asking for diagnostics to be emitted multiple times.
1 parent 75c68cf commit ca2fc42

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed
 

Diff for: ‎compiler/rustc_errors/src/diagnostic_builder.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ where
4242
/// access in the methods of `DiagnosticBuilder` here, consider
4343
/// extending `DiagCtxtFlags`.
4444
#[must_use]
45-
#[derive(Clone)]
4645
pub struct DiagnosticBuilder<'a, G: EmissionGuarantee = ErrorGuaranteed> {
4746
state: DiagnosticBuilderState<'a>,
4847

@@ -55,6 +54,10 @@ pub struct DiagnosticBuilder<'a, G: EmissionGuarantee = ErrorGuaranteed> {
5554
_marker: PhantomData<G>,
5655
}
5756

57+
// Cloning a `DiagnosticBuilder` is a recipe for a diagnostic being emitted
58+
// twice, which would be bad.
59+
impl<G> !Clone for DiagnosticBuilder<'_, G> {}
60+
5861
#[derive(Clone)]
5962
enum DiagnosticBuilderState<'a> {
6063
/// Initial state of a `DiagnosticBuilder`, before `.emit()` or `.cancel()`.

Diff for: ‎compiler/rustc_errors/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![feature(extract_if)]
1111
#![feature(if_let_guard)]
1212
#![feature(let_chains)]
13+
#![feature(negative_impls)]
1314
#![feature(never_type)]
1415
#![feature(rustc_attrs)]
1516
#![feature(yeet_expr)]

0 commit comments

Comments
 (0)