Skip to content

Commit b1efa8e

Browse files
committed
stylistic test changes
1 parent 0104d69 commit b1efa8e

21 files changed

+132
-35
lines changed

tests/ui/never_type/call-fn-never-arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test that we can use a ! for an argument of type !
2-
2+
//
33
//@ check-pass
44

55
#![feature(never_type)]

tests/ui/never_type/cast-never.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test that we can explicitly cast ! to another type
2-
2+
//
33
//@ check-pass
44

55
#![feature(never_type)]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Future incompatibility report: Future breakage diagnostic:
2+
warning: this function depends on never type fallback being `()`
3+
--> $DIR/diverging-fallback-no-leak.rs:17:1
4+
|
5+
LL | fn main() {
6+
| ^^^^^^^^^
7+
|
8+
= help: specify the types explicitly
9+
note: in edition 2024, the requirement `!: Test` will fail
10+
--> $DIR/diverging-fallback-no-leak.rs:20:23
11+
|
12+
LL | unconstrained_arg(return);
13+
| ^^^^^^
14+
help: use `()` annotations to avoid fallback changes
15+
|
16+
LL | unconstrained_arg::<()>(return);
17+
| ++++++
18+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0277]: the trait bound `!: Test` is not satisfied
2+
--> $DIR/diverging-fallback-no-leak.rs:20:23
3+
|
4+
LL | unconstrained_arg(return);
5+
| ----------------- ^^^^^^ the trait `Test` is not implemented for `!`
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
help: the following other types implement trait `Test`
10+
--> $DIR/diverging-fallback-no-leak.rs:11:1
11+
|
12+
LL | impl Test for i32 {}
13+
| ^^^^^^^^^^^^^^^^^ `i32`
14+
LL | impl Test for () {}
15+
| ^^^^^^^^^^^^^^^^ `()`
16+
= 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)
17+
= help: you might have intended to use the type `()` here instead
18+
note: required by a bound in `unconstrained_arg`
19+
--> $DIR/diverging-fallback-no-leak.rs:14:25
20+
|
21+
LL | fn unconstrained_arg<T: Test>(_: T) {}
22+
| ^^^^ required by this bound in `unconstrained_arg`
23+
24+
error: aborting due to 1 previous error
25+
26+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
//@ revisions: nofallback fallback
2-
//@[fallback] edition: 2024
3-
//@[nofallback] check-pass
1+
//@ revisions: e2021 e2024
2+
//@[e2021] edition: 2021
3+
//@[e2024] edition: 2024
4+
//
5+
//@[e2021] check-pass
46

5-
#![cfg_attr(nofallback, expect(dependency_on_unit_never_type_fallback))]
67

78
fn make_unit() {}
89

@@ -12,9 +13,10 @@ impl Test for () {}
1213

1314
fn unconstrained_arg<T: Test>(_: T) {}
1415

16+
#[cfg_attr(e2021, expect(dependency_on_unit_never_type_fallback))]
1517
fn main() {
1618
// Here the type variable falls back to `!`,
1719
// and hence we get a type error.
1820
unconstrained_arg(return);
19-
//[fallback]~^ error: trait bound `!: Test` is not satisfied
21+
//[e2024]~^ error: trait bound `!: Test` is not satisfied
2022
}

tests/ui/never_type/eq-never-types.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
//@ check-pass
1+
// Regression test for <https://github.com/rust-lang/rust/issues/120600>
22
//
3-
// issue: rust-lang/rust#120600
3+
//@ edition: 2024
4+
//@ check-pass
45

5-
#![allow(internal_features)]
6-
#![feature(never_type, rustc_attrs)]
7-
#![rustc_never_type_options(fallback = "never")]
6+
#![feature(never_type)]
87

98
fn ice(a: !) {
109
a == a;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Future incompatibility report: Future breakage diagnostic:
2+
warning: this function depends on never type fallback being `()`
3+
--> $DIR/fallback-closure-ret.rs:21:1
4+
|
5+
LL | fn main() {
6+
| ^^^^^^^^^
7+
|
8+
= help: specify the types explicitly
9+
note: in edition 2024, the requirement `!: Bar` will fail
10+
--> $DIR/fallback-closure-ret.rs:22:5
11+
|
12+
LL | foo(|| panic!());
13+
| ^^^^^^^^^^^^^^^^
14+
help: use `()` annotations to avoid fallback changes
15+
|
16+
LL | foo::<()>(|| panic!());
17+
| ++++++
18+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0277]: the trait bound `!: Bar` is not satisfied
2+
--> $DIR/fallback-closure-ret.rs:22:5
3+
|
4+
LL | foo(|| panic!());
5+
| ^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `!`
6+
|
7+
help: the following other types implement trait `Bar`
8+
--> $DIR/fallback-closure-ret.rs:15:1
9+
|
10+
LL | impl Bar for () {}
11+
| ^^^^^^^^^^^^^^^ `()`
12+
LL | impl Bar for u32 {}
13+
| ^^^^^^^^^^^^^^^^ `u32`
14+
= 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)
15+
= help: you might have intended to use the type `()` here instead
16+
note: required by a bound in `foo`
17+
--> $DIR/fallback-closure-ret.rs:18:11
18+
|
19+
LL | fn foo<R: Bar>(_: impl Fn() -> R) {}
20+
| ^^^ required by this bound in `foo`
21+
22+
error: aborting due to 1 previous error
23+
24+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
// Tests the pattern of returning `!` from a closure and then checking if the
2+
// return type iumplements a trait (not implemented for `!`).
3+
//
14
// This test used to test that this pattern is not broken by context dependant
25
// never type fallback. However, it got removed, so now this is an example of
36
// expected breakage from the never type fallback change.
47
//
5-
//@ revisions: nofallback fallback
6-
//@[nofallback] check-pass
7-
//@[fallback] edition: 2024
8-
9-
#![cfg_attr(nofallback, expect(dependency_on_unit_never_type_fallback))]
8+
//@ revisions: e2021 e2024
9+
//@[e2021] edition: 2021
10+
//@[e2024] edition: 2024
11+
//
12+
//@[e2021] check-pass
1013

1114
trait Bar {}
1215
impl Bar for () {}
1316
impl Bar for u32 {}
1417

1518
fn foo<R: Bar>(_: impl Fn() -> R) {}
1619

20+
#[cfg_attr(e2021, expect(dependency_on_unit_never_type_fallback))]
1721
fn main() {
18-
foo(|| panic!()); //[fallback]~ error: the trait bound `!: Bar` is not satisfied
22+
foo(|| panic!()); //[e2024]~ error: the trait bound `!: Bar` is not satisfied
1923
}

tests/ui/never_type/impl-for-never.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
// Test that we can call static methods on ! both directly and when it appears in a generic
2+
//
13
//@ run-pass
24

35
#![feature(never_type)]
46

5-
// Test that we can call static methods on ! both directly and when it appears in a generic
67

78
trait StringifyType {
89
fn stringify_type() -> &'static str;

0 commit comments

Comments
 (0)