Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
3b0cafbc
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,发现更多精彩内容 >>
提交
3b0cafbc
编写于
2月 20, 2015
作者:
E
Eduard Burtescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests: update expected recursion limit errors for the temporary lack of spans.
上级
7a8a5172
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
16 deletion
+29
-16
src/librustc_trans/trans/common.rs
src/librustc_trans/trans/common.rs
+10
-1
src/test/compile-fail/infinite-instantiation.rs
src/test/compile-fail/infinite-instantiation.rs
+13
-7
src/test/compile-fail/recursion.rs
src/test/compile-fail/recursion.rs
+6
-8
未找到文件。
src/librustc_trans/trans/common.rs
浏览文件 @
3b0cafbc
...
...
@@ -120,7 +120,16 @@ fn fold_substs(&mut self,
// Is the type's representation size known at compile time?
pub
fn
type_is_sized
<
'tcx
>
(
tcx
:
&
ty
::
ctxt
<
'tcx
>
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
let
param_env
=
ty
::
empty_parameter_environment
(
tcx
);
ty
::
type_is_sized
(
&
param_env
,
DUMMY_SP
,
ty
)
// FIXME(#4287) This can cause errors due to polymorphic recursion,
// a better span should be provided, if available.
let
err_count
=
tcx
.sess
.err_count
();
let
is_sized
=
ty
::
type_is_sized
(
&
param_env
,
DUMMY_SP
,
ty
);
// Those errors aren't fatal, but an incorrect result can later
// trip over asserts in both rustc's trans and LLVM.
if
err_count
<
tcx
.sess
.err_count
()
{
tcx
.sess
.abort_if_errors
();
}
is_sized
}
pub
fn
type_is_fat_ptr
<
'tcx
>
(
cx
:
&
ty
::
ctxt
<
'tcx
>
,
ty
:
Ty
<
'tcx
>
)
->
bool
{
...
...
src/test/compile-fail/infinite-instantiation.rs
浏览文件 @
3b0cafbc
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012
-2015
The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
...
...
@@ -8,28 +8,34 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: reached the recursion limit during monomorphization
// issue 2258
//~^^^^^^^^^^ ERROR overflow
//
// We get an error message at the top of file (dummy span).
// This is not helpful, but also kind of annoying to prevent,
// so for now just live with it.
// This test case was originally for issue #2258.
trait
to_o
pt
{
trait
ToO
pt
{
fn
to_option
(
&
self
)
->
Option
<
Self
>
;
}
impl
to_o
pt
for
usize
{
impl
ToO
pt
for
usize
{
fn
to_option
(
&
self
)
->
Option
<
usize
>
{
Some
(
*
self
)
}
}
impl
<
T
:
Clone
>
to_o
pt
for
Option
<
T
>
{
impl
<
T
:
Clone
>
ToO
pt
for
Option
<
T
>
{
fn
to_option
(
&
self
)
->
Option
<
Option
<
T
>>
{
Some
((
*
self
)
.clone
())
}
}
fn
function
<
T
:
to_o
pt
+
Clone
>
(
counter
:
usize
,
t
:
T
)
{
fn
function
<
T
:
ToO
pt
+
Clone
>
(
counter
:
usize
,
t
:
T
)
{
if
counter
>
0_u
size
{
function
(
counter
-
1_u
size
,
t
.to_option
());
// FIXME(#4287) Error message should be here. It should be
// a type error to instantiate `test` at a type other than T.
}
}
...
...
src/test/compile-fail/recursion.rs
浏览文件 @
3b0cafbc
// Copyright 2012-201
4
The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-201
5
The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
...
...
@@ -10,10 +10,9 @@
//~^^^^^^^^^^ ERROR overflow
//
// We also get a second error message at the top of file (dummy
// span). This is not helpful, but also kind of annoying to prevent,
// so for now just live with it, since we also get a second message
// that is more helpful.
// We get an error message at the top of file (dummy span).
// This is not helpful, but also kind of annoying to prevent,
// so for now just live with it.
enum
Nil
{
NilValue
}
struct
Cons
<
T
>
{
head
:
isize
,
tail
:
T
}
...
...
@@ -28,9 +27,8 @@ fn dot(&self, other:Cons<T>) -> isize {
}
fn
test
<
T
:
Dot
>
(
n
:
isize
,
i
:
isize
,
first
:
T
,
second
:
T
)
->
isize
{
match
n
{
0
=>
{
first
.dot
(
second
)}
//~^ ERROR: reached the recursion limit during monomorphization
// Error message should be here. It should be a type error
// to instantiate `test` at a type other than T. (See #4287)
// FIXME(#4287) Error message should be here. It should be
// a type error to instantiate `test` at a type other than T.
_
=>
{
test
(
n
-
1
,
i
+
1
,
Cons
{
head
:
2
*
i
+
1
,
tail
:
first
},
Cons
{
head
:
i
*
i
,
tail
:
second
})}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录