Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e9009c86
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,发现更多精彩内容 >>
提交
e9009c86
编写于
10月 03, 2019
作者:
W
Wesley Wiser
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[const-prop] Fix ICE when trying to eval polymorphic promoted MIR
上级
cfb6d847
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
11 deletion
+29
-11
src/librustc_mir/interpret/place.rs
src/librustc_mir/interpret/place.rs
+7
-0
src/test/ui/consts/const-eval/issue-50814.rs
src/test/ui/consts/const-eval/issue-50814.rs
+0
-1
src/test/ui/consts/const-eval/issue-50814.stderr
src/test/ui/consts/const-eval/issue-50814.stderr
+2
-10
src/test/ui/consts/const-eval/issue-64908.rs
src/test/ui/consts/const-eval/issue-64908.rs
+20
-0
未找到文件。
src/librustc_mir/interpret/place.rs
浏览文件 @
e9009c86
...
...
@@ -594,6 +594,13 @@ pub(super) fn eval_static_to_mplace(
StaticKind
::
Promoted
(
promoted
,
promoted_substs
)
=>
{
let
substs
=
self
.subst_from_frame_and_normalize_erasing_regions
(
promoted_substs
);
let
instance
=
ty
::
Instance
::
new
(
place_static
.def_id
,
substs
);
// Even after getting `substs` from the frame, this instance may still be
// polymorphic because `ConstProp` will try to promote polymorphic MIR.
if
instance
.needs_subst
()
{
throw_inval!
(
TooGeneric
);
}
self
.const_eval_raw
(
GlobalId
{
instance
,
promoted
:
Some
(
promoted
),
...
...
src/test/ui/consts/const-eval/issue-50814.rs
浏览文件 @
e9009c86
...
...
@@ -11,7 +11,6 @@ impl Unsigned for U8 {
impl
<
A
:
Unsigned
,
B
:
Unsigned
>
Unsigned
for
Sum
<
A
,
B
>
{
const
MAX
:
u8
=
A
::
MAX
+
B
::
MAX
;
//~ ERROR any use of this value will cause an error
//~| ERROR any use of this value will cause an error
}
fn
foo
<
T
>
(
_
:
T
)
->
&
'static
u8
{
...
...
src/test/ui/consts/const-eval/issue-50814.stderr
浏览文件 @
e9009c86
...
...
@@ -9,21 +9,13 @@ LL | const MAX: u8 = A::MAX + B::MAX;
= note: `#[deny(const_err)]` on by default
error[E0080]: evaluation of constant expression failed
--> $DIR/issue-50814.rs:1
8
:5
--> $DIR/issue-50814.rs:1
7
:5
|
LL | &Sum::<U8,U8>::MAX
| ^-----------------
| |
| referenced constant has errors
error: any use of this value will cause an error
--> $DIR/issue-50814.rs:13:21
|
LL | const MAX: u8 = A::MAX + B::MAX;
| ----------------^^^^^^^^^^^^^^^-
| |
| attempt to add with overflow
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0080`.
src/test/ui/consts/const-eval/issue-64908.rs
0 → 100644
浏览文件 @
e9009c86
// run-pass
// This test verifies that the `ConstProp` pass doesn't cause an ICE when evaluating polymorphic
// promoted MIR.
pub
trait
ArrowPrimitiveType
{
type
Native
;
}
pub
fn
new
<
T
:
ArrowPrimitiveType
>
()
{
assert_eq!
(
0
,
std
::
mem
::
size_of
::
<
T
::
Native
>
());
}
impl
ArrowPrimitiveType
for
()
{
type
Native
=
();
}
fn
main
()
{
new
::
<
()
>
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录