Skip to content

Commit c2e7af5

Browse files
authored
Rollup merge of rust-lang#65191 - varkor:const-generics-test-cases, r=nikomatsakis
Add some regression tests - Add a test for rust-lang#62187. - Clean up the directory structure in `src/test/ui/const-generics` - Closes rust-lang#64792. - Closes rust-lang#57399. - Closes rust-lang#57271.
2 parents b851efb + c990744 commit c2e7af5

27 files changed

+142
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// run-pass
2+
3+
#![feature(const_generics)]
4+
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
5+
6+
pub trait BitLen: Sized {
7+
const BIT_LEN: usize;
8+
}
9+
10+
impl<const L: usize> BitLen for [u8; L] {
11+
const BIT_LEN: usize = 8 * L;
12+
}
13+
14+
fn main() {
15+
let foo = <[u8; 2]>::BIT_LEN;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
2+
--> $DIR/issue-62187-encountered-polymorphic-const.rs:3:12
3+
|
4+
LL | #![feature(const_generics)]
5+
| ^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(incomplete_features)]` on by default
8+
9+
warning: unused variable: `foo`
10+
--> $DIR/issue-62187-encountered-polymorphic-const.rs:15:9
11+
|
12+
LL | let foo = <[u8; 2]>::BIT_LEN;
13+
| ^^^ help: consider prefixing with an underscore: `_foo`
14+
|
15+
= note: `#[warn(unused_variables)]` on by default
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
2+
pub enum BaseType {
3+
Byte,
4+
Char,
5+
Double,
6+
Float,
7+
Int,
8+
Long,
9+
Short,
10+
Boolean,
11+
}
File renamed without changes.

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

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// aux-build:issue-57271-lib.rs
2+
3+
extern crate issue_57271_lib;
4+
5+
use issue_57271_lib::BaseType;
6+
7+
pub enum ObjectType { //~ ERROR recursive type `ObjectType` has infinite size
8+
Class(ClassTypeSignature),
9+
Array(TypeSignature),
10+
TypeVariable(()),
11+
}
12+
13+
pub struct ClassTypeSignature {
14+
pub package: (),
15+
pub class: (),
16+
pub inner: (),
17+
}
18+
19+
pub enum TypeSignature { //~ ERROR recursive type `TypeSignature` has infinite size
20+
Base(BaseType),
21+
Object(ObjectType),
22+
}
23+
24+
fn main() {}

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

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0072]: recursive type `ObjectType` has infinite size
2+
--> $DIR/issue-57271.rs:7:1
3+
|
4+
LL | pub enum ObjectType {
5+
| ^^^^^^^^^^^^^^^^^^^ recursive type has infinite size
6+
LL | Class(ClassTypeSignature),
7+
LL | Array(TypeSignature),
8+
| ------------- recursive without indirection
9+
|
10+
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ObjectType` representable
11+
12+
error[E0072]: recursive type `TypeSignature` has infinite size
13+
--> $DIR/issue-57271.rs:19:1
14+
|
15+
LL | pub enum TypeSignature {
16+
| ^^^^^^^^^^^^^^^^^^^^^^ recursive type has infinite size
17+
LL | Base(BaseType),
18+
LL | Object(ObjectType),
19+
| ---------- recursive without indirection
20+
|
21+
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `TypeSignature` representable
22+
23+
error: aborting due to 2 previous errors
24+
25+
For more information about this error, try `rustc --explain E0072`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// run-pass
2+
3+
trait T {
4+
type T;
5+
}
6+
7+
impl T for i32 {
8+
type T = u32;
9+
}
10+
11+
struct S<A> {
12+
a: A,
13+
}
14+
15+
16+
impl From<u32> for S<<i32 as T>::T> {
17+
fn from(a: u32) -> Self {
18+
Self { a }
19+
}
20+
}
21+
22+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
warning: field is never used: `a`
2+
--> $DIR/issue-57399-self-return-impl-trait.rs:12:5
3+
|
4+
LL | a: A,
5+
| ^^^^
6+
|
7+
= note: `#[warn(dead_code)]` on by default
8+
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
struct X {}
2+
3+
const Y: X = X("ö"); //~ ERROR expected function, found struct `X`
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0423]: expected function, found struct `X`
2+
--> $DIR/issue-64792-bad-unicode-ctor.rs:3:14
3+
|
4+
LL | struct X {}
5+
| ----------- `X` defined here
6+
LL |
7+
LL | const Y: X = X("ö");
8+
| ^
9+
| |
10+
| did you mean `X { /* fields */ }`?
11+
| help: a constant with a similar name exists: `Y`
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0423`.

0 commit comments

Comments
 (0)