-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
157 additions
and
5 deletions.
There are no files selected for viewing
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
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
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
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
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
14 changes: 14 additions & 0 deletions
14
tests/ui/const-generics/mgca/assoc-const-without-type_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,14 @@ | ||
#![feature(min_generic_const_args)] | ||
#![allow(incomplete_features)] | ||
|
||
pub trait Tr { | ||
const SIZE: usize; | ||
} | ||
|
||
fn mk_array<T: Tr>(_x: T) -> [(); T::SIZE] { | ||
//~^ ERROR type_const | ||
[(); T::SIZE] | ||
//~^ ERROR type_const | ||
} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
tests/ui/const-generics/mgca/assoc-const-without-type_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,18 @@ | ||
error: use of trait associated const without `#[type_const]` | ||
--> $DIR/assoc-const-without-type_const.rs:8:35 | ||
| | ||
LL | fn mk_array<T: Tr>(_x: T) -> [(); T::SIZE] { | ||
| ^^^^^^^ | ||
| | ||
= note: the declaration in the trait must be marked with `#[type_const]` | ||
|
||
error: use of trait associated const without `#[type_const]` | ||
--> $DIR/assoc-const-without-type_const.rs:10:10 | ||
| | ||
LL | [(); T::SIZE] | ||
| ^^^^^^^ | ||
| | ||
= note: the declaration in the trait must be marked with `#[type_const]` | ||
|
||
error: aborting due to 2 previous errors | ||
|
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
#![allow(incomplete_features)] | ||
|
||
pub trait Tr { | ||
#[type_const] | ||
const SIZE: usize; | ||
} | ||
|
||
|
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,17 @@ | ||
trait Tr { | ||
#[type_const()] | ||
//~^ ERROR malformed | ||
//~| ERROR experimental | ||
const N: usize; | ||
} | ||
|
||
struct S; | ||
|
||
impl Tr for S { | ||
#[type_const] | ||
//~^ ERROR must only be applied to trait associated constants | ||
//~| ERROR experimental | ||
const N: usize = 0; | ||
} | ||
|
||
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,35 @@ | ||
error: malformed `type_const` attribute input | ||
--> $DIR/bad-type_const-syntax.rs:2:5 | ||
| | ||
LL | #[type_const()] | ||
| ^^^^^^^^^^^^^^^ help: must be of the form: `#[type_const]` | ||
|
||
error[E0658]: the `#[type_const]` attribute is an experimental feature | ||
--> $DIR/bad-type_const-syntax.rs:2:5 | ||
| | ||
LL | #[type_const()] | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information | ||
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error[E0658]: the `#[type_const]` attribute is an experimental feature | ||
--> $DIR/bad-type_const-syntax.rs:11:5 | ||
| | ||
LL | #[type_const] | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information | ||
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error: `#[type_const]` must only be applied to trait associated constants | ||
--> $DIR/bad-type_const-syntax.rs:11:5 | ||
| | ||
LL | #[type_const] | ||
| ^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
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
15 changes: 13 additions & 2 deletions
15
tests/ui/feature-gates/feature-gate-min-generic-const-args.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 |
---|---|---|
@@ -1,11 +1,22 @@ | ||
error: generic parameters may not be used in const operations | ||
--> $DIR/feature-gate-min-generic-const-args.rs:6:29 | ||
--> $DIR/feature-gate-min-generic-const-args.rs:8:29 | ||
| | ||
LL | fn foo<T: Trait>() -> [u8; <T as Trait>::ASSOC] { | ||
| ^ cannot perform const operation using `T` | ||
| | ||
= note: type parameters may not be used in const expressions | ||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions | ||
|
||
error: aborting due to 1 previous error | ||
error[E0658]: the `#[type_const]` attribute is an experimental feature | ||
--> $DIR/feature-gate-min-generic-const-args.rs:2:5 | ||
| | ||
LL | #[type_const] | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information | ||
= help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable | ||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0658`. |