Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b7a0e401
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,发现更多精彩内容 >>
提交
b7a0e401
编写于
6月 25, 2019
作者:
V
varkor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix an ICE with uninhabited consts
上级
8aa42ed7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
7 deletion
+48
-7
src/librustc/ty/inhabitedness/mod.rs
src/librustc/ty/inhabitedness/mod.rs
+1
-1
src/librustc_mir/interpret/terminator.rs
src/librustc_mir/interpret/terminator.rs
+4
-6
src/test/ui/consts/uninhabited-const-issue-61744.rs
src/test/ui/consts/uninhabited-const-issue-61744.rs
+19
-0
src/test/ui/consts/uninhabited-const-issue-61744.stderr
src/test/ui/consts/uninhabited-const-issue-61744.stderr
+24
-0
未找到文件。
src/librustc/ty/inhabitedness/mod.rs
浏览文件 @
b7a0e401
...
...
@@ -97,7 +97,7 @@ pub fn is_ty_uninhabited_from(self, module: DefId, ty: Ty<'tcx>) -> bool {
self
.ty_inhabitedness_forest
(
ty
)
.contains
(
self
,
module
)
}
pub
fn
is_ty_uninhabited_from_a
ll_modules
(
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
pub
fn
is_ty_uninhabited_from_a
ny_module
(
self
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
!
self
.ty_inhabitedness_forest
(
ty
)
.is_empty
()
}
...
...
src/librustc_mir/interpret/terminator.rs
浏览文件 @
b7a0e401
...
...
@@ -388,12 +388,10 @@ fn eval_fn_call(
));
}
}
else
{
let
callee_layout
=
self
.layout_of_local
(
self
.frame
(),
mir
::
RETURN_PLACE
,
None
)
?
;
if
!
callee_layout
.abi
.is_uninhabited
()
{
return
err!
(
FunctionRetMismatch
(
self
.tcx.types.never
,
callee_layout
.ty
));
let
local
=
mir
::
RETURN_PLACE
;
let
ty
=
self
.frame
()
.body.local_decls
[
local
]
.ty
;
if
!
self
.tcx
.is_ty_uninhabited_from_any_module
(
ty
)
{
return
err!
(
FunctionRetMismatch
(
self
.tcx.types.never
,
ty
));
}
}
Ok
(())
...
...
src/test/ui/consts/uninhabited-const-issue-61744.rs
0 → 100644
浏览文件 @
b7a0e401
// compile-fail
pub
const
unsafe
fn
fake_type
<
T
>
()
->
T
{
hint_unreachable
()
}
pub
const
unsafe
fn
hint_unreachable
()
->
!
{
fake_type
()
//~ ERROR any use of this value will cause an error
}
trait
Const
{
const
CONSTANT
:
i32
=
unsafe
{
fake_type
()
};
}
impl
<
T
>
Const
for
T
{}
pub
fn
main
()
->
()
{
dbg!
(
i32
::
CONSTANT
);
//~ ERROR erroneous constant used
}
src/test/ui/consts/uninhabited-const-issue-61744.stderr
0 → 100644
浏览文件 @
b7a0e401
error: any use of this value will cause an error
--> $DIR/uninhabited-const-issue-61744.rs:8:5
|
LL | fake_type()
| ^^^^^^^^^^^
| |
| tried to call a function with return type T passing return place of type !
| inside call to `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:4:5
| inside call to `fake_type::<i32>` at $DIR/uninhabited-const-issue-61744.rs:12:36
...
LL | const CONSTANT: i32 = unsafe { fake_type() };
| ---------------------------------------------
|
= note: #[deny(const_err)] on by default
error[E0080]: erroneous constant used
--> $DIR/uninhabited-const-issue-61744.rs:18:10
|
LL | dbg!(i32::CONSTANT);
| ^^^^^^^^^^^^^ referenced constant has errors
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0080`.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录