-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #84547 - RalfJung:max_const_fn, r=oli-obk
Get rid of is_min_const_fn This removes the last trace of the min_const_fn mechanism by making the unsafety checker agnostic about whether something is a min or "non-min" const fn. It seems this distinction was used to disallow some features inside `const fn`, but that is the responsibility of the const checker, not of the unsafety checker. No test seems to even notice this change in the unsafety checker so I guess we are good... r? `@oli-obk` Cc #84510
- Loading branch information
Showing
11 changed files
with
102 additions
and
142 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 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
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,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 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.