Skip to content

Commit 2e7884b

Browse files
committed
Add diagnostics checks to CI
1 parent 6dc0c1b commit 2e7884b

6 files changed

Lines changed: 526 additions & 0 deletions

File tree

‎.github/workflows/check.yml‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,43 @@ jobs:
109109
- name: Dry run publishing
110110
run: cargo publish --dry-run
111111

112+
diagnostics-rust:
113+
name: 8. Diagnostics tests on Rust crates
114+
runs-on: ubuntu-latest
115+
steps:
116+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
117+
- uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0
118+
with:
119+
toolchain: nightly
120+
# Use the same components in every step for caching
121+
components: cargo,clippy,rustfmt
122+
- name: Build each Rust crate
123+
# To bless (update the expected diagnostics), change '/tmp' to 'splat-overload-diagnostics/src/bin',
124+
# and disable color output.
125+
run: |
126+
export CARGO_TERM_COLOR=never
127+
set -o pipefail
128+
TEST_NAMES=$(find splat-overload-diagnostics/src/bin -name "*.rs" | \
129+
sed 's|.*/\([^/]*\).rs|\1|g' )
130+
echo "testing: $TEST_NAMES"
131+
for test_name in $TEST_NAMES; do
132+
echo "testing: $test_name"
133+
# We expect cargo to fail, so don't exit the shell when it does
134+
set +e
135+
# Ignore build progress, if it's cached then the built crates change
136+
cargo build --all-features --package splat-overload-diagnostics --bin "$test_name" 2>&1 | \
137+
grep --invert-match -e 'Updating .* index' -e 'Compiling [^ ]* .*' \
138+
> "/tmp/$test_name.stderr"
139+
CARGO_EXIT_CODE=$?
140+
set -e
141+
if [[ $CARGO_EXIT_CODE -ne 101 ]]; then
142+
echo "error: $test_name compilation unexpectedly returned exit code $CARGO_EXIT_CODE rather than 101"
143+
exit 1
144+
fi
145+
echo "comparing diagnostics for: $test_name"
146+
diff --unified=5 "splat-overload-diagnostics/src/bin/$test_name.stderr" /tmp/"$test_name.stderr"
147+
done
148+
112149
all:
113150
name: All checks
114151
# Always run this job, even if earlier steps were skipped (or failed):
@@ -123,6 +160,7 @@ jobs:
123160
- doc-rust
124161
- fmt-rust
125162
- publish-dry-run
163+
- diagnostics-rust
126164
steps:
127165
- name: Fail if any other job failed
128166
# Every job status needs to be checked here, because `always()` stops failures from propagating automatically
@@ -135,3 +173,4 @@ jobs:
135173
[[ "${{ needs.doc-rust.result }}" == "success" ]] || exit 1
136174
[[ "${{ needs.fmt-rust.result }}" == "success" ]] || exit 1
137175
[[ "${{ needs.publish-dry-run.result }}" == "success" ]] || exit 1
176+
[[ "${{ needs.diagnostics-rust.result }}" == "success" ]] || exit 1
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
error[E0277]: the trait bound `(): FooArgs` is not satisfied
2+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:15:5
3+
|
4+
15 | foo();
5+
| ^^^ the trait `FooArgs` is not implemented for `()`
6+
|
7+
help: the following other types implement trait `FooArgs`
8+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:8:1
9+
|
10+
8 | / overload! {
11+
9 | | fn foo(x: i32) -> i32 { x }
12+
10 | | fn foo(x: f64) -> f64 { x }
13+
11 | | }
14+
| | ^
15+
| | |
16+
| |_`(f64,)`
17+
| `(i32,)`
18+
note: required by a bound in `foo`
19+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:8:1
20+
|
21+
8 | / overload! {
22+
9 | | fn foo(x: i32) -> i32 { x }
23+
10 | | fn foo(x: f64) -> f64 { x }
24+
11 | | }
25+
| |_^ required by this bound in `foo`
26+
= note: this error originates in the macro `overload` (in Nightly builds, run with -Z macro-backtrace for more info)
27+
28+
error[E0277]: the trait bound `(&str,): FooArgs` is not satisfied
29+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:16:9
30+
|
31+
16 | foo("wrong type");
32+
| --- ^^^^^^^^^^^^ the trait `FooArgs` is not implemented for `(&str,)`
33+
| |
34+
| required by a bound introduced by this call
35+
|
36+
help: the following other types implement trait `FooArgs`
37+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:8:1
38+
|
39+
8 | / overload! {
40+
9 | | fn foo(x: i32) -> i32 { x }
41+
10 | | fn foo(x: f64) -> f64 { x }
42+
11 | | }
43+
| | ^
44+
| | |
45+
| |_`(f64,)`
46+
| `(i32,)`
47+
note: required by a bound in `foo`
48+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:8:1
49+
|
50+
8 | / overload! {
51+
9 | | fn foo(x: i32) -> i32 { x }
52+
10 | | fn foo(x: f64) -> f64 { x }
53+
11 | | }
54+
| |_^ required by this bound in `foo`
55+
= note: this error originates in the macro `overload` (in Nightly builds, run with -Z macro-backtrace for more info)
56+
57+
error[E0277]: the trait bound `(_, _, _): FooArgs` is not satisfied
58+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:18:9
59+
|
60+
18 | foo(1_i32, 2, 3);
61+
| --- ^^^^^ the trait `FooArgs` is not implemented for `(_, _, _)`
62+
| |
63+
| required by a bound introduced by this call
64+
|
65+
help: the following other types implement trait `FooArgs`
66+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:8:1
67+
|
68+
8 | / overload! {
69+
9 | | fn foo(x: i32) -> i32 { x }
70+
10 | | fn foo(x: f64) -> f64 { x }
71+
11 | | }
72+
| | ^
73+
| | |
74+
| |_`(f64,)`
75+
| `(i32,)`
76+
note: required by a bound in `foo`
77+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:8:1
78+
|
79+
8 | / overload! {
80+
9 | | fn foo(x: i32) -> i32 { x }
81+
10 | | fn foo(x: f64) -> f64 { x }
82+
11 | | }
83+
| |_^ required by this bound in `foo`
84+
= note: this error originates in the macro `overload` (in Nightly builds, run with -Z macro-backtrace for more info)
85+
86+
error[E0308]: mismatched types
87+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:20:18
88+
|
89+
20 | let a: i32 = foo(1.0_f64);
90+
| --- ^^^^^^^^^^^^ expected `i32`, found `f64`
91+
| |
92+
| expected due to this
93+
94+
error[E0277]: the trait bound `(): FooArgs` is not satisfied
95+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:15:5
96+
|
97+
15 | foo();
98+
| ^^^^^ the trait `FooArgs` is not implemented for `()`
99+
|
100+
help: the following other types implement trait `FooArgs`
101+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:8:1
102+
|
103+
8 | / overload! {
104+
9 | | fn foo(x: i32) -> i32 { x }
105+
10 | | fn foo(x: f64) -> f64 { x }
106+
11 | | }
107+
| | ^
108+
| | |
109+
| |_`(f64,)`
110+
| `(i32,)`
111+
= note: this error originates in the macro `overload` (in Nightly builds, run with -Z macro-backtrace for more info)
112+
113+
error[E0277]: the trait bound `(&str,): FooArgs` is not satisfied
114+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:16:5
115+
|
116+
16 | foo("wrong type");
117+
| ^^^^^^^^^^^^^^^^^ the trait `FooArgs` is not implemented for `(&str,)`
118+
|
119+
help: the following other types implement trait `FooArgs`
120+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:8:1
121+
|
122+
8 | / overload! {
123+
9 | | fn foo(x: i32) -> i32 { x }
124+
10 | | fn foo(x: f64) -> f64 { x }
125+
11 | | }
126+
| | ^
127+
| | |
128+
| |_`(f64,)`
129+
| `(i32,)`
130+
= note: this error originates in the macro `overload` (in Nightly builds, run with -Z macro-backtrace for more info)
131+
132+
error[E0277]: the trait bound `(i32, {integer}, {integer}): FooArgs` is not satisfied
133+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:18:5
134+
|
135+
18 | foo(1_i32, 2, 3);
136+
| ^^^^^^^^^^^^^^^^ the trait `FooArgs` is not implemented for `(i32, {integer}, {integer})`
137+
|
138+
help: the following other types implement trait `FooArgs`
139+
--> splat-overload-diagnostics/src/bin/diag-function-return-values.rs:8:1
140+
|
141+
8 | / overload! {
142+
9 | | fn foo(x: i32) -> i32 { x }
143+
10 | | fn foo(x: f64) -> f64 { x }
144+
11 | | }
145+
| | ^
146+
| | |
147+
| |_`(f64,)`
148+
| `(i32,)`
149+
= note: this error originates in the macro `overload` (in Nightly builds, run with -Z macro-backtrace for more info)
150+
151+
Some errors have detailed explanations: E0277, E0308.
152+
For more information about an error, try `rustc --explain E0277`.
153+
error: could not compile `splat-overload-diagnostics` (bin "diag-function-return-values") due to 7 previous errors
File renamed without changes.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
error[E0277]: the trait bound `(): FooArgs` is not satisfied
2+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:15:5
3+
|
4+
15 | foo();
5+
| ^^^ the trait `FooArgs` is not implemented for `()`
6+
|
7+
help: the following other types implement trait `FooArgs`
8+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:7:1
9+
|
10+
7 | / overload! {
11+
8 | | fn foo(_x: i32, _y: f64) {}
12+
9 | | fn foo(_x: bool, _y: i32, _z: f64) {}
13+
10 | | fn foo(_a: i32, _b: f64, _c: bool, _d: u8) {}
14+
11 | | }
15+
| | ^
16+
| | |
17+
| | `(bool, i32, f64)`
18+
| |_`(i32, f64)`
19+
| `(i32, f64, bool, u8)`
20+
note: required by a bound in `foo`
21+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:7:1
22+
|
23+
7 | / overload! {
24+
8 | | fn foo(_x: i32, _y: f64) {}
25+
9 | | fn foo(_x: bool, _y: i32, _z: f64) {}
26+
10 | | fn foo(_a: i32, _b: f64, _c: bool, _d: u8) {}
27+
11 | | }
28+
| |_^ required by this bound in `foo`
29+
= note: this error originates in the macro `overload` (in Nightly builds, run with -Z macro-backtrace for more info)
30+
31+
error[E0308]: mismatched types
32+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:16:9
33+
|
34+
16 | foo("one wrong type", 2.0_f64);
35+
| --- ^^^^^^^^^^^^^^^^ expected `i32`, found `&str`
36+
| |
37+
| arguments to this function are incorrect
38+
|
39+
help: the return type of this call is `&'static str` due to the type of the argument passed
40+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:16:5
41+
|
42+
16 | foo("one wrong type", 2.0_f64);
43+
| ^^^^----------------^^^^^^^^^^
44+
| |
45+
| this argument influences the return type of `foo`
46+
note: function defined here
47+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:8:8
48+
|
49+
7 | / overload! {
50+
8 | | fn foo(_x: i32, _y: f64) {}
51+
| | ^^^
52+
9 | | fn foo(_x: bool, _y: i32, _z: f64) {}
53+
10 | | fn foo(_a: i32, _b: f64, _c: bool, _d: u8) {}
54+
11 | | }
55+
| |_-
56+
57+
error[E0277]: the trait bound `(_, _, _, _, _): FooArgs` is not satisfied
58+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:18:9
59+
|
60+
18 | foo(1_i32, 2_f64, true, 4_u8, 5);
61+
| --- ^^^^^ the trait `FooArgs` is not implemented for `(_, _, _, _, _)`
62+
| |
63+
| required by a bound introduced by this call
64+
|
65+
help: the following other types implement trait `FooArgs`
66+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:7:1
67+
|
68+
7 | / overload! {
69+
8 | | fn foo(_x: i32, _y: f64) {}
70+
9 | | fn foo(_x: bool, _y: i32, _z: f64) {}
71+
10 | | fn foo(_a: i32, _b: f64, _c: bool, _d: u8) {}
72+
11 | | }
73+
| | ^
74+
| | |
75+
| | `(bool, i32, f64)`
76+
| |_`(i32, f64)`
77+
| `(i32, f64, bool, u8)`
78+
note: required by a bound in `foo`
79+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:7:1
80+
|
81+
7 | / overload! {
82+
8 | | fn foo(_x: i32, _y: f64) {}
83+
9 | | fn foo(_x: bool, _y: i32, _z: f64) {}
84+
10 | | fn foo(_a: i32, _b: f64, _c: bool, _d: u8) {}
85+
11 | | }
86+
| |_^ required by this bound in `foo`
87+
= note: this error originates in the macro `overload` (in Nightly builds, run with -Z macro-backtrace for more info)
88+
89+
error[E0277]: the trait bound `(): FooArgs` is not satisfied
90+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:15:5
91+
|
92+
15 | foo();
93+
| ^^^^^ the trait `FooArgs` is not implemented for `()`
94+
|
95+
help: the following other types implement trait `FooArgs`
96+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:7:1
97+
|
98+
7 | / overload! {
99+
8 | | fn foo(_x: i32, _y: f64) {}
100+
9 | | fn foo(_x: bool, _y: i32, _z: f64) {}
101+
10 | | fn foo(_a: i32, _b: f64, _c: bool, _d: u8) {}
102+
11 | | }
103+
| | ^
104+
| | |
105+
| | `(bool, i32, f64)`
106+
| |_`(i32, f64)`
107+
| `(i32, f64, bool, u8)`
108+
= note: this error originates in the macro `overload` (in Nightly builds, run with -Z macro-backtrace for more info)
109+
110+
error[E0277]: the trait bound `(i32, f64, bool, u8, {integer}): FooArgs` is not satisfied
111+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:18:5
112+
|
113+
18 | foo(1_i32, 2_f64, true, 4_u8, 5);
114+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `FooArgs` is not implemented for `(i32, f64, bool, u8, {integer})`
115+
|
116+
help: the following other types implement trait `FooArgs`
117+
--> splat-overload-diagnostics/src/bin/diag-functions.rs:7:1
118+
|
119+
7 | / overload! {
120+
8 | | fn foo(_x: i32, _y: f64) {}
121+
9 | | fn foo(_x: bool, _y: i32, _z: f64) {}
122+
10 | | fn foo(_a: i32, _b: f64, _c: bool, _d: u8) {}
123+
11 | | }
124+
| | ^
125+
| | |
126+
| | `(bool, i32, f64)`
127+
| |_`(i32, f64)`
128+
| `(i32, f64, bool, u8)`
129+
= note: this error originates in the macro `overload` (in Nightly builds, run with -Z macro-backtrace for more info)
130+
131+
Some errors have detailed explanations: E0277, E0308.
132+
For more information about an error, try `rustc --explain E0277`.
133+
error: could not compile `splat-overload-diagnostics` (bin "diag-functions") due to 5 previous errors

0 commit comments

Comments
 (0)