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
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Compile-fail tests pinning the diagnostics a developer sees when they get the wiring wrong.
//!
//! Error quality is a feature here, not a nicety: the whole point of the builder is that a missing
//! or renamed template variable is caught at compile time *and* says what to do about it. These
//! tests exist so that stays true.
//!
//! The expected output lives in `tests/ui/*.stderr`. After an intentional change, regenerate it
//! with `TRYBUILD=overwrite cargo test -p typed-handlebars --test ui` and read the diff.
//!
//! # Expectations must not quote the standard library
//!
//! Some diagnostics — `E0599`'s "method exists but its trait bounds were not satisfied" is the one
//! that bit us — quote the definition of a std type or trait, rendered from the standard library's
//! *source*. rustc can only do that where the `rust-src` component is installed. It is on a
//! developer's rustup, and it is not on a GitHub runner, so an expectation containing one passes
//! locally and fails in CI with a diff nobody can reproduce.
//!
//! [`expectations_do_not_depend_on_rust_src`] makes that reproducible: it fails on any machine, at
//! the moment the expectation is blessed. The fix is to write the case so the diagnostic never
//! reaches for std — usually by dropping a trailing method call, since the bound is already
//! reported against the constructor.
use fs;
/// Guards the rule in this file's docs: no expectation may quote the standard library's source.
///
/// `$RUST` is trybuild's placeholder for the sysroot, so its presence is exactly the signal that a
/// diagnostic reached into std and that the case will behave differently without `rust-src`.