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)
This commit is contained in:
commit
a73e0731f4
8 changed files with 131 additions and 0 deletions
8
src/test/ui/associated-item/issue-48027.rs
Normal file
8
src/test/ui/associated-item/issue-48027.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
trait Bar {
|
||||
const X: usize;
|
||||
fn return_n(&self) -> [u8; Bar::X]; //~ ERROR: type annotations needed
|
||||
}
|
||||
|
||||
impl dyn Bar {} //~ ERROR: the trait `Bar` cannot be made into an object
|
||||
|
||||
fn main() {}
|
21
src/test/ui/associated-item/issue-48027.stderr
Normal file
21
src/test/ui/associated-item/issue-48027.stderr
Normal file
|
@ -0,0 +1,21 @@
|
|||
error[E0038]: the trait `Bar` cannot be made into an object
|
||||
--> $DIR/issue-48027.rs:6:6
|
||||
|
|
||||
LL | const X: usize;
|
||||
| - the trait cannot contain associated consts like `X`
|
||||
...
|
||||
LL | impl dyn Bar {}
|
||||
| ^^^^^^^ the trait `Bar` cannot be made into an object
|
||||
|
||||
error[E0283]: type annotations needed: cannot resolve `_: Bar`
|
||||
--> $DIR/issue-48027.rs:3:32
|
||||
|
|
||||
LL | const X: usize;
|
||||
| --------------- required by `Bar::X`
|
||||
LL | fn return_n(&self) -> [u8; Bar::X];
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0038, E0283.
|
||||
For more information about an error, try `rustc --explain E0038`.
|
19
src/test/ui/associated-types/issue-44153.rs
Normal file
19
src/test/ui/associated-types/issue-44153.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
pub trait Array {
|
||||
type Element;
|
||||
}
|
||||
|
||||
pub trait Visit {
|
||||
fn visit() {}
|
||||
}
|
||||
|
||||
impl Array for () {
|
||||
type Element = ();
|
||||
}
|
||||
|
||||
impl<'a> Visit for () where
|
||||
(): Array<Element=&'a ()>,
|
||||
{}
|
||||
|
||||
fn main() {
|
||||
<() as Visit>::visit(); //~ ERROR: type mismatch resolving
|
||||
}
|
16
src/test/ui/associated-types/issue-44153.stderr
Normal file
16
src/test/ui/associated-types/issue-44153.stderr
Normal file
|
@ -0,0 +1,16 @@
|
|||
error[E0271]: type mismatch resolving `<() as Array>::Element == &()`
|
||||
--> $DIR/issue-44153.rs:18:5
|
||||
|
|
||||
LL | fn visit() {}
|
||||
| ---------- required by `Visit::visit`
|
||||
...
|
||||
LL | <() as Visit>::visit();
|
||||
| ^^^^^^^^^^^^^^^^^^^^ expected (), found &()
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `&()`
|
||||
= note: required because of the requirements on the impl of `Visit` for `()`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0271`.
|
23
src/test/ui/associated-types/issue-48010.rs
Normal file
23
src/test/ui/associated-types/issue-48010.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// check-pass
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
pub struct Foo;
|
||||
|
||||
pub struct Path<T: Bar> {
|
||||
_inner: T::Slice,
|
||||
}
|
||||
|
||||
pub trait Bar: Sized {
|
||||
type Slice: ?Sized;
|
||||
|
||||
fn open(_: &Path<Self>);
|
||||
}
|
||||
|
||||
impl Bar for Foo {
|
||||
type Slice = [u8];
|
||||
|
||||
fn open(_: &Path<Self>) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
4
src/test/ui/issues/issue-47486.rs
Normal file
4
src/test/ui/issues/issue-47486.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
fn main() {
|
||||
() < std::mem::size_of::<_>(); //~ ERROR: mismatched types
|
||||
[0u8; std::mem::size_of::<_>()]; //~ ERROR: type annotations needed
|
||||
}
|
19
src/test/ui/issues/issue-47486.stderr
Normal file
19
src/test/ui/issues/issue-47486.stderr
Normal file
|
@ -0,0 +1,19 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-47486.rs:2:10
|
||||
|
|
||||
LL | () < std::mem::size_of::<_>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found usize
|
||||
|
|
||||
= note: expected type `()`
|
||||
found type `usize`
|
||||
|
||||
error[E0282]: type annotations needed
|
||||
--> $DIR/issue-47486.rs:3:11
|
||||
|
|
||||
LL | [0u8; std::mem::size_of::<_>()];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0282, E0308.
|
||||
For more information about an error, try `rustc --explain E0282`.
|
21
src/test/ui/wf/issue-48638.rs
Normal file
21
src/test/ui/wf/issue-48638.rs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// check-pass
|
||||
|
||||
pub trait D {}
|
||||
pub struct DT;
|
||||
impl D for DT {}
|
||||
|
||||
pub trait A<R: D>: Sized {
|
||||
type AS;
|
||||
}
|
||||
|
||||
pub struct As<R: D>(R);
|
||||
|
||||
pub struct AT;
|
||||
impl<R: D> A<R> for AT {
|
||||
type AS = As<R>;
|
||||
}
|
||||
|
||||
#[repr(packed)]
|
||||
struct S(<AT as A<DT>>::AS);
|
||||
|
||||
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue