-
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.
Unconditionally error at definition if default field value has const …
…errors Emit E0080 always on struct definition with default fields that have unconditional const errors and remove `default_field_always_invalid_const` lint.
- Loading branch information
Showing
8 changed files
with
27 additions
and
148 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 was deleted.
Oops, something went wrong.
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
36 changes: 4 additions & 32 deletions
36
tests/ui/structs/default-field-values-invalid-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 |
---|---|---|
@@ -1,45 +1,17 @@ | ||
warning: lint `default_field_always_invalid_const` can't be warned on | ||
--> $DIR/default-field-values-invalid-const.rs:4:8 | ||
| | ||
LL | #[warn(default_field_always_invalid_const)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ either `deny` or `allow`, no other lint level is supported for this lint | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/default-field-values-invalid-const.rs:6:19 | ||
--> $DIR/default-field-values-invalid-const.rs:5:19 | ||
| | ||
LL | pub bax: u8 = panic!("asdf"), | ||
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/default-field-values-invalid-const.rs:6:19 | ||
| ^^^^^^^^^^^^^^ the evaluated program panicked at 'asdf', $DIR/default-field-values-invalid-const.rs:5:19 | ||
| | ||
= 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) | ||
|
||
warning: default field fails const-evaluation | ||
--> $DIR/default-field-values-invalid-const.rs:6:5 | ||
| | ||
LL | pub bax: u8 = panic!("asdf"), | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this field's constant fails const-evaluation, as seen in the previous error | ||
| | ||
= help: you can skip const-evaluation of default fields by enabling this lint | ||
note: the lint level is defined here | ||
--> $DIR/default-field-values-invalid-const.rs:4:8 | ||
| | ||
LL | #[warn(default_field_always_invalid_const)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0080]: evaluation of `Baz::<C>::bat::{constant#0}` failed | ||
--> $DIR/default-field-values-invalid-const.rs:13:19 | ||
--> $DIR/default-field-values-invalid-const.rs:11:19 | ||
| | ||
LL | pub bat: u8 = 130 + 130, | ||
| ^^^^^^^^^ attempt to compute `130_u8 + 130_u8`, which would overflow | ||
|
||
error: default field fails const-evaluation | ||
--> $DIR/default-field-values-invalid-const.rs:13:5 | ||
| | ||
LL | pub bat: u8 = 130 + 130, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ this field's constant fails const-evaluation, as seen in the previous error | ||
| | ||
= help: you can skip const-evaluation of default fields by enabling this lint | ||
= note: `#[deny(default_field_always_invalid_const)]` on by default | ||
|
||
error: aborting due to 3 previous errors; 2 warnings emitted | ||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0080`. |