Skip to content

Commit ba00750

Browse files
committed
Auto merge of #124435 - matthiaskrgr:tests, r=jieyouxu
add more tests r? `@jieyouxu`
2 parents 91d5e4a + a15996c commit ba00750

11 files changed

+277
-0
lines changed

tests/crashes/109812.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ known-bug: #109812
2+
3+
#![warn(rust_2021_incompatible_closure_captures)]
4+
5+
enum Either {
6+
One(X),
7+
Two(X),
8+
}
9+
10+
struct X(Y);
11+
12+
struct Y;
13+
14+
fn move_into_fnmut() {
15+
let x = X(Y);
16+
17+
consume_fnmut(|| {
18+
let Either::Two(ref mut _t) = x;
19+
20+
let X(mut _t) = x;
21+
});
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ edition:2021
2+
// issues rust-lang/rust#111911
3+
// test for ICE opaque type with non-universal region substs
4+
5+
#![feature(adt_const_params)]
6+
#![allow(incomplete_features)]
7+
8+
pub async fn foo<const X: &'static str>() {}
9+
//~^ ERROR const parameter `X` is part of concrete type but not used in parameter list for the `impl Trait` type alias
10+
//~| ERROR const parameter `X` is part of concrete type but not used in parameter list for the `impl Trait` type alias
11+
fn bar<const N: &'static u8>() -> impl Sized {}
12+
13+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: const parameter `X` is part of concrete type but not used in parameter list for the `impl Trait` type alias
2+
--> $DIR/opaque_type_with_non-universal_region_substs_ice-111911.rs:8:43
3+
|
4+
LL | pub async fn foo<const X: &'static str>() {}
5+
| ^^
6+
7+
error: const parameter `X` is part of concrete type but not used in parameter list for the `impl Trait` type alias
8+
--> $DIR/opaque_type_with_non-universal_region_substs_ice-111911.rs:8:43
9+
|
10+
LL | pub async fn foo<const X: &'static str>() {}
11+
| ^^
12+
|
13+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
14+
15+
error: aborting due to 2 previous errors
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// ICE Inconsistent rustc_transmute::is_transmutable(...) result, got Yes
2+
// issue: rust-lang/rust#110969
3+
#![feature(adt_const_params, generic_const_exprs, transmutability)]
4+
#![allow(incomplete_features, unstable_features)]
5+
6+
mod assert {
7+
use std::mem::BikeshedIntrinsicFrom;
8+
9+
pub fn is_transmutable<Src, Dst, Context, const ASSUME: std::mem::Assume>()
10+
where
11+
Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
12+
//~^ ERROR trait takes at most 2 generic arguments but 3 generic arguments were supplied
13+
{
14+
}
15+
}
16+
17+
fn via_associated_const() {
18+
struct Context;
19+
#[repr(C)]
20+
struct Src;
21+
#[repr(C)]
22+
struct Dst;
23+
24+
trait Trait {
25+
const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
26+
//~^ ERROR mismatched types
27+
//~| ERROR `Src` cannot be safely transmuted into `Dst`
28+
//~| ERROR mismatched types
29+
}
30+
}
31+
32+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0107]: trait takes at most 2 generic arguments but 3 generic arguments were supplied
2+
--> $DIR/transmutable-ice-110969.rs:11:14
3+
|
4+
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
5+
| ^^^^^^^^^^^^^^^^^^^^^ ------ help: remove this generic argument
6+
| |
7+
| expected at most 2 generic arguments
8+
9+
error[E0308]: mismatched types
10+
--> $DIR/transmutable-ice-110969.rs:25:74
11+
|
12+
LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
13+
| ^^ expected `Assume`, found `()`
14+
15+
error[E0277]: `Src` cannot be safely transmuted into `Dst`
16+
--> $DIR/transmutable-ice-110969.rs:25:60
17+
|
18+
LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
19+
| ^^^ `Dst` may carry safety invariants
20+
|
21+
note: required by a bound in `is_transmutable`
22+
--> $DIR/transmutable-ice-110969.rs:11:14
23+
|
24+
LL | pub fn is_transmutable<Src, Dst, Context, const ASSUME: std::mem::Assume>()
25+
| --------------- required by a bound in this function
26+
LL | where
27+
LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME>,
28+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable`
29+
30+
error[E0308]: mismatched types
31+
--> $DIR/transmutable-ice-110969.rs:25:29
32+
|
33+
LL | const FALSE: bool = assert::is_transmutable::<Src, Dst, Context, {}>();
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
35+
36+
error: aborting due to 4 previous errors
37+
38+
Some errors have detailed explanations: E0107, E0277, E0308.
39+
For more information about an error, try `rustc --explain E0107`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// issue: rust-lang/rust#113776
2+
// ice: expected type of closure body to be a closure or coroutine
3+
//@ edition: 2021
4+
#![allow(incomplete_features)]
5+
#![feature(generic_const_exprs)]
6+
7+
use core::ops::SubAssign;
8+
9+
fn f<T>(
10+
data: &[(); {
11+
let f: F = async { 1 };
12+
//~^ ERROR cannot find type `F` in this scope
13+
14+
1
15+
}],
16+
) -> impl Iterator<Item = SubAssign> {
17+
//~^ ERROR the type parameter `Rhs` must be explicitly specified
18+
//~| ERROR `()` is not an iterator
19+
//~| ERROR trait objects must include the `dyn` keyword
20+
//~| ERROR the type parameter `Rhs` must be explicitly specified [E0393]
21+
}
22+
23+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
error[E0412]: cannot find type `F` in this scope
2+
--> $DIR/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs:11:17
3+
|
4+
LL | let f: F = async { 1 };
5+
| ^
6+
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
7+
|
8+
= note: similarly named trait `Fn` defined here
9+
|
10+
help: a trait with a similar name exists
11+
|
12+
LL | let f: Fn = async { 1 };
13+
| ~~
14+
help: you might be missing a type parameter
15+
|
16+
LL | fn f<T, F>(
17+
| +++
18+
19+
error[E0393]: the type parameter `Rhs` must be explicitly specified
20+
--> $DIR/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs:16:27
21+
|
22+
LL | ) -> impl Iterator<Item = SubAssign> {
23+
| ^^^^^^^^^ help: set the type parameter to the desired type: `SubAssign<Rhs>`
24+
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
25+
|
26+
= note: type parameter `Rhs` must be specified for this
27+
|
28+
= note: because of the default `Self` reference, type parameters must be specified on object types
29+
30+
error[E0393]: the type parameter `Rhs` must be explicitly specified
31+
--> $DIR/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs:16:27
32+
|
33+
LL | ) -> impl Iterator<Item = SubAssign> {
34+
| ^^^^^^^^^ help: set the type parameter to the desired type: `SubAssign<Rhs>`
35+
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
36+
|
37+
= note: type parameter `Rhs` must be specified for this
38+
|
39+
= note: because of the default `Self` reference, type parameters must be specified on object types
40+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
41+
42+
error[E0277]: `()` is not an iterator
43+
--> $DIR/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs:16:6
44+
|
45+
LL | ) -> impl Iterator<Item = SubAssign> {
46+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
47+
|
48+
= help: the trait `Iterator` is not implemented for `()`
49+
50+
error[E0782]: trait objects must include the `dyn` keyword
51+
--> $DIR/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.rs:16:27
52+
|
53+
LL | ) -> impl Iterator<Item = SubAssign> {
54+
| ^^^^^^^^^
55+
|
56+
help: add `dyn` keyword before this trait
57+
|
58+
LL | ) -> impl Iterator<Item = dyn SubAssign> {
59+
| +++
60+
help: you might have meant to write a bound here
61+
|
62+
LL | ) -> impl Iterator<Item: SubAssign> {
63+
| ~
64+
65+
error: aborting due to 5 previous errors
66+
67+
Some errors have detailed explanations: E0277, E0393, E0412, E0782.
68+
For more information about an error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// issue rust-lang/rust#111667
2+
// ICE failed to resolve instance for <[f32; 2] as CrossProduct ..
3+
//@ check-pass
4+
5+
#![feature(generic_const_exprs)]
6+
#![allow(incomplete_features)]
7+
8+
pub trait CrossProduct<'a, T, R> {
9+
fn cross(&'a self, t: &'a T) -> R;
10+
}
11+
12+
impl<'a, T, U, const N: usize> CrossProduct<'a, [U; N], [(&'a T, &'a U); N * N]> for [T; N] {
13+
fn cross(&'a self, us: &'a [U; N]) -> [(&'a T, &'a U); N * N] {
14+
std::array::from_fn(|i| (&self[i / N], &us[i % N]))
15+
}
16+
}
17+
18+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// issue: rust-lang/rust#112347
2+
// ICE future has no bound vars
3+
//@ edition:2021
4+
//@ check-pass
5+
6+
#![feature(type_alias_impl_trait)]
7+
8+
use std::future::Future;
9+
10+
type Fut<'a> = impl Future<Output = ()> + 'a;
11+
12+
fn foo<'a>(_: &()) -> Fut<'_> {
13+
async {}
14+
}
15+
16+
trait Test {
17+
fn hello();
18+
}
19+
20+
impl Test for ()
21+
where
22+
for<'a> Fut<'a>: Future<Output = ()>,
23+
{
24+
fn hello() {}
25+
}
26+
27+
fn main() {
28+
<()>::hello();
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// issue: rust-lang/rust#108697
2+
// ICE: tcx.resolutions(()) is not supported for local crate -Zunpretty=mir
3+
// on invalid module path with staged_api
4+
//@ compile-flags: -Zunpretty=mir
5+
//@ normalize-stderr-test: "The system cannot find the file specified." -> "No such file or directory"
6+
#![feature(staged_api)]
7+
#[path = "lol"]
8+
mod foo;
9+
//~^ ERROR couldn't read
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: couldn't read $DIR/lol: No such file or directory (os error 2)
2+
--> $DIR/staged-api-invalid-path-108697.rs:8:1
3+
|
4+
LL | mod foo;
5+
| ^^^^^^^^
6+
7+
error: aborting due to 1 previous error
8+

0 commit comments

Comments
 (0)