Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
cf9164f9
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,发现更多精彩内容 >>
提交
cf9164f9
编写于
2月 10, 2014
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
auto merge of #12095 : FlaPer87/rust/issue-11709, r=nikomatsakis
Closes #11709
上级
1f245cc7
31576c7e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
7 deletion
+65
-7
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/base.rs
+9
-6
src/librustc/middle/trans/controlflow.rs
src/librustc/middle/trans/controlflow.rs
+9
-1
src/test/run-pass/issue-11709.rs
src/test/run-pass/issue-11709.rs
+47
-0
未找到文件。
src/librustc/middle/trans/base.rs
浏览文件 @
cf9164f9
...
...
@@ -1506,16 +1506,19 @@ pub fn trans_closure<'a>(ccx: @CrateContext,
// emitting should be enabled.
debuginfo
::
start_emitting_source_locations
(
&
fcx
);
let
dest
=
match
fcx
.llretptr
.get
()
{
Some
(
e
)
=>
{
expr
::
SaveIn
(
e
)}
None
=>
{
assert
!
(
type_is_zero_size
(
bcx
.ccx
(),
block_ty
))
expr
::
Ignore
}
};
// This call to trans_block is the place where we bridge between
// translation calls that don't have a return value (trans_crate,
// trans_mod, trans_item, et cetera) and those that do
// (trans_block, trans_expr, et cetera).
if
body
.expr
.is_none
()
||
type_is_zero_size
(
bcx
.ccx
(),
block_ty
)
{
bcx
=
controlflow
::
trans_block
(
bcx
,
body
,
expr
::
Ignore
);
}
else
{
let
dest
=
expr
::
SaveIn
(
fcx
.llretptr
.get
()
.unwrap
());
bcx
=
controlflow
::
trans_block
(
bcx
,
body
,
dest
);
}
bcx
=
controlflow
::
trans_block
(
bcx
,
body
,
dest
);
match
fcx
.llreturn
.get
()
{
Some
(
_
)
=>
{
...
...
src/librustc/middle/trans/controlflow.rs
浏览文件 @
cf9164f9
...
...
@@ -74,7 +74,7 @@ pub fn trans_stmt<'a>(cx: &'a Block<'a>,
pub
fn
trans_block
<
'a
>
(
bcx
:
&
'a
Block
<
'a
>
,
b
:
&
ast
::
Block
,
dest
:
expr
::
Dest
)
mut
dest
:
expr
::
Dest
)
->
&
'a
Block
<
'a
>
{
let
_
icx
=
push_ctxt
(
"trans_block"
);
let
fcx
=
bcx
.fcx
;
...
...
@@ -85,6 +85,14 @@ pub fn trans_block<'a>(bcx: &'a Block<'a>,
for
s
in
b
.stmts
.iter
()
{
bcx
=
trans_stmt
(
bcx
,
*
s
);
}
if
dest
!=
expr
::
Ignore
{
let
block_ty
=
node_id_type
(
bcx
,
b
.id
);
if
b
.expr
.is_none
()
||
type_is_zero_size
(
bcx
.ccx
(),
block_ty
)
{
dest
=
expr
::
Ignore
;
}
}
match
b
.expr
{
Some
(
e
)
=>
{
bcx
=
expr
::
trans_into
(
bcx
,
e
,
dest
);
...
...
src/test/run-pass/issue-11709.rs
0 → 100644
浏览文件 @
cf9164f9
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// xfail-pretty
// Don't fail on blocks without results
// There are several tests in this run-pass that raised
// when this bug was oppened. The cases where the compiler
// failed before the fix have a comment.
struct
S
{
x
:()}
fn
test
(
slot
:
&
mut
Option
<
proc
()
->
proc
()
>
,
_
:
proc
())
->
()
{
let
a
=
slot
.take
();
let
_
a
=
match
a
{
// `{let .. a(); }` would break
Some
(
a
)
=>
{
let
_
a
=
a
();
},
None
=>
(),
};
}
fn
not
(
b
:
bool
)
->
bool
{
if
b
{
!
b
}
else
{
// `fail!(...)` would break
fail
!
(
"Break the compiler"
);
}
}
pub
fn
main
()
{
// {} would break
let
_
r
=
{};
let
mut
slot
=
None
;
// `{ test(...); }` would break
let
_
s
:
S
=
S
{
x
:
{
test
(
&
mut
slot
,
proc
()
{});
}
};
let
_
b
=
not
(
true
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录