forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
27 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions
16
src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |