Skip to content

Commit

Permalink
Rollup merge of rust-lang#65191 - varkor:const-generics-test-cases, r…
Browse files Browse the repository at this point in the history
…=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.
  • Loading branch information
tmandry authored Oct 11, 2019
2 parents ec1d008 + c990744 commit 728adc4
Show file tree
Hide file tree
Showing 27 changed files with 142 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// run-pass

#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

pub trait BitLen: Sized {
const BIT_LEN: usize;
}

impl<const L: usize> BitLen for [u8; L] {
const BIT_LEN: usize = 8 * L;
}

fn main() {
let foo = <[u8; 2]>::BIT_LEN;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
--> $DIR/issue-62187-encountered-polymorphic-const.rs:3:12
|
LL | #![feature(const_generics)]
| ^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default

warning: unused variable: `foo`
--> $DIR/issue-62187-encountered-polymorphic-const.rs:15:9
|
LL | let foo = <[u8; 2]>::BIT_LEN;
| ^^^ help: consider prefixing with an underscore: `_foo`
|
= note: `#[warn(unused_variables)]` on by default

File renamed without changes.
11 changes: 11 additions & 0 deletions src/test/ui/issues/auxiliary/issue-57271-lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub enum BaseType {
Byte,
Char,
Double,
Float,
Int,
Long,
Short,
Boolean,
}
File renamed without changes.
24 changes: 24 additions & 0 deletions src/test/ui/issues/issue-57271.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// aux-build:issue-57271-lib.rs

extern crate issue_57271_lib;

use issue_57271_lib::BaseType;

pub enum ObjectType { //~ ERROR recursive type `ObjectType` has infinite size
Class(ClassTypeSignature),
Array(TypeSignature),
TypeVariable(()),
}

pub struct ClassTypeSignature {
pub package: (),
pub class: (),
pub inner: (),
}

pub enum TypeSignature { //~ ERROR recursive type `TypeSignature` has infinite size
Base(BaseType),
Object(ObjectType),
}

fn main() {}
25 changes: 25 additions & 0 deletions src/test/ui/issues/issue-57271.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error[E0072]: recursive type `ObjectType` has infinite size
--> $DIR/issue-57271.rs:7:1
|
LL | pub enum ObjectType {
| ^^^^^^^^^^^^^^^^^^^ recursive type has infinite size
LL | Class(ClassTypeSignature),
LL | Array(TypeSignature),
| ------------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `ObjectType` representable

error[E0072]: recursive type `TypeSignature` has infinite size
--> $DIR/issue-57271.rs:19:1
|
LL | pub enum TypeSignature {
| ^^^^^^^^^^^^^^^^^^^^^^ recursive type has infinite size
LL | Base(BaseType),
LL | Object(ObjectType),
| ---------- recursive without indirection
|
= help: insert indirection (e.g., a `Box`, `Rc`, or `&`) at some point to make `TypeSignature` representable

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0072`.
22 changes: 22 additions & 0 deletions src/test/ui/issues/issue-57399-self-return-impl-trait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// run-pass

trait T {
type T;
}

impl T for i32 {
type T = u32;
}

struct S<A> {
a: A,
}


impl From<u32> for S<<i32 as T>::T> {
fn from(a: u32) -> Self {
Self { a }
}
}

fn main() {}
8 changes: 8 additions & 0 deletions src/test/ui/issues/issue-57399-self-return-impl-trait.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
warning: field is never used: `a`
--> $DIR/issue-57399-self-return-impl-trait.rs:12:5
|
LL | a: A,
| ^^^^
|
= note: `#[warn(dead_code)]` on by default

File renamed without changes.
5 changes: 5 additions & 0 deletions src/test/ui/issues/issue-64792-bad-unicode-ctor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
struct X {}

const Y: X = X("ö"); //~ ERROR expected function, found struct `X`

fn main() {}
15 changes: 15 additions & 0 deletions src/test/ui/issues/issue-64792-bad-unicode-ctor.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error[E0423]: expected function, found struct `X`
--> $DIR/issue-64792-bad-unicode-ctor.rs:3:14
|
LL | struct X {}
| ----------- `X` defined here
LL |
LL | const Y: X = X("ö");
| ^
| |
| did you mean `X { /* fields */ }`?
| help: a constant with a similar name exists: `Y`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0423`.

0 comments on commit 728adc4

Please sign in to comment.