-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Get rid of is_min_const_fn #84547
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
Get rid of is_min_const_fn #84547
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9082078
unsafety checking: no longer care about is_min_const_fn
RalfJung 1ecdaa2
remove now-unused 'is_min_const_fn'
RalfJung 43126f3
get rid of min_const_fn references in library/ and rustdoc
RalfJung b1ad1fb
make sure raw ptr casts in 'const' context are unsafe
RalfJung 421d54e
fix clippy
RalfJung 588530d
fix typography
RalfJung 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
// gate-test-const_raw_ptr_to_usize_cast | ||
// revisions: with_feature without_feature | ||
|
||
#![cfg_attr(with_feature, feature(const_raw_ptr_to_usize_cast))] | ||
|
||
fn main() { | ||
const X: u32 = unsafe { | ||
main as u32 //~ ERROR casting pointers to integers in constants is unstable | ||
const X: usize = unsafe { | ||
main as usize //[without_feature]~ ERROR casting pointers to integers in constants is unstable | ||
}; | ||
const Y: u32 = 0; | ||
const Z: u32 = unsafe { | ||
&Y as *const u32 as u32 //~ ERROR is unstable | ||
const Z: usize = unsafe { | ||
&Y as *const u32 as usize //[without_feature]~ ERROR is unstable | ||
}; | ||
// Cast in `const` without `unsafe` block | ||
const SAFE: usize = { | ||
&Y as *const u32 as usize //[without_feature]~ ERROR is unstable | ||
//[with_feature]~^ ERROR cast of pointer to int is unsafe and requires unsafe | ||
}; | ||
} | ||
|
||
// Cast in `const fn` without `unsafe` block | ||
const fn test() -> usize { | ||
&0 as *const i32 as usize //[without_feature]~ ERROR is unstable | ||
//[with_feature]~^ ERROR cast of pointer to int is unsafe and requires unsafe | ||
} |
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
src/test/ui/cast/cast-ptr-to-int-const.with_feature.stderr
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0133]: cast of pointer to int is unsafe and requires unsafe function or block | ||
--> $DIR/cast-ptr-to-int-const.rs:16:9 | ||
| | ||
LL | &Y as *const u32 as usize | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cast of pointer to int | ||
| | ||
= note: casting pointers to integers in constants | ||
|
||
error[E0133]: cast of pointer to int is unsafe and requires unsafe function or block | ||
--> $DIR/cast-ptr-to-int-const.rs:23:5 | ||
| | ||
LL | &0 as *const i32 as usize | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cast of pointer to int | ||
| | ||
= note: casting pointers to integers in constants | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0133`. |
Oops, something went wrong.
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.