Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1c36d1c7
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,发现更多精彩内容 >>
提交
1c36d1c7
编写于
9月 23, 2014
作者:
N
Nick Cameron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Emit an error rather than ICEing for a missing built-in bound lang item.
closes #17392
上级
1f3cda8b
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
102 addition
and
45 deletion
+102
-45
src/librustc/middle/traits/mod.rs
src/librustc/middle/traits/mod.rs
+5
-1
src/librustc/middle/traits/select.rs
src/librustc/middle/traits/select.rs
+5
-0
src/librustc/middle/traits/util.rs
src/librustc/middle/traits/util.rs
+25
-18
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+9
-6
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/check/regionck.rs
+7
-1
src/librustc/middle/typeck/check/vtable2.rs
src/librustc/middle/typeck/check/vtable2.rs
+6
-3
src/librustc/middle/typeck/check/wf.rs
src/librustc/middle/typeck/check/wf.rs
+24
-16
src/test/compile-fail/lang-item-missing.rs
src/test/compile-fail/lang-item-missing.rs
+21
-0
未找到文件。
src/librustc/middle/traits/mod.rs
浏览文件 @
1c36d1c7
...
...
@@ -86,6 +86,10 @@ pub enum ObligationCauseCode {
FieldSized
,
}
// An error has already been reported to the user, so no need to continue checking.
#[deriving(Clone,Show)]
pub
struct
ErrorReported
;
pub
type
Obligations
=
subst
::
VecPerParamSpace
<
Obligation
>
;
pub
type
Selection
=
Vtable
<
Obligation
>
;
...
...
@@ -332,7 +336,7 @@ pub fn obligation_for_builtin_bound(tcx: &ty::ctxt,
cause
:
ObligationCause
,
source_ty
:
ty
::
t
,
builtin_bound
:
ty
::
BuiltinBound
)
->
Obligation
->
Result
<
Obligation
,
ErrorReported
>
{
util
::
obligation_for_builtin_bound
(
tcx
,
cause
,
builtin_bound
,
0
,
source_ty
)
}
...
...
src/librustc/middle/traits/select.rs
浏览文件 @
1c36d1c7
...
...
@@ -228,6 +228,11 @@ fn evaluate_builtin_bound_recursively(&mut self,
bound
,
previous_stack
.obligation.recursion_depth
+
1
,
ty
);
let
obligation
=
match
obligation
{
Ok
(
ob
)
=>
ob
,
_
=>
return
EvaluatedToMatch
};
self
.evaluate_obligation_recursively
(
previous_stack
,
&
obligation
)
}
...
...
src/librustc/middle/traits/util.rs
浏览文件 @
1c36d1c7
...
...
@@ -20,7 +20,8 @@
use
syntax
::
codemap
::
Span
;
use
util
::
ppaux
::
Repr
;
use
super
::{
Obligation
,
ObligationCause
,
VtableImpl
,
VtableParam
,
VtableParamData
,
VtableImplData
};
use
super
::{
ErrorReported
,
Obligation
,
ObligationCause
,
VtableImpl
,
VtableParam
,
VtableParamData
,
VtableImplData
};
///////////////////////////////////////////////////////////////////////////
// Supertrait iterator
...
...
@@ -82,7 +83,7 @@ fn push(&mut self, trait_ref: &ty::TraitRef) {
let
bound_trait_ref
=
trait_ref_for_builtin_bound
(
self
.tcx
,
builtin_bound
,
trait_ref
.self_ty
());
trait_bounds
.push
(
bound_trait_ref
);
bound_trait_ref
.map
(|
trait_ref
|
trait_bounds
.push
(
trait_ref
)
);
}
// Only keep those bounds that we haven't already seen. This
...
...
@@ -213,13 +214,15 @@ fn push_obligations_for_param_bounds(
let
param_ty
=
*
param_substs
.types
.get
(
space
,
index
);
for
builtin_bound
in
param_bounds
.builtin_bounds
.iter
()
{
obligations
.push
(
space
,
obligation_for_builtin_bound
(
tcx
,
cause
,
builtin_bound
,
recursion_depth
,
param_ty
));
let
obligation
=
obligation_for_builtin_bound
(
tcx
,
cause
,
builtin_bound
,
recursion_depth
,
param_ty
);
match
obligation
{
Ok
(
ob
)
=>
obligations
.push
(
space
,
ob
),
_
=>
{}
}
}
for
bound_trait_ref
in
param_bounds
.trait_bounds
.iter
()
{
...
...
@@ -236,17 +239,18 @@ pub fn trait_ref_for_builtin_bound(
tcx
:
&
ty
::
ctxt
,
builtin_bound
:
ty
::
BuiltinBound
,
param_ty
:
ty
::
t
)
->
Rc
<
ty
::
TraitRef
>
->
Option
<
Rc
<
ty
::
TraitRef
>
>
{
match
tcx
.lang_items
.from_builtin_kind
(
builtin_bound
)
{
Ok
(
def_id
)
=>
{
Rc
::
new
(
ty
::
TraitRef
{
Some
(
Rc
::
new
(
ty
::
TraitRef
{
def_id
:
def_id
,
substs
:
Substs
::
empty
()
.with_self_ty
(
param_ty
)
})
})
)
}
Err
(
e
)
=>
{
tcx
.sess
.bug
(
e
.as_slice
());
tcx
.sess
.err
(
e
.as_slice
());
None
}
}
}
...
...
@@ -257,13 +261,16 @@ pub fn obligation_for_builtin_bound(
builtin_bound
:
ty
::
BuiltinBound
,
recursion_depth
:
uint
,
param_ty
:
ty
::
t
)
->
Obligation
->
Result
<
Obligation
,
ErrorReported
>
{
let
trait_ref
=
trait_ref_for_builtin_bound
(
tcx
,
builtin_bound
,
param_ty
);
Obligation
{
cause
:
cause
,
recursion_depth
:
recursion_depth
,
trait_ref
:
trait_ref
match
trait_ref
{
Some
(
trait_ref
)
=>
Ok
(
Obligation
{
cause
:
cause
,
recursion_depth
:
recursion_depth
,
trait_ref
:
trait_ref
}),
None
=>
Err
(
ErrorReported
)
}
}
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
1c36d1c7
...
...
@@ -1795,12 +1795,15 @@ pub fn require_type_meets(&self,
code
:
traits
::
ObligationCauseCode
,
bound
:
ty
::
BuiltinBound
)
{
self
.register_obligation
(
traits
::
obligation_for_builtin_bound
(
self
.tcx
(),
traits
::
ObligationCause
::
new
(
span
,
code
),
ty
,
bound
));
let
obligation
=
traits
::
obligation_for_builtin_bound
(
self
.tcx
(),
traits
::
ObligationCause
::
new
(
span
,
code
),
ty
,
bound
);
match
obligation
{
Ok
(
ob
)
=>
self
.register_obligation
(
ob
),
_
=>
{}
}
}
pub
fn
require_type_is_sized
(
&
self
,
...
...
src/librustc/middle/typeck/check/regionck.rs
浏览文件 @
1c36d1c7
...
...
@@ -945,7 +945,13 @@ fn ensure_free_variable_types_outlive_closure_bound(
let
cause
=
traits
::
ObligationCause
::
new
(
freevar
.span
,
code
);
let
obligation
=
traits
::
obligation_for_builtin_bound
(
rcx
.tcx
(),
cause
,
var_ty
,
builtin_bound
);
rcx
.fcx.inh.fulfillment_cx
.borrow_mut
()
.register_obligation
(
rcx
.tcx
(),
obligation
);
match
obligation
{
Ok
(
obligation
)
=>
{
rcx
.fcx.inh.fulfillment_cx
.borrow_mut
()
.register_obligation
(
rcx
.tcx
(),
obligation
)
}
_
=>
{}
}
}
type_must_outlive
(
rcx
,
infer
::
RelateProcBound
(
expr
.span
,
var_node_id
,
var_ty
),
...
...
src/librustc/middle/typeck/check/vtable2.rs
浏览文件 @
1c36d1c7
...
...
@@ -170,13 +170,16 @@ pub fn register_object_cast_obligations(fcx: &FnCtxt,
// object type is Foo+Send, this would create an obligation
// for the Send check.)
for
builtin_bound
in
object_trait
.bounds.builtin_bounds
.iter
()
{
fcx
.register_obligation
(
obligation_for_builtin_bound
(
let
obligation
=
obligation_for_builtin_bound
(
fcx
.tcx
(),
ObligationCause
::
new
(
span
,
traits
::
ObjectCastObligation
(
object_trait_ty
)),
referent_ty
,
builtin_bound
));
builtin_bound
);
match
obligation
{
Ok
(
obligation
)
=>
fcx
.register_obligation
(
obligation
),
_
=>
{}
}
}
object_trait_ref
...
...
src/librustc/middle/typeck/check/wf.rs
浏览文件 @
1c36d1c7
...
...
@@ -124,11 +124,14 @@ fn check_type_defn(&mut self,
if
variant
.fields
.len
()
>
0
{
for
field
in
variant
.fields
.init
()
.iter
()
{
let
cause
=
traits
::
ObligationCause
::
new
(
field
.span
,
traits
::
FieldSized
);
fcx
.register_obligation
(
traits
::
obligation_for_builtin_bound
(
fcx
.tcx
(),
cause
,
field
.ty
,
ty
::
BoundSized
));
let
obligation
=
traits
::
obligation_for_builtin_bound
(
fcx
.tcx
(),
cause
,
field
.ty
,
ty
::
BoundSized
);
match
obligation
{
Ok
(
obligation
)
=>
fcx
.register_obligation
(
obligation
),
_
=>
{}
}
}
}
}
...
...
@@ -213,11 +216,14 @@ fn check_impl(&mut self,
&
trait_def
.bounds
,
trait_ref
.self_ty
());
for
builtin_bound
in
trait_def
.bounds.builtin_bounds
.iter
()
{
fcx
.register_obligation
(
traits
::
obligation_for_builtin_bound
(
fcx
.tcx
(),
cause
,
trait_ref
.self_ty
(),
builtin_bound
));
let
obligation
=
traits
::
obligation_for_builtin_bound
(
fcx
.tcx
(),
cause
,
trait_ref
.self_ty
(),
builtin_bound
);
match
obligation
{
Ok
(
obligation
)
=>
fcx
.register_obligation
(
obligation
),
_
=>
{}
}
}
for
trait_bound
in
trait_def
.bounds.trait_bounds
.iter
()
{
let
trait_bound
=
trait_bound
.subst
(
fcx
.tcx
(),
&
trait_ref
.substs
);
...
...
@@ -453,12 +459,14 @@ fn check_struct_safe_for_destructor(fcx: &FnCtxt,
&&
!
struct_tpt
.generics
.has_region_params
(
subst
::
TypeSpace
)
{
let
cause
=
traits
::
ObligationCause
::
new
(
span
,
traits
::
DropTrait
);
fcx
.register_obligation
(
traits
::
obligation_for_builtin_bound
(
fcx
.tcx
(),
cause
,
self_ty
,
ty
::
BoundSend
));
let
obligation
=
traits
::
obligation_for_builtin_bound
(
fcx
.tcx
(),
cause
,
self_ty
,
ty
::
BoundSend
);
match
obligation
{
Ok
(
obligation
)
=>
fcx
.register_obligation
(
obligation
),
_
=>
{}
}
}
else
{
span_err!
(
fcx
.tcx
()
.sess
,
span
,
E0141
,
"cannot implement a destructor on a structure
\
...
...
src/test/compile-fail/lang-item-missing.rs
0 → 100644
浏览文件 @
1c36d1c7
// 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.
// Test that a missing lang item (in this case `sized`) does not cause an ICE,
// see #17392.
// error-pattern: requires `sized` lang_item
#![no_std]
#[start]
fn
start
(
argc
:
int
,
argv
:
*
const
*
const
u8
)
->
int
{
0
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录