1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Tell a transient read race apart from a real error in the config file.
//!
//! Config writes are not atomic, so a watcher that fires between truncate and
//! write reads zero bytes. That is harmless and self-heals, and telling the
//! user to hunt for a typo would send them after one that does not exist.
//!
//! The original test for it was `reason.contains("line 1, column 1")`, on the
//! reasoning that only an empty file reports there. It does not: serde reports
//! a FIELD error against the whole struct, which is also line 1, column 1. So
//! `duplicate field \`a2a\`` was announced as a write race with the assurance
//! "your file is almost certainly fine", while the file had a real error and
//! every edit silently did nothing (#1116).
//!
//! Being wrong in that direction is worse than being unsure: a real error
//! described as transient is actively misleading, whereas a transient one
//! described plainly still resolves itself.
/// Signatures that a parse failure is about the file's CONTENT, not about
/// having read it at a bad moment. Any of these means a human has to act.
const CONTENT_ERRORS: & = &;
/// Is this failure a transient read race rather than a real config error?
///
/// Requires positive evidence of emptiness and the absence of any content
/// error. Anything unrecognised is treated as real, so an unfamiliar error is
/// reported honestly instead of being waved away.
pub