Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fc239e82
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,发现更多精彩内容 >>
提交
fc239e82
编写于
6月 26, 2020
作者:
G
Gary Guo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make `likely` and `unlikely` const
They are gated by internal feature gate const_likely
上级
224bc052
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
10 addition
and
0 deletion
+10
-0
src/libcore/intrinsics.rs
src/libcore/intrinsics.rs
+2
-0
src/libcore/lib.rs
src/libcore/lib.rs
+1
-0
src/librustc_mir/interpret/intrinsics.rs
src/librustc_mir/interpret/intrinsics.rs
+5
-0
src/librustc_span/symbol.rs
src/librustc_span/symbol.rs
+2
-0
未找到文件。
src/libcore/intrinsics.rs
浏览文件 @
fc239e82
...
...
@@ -952,6 +952,7 @@
/// Any use other than with `if` statements will probably not have an effect.
///
/// This intrinsic does not have a stable counterpart.
#[rustc_const_unstable(feature
=
"const_likely"
,
issue
=
"none"
)]
pub
fn
likely
(
b
:
bool
)
->
bool
;
/// Hints to the compiler that branch condition is likely to be false.
...
...
@@ -960,6 +961,7 @@
/// Any use other than with `if` statements will probably not have an effect.
///
/// This intrinsic does not have a stable counterpart.
#[rustc_const_unstable(feature
=
"const_likely"
,
issue
=
"none"
)]
pub
fn
unlikely
(
b
:
bool
)
->
bool
;
/// Executes a breakpoint trap, for inspection by a debugger.
...
...
src/libcore/lib.rs
浏览文件 @
fc239e82
...
...
@@ -92,6 +92,7 @@
#![feature(const_slice_from_raw_parts)]
#![feature(const_slice_ptr_len)]
#![feature(const_type_name)]
#![feature(const_likely)]
#![feature(custom_inner_attributes)]
#![feature(decl_macro)]
#![feature(doc_cfg)]
...
...
src/librustc_mir/interpret/intrinsics.rs
浏览文件 @
fc239e82
...
...
@@ -399,6 +399,11 @@ pub fn emulate_intrinsic(
);
self
.copy_op
(
self
.operand_index
(
args
[
0
],
index
)
?
,
dest
)
?
;
}
sym
::
likely
|
sym
::
unlikely
=>
{
// These just return their argument
let
a
=
self
.read_immediate
(
args
[
0
])
?
;
self
.write_immediate
(
*
a
,
dest
)
?
;
}
// FIXME(#73156): Handle source code coverage in const eval
sym
::
count_code_region
=>
(),
_
=>
return
Ok
(
false
),
...
...
src/librustc_span/symbol.rs
浏览文件 @
fc239e82
...
...
@@ -427,6 +427,7 @@
lhs
,
lib
,
lifetime
,
likely
,
line
,
link
,
linkage
,
...
...
@@ -813,6 +814,7 @@
underscore_lifetimes
,
uniform_paths
,
universal_impl_trait
,
unlikely
,
unmarked_api
,
unreachable_code
,
unrestricted_attribute_tokens
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录