You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of rust-lang#134314 - compiler-errors:default-struct-value-const, r=estebank
Make sure to use normalized ty for unevaluated const in default struct value
This cleans up the way that we construct the `mir::Const::Unevaluated` for default struct values. We were previously using `from_unevaluated`, which doesn't normalize the type, and is really only used for inline assembly. Other codepaths (such as `ExprKind::NamedConst`) use the type from the body.
Also, let's stop using `literal_operand`, which also is really not meant for calls other than for literal comparisons in pattern lowering.
Also move all of the tests to a separate subdirectory so they don't need to have the same prefix on all the test files.
Fixesrust-lang#134298
r? estebank or reassign
Copy file name to clipboardexpand all lines: tests/ui/structs/default-field-values/failures.stderr
+15-15
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
error: the `#[default]` attribute may only be used on unit enum variants or variants where every field has a default value
2
-
--> $DIR/default-field-values-failures.rs:47:5
2
+
--> $DIR/failures.rs:47:5
3
3
|
4
4
LL | Variant {}
5
5
| ^^^^^^^
6
6
|
7
7
= help: consider a manual implementation of `Default`
8
8
9
9
error: generic parameters may not be used in const operations
10
-
--> $DIR/default-field-values-failures.rs:22:23
10
+
--> $DIR/failures.rs:22:23
11
11
|
12
12
LL | bat: i32 = <Qux<{ C }> as T>::K,
13
13
| ^ cannot perform const operation using `C`
@@ -16,19 +16,19 @@ LL | bat: i32 = <Qux<{ C }> as T>::K,
16
16
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
17
17
18
18
error: default fields are not supported in tuple structs
19
-
--> $DIR/default-field-values-failures.rs:26:22
19
+
--> $DIR/failures.rs:26:22
20
20
|
21
21
LL | pub struct Rak(i32 = 42);
22
22
| ^^ default fields are only supported on structs
23
23
24
24
error: generic `Self` types are currently not permitted in anonymous constants
25
-
--> $DIR/default-field-values-failures.rs:20:14
25
+
--> $DIR/failures.rs:20:14
26
26
|
27
27
LL | bar: S = Self::S,
28
28
| ^^^^
29
29
30
30
error[E0277]: the trait bound `S: Default` is not satisfied
31
-
--> $DIR/default-field-values-failures.rs:14:5
31
+
--> $DIR/failures.rs:14:5
32
32
|
33
33
LL | #[derive(Debug, Default)]
34
34
| ------- in this derive macro expansion
@@ -44,43 +44,43 @@ LL | pub struct S;
44
44
|
45
45
46
46
error: missing mandatory field `bar`
47
-
--> $DIR/default-field-values-failures.rs:53:21
47
+
--> $DIR/failures.rs:53:21
48
48
|
49
49
LL | let _ = Bar { .. };
50
50
| ^
51
51
52
52
error[E0308]: mismatched types
53
-
--> $DIR/default-field-values-failures.rs:57:17
53
+
--> $DIR/failures.rs:57:17
54
54
|
55
55
LL | let _ = Rak(..);
56
56
| --- ^^ expected `i32`, found `RangeFull`
57
57
| |
58
58
| arguments to this struct are incorrect
59
59
|
60
60
note: tuple struct defined here
61
-
--> $DIR/default-field-values-failures.rs:26:12
61
+
--> $DIR/failures.rs:26:12
62
62
|
63
63
LL | pub struct Rak(i32 = 42);
64
64
| ^^^
65
65
help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal
66
-
--> $DIR/default-field-values-failures.rs:57:17
66
+
--> $DIR/failures.rs:57:17
67
67
|
68
68
LL | let _ = Rak(..);
69
69
| ^^
70
70
71
71
error[E0061]: this struct takes 1 argument but 2 arguments were supplied
72
-
--> $DIR/default-field-values-failures.rs:59:13
72
+
--> $DIR/failures.rs:59:13
73
73
|
74
74
LL | let _ = Rak(0, ..);
75
75
| ^^^ -- unexpected argument #2 of type `RangeFull`
76
76
|
77
77
help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal
78
-
--> $DIR/default-field-values-failures.rs:59:20
78
+
--> $DIR/failures.rs:59:20
79
79
|
80
80
LL | let _ = Rak(0, ..);
81
81
| ^^
82
82
note: tuple struct defined here
83
-
--> $DIR/default-field-values-failures.rs:26:12
83
+
--> $DIR/failures.rs:26:12
84
84
|
85
85
LL | pub struct Rak(i32 = 42);
86
86
| ^^^
@@ -91,18 +91,18 @@ LL + let _ = Rak(0);
91
91
|
92
92
93
93
error[E0061]: this struct takes 1 argument but 2 arguments were supplied
94
-
--> $DIR/default-field-values-failures.rs:61:13
94
+
--> $DIR/failures.rs:61:13
95
95
|
96
96
LL | let _ = Rak(.., 0);
97
97
| ^^^ -- unexpected argument #1 of type `RangeFull`
98
98
|
99
99
help: you might have meant to use `..` to skip providing a value for expected fields, but this is only supported on non-tuple struct literals; it is instead interpreted as a `std::ops::RangeFull` literal
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/default-field-values-invalid-const.rs:5:19
5
+
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/invalid-const.rs:5:19
6
6
|
7
7
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
8
8
9
9
error[E0080]: evaluation of `Baz::<C>::bat::{constant#0}` failed
0 commit comments