- Notifications
You must be signed in to change notification settings - Fork 13.9k
Allow calling const unsafe fn in const fn behind a feature gate #55635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
23 commits Select commit Hold shift + click to select a range
f2ae7b7 Allow calling `const unsafe fn` in `const fn` behind a feature gate
oli-obk 906a49e Document unsafe rules with comments and `bug!` calls
oli-obk cc3470c Add test for dereferencing raw pointers and immediately referencing a…
oli-obk 02b2232 Make sure the initialization of constrained int range newtypes is unsafe
oli-obk ec6573f Make `newtype_index` safe
oli-obk 693c553 Move ref to packed struct field check into projection arm
oli-obk 8bdb11c Forbid the creation of mutable borrows to fields of layout constraine…
oli-obk 14218e3 Trailing newlines again
oli-obk c4a8500 Adjust a rustc test to the safety changes
oli-obk 081c497 generalize the message about the creation of layout restricted types
oli-obk 1894a5f Also make immutable references to non-freeze restricted value range t…
oli-obk 55abc0b Also prevent mutation fields directly
oli-obk e5d9065 Comment on the unsafety code for layout constrained fields
oli-obk 4497ff3 Emit feature gate suggestion
oli-obk 37ef5e4 Add tests for stable unsafe features in const fn
oli-obk 3ce211d Increase code-reuse and -readability
oli-obk 137a640 Automatically generate imports for newtype_index `Deserialize` impls
oli-obk ae0b00c Add and update tests
oli-obk b75d5f1 Clean up the logic in `is_min_const_fn`
oli-obk 932dbe8 Explain unsafety trickery of const functions
oli-obk b779694 Clear up some code
oli-obk f411576 Intrinsic checks are just needed for `qualify_min_const_fn`
oli-obk cb71752 Tidy fixup
oli-obk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add and update tests
- Loading branch information
commit ae0b00cadace32fd85c6786df24a20d6b55a87d2
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,28 +1,11 @@ | ||
| error[E0658]: statements in constant functions are unstable (see issue #48821) | ||
| --> $DIR/ranged_ints4_const.rs:10:5 | ||
| | | ||
| LL | x.0 = 0; //~ ERROR statements in constant functions are unstable | ||
| | ^^^^^^^ | ||
| | | ||
| = help: add #![feature(const_let)] to the crate attributes to enable | ||
| | ||
| error[E0658]: statements in constant functions are unstable (see issue #48821) | ||
| --> $DIR/ranged_ints4_const.rs:17:14 | ||
| | | ||
| LL | unsafe { x.0 = 0 }; //~ ERROR statements in constant functions are unstable | ||
| | ^^^^^^^ | ||
| | | ||
| = help: add #![feature(const_let)] to the crate attributes to enable | ||
| | ||
| error[E0133]: mutation of layout constrained field is unsafe and requires unsafe function or block | ||
| --> $DIR/ranged_ints4_const.rs:10:5 | ||
| | | ||
| LL | x.0 = 0; //~ ERROR statements in constant functions are unstable | ||
| LL | x.0 = 0; | ||
| | ^^^^^^^ mutation of layout constrained field | ||
| | | ||
| = note: mutating layout constrained fields cannot statically be checked for valid values | ||
| | ||
| error: aborting due to 3 previous errors | ||
| error: aborting due to previous error | ||
| | ||
| Some errors occurred: E0133, E0658. | ||
| For more information about an error, try `rustc --explain E0133`. | ||
| For more information about this error, try `rustc --explain E0133`. |
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.