-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
supply substs to anon consts in defaults
- Loading branch information
Showing
11 changed files
with
62 additions
and
71 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
24 changes: 13 additions & 11 deletions
24
src/test/ui/const-generics/defaults/complex-generic-default-expr.full.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,16 +1,18 @@ | ||
error[E0277]: the size for values of type `T` cannot be known at compilation time | ||
--> $DIR/complex-generic-default-expr.rs:9:62 | ||
error: constant expression depends on a generic parameter | ||
--> $DIR/complex-generic-default-expr.rs:6:34 | ||
| | ||
LL | struct Foo<const N: usize, const M: usize = { N + 1 }>; | ||
| ^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error: constant expression depends on a generic parameter | ||
--> $DIR/complex-generic-default-expr.rs:10:21 | ||
| | ||
LL | struct Bar<T, const TYPE_SIZE: usize = { std::mem::size_of::<T>() }>(T); | ||
| - ^ doesn't have a size known at compile-time | ||
| | | ||
| this type parameter needs to be `std::marker::Sized` | ||
| | ||
::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | ||
| ^^^^^^^^^ | ||
| | ||
LL | pub const fn size_of<T>() -> usize { | ||
| - required by this bound in `std::mem::size_of` | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error: aborting due to previous error | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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
13 changes: 5 additions & 8 deletions
13
src/test/ui/const-generics/defaults/complex-generic-default-expr.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 |
---|---|---|
@@ -1,17 +1,14 @@ | ||
// revisions: min | ||
// FIXME(const_generics): add the `full` revision, | ||
// currently causes an ICE as we don't supply substs to | ||
// anon consts in the parameter listing, as that would | ||
// cause that anon const to reference itself. | ||
// revisions: full min | ||
#![cfg_attr(full, feature(const_generics))] | ||
#![feature(const_generics_defaults)] | ||
#![allow(incomplete_features)] | ||
|
||
struct Foo<const N: usize, const M: usize = { N + 1 }>; | ||
//[min]~^ ERROR generic parameters may not be used in const operations | ||
//[full]~^ ERROR constant expression depends on a generic parameter | ||
//[min]~^^ ERROR generic parameters may not be used in const operations | ||
|
||
struct Bar<T, const TYPE_SIZE: usize = { std::mem::size_of::<T>() }>(T); | ||
//[min]~^ ERROR generic parameters may not be used in const operations | ||
//[full]~^^ ERROR the size for values of type `T` cannot be known at compilation time | ||
//[full]~^ ERROR constant expression depends on a generic parameter | ||
//[min]~^^ ERROR generic parameters may not be used in const operations | ||
|
||
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
4 changes: 0 additions & 4 deletions
4
src/test/ui/const-generics/defaults/const-param-in-ty-defaults.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
22 changes: 4 additions & 18 deletions
22
src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.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,31 +1,17 @@ | ||
error: generic parameters with a default must be trailing | ||
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:10:12 | ||
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:8:12 | ||
| | ||
LL | struct Bar<T = [u8; N], const N: usize>(T); | ||
| ^ | ||
| | ||
= note: using type defaults and const parameters in the same parameter list is currently not permitted | ||
|
||
error[E0128]: generic parameters with a default cannot use forward declared identifiers | ||
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:10:21 | ||
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:8:21 | ||
| | ||
LL | struct Bar<T = [u8; N], const N: usize>(T); | ||
| ^ defaulted generic parameters cannot be forward declared | ||
|
||
error[E0277]: the size for values of type `T` cannot be known at compilation time | ||
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:6:44 | ||
| | ||
LL | struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U); | ||
| - ^ doesn't have a size known at compile-time | ||
| | | ||
| this type parameter needs to be `std::marker::Sized` | ||
| | ||
::: $SRC_DIR/core/src/mem/mod.rs:LL:COL | ||
| | ||
LL | pub const fn size_of<T>() -> usize { | ||
| - required by this bound in `std::mem::size_of` | ||
|
||
error: aborting due to 3 previous errors | ||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0128, E0277. | ||
For more information about an error, try `rustc --explain E0128`. | ||
For more information about this error, try `rustc --explain E0128`. |
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
4 changes: 1 addition & 3 deletions
4
src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.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