Skip to content

Commit 86dc39f

Browse files
committed
expect never type lint in tests which do not test it
1 parent 602959e commit 86dc39f

12 files changed

+33
-178
lines changed

tests/ui/never_type/defaulted-never-note.fallback.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `!: ImplementedForUnitButNotNever` is not satisfied
2-
--> $DIR/defaulted-never-note.rs:30:9
2+
--> $DIR/defaulted-never-note.rs:31:9
33
|
44
LL | foo(_x);
55
| --- ^^ the trait `ImplementedForUnitButNotNever` is not implemented for `!`
@@ -10,7 +10,7 @@ LL | foo(_x);
1010
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
1111
= help: you might have intended to use the type `()` here instead
1212
note: required by a bound in `foo`
13-
--> $DIR/defaulted-never-note.rs:23:11
13+
--> $DIR/defaulted-never-note.rs:26:11
1414
|
1515
LL | fn foo<T: ImplementedForUnitButNotNever>(_t: T) {}
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo`

tests/ui/never_type/defaulted-never-note.nofallback.stderr

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,16 @@
1-
error: this function depends on never type fallback being `()`
2-
--> $DIR/defaulted-never-note.rs:26:1
3-
|
4-
LL | fn smeg() {
5-
| ^^^^^^^^^
6-
|
7-
= warning: 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!
8-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
9-
= help: specify the types explicitly
10-
note: in edition 2024, the requirement `!: ImplementedForUnitButNotNever` will fail
11-
--> $DIR/defaulted-never-note.rs:30:9
12-
|
13-
LL | foo(_x);
14-
| ^^
15-
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
16-
help: use `()` annotations to avoid fallback changes
17-
|
18-
LL | let _x: () = return;
19-
| ++++
20-
21-
error: aborting due to 1 previous error
22-
231
Future incompatibility report: Future breakage diagnostic:
24-
error: this function depends on never type fallback being `()`
25-
--> $DIR/defaulted-never-note.rs:26:1
2+
warning: this function depends on never type fallback being `()`
3+
--> $DIR/defaulted-never-note.rs:29:1
264
|
275
LL | fn smeg() {
286
| ^^^^^^^^^
297
|
30-
= warning: 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!
31-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
328
= help: specify the types explicitly
339
note: in edition 2024, the requirement `!: ImplementedForUnitButNotNever` will fail
34-
--> $DIR/defaulted-never-note.rs:30:9
10+
--> $DIR/defaulted-never-note.rs:31:9
3511
|
3612
LL | foo(_x);
3713
| ^^
38-
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
3914
help: use `()` annotations to avoid fallback changes
4015
|
4116
LL | let _x: () = return;

tests/ui/never_type/defaulted-never-note.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
//@ revisions: nofallback fallback
2+
//@[nofallback] run-pass
3+
//@[fallback] check-fail
24

35
// We need to opt into the `never_type_fallback` feature
46
// to trigger the requirement that this is testing.
57
#![cfg_attr(fallback, feature(never_type, never_type_fallback))]
68

79
#![allow(unused)]
10+
#![expect(dependency_on_unit_never_type_fallback)]
811

912
trait Deserialize: Sized {
1013
fn deserialize() -> Result<Self, String>;
@@ -24,8 +27,6 @@ fn foo<T: ImplementedForUnitButNotNever>(_t: T) {}
2427
//[fallback]~^ note: required by this bound in `foo`
2528
//[fallback]~| note: required by a bound in `foo`
2629
fn smeg() {
27-
//[nofallback]~^ error: this function depends on never type fallback being `()`
28-
//[nofallback]~| 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!
2930
let _x = return;
3031
foo(_x);
3132
//[fallback]~^ error: the trait bound

tests/ui/never_type/diverging-fallback-control-flow.nofallback.stderr

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,34 @@
1-
error: this function depends on never type fallback being `()`
2-
--> $DIR/diverging-fallback-control-flow.rs:30:1
3-
|
4-
LL | fn assignment() {
5-
| ^^^^^^^^^^^^^^^
6-
|
7-
= warning: 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!
8-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
9-
= help: specify the types explicitly
10-
note: in edition 2024, the requirement `!: UnitDefault` will fail
11-
--> $DIR/diverging-fallback-control-flow.rs:36:13
12-
|
13-
LL | x = UnitDefault::default();
14-
| ^^^^^^^^^^^^^^^^^^^^^^
15-
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
16-
help: use `()` annotations to avoid fallback changes
17-
|
18-
LL | let x: ();
19-
| ++++
20-
21-
error: this function depends on never type fallback being `()`
22-
--> $DIR/diverging-fallback-control-flow.rs:42:1
23-
|
24-
LL | fn assignment_rev() {
25-
| ^^^^^^^^^^^^^^^^^^^
26-
|
27-
= warning: 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!
28-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
29-
= help: specify the types explicitly
30-
note: in edition 2024, the requirement `!: UnitDefault` will fail
31-
--> $DIR/diverging-fallback-control-flow.rs:50:13
32-
|
33-
LL | x = UnitDefault::default();
34-
| ^^^^^^^^^^^^^^^^^^^^^^
35-
help: use `()` annotations to avoid fallback changes
36-
|
37-
LL | let x: ();
38-
| ++++
39-
40-
error: aborting due to 2 previous errors
41-
421
Future incompatibility report: Future breakage diagnostic:
43-
error: this function depends on never type fallback being `()`
44-
--> $DIR/diverging-fallback-control-flow.rs:30:1
2+
warning: this function depends on never type fallback being `()`
3+
--> $DIR/diverging-fallback-control-flow.rs:32:1
454
|
465
LL | fn assignment() {
476
| ^^^^^^^^^^^^^^^
487
|
49-
= warning: 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!
50-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
518
= help: specify the types explicitly
529
note: in edition 2024, the requirement `!: UnitDefault` will fail
5310
--> $DIR/diverging-fallback-control-flow.rs:36:13
5411
|
5512
LL | x = UnitDefault::default();
5613
| ^^^^^^^^^^^^^^^^^^^^^^
57-
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
5814
help: use `()` annotations to avoid fallback changes
5915
|
6016
LL | let x: ();
6117
| ++++
6218

6319
Future breakage diagnostic:
64-
error: this function depends on never type fallback being `()`
20+
warning: this function depends on never type fallback being `()`
6521
--> $DIR/diverging-fallback-control-flow.rs:42:1
6622
|
6723
LL | fn assignment_rev() {
6824
| ^^^^^^^^^^^^^^^^^^^
6925
|
70-
= warning: 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!
71-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
7226
= help: specify the types explicitly
7327
note: in edition 2024, the requirement `!: UnitDefault` will fail
74-
--> $DIR/diverging-fallback-control-flow.rs:50:13
28+
--> $DIR/diverging-fallback-control-flow.rs:48:13
7529
|
7630
LL | x = UnitDefault::default();
7731
| ^^^^^^^^^^^^^^^^^^^^^^
78-
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
7932
help: use `()` annotations to avoid fallback changes
8033
|
8134
LL | let x: ();

tests/ui/never_type/diverging-fallback-control-flow.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
//@ revisions: nofallback fallback
2-
//@[fallback] check-pass
2+
//@ check-pass
33

44
#![allow(dead_code)]
55
#![allow(unused_assignments)]
66
#![allow(unused_variables)]
77
#![allow(unreachable_code)]
8+
#![cfg_attr(nofallback, expect(dependency_on_unit_never_type_fallback))]
9+
810
// Test various cases where we permit an unconstrained variable
911
// to fallback based on control-flow. In all of these cases,
1012
// the type variable winds up being the target of both a `!` coercion
@@ -28,8 +30,6 @@ impl UnitDefault for () {
2830
}
2931

3032
fn assignment() {
31-
//[nofallback]~^ error: this function depends on never type fallback being `()`
32-
//[nofallback]~| 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!
3333
let x;
3434

3535
if true {
@@ -40,8 +40,6 @@ fn assignment() {
4040
}
4141

4242
fn assignment_rev() {
43-
//[nofallback]~^ error: this function depends on never type fallback being `()`
44-
//[nofallback]~| 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!
4543
let x;
4644

4745
if true {

tests/ui/never_type/diverging-fallback-no-leak.fallback.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `!: Test` is not satisfied
2-
--> $DIR/diverging-fallback-no-leak.rs:19:23
2+
--> $DIR/diverging-fallback-no-leak.rs:18:23
33
|
44
LL | unconstrained_arg(return);
55
| ----------------- ^^^^^^ the trait `Test` is not implemented for `!`
@@ -12,7 +12,7 @@ LL | unconstrained_arg(return);
1212
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
1313
= help: you might have intended to use the type `()` here instead
1414
note: required by a bound in `unconstrained_arg`
15-
--> $DIR/diverging-fallback-no-leak.rs:11:25
15+
--> $DIR/diverging-fallback-no-leak.rs:13:25
1616
|
1717
LL | fn unconstrained_arg<T: Test>(_: T) {}
1818
| ^^^^ required by this bound in `unconstrained_arg`

tests/ui/never_type/diverging-fallback-no-leak.nofallback.stderr

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,16 @@
1-
error: this function depends on never type fallback being `()`
2-
--> $DIR/diverging-fallback-no-leak.rs:13:1
3-
|
4-
LL | fn main() {
5-
| ^^^^^^^^^
6-
|
7-
= warning: 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!
8-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
9-
= help: specify the types explicitly
10-
note: in edition 2024, the requirement `!: Test` will fail
11-
--> $DIR/diverging-fallback-no-leak.rs:19:23
12-
|
13-
LL | unconstrained_arg(return);
14-
| ^^^^^^
15-
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
16-
help: use `()` annotations to avoid fallback changes
17-
|
18-
LL | unconstrained_arg::<()>(return);
19-
| ++++++
20-
21-
error: aborting due to 1 previous error
22-
231
Future incompatibility report: Future breakage diagnostic:
24-
error: this function depends on never type fallback being `()`
25-
--> $DIR/diverging-fallback-no-leak.rs:13:1
2+
warning: this function depends on never type fallback being `()`
3+
--> $DIR/diverging-fallback-no-leak.rs:15:1
264
|
275
LL | fn main() {
286
| ^^^^^^^^^
297
|
30-
= warning: 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!
31-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
328
= help: specify the types explicitly
339
note: in edition 2024, the requirement `!: Test` will fail
34-
--> $DIR/diverging-fallback-no-leak.rs:19:23
10+
--> $DIR/diverging-fallback-no-leak.rs:18:23
3511
|
3612
LL | unconstrained_arg(return);
3713
| ^^^^^^
38-
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
3914
help: use `()` annotations to avoid fallback changes
4015
|
4116
LL | unconstrained_arg::<()>(return);

tests/ui/never_type/diverging-fallback-no-leak.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ revisions: nofallback fallback
2+
//@[nofallback] check-pass
23

34
#![cfg_attr(fallback, feature(never_type, never_type_fallback))]
5+
#![cfg_attr(nofallback, expect(dependency_on_unit_never_type_fallback))]
46

57
fn make_unit() {}
68

@@ -11,9 +13,6 @@ impl Test for () {}
1113
fn unconstrained_arg<T: Test>(_: T) {}
1214

1315
fn main() {
14-
//[nofallback]~^ error: this function depends on never type fallback being `()`
15-
//[nofallback]~| 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!
16-
1716
// Here the type variable falls back to `!`,
1817
// and hence we get a type error.
1918
unconstrained_arg(return);

tests/ui/never_type/fallback-closure-ret.nofallback.stderr

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,16 @@
1-
error: this function depends on never type fallback being `()`
2-
--> $DIR/fallback-closure-ret.rs:21:1
3-
|
4-
LL | fn main() {
5-
| ^^^^^^^^^
6-
|
7-
= warning: 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!
8-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
9-
= help: specify the types explicitly
10-
note: in edition 2024, the requirement `!: Bar` will fail
11-
--> $DIR/fallback-closure-ret.rs:24:5
12-
|
13-
LL | foo(|| panic!());
14-
| ^^^^^^^^^^^^^^^^
15-
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
16-
help: use `()` annotations to avoid fallback changes
17-
|
18-
LL | foo::<()>(|| panic!());
19-
| ++++++
20-
21-
error: aborting due to 1 previous error
22-
231
Future incompatibility report: Future breakage diagnostic:
24-
error: this function depends on never type fallback being `()`
25-
--> $DIR/fallback-closure-ret.rs:21:1
2+
warning: this function depends on never type fallback being `()`
3+
--> $DIR/fallback-closure-ret.rs:22:1
264
|
275
LL | fn main() {
286
| ^^^^^^^^^
297
|
30-
= warning: 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!
31-
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
328
= help: specify the types explicitly
339
note: in edition 2024, the requirement `!: Bar` will fail
34-
--> $DIR/fallback-closure-ret.rs:24:5
10+
--> $DIR/fallback-closure-ret.rs:23:5
3511
|
3612
LL | foo(|| panic!());
3713
| ^^^^^^^^^^^^^^^^
38-
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
3914
help: use `()` annotations to avoid fallback changes
4015
|
4116
LL | foo::<()>(|| panic!());

tests/ui/never_type/fallback-closure-ret.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
// ?T`. In the code below, these are `R: Bar` and `Fn::Output = R`.
99
//
1010
//@ revisions: nofallback fallback
11-
//@[fallback] check-pass
11+
//@ check-pass
1212

1313
#![cfg_attr(fallback, feature(never_type_fallback))]
14+
#![cfg_attr(nofallback, expect(dependency_on_unit_never_type_fallback))]
1415

1516
trait Bar {}
1617
impl Bar for () {}
@@ -19,7 +20,5 @@ impl Bar for u32 {}
1920
fn foo<R: Bar>(_: impl Fn() -> R) {}
2021

2122
fn main() {
22-
//[nofallback]~^ error: this function depends on never type fallback being `()`
23-
//[nofallback]~| 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!
2423
foo(|| panic!());
2524
}

0 commit comments

Comments
 (0)