Skip to content

Commit 3f17cd7

Browse files
authored
Rollup merge of rust-lang#98050 - JohnTitor:issue-67945, r=compiler-errors
Add some more regression tests for rust-lang#67945 Closes rust-lang#67945, added two tests from rust-lang#67945 (comment), other snippets were already added in rust-lang#71952 and rust-lang#77439 r? `@compiler-errors`
2 parents 62eb97a + c4b43d8 commit 3f17cd7

6 files changed

+107
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: overly complex generic constant
2+
--> $DIR/issue-67945-3.rs:10:13
3+
|
4+
LL | A: [(); {
5+
| _____________^
6+
LL | | let x: Option<S> = None;
7+
LL | |
8+
LL | | 0
9+
LL | | }],
10+
| |_____^ blocks are not supported in generic constant
11+
|
12+
= help: consider moving this anonymous constant into a `const` function
13+
= note: this operation may be supported in the future
14+
15+
error: aborting due to previous error
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: generic parameters may not be used in const operations
2+
--> $DIR/issue-67945-3.rs:11:23
3+
|
4+
LL | let x: Option<S> = None;
5+
| ^ cannot perform const operation using `S`
6+
|
7+
= note: type parameters may not be used in const expressions
8+
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
9+
10+
error[E0392]: parameter `S` is never used
11+
--> $DIR/issue-67945-3.rs:9:12
12+
|
13+
LL | struct Bug<S> {
14+
| ^ unused parameter
15+
|
16+
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
17+
= help: if you intended `S` to be a const parameter, use `const S: usize` instead
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0392`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Regression test for
2+
// https://github.com/rust-lang/rust/issues/67945#issuecomment-572617285
3+
// Make sure we don't emit an E0277 error.
4+
5+
// revisions: full min
6+
#![cfg_attr(full, feature(generic_const_exprs))]
7+
#![cfg_attr(full, allow(incomplete_features))]
8+
9+
struct Bug<S> { //[min]~ ERROR: parameter `S` is never used
10+
A: [(); { //[full]~ ERROR: overly complex generic constant
11+
let x: Option<S> = None;
12+
//[min]~^ ERROR: generic parameters may not be used in const operations
13+
0
14+
}],
15+
}
16+
17+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: overly complex generic constant
2+
--> $DIR/issue-67945-4.rs:9:13
3+
|
4+
LL | A: [(); {
5+
| _____________^
6+
LL | | let x: Option<Box<S>> = None;
7+
LL | |
8+
LL | | 0
9+
LL | | }],
10+
| |_____^ blocks are not supported in generic constant
11+
|
12+
= help: consider moving this anonymous constant into a `const` function
13+
= note: this operation may be supported in the future
14+
15+
error: aborting due to previous error
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: generic parameters may not be used in const operations
2+
--> $DIR/issue-67945-4.rs:10:27
3+
|
4+
LL | let x: Option<Box<S>> = None;
5+
| ^ cannot perform const operation using `S`
6+
|
7+
= note: type parameters may not be used in const expressions
8+
= help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
9+
10+
error[E0392]: parameter `S` is never used
11+
--> $DIR/issue-67945-4.rs:8:12
12+
|
13+
LL | struct Bug<S> {
14+
| ^ unused parameter
15+
|
16+
= help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
17+
= help: if you intended `S` to be a const parameter, use `const S: usize` instead
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0392`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Regression test for
2+
// https://github.com/rust-lang/rust/issues/67945#issuecomment-572617285
3+
4+
// revisions: full min
5+
#![cfg_attr(full, feature(generic_const_exprs))]
6+
#![cfg_attr(full, allow(incomplete_features))]
7+
8+
struct Bug<S> { //[min]~ ERROR: parameter `S` is never used
9+
A: [(); { //[full]~ ERROR: overly complex generic constant
10+
let x: Option<Box<S>> = None;
11+
//[min]~^ ERROR: generic parameters may not be used in const operations
12+
0
13+
}],
14+
}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)