Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
72f15ea2
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
72f15ea2
编写于
12月 23, 2021
作者:
W
woppopo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Constify `core::intrinsics::black_box`
上级
390bb340
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
23 addition
and
1 deletion
+23
-1
library/core/src/hint.rs
library/core/src/hint.rs
+2
-1
library/core/src/intrinsics.rs
library/core/src/intrinsics.rs
+1
-0
library/core/src/lib.rs
library/core/src/lib.rs
+1
-0
library/core/tests/intrinsics.rs
library/core/tests/intrinsics.rs
+15
-0
library/core/tests/lib.rs
library/core/tests/lib.rs
+4
-0
未找到文件。
library/core/src/hint.rs
浏览文件 @
72f15ea2
...
...
@@ -159,6 +159,7 @@ pub fn spin_loop() {
/// [`std::convert::identity`]: crate::convert::identity
#[inline]
#[unstable(feature
=
"bench_black_box"
,
issue
=
"64102"
)]
pub
fn
black_box
<
T
>
(
dummy
:
T
)
->
T
{
#[rustc_const_unstable(feature
=
"const_black_box"
,
issue
=
"none"
)]
pub
const
fn
black_box
<
T
>
(
dummy
:
T
)
->
T
{
crate
::
intrinsics
::
black_box
(
dummy
)
}
library/core/src/intrinsics.rs
浏览文件 @
72f15ea2
...
...
@@ -1940,6 +1940,7 @@ pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
/// See documentation of [`std::hint::black_box`] for details.
///
/// [`std::hint::black_box`]: crate::hint::black_box
#[rustc_const_unstable(feature
=
"const_black_box"
,
issue
=
"none"
)]
pub
fn
black_box
<
T
>
(
dummy
:
T
)
->
T
;
}
...
...
library/core/src/lib.rs
浏览文件 @
72f15ea2
...
...
@@ -103,6 +103,7 @@
#![feature(const_arguments_as_str)]
#![feature(const_array_into_iter_constructors)]
#![feature(const_bigint_helper_methods)]
#![feature(const_black_box)]
#![feature(const_caller_location)]
#![feature(const_cell_into_inner)]
#![feature(const_char_convert)]
...
...
library/core/tests/intrinsics.rs
浏览文件 @
72f15ea2
...
...
@@ -65,3 +65,18 @@ const fn test_write_bytes_in_const_contexts() {
assert
!
(
TEST2
[
1
]
==
16843009
);
assert
!
(
TEST2
[
2
]
==
3
);
}
#[test]
fn
test_hints_in_const_contexts
()
{
use
core
::
intrinsics
::{
likely
,
unlikely
};
// In const contexts, they just return their argument.
const
{
assert
!
(
true
==
likely
(
true
));
assert
!
(
false
==
likely
(
false
));
assert
!
(
true
==
unlikely
(
true
));
assert
!
(
false
==
unlikely
(
false
));
assert
!
(
42u32
==
core
::
intrinsics
::
black_box
(
42u32
));
assert
!
(
42u32
==
core
::
hint
::
black_box
(
42u32
));
}
}
library/core/tests/lib.rs
浏览文件 @
72f15ea2
...
...
@@ -2,12 +2,14 @@
#![feature(array_chunks)]
#![feature(array_methods)]
#![feature(array_windows)]
#![feature(bench_black_box)]
#![feature(bool_to_option)]
#![feature(box_syntax)]
#![feature(cell_update)]
#![feature(cfg_panic)]
#![feature(cfg_target_has_atomic)]
#![feature(const_assume)]
#![feature(const_black_box)]
#![feature(const_bool_to_option)]
#![feature(const_cell_into_inner)]
#![feature(const_convert)]
...
...
@@ -18,6 +20,7 @@
#![feature(const_ptr_write)]
#![feature(const_ptr_offset)]
#![feature(const_trait_impl)]
#![feature(const_likely)]
#![feature(core_intrinsics)]
#![feature(core_private_bignum)]
#![feature(core_private_diy_float)]
...
...
@@ -35,6 +38,7 @@
#![feature(array_from_fn)]
#![feature(hashmap_internals)]
#![feature(try_find)]
#![feature(inline_const)]
#![feature(is_sorted)]
#![feature(pattern)]
#![feature(sort_internals)]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录