Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some regression tests #65191

Merged
merged 6 commits into from
Oct 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

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`.