Skip to content

Commit a73e073

Browse files
authored
Rollup merge of #65395 - JohnTitor:add-tests, r=Centril
Add some tests for fixed ICEs Fixes #44153 (from 1.23.0) Fixes #47486 (from 1.36.0) Fixes #48010 (from 1.38.0) Fixes #48027 (from nightly) Fixes #48638 (from nightly)
2 parents 28d08f3 + f6e01e8 commit a73e073

File tree

8 files changed

+131
-0
lines changed

8 files changed

+131
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
trait Bar {
2+
const X: usize;
3+
fn return_n(&self) -> [u8; Bar::X]; //~ ERROR: type annotations needed
4+
}
5+
6+
impl dyn Bar {} //~ ERROR: the trait `Bar` cannot be made into an object
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0038]: the trait `Bar` cannot be made into an object
2+
--> $DIR/issue-48027.rs:6:6
3+
|
4+
LL | const X: usize;
5+
| - the trait cannot contain associated consts like `X`
6+
...
7+
LL | impl dyn Bar {}
8+
| ^^^^^^^ the trait `Bar` cannot be made into an object
9+
10+
error[E0283]: type annotations needed: cannot resolve `_: Bar`
11+
--> $DIR/issue-48027.rs:3:32
12+
|
13+
LL | const X: usize;
14+
| --------------- required by `Bar::X`
15+
LL | fn return_n(&self) -> [u8; Bar::X];
16+
| ^^^^^^
17+
18+
error: aborting due to 2 previous errors
19+
20+
Some errors have detailed explanations: E0038, E0283.
21+
For more information about an error, try `rustc --explain E0038`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pub trait Array {
2+
type Element;
3+
}
4+
5+
pub trait Visit {
6+
fn visit() {}
7+
}
8+
9+
impl Array for () {
10+
type Element = ();
11+
}
12+
13+
impl<'a> Visit for () where
14+
(): Array<Element=&'a ()>,
15+
{}
16+
17+
fn main() {
18+
<() as Visit>::visit(); //~ ERROR: type mismatch resolving
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0271]: type mismatch resolving `<() as Array>::Element == &()`
2+
--> $DIR/issue-44153.rs:18:5
3+
|
4+
LL | fn visit() {}
5+
| ---------- required by `Visit::visit`
6+
...
7+
LL | <() as Visit>::visit();
8+
| ^^^^^^^^^^^^^^^^^^^^ expected (), found &()
9+
|
10+
= note: expected type `()`
11+
found type `&()`
12+
= note: required because of the requirements on the impl of `Visit` for `()`
13+
14+
error: aborting due to previous error
15+
16+
For more information about this error, try `rustc --explain E0271`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// check-pass
2+
3+
#![crate_type = "lib"]
4+
5+
pub struct Foo;
6+
7+
pub struct Path<T: Bar> {
8+
_inner: T::Slice,
9+
}
10+
11+
pub trait Bar: Sized {
12+
type Slice: ?Sized;
13+
14+
fn open(_: &Path<Self>);
15+
}
16+
17+
impl Bar for Foo {
18+
type Slice = [u8];
19+
20+
fn open(_: &Path<Self>) {
21+
unimplemented!()
22+
}
23+
}

src/test/ui/issues/issue-47486.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
() < std::mem::size_of::<_>(); //~ ERROR: mismatched types
3+
[0u8; std::mem::size_of::<_>()]; //~ ERROR: type annotations needed
4+
}

src/test/ui/issues/issue-47486.stderr

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-47486.rs:2:10
3+
|
4+
LL | () < std::mem::size_of::<_>();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found usize
6+
|
7+
= note: expected type `()`
8+
found type `usize`
9+
10+
error[E0282]: type annotations needed
11+
--> $DIR/issue-47486.rs:3:11
12+
|
13+
LL | [0u8; std::mem::size_of::<_>()];
14+
| ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
15+
16+
error: aborting due to 2 previous errors
17+
18+
Some errors have detailed explanations: E0282, E0308.
19+
For more information about an error, try `rustc --explain E0282`.

src/test/ui/wf/issue-48638.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// check-pass
2+
3+
pub trait D {}
4+
pub struct DT;
5+
impl D for DT {}
6+
7+
pub trait A<R: D>: Sized {
8+
type AS;
9+
}
10+
11+
pub struct As<R: D>(R);
12+
13+
pub struct AT;
14+
impl<R: D> A<R> for AT {
15+
type AS = As<R>;
16+
}
17+
18+
#[repr(packed)]
19+
struct S(<AT as A<DT>>::AS);
20+
21+
fn main() {}

0 commit comments

Comments
 (0)