Skip to content

Commit 7d33e7e

Browse files
committed
clarify purposes of tests
1 parent e987343 commit 7d33e7e

8 files changed

+46
-37
lines changed

tests/ui/editions/never-type-fallback-breaking.e2021.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// This is a test for various ways in which the change to the never type
2+
// fallback can break things and for the `dependency_on_unit_never_type_fallback`
3+
// lint.
4+
//
15
//@ revisions: e2021 e2024
26
//
37
//@[e2021] edition: 2021

tests/ui/editions/never-type-fallback-breaking.e2021.stderr

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this function depends on never type fallback being `()`
2-
--> $DIR/never-type-fallback-breaking.rs:16:1
2+
--> $DIR/never-type-fallback-breaking.rs:20:1
33
|
44
LL | fn m() {
55
| ^^^^^^
@@ -8,7 +8,7 @@ LL | fn m() {
88
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
99
= help: specify the types explicitly
1010
note: in edition 2024, the requirement `!: Default` will fail
11-
--> $DIR/never-type-fallback-breaking.rs:20:17
11+
--> $DIR/never-type-fallback-breaking.rs:24:17
1212
|
1313
LL | true => Default::default(),
1414
| ^^^^^^^^^^^^^^^^^^
@@ -19,7 +19,7 @@ LL | let x: () = match true {
1919
| ++++
2020

2121
error: this function depends on never type fallback being `()`
22-
--> $DIR/never-type-fallback-breaking.rs:28:1
22+
--> $DIR/never-type-fallback-breaking.rs:32:1
2323
|
2424
LL | fn q() -> Option<()> {
2525
| ^^^^^^^^^^^^^^^^^^^^
@@ -28,7 +28,7 @@ LL | fn q() -> Option<()> {
2828
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
2929
= help: specify the types explicitly
3030
note: in edition 2024, the requirement `!: Default` will fail
31-
--> $DIR/never-type-fallback-breaking.rs:35:5
31+
--> $DIR/never-type-fallback-breaking.rs:39:5
3232
|
3333
LL | deserialize()?;
3434
| ^^^^^^^^^^^^^
@@ -38,7 +38,7 @@ LL | deserialize::<()>()?;
3838
| ++++++
3939

4040
error: this function depends on never type fallback being `()`
41-
--> $DIR/never-type-fallback-breaking.rs:45:1
41+
--> $DIR/never-type-fallback-breaking.rs:49:1
4242
|
4343
LL | fn meow() -> Result<(), ()> {
4444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -47,7 +47,7 @@ LL | fn meow() -> Result<(), ()> {
4747
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
4848
= help: specify the types explicitly
4949
note: in edition 2024, the requirement `(): From<!>` will fail
50-
--> $DIR/never-type-fallback-breaking.rs:48:5
50+
--> $DIR/never-type-fallback-breaking.rs:52:5
5151
|
5252
LL | help(1)?;
5353
| ^^^^^^^
@@ -57,7 +57,7 @@ LL | help::<(), _>(1)?;
5757
| +++++++++
5858

5959
error: this function depends on never type fallback being `()`
60-
--> $DIR/never-type-fallback-breaking.rs:57:1
60+
--> $DIR/never-type-fallback-breaking.rs:61:1
6161
|
6262
LL | pub fn fallback_return() -> Result<(), ()> {
6363
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -66,7 +66,7 @@ LL | pub fn fallback_return() -> Result<(), ()> {
6666
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
6767
= help: specify the types explicitly
6868
note: in edition 2024, the requirement `!: Default` will fail
69-
--> $DIR/never-type-fallback-breaking.rs:60:19
69+
--> $DIR/never-type-fallback-breaking.rs:64:19
7070
|
7171
LL | takes_apit(|| Default::default())?;
7272
| ^^^^^^^^^^^^^^^^^^
@@ -76,7 +76,7 @@ LL | takes_apit::<()>(|| Default::default())?;
7676
| ++++++
7777

7878
error: this function depends on never type fallback being `()`
79-
--> $DIR/never-type-fallback-breaking.rs:71:1
79+
--> $DIR/never-type-fallback-breaking.rs:75:1
8080
|
8181
LL | fn fully_apit() -> Result<(), ()> {
8282
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -85,7 +85,7 @@ LL | fn fully_apit() -> Result<(), ()> {
8585
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
8686
= help: specify the types explicitly
8787
note: in edition 2024, the requirement `!: Default` will fail
88-
--> $DIR/never-type-fallback-breaking.rs:74:17
88+
--> $DIR/never-type-fallback-breaking.rs:78:17
8989
|
9090
LL | takes_apit2(mk()?);
9191
| ^^^^^
@@ -98,7 +98,7 @@ error: aborting due to 5 previous errors
9898

9999
Future incompatibility report: Future breakage diagnostic:
100100
error: this function depends on never type fallback being `()`
101-
--> $DIR/never-type-fallback-breaking.rs:16:1
101+
--> $DIR/never-type-fallback-breaking.rs:20:1
102102
|
103103
LL | fn m() {
104104
| ^^^^^^
@@ -107,7 +107,7 @@ LL | fn m() {
107107
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
108108
= help: specify the types explicitly
109109
note: in edition 2024, the requirement `!: Default` will fail
110-
--> $DIR/never-type-fallback-breaking.rs:20:17
110+
--> $DIR/never-type-fallback-breaking.rs:24:17
111111
|
112112
LL | true => Default::default(),
113113
| ^^^^^^^^^^^^^^^^^^
@@ -119,7 +119,7 @@ LL | let x: () = match true {
119119

120120
Future breakage diagnostic:
121121
error: this function depends on never type fallback being `()`
122-
--> $DIR/never-type-fallback-breaking.rs:28:1
122+
--> $DIR/never-type-fallback-breaking.rs:32:1
123123
|
124124
LL | fn q() -> Option<()> {
125125
| ^^^^^^^^^^^^^^^^^^^^
@@ -128,7 +128,7 @@ LL | fn q() -> Option<()> {
128128
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
129129
= help: specify the types explicitly
130130
note: in edition 2024, the requirement `!: Default` will fail
131-
--> $DIR/never-type-fallback-breaking.rs:35:5
131+
--> $DIR/never-type-fallback-breaking.rs:39:5
132132
|
133133
LL | deserialize()?;
134134
| ^^^^^^^^^^^^^
@@ -140,7 +140,7 @@ LL | deserialize::<()>()?;
140140

141141
Future breakage diagnostic:
142142
error: this function depends on never type fallback being `()`
143-
--> $DIR/never-type-fallback-breaking.rs:45:1
143+
--> $DIR/never-type-fallback-breaking.rs:49:1
144144
|
145145
LL | fn meow() -> Result<(), ()> {
146146
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -149,7 +149,7 @@ LL | fn meow() -> Result<(), ()> {
149149
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
150150
= help: specify the types explicitly
151151
note: in edition 2024, the requirement `(): From<!>` will fail
152-
--> $DIR/never-type-fallback-breaking.rs:48:5
152+
--> $DIR/never-type-fallback-breaking.rs:52:5
153153
|
154154
LL | help(1)?;
155155
| ^^^^^^^
@@ -161,7 +161,7 @@ LL | help::<(), _>(1)?;
161161

162162
Future breakage diagnostic:
163163
error: this function depends on never type fallback being `()`
164-
--> $DIR/never-type-fallback-breaking.rs:57:1
164+
--> $DIR/never-type-fallback-breaking.rs:61:1
165165
|
166166
LL | pub fn fallback_return() -> Result<(), ()> {
167167
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -170,7 +170,7 @@ LL | pub fn fallback_return() -> Result<(), ()> {
170170
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
171171
= help: specify the types explicitly
172172
note: in edition 2024, the requirement `!: Default` will fail
173-
--> $DIR/never-type-fallback-breaking.rs:60:19
173+
--> $DIR/never-type-fallback-breaking.rs:64:19
174174
|
175175
LL | takes_apit(|| Default::default())?;
176176
| ^^^^^^^^^^^^^^^^^^
@@ -182,7 +182,7 @@ LL | takes_apit::<()>(|| Default::default())?;
182182

183183
Future breakage diagnostic:
184184
error: this function depends on never type fallback being `()`
185-
--> $DIR/never-type-fallback-breaking.rs:71:1
185+
--> $DIR/never-type-fallback-breaking.rs:75:1
186186
|
187187
LL | fn fully_apit() -> Result<(), ()> {
188188
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -191,7 +191,7 @@ LL | fn fully_apit() -> Result<(), ()> {
191191
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
192192
= help: specify the types explicitly
193193
note: in edition 2024, the requirement `!: Default` will fail
194-
--> $DIR/never-type-fallback-breaking.rs:74:17
194+
--> $DIR/never-type-fallback-breaking.rs:78:17
195195
|
196196
LL | takes_apit2(mk()?);
197197
| ^^^^^

tests/ui/editions/never-type-fallback-breaking.e2024.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `!: Default` is not satisfied
2-
--> $DIR/never-type-fallback-breaking.rs:20:17
2+
--> $DIR/never-type-fallback-breaking.rs:24:17
33
|
44
LL | true => Default::default(),
55
| ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `!`
@@ -8,21 +8,21 @@ LL | true => Default::default(),
88
= help: you might have intended to use the type `()` here instead
99

1010
error[E0277]: the trait bound `!: Default` is not satisfied
11-
--> $DIR/never-type-fallback-breaking.rs:35:5
11+
--> $DIR/never-type-fallback-breaking.rs:39:5
1212
|
1313
LL | deserialize()?;
1414
| ^^^^^^^^^^^^^ the trait `Default` is not implemented for `!`
1515
|
1616
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #148922 <https://github.com/rust-lang/rust/issues/148922> for more information)
1717
= help: you might have intended to use the type `()` here instead
1818
note: required by a bound in `deserialize`
19-
--> $DIR/never-type-fallback-breaking.rs:31:23
19+
--> $DIR/never-type-fallback-breaking.rs:35:23
2020
|
2121
LL | fn deserialize<T: Default>() -> Option<T> {
2222
| ^^^^^^^ required by this bound in `deserialize`
2323

2424
error[E0277]: the trait bound `(): From<!>` is not satisfied
25-
--> $DIR/never-type-fallback-breaking.rs:48:5
25+
--> $DIR/never-type-fallback-breaking.rs:52:5
2626
|
2727
LL | help(1)?;
2828
| ^^^^^^^ the trait `From<!>` is not implemented for `()`
@@ -39,13 +39,13 @@ LL | help(1)?;
3939
and 4 others
4040
= note: required for `!` to implement `Into<()>`
4141
note: required by a bound in `help`
42-
--> $DIR/never-type-fallback-breaking.rs:42:20
42+
--> $DIR/never-type-fallback-breaking.rs:46:20
4343
|
4444
LL | fn help<'a: 'a, T: Into<()>, U>(_: U) -> Result<T, ()> {
4545
| ^^^^^^^^ required by this bound in `help`
4646

4747
error[E0277]: the trait bound `!: Default` is not satisfied
48-
--> $DIR/never-type-fallback-breaking.rs:60:19
48+
--> $DIR/never-type-fallback-breaking.rs:64:19
4949
|
5050
LL | takes_apit(|| Default::default())?;
5151
| ^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `!`
@@ -54,7 +54,7 @@ LL | takes_apit(|| Default::default())?;
5454
= help: you might have intended to use the type `()` here instead
5555

5656
error[E0277]: the trait bound `!: Default` is not satisfied
57-
--> $DIR/never-type-fallback-breaking.rs:74:17
57+
--> $DIR/never-type-fallback-breaking.rs:78:17
5858
|
5959
LL | takes_apit2(mk()?);
6060
| ----------- ^^^^^ the trait `Default` is not implemented for `!`
@@ -64,7 +64,7 @@ LL | takes_apit2(mk()?);
6464
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #148922 <https://github.com/rust-lang/rust/issues/148922> for more information)
6565
= help: you might have intended to use the type `()` here instead
6666
note: required by a bound in `takes_apit2`
67-
--> $DIR/never-type-fallback-breaking.rs:69:25
67+
--> $DIR/never-type-fallback-breaking.rs:73:25
6868
|
6969
LL | fn takes_apit2(_x: impl Default) {}
7070
| ^^^^^^^ required by this bound in `takes_apit2`

tests/ui/editions/never-type-fallback-breaking.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// This is a test for various ways in which the change to the never type
2+
// fallback can break things and for the `dependency_on_unit_never_type_fallback`
3+
// lint.
4+
//
15
//@ revisions: e2021 e2024
26
//
37
//@[e2021] edition: 2021
@@ -75,10 +79,3 @@ fn fully_apit() -> Result<(), ()> {
7579
//[e2024]~^ error: the trait bound `!: Default` is not satisfied
7680
Ok(())
7781
}
78-
79-
fn return_as_argument() {
80-
//[e2021]~^ error: this function depends on never type fallback being `()`
81-
//[e2021]~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
82-
takes_apit2(return);
83-
//[e2024]~^ error: trait bound `!: Test` is not satisfied
84-
}

tests/ui/never_type/exhaustive_patterns.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Check that we don't consider types which aren't publicly uninhabited as
2+
// uninhabited for purposes of pattern matching.
3+
//
14
//@ check-fail
25

36
#![feature(exhaustive_patterns, never_type)]

tests/ui/never_type/exhaustive_patterns.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0005]: refutable pattern in local binding
2-
--> $DIR/exhaustive_patterns.rs:21:9
2+
--> $DIR/exhaustive_patterns.rs:24:9
33
|
44
LL | let Either::A(()) = foo();
55
| ^^^^^^^^^^^^^ pattern `Either::B(_)` not covered
66
|
77
= note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
88
= note: for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
99
note: `Either<(), !>` defined here
10-
--> $DIR/exhaustive_patterns.rs:9:6
10+
--> $DIR/exhaustive_patterns.rs:12:6
1111
|
1212
LL | enum Either<A, B> {
1313
| ^^^^^^

tests/ui/never_type/never-result.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Test that `!` can be coerced to multiple different types after getting it
2+
// from pattern matching.
3+
//
14
//@ run-pass
25

36
#![allow(unused_variables)]

tests/ui/never_type/never-type-rvalues.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Check that the never type can be used in various positions.
2+
//
13
//@ run-pass
24

35
#![feature(never_type)]

0 commit comments

Comments
 (0)