Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
35e16036
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,发现更多精彩内容 >>
提交
35e16036
编写于
3月 29, 2016
作者:
B
Benjamin Herr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
librustc_typeck: use bug!(), span_bug!()
上级
4bb76796
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
129 addition
and
151 deletion
+129
-151
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+7
-7
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/_match.rs
+2
-3
src/librustc_typeck/check/callee.rs
src/librustc_typeck/check/callee.rs
+1
-1
src/librustc_typeck/check/cast.rs
src/librustc_typeck/check/cast.rs
+1
-1
src/librustc_typeck/check/coercion.rs
src/librustc_typeck/check/coercion.rs
+1
-2
src/librustc_typeck/check/dropck.rs
src/librustc_typeck/check/dropck.rs
+5
-6
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/confirm.rs
+15
-15
src/librustc_typeck/check/method/mod.rs
src/librustc_typeck/check/method/mod.rs
+6
-8
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/method/probe.rs
+3
-3
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+14
-20
src/librustc_typeck/check/op.rs
src/librustc_typeck/check/op.rs
+4
-3
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/check/regionck.rs
+15
-20
src/librustc_typeck/check/upvar.rs
src/librustc_typeck/check/upvar.rs
+3
-3
src/librustc_typeck/check/wfcheck.rs
src/librustc_typeck/check/wfcheck.rs
+3
-3
src/librustc_typeck/coherence/mod.rs
src/librustc_typeck/coherence/mod.rs
+7
-10
src/librustc_typeck/collect.rs
src/librustc_typeck/collect.rs
+21
-21
src/librustc_typeck/lib.rs
src/librustc_typeck/lib.rs
+8
-8
src/librustc_typeck/variance/constraints.rs
src/librustc_typeck/variance/constraints.rs
+13
-17
未找到文件。
src/librustc_typeck/astconv.rs
浏览文件 @
35e16036
...
...
@@ -161,7 +161,7 @@ pub fn ast_region_to_region(tcx: &TyCtxt, lifetime: &hir::Lifetime)
let
r
=
match
tcx
.named_region_map
.get
(
&
lifetime
.id
)
{
None
=>
{
// should have been recorded by the `resolve_lifetime` pass
tcx
.sess
.span_bug
(
lifetime
.span
,
"unresolved lifetime"
);
span_bug!
(
lifetime
.span
,
"unresolved lifetime"
);
}
Some
(
&
rl
::
DefStaticRegion
)
=>
{
...
...
@@ -485,7 +485,7 @@ fn create_substs_for_ast_path<'tcx>(
substs
.types
.push
(
TypeSpace
,
default
);
}
}
else
{
tcx
.sess
.span_bug
(
span
,
"extra parameter without default"
);
span_bug!
(
span
,
"extra parameter without default"
);
}
}
...
...
@@ -839,7 +839,7 @@ fn create_substs_for_ast_trait_ref<'a,'tcx>(this: &AstConv<'tcx>,
Err
(
ErrorReported
)
=>
{
// No convenient way to recover from a cycle here. Just bail. Sorry!
this
.tcx
()
.sess
.abort_if_errors
();
this
.tcx
()
.sess
.bug
(
"ErrorReported returned, but no errors reports?"
)
bug!
(
"ErrorReported returned, but no errors reports?"
)
}
};
...
...
@@ -1353,7 +1353,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
.expect
(
"missing associated type"
);
tcx
.map
.local_def_id
(
item
.id
)
}
_
=>
unreachable
!
()
_
=>
bug
!
()
}
}
else
{
let
trait_items
=
tcx
.trait_items
(
trait_did
);
...
...
@@ -1496,7 +1496,7 @@ fn base_def_to_ty<'tcx>(this: &AstConv<'tcx>,
ty
}
}
else
{
tcx
.sess
.span_bug
(
span
,
"self type has not been fully resolved"
)
span_bug!
(
span
,
"self type has not been fully resolved"
)
}
}
Def
::
SelfTy
(
Some
(
_
),
None
)
=>
{
...
...
@@ -1654,7 +1654,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
depth
:
path
.segments
.len
()
}
}
else
{
tcx
.sess
.span_bug
(
ast_ty
.span
,
&
format!
(
"unbound path {:?}"
,
ast_ty
)
)
span_bug!
(
ast_ty
.span
,
"unbound path {:?}"
,
ast_ty
)
};
let
def
=
path_res
.base_def
;
let
base_ty_end
=
path
.segments
.len
()
-
path_res
.depth
;
...
...
@@ -1961,7 +1961,7 @@ pub fn ty_of_closure<'tcx>(
ty
::
FnConverging
(
this
.ty_infer
(
None
,
None
,
None
,
decl
.output
.span
())),
hir
::
Return
(
ref
output
)
=>
ty
::
FnConverging
(
ast_ty_to_ty
(
this
,
&
rb
,
&
output
)),
hir
::
DefaultReturn
(
..
)
=>
unreachable
!
(),
hir
::
DefaultReturn
(
..
)
=>
bug
!
(),
hir
::
NoReturn
(
..
)
=>
ty
::
FnDiverging
};
...
...
src/librustc_typeck/check/_match.rs
浏览文件 @
35e16036
...
...
@@ -413,8 +413,7 @@ fn check_assoc_item_is_const(pcx: &pat_ctxt, def: Def, span: Span) -> bool {
false
}
_
=>
{
pcx
.fcx.ccx.tcx.sess
.span_bug
(
span
,
"non-associated item in
check_assoc_item_is_const"
);
span_bug!
(
span
,
"non-associated item in check_assoc_item_is_const"
);
}
}
}
...
...
@@ -588,7 +587,7 @@ pub fn check_pat_struct<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &'tcx hir::Pat,
let
pat_ty
=
pcx
.fcx
.instantiate_type
(
def
.def_id
(),
path
);
let
item_substs
=
match
pat_ty
.sty
{
ty
::
TyStruct
(
_
,
substs
)
|
ty
::
TyEnum
(
_
,
substs
)
=>
substs
,
_
=>
tcx
.sess
.span_bug
(
pat
.span
,
"struct variant is not an ADT"
)
_
=>
span_bug!
(
pat
.span
,
"struct variant is not an ADT"
)
};
demand
::
eqtype
(
fcx
,
pat
.span
,
expected
,
pat_ty
);
check_struct_pat_fields
(
pcx
,
pat
.span
,
fields
,
variant
,
&
item_substs
,
etc
);
...
...
src/librustc_typeck/check/callee.rs
浏览文件 @
35e16036
...
...
@@ -397,7 +397,7 @@ fn resolve<'a>(&mut self, fcx: &FnCtxt<'a,'tcx>) {
write_overloaded_call_method_map
(
fcx
,
self
.call_expr
,
method_callee
);
}
None
=>
{
fcx
.tcx
()
.sess
.span_bug
(
span_bug!
(
self
.call_expr.span
,
"failed to find an overloaded call trait for closure call"
);
}
...
...
src/librustc_typeck/check/cast.rs
浏览文件 @
35e16036
...
...
@@ -139,7 +139,7 @@ fn report_cast_error<'a>(&self, fcx: &FnCtxt<'a, 'tcx>,
CastError
::
NeedViaThinPtr
=>
"a thin pointer"
,
CastError
::
NeedViaInt
=>
"an integer"
,
CastError
::
NeedViaUsize
=>
"a usize"
,
_
=>
unreachable
!
()
_
=>
bug
!
()
}))
.emit
();
}
...
...
src/librustc_typeck/check/coercion.rs
浏览文件 @
35e16036
...
...
@@ -372,8 +372,7 @@ fn coerce_borrowed_pointer<'a, E, I>(&self,
}
let
r_borrow
=
match
ty
.sty
{
ty
::
TyRef
(
r_borrow
,
_
)
=>
r_borrow
,
_
=>
self
.tcx
()
.sess
.span_bug
(
span
,
&
format!
(
"expected a ref type, got {:?}"
,
ty
))
_
=>
span_bug!
(
span
,
"expected a ref type, got {:?}"
,
ty
)
};
let
autoref
=
Some
(
AutoPtr
(
r_borrow
,
mt_b
.mutbl
));
debug!
(
"coerce_borrowed_pointer: succeeded ty={:?} autoderefs={:?} autoref={:?}"
,
...
...
src/librustc_typeck/check/dropck.rs
浏览文件 @
35e16036
...
...
@@ -62,9 +62,9 @@ pub fn check_drop_impl(tcx: &TyCtxt, drop_impl_did: DefId) -> Result<(), ()> {
// Destructors only work on nominal types. This was
// already checked by coherence, so we can panic here.
let
span
=
tcx
.map
.def_id_span
(
drop_impl_did
,
codemap
::
DUMMY_SP
);
tcx
.sess
.span_bug
(
span
,
&
format!
(
"should have been rejected by coherence check: {}"
,
dtor_self_type
)
);
span_bug!
(
span
,
"should have been rejected by coherence check: {}"
,
dtor_self_type
);
}
}
}
...
...
@@ -276,8 +276,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>
typ
,
scope
);
let
parent_scope
=
rcx
.tcx
()
.region_maps
.opt_encl_scope
(
scope
)
.unwrap_or_else
(||
{
rcx
.tcx
()
.sess
.span_bug
(
span
,
&
format!
(
"no enclosing scope found for scope: {:?}"
,
scope
))
span_bug!
(
span
,
"no enclosing scope found for scope: {:?}"
,
scope
)
});
let
result
=
iterate_over_potentially_unsafe_regions_in_type
(
...
...
@@ -493,7 +492,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'b, 'tcx>(
}
// these are always dtorck
ty
::
TyTrait
(
..
)
|
ty
::
TyProjection
(
_
)
=>
unreachable
!
(),
ty
::
TyTrait
(
..
)
|
ty
::
TyProjection
(
_
)
=>
bug
!
(),
}
}
...
...
src/librustc_typeck/check/method/confirm.rs
浏览文件 @
35e16036
...
...
@@ -300,10 +300,10 @@ fn extract_trait_ref<R, F>(&mut self, self_ty: Ty<'tcx>, mut closure: F) -> R wh
match
result
{
Some
(
r
)
=>
r
,
None
=>
{
s
elf
.tcx
()
.sess
.span_bug
(
s
pan_bug!
(
self
.span
,
&
format!
(
"self-type `{}` for ObjectPick never dereferenced to an object"
,
self_ty
)
)
"self-type `{}` for ObjectPick never dereferenced to an object"
,
self_ty
)
}
}
}
...
...
@@ -372,10 +372,10 @@ fn unify_receivers(&mut self,
match
self
.fcx
.mk_subty
(
false
,
TypeOrigin
::
Misc
(
self
.span
),
self_ty
,
method_self_ty
)
{
Ok
(
_
)
=>
{}
Err
(
_
)
=>
{
s
elf
.tcx
()
.sess
.span_bug
(
s
pan_bug!
(
self
.span
,
&
format!
(
"{} was a subtype of {} but now is not?"
,
self_ty
,
method_self_ty
)
);
"{} was a subtype of {} but now is not?"
,
self_ty
,
method_self_ty
);
}
}
}
...
...
@@ -550,15 +550,15 @@ fn fixup_derefs_on_method_receiver_if_necessary(&self,
}))
}
Some
(
_
)
=>
{
s
elf
.tcx
()
.sess
.span_bug
(
s
pan_bug!
(
base_expr
.span
,
&
format!
(
"unexpected adjustment autoref {:?}"
,
adr
)
);
"unexpected adjustment autoref {:?}"
,
adr
);
}
},
None
=>
(
0
,
None
),
Some
(
_
)
=>
{
s
elf
.tcx
()
.sess
.span_bug
(
s
pan_bug!
(
base_expr
.span
,
"unexpected adjustment type"
);
}
...
...
@@ -646,12 +646,12 @@ fn upcast(&mut self,
// must be exactly one trait ref or we'd get an ambig error etc
if
upcast_trait_refs
.len
()
!=
1
{
s
elf
.tcx
()
.sess
.span_bug
(
s
pan_bug!
(
self
.span
,
&
format!
(
"cannot uniquely upcast `{:?}` to `{:?}`: `{:?}`"
,
source_trait_ref
,
target_trait_def_id
,
upcast_trait_refs
)
);
"cannot uniquely upcast `{:?}` to `{:?}`: `{:?}`"
,
source_trait_ref
,
target_trait_def_id
,
upcast_trait_refs
);
}
upcast_trait_refs
.into_iter
()
.next
()
.unwrap
()
...
...
src/librustc_typeck/check/method/mod.rs
浏览文件 @
35e16036
...
...
@@ -302,21 +302,19 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
}
_
=>
{
fcx
.tcx
()
.sess
.span_bug
(
span_bug!
(
span
,
&
format!
(
"trait method is &self but first arg is: {}"
,
transformed_self_ty
));
"trait method is &self but first arg is: {}"
,
transformed_self_ty
);
}
}
}
_
=>
{
fcx
.tcx
()
.sess
.span_bug
(
span_bug!
(
span
,
&
format!
(
"unexpected explicit self type in operator method: {:?}"
,
method_ty
.explicit_self
));
"unexpected explicit self type in operator method: {:?}"
,
method_ty
.explicit_self
);
}
}
}
...
...
src/librustc_typeck/check/method/probe.rs
浏览文件 @
35e16036
...
...
@@ -877,8 +877,8 @@ fn pick(mut self) -> PickResult<'tcx> {
match
tcx
.trait_id_of_impl
(
impl_id
)
{
Some
(
id
)
=>
id
,
None
=>
tcx
.sess
.span_bug
(
span
,
"found inherent method when looking at traits"
)
span_bug!
(
span
,
"found inherent method when looking at traits"
)
}
}
}
...
...
@@ -889,7 +889,7 @@ fn pick(mut self) -> PickResult<'tcx> {
}
Some
(
Err
(
MethodError
::
ClosureAmbiguity
(
..
)))
=>
{
// this error only occurs when assembling candidates
tcx
.sess
.span_bug
(
span
,
"encountered ClosureAmbiguity from pick_core"
);
span_bug!
(
span
,
"encountered ClosureAmbiguity from pick_core"
);
}
_
=>
vec!
[],
};
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
35e16036
...
...
@@ -463,8 +463,7 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
regionck
::
regionck_fn
(
&
fcx
,
fn_id
,
fn_span
,
decl
,
body
);
writeback
::
resolve_type_vars_in_fn
(
&
fcx
,
decl
,
body
);
}
_
=>
ccx
.tcx.sess
.impossible_case
(
body
.span
,
"check_bare_fn: function type expected"
)
_
=>
span_bug!
(
body
.span
,
"check_bare_fn: function type expected"
)
}
}
...
...
@@ -946,7 +945,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
hir
::
ImplItemKind
::
Const
(
..
)
=>
{
let
impl_const
=
match
ty_impl_item
{
ty
::
ConstTraitItem
(
ref
cti
)
=>
cti
,
_
=>
tcx
.sess
.span_bug
(
impl_item
.span
,
"non-const impl-item for const"
)
_
=>
span_bug!
(
impl_item
.span
,
"non-const impl-item for const"
)
};
// Find associated const definition.
...
...
@@ -969,7 +968,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
let
impl_method
=
match
ty_impl_item
{
ty
::
MethodTraitItem
(
ref
mti
)
=>
mti
,
_
=>
tcx
.sess
.span_bug
(
impl_item
.span
,
"non-method impl-item for method"
)
_
=>
span_bug!
(
impl_item
.span
,
"non-method impl-item for method"
)
};
if
let
&
ty
::
MethodTraitItem
(
ref
trait_method
)
=
ty_trait_item
{
...
...
@@ -990,7 +989,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
hir
::
ImplItemKind
::
Type
(
_
)
=>
{
let
impl_type
=
match
ty_impl_item
{
ty
::
TypeTraitItem
(
ref
tti
)
=>
tti
,
_
=>
tcx
.sess
.span_bug
(
impl_item
.span
,
"non-type impl-item for type"
)
_
=>
span_bug!
(
impl_item
.span
,
"non-type impl-item for type"
)
};
if
let
&
ty
::
TypeTraitItem
(
ref
at
)
=
ty_trait_item
{
...
...
@@ -1567,8 +1566,7 @@ pub fn expr_ty(&self, ex: &hir::Expr) -> Ty<'tcx> {
match
self
.inh.tables
.borrow
()
.node_types
.get
(
&
ex
.id
)
{
Some
(
&
t
)
=>
t
,
None
=>
{
self
.tcx
()
.sess
.bug
(
&
format!
(
"no type for expr in fcx {}"
,
self
.tag
()));
bug!
(
"no type for expr in fcx {}"
,
self
.tag
());
}
}
}
...
...
@@ -1593,10 +1591,9 @@ pub fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx> {
Some
(
&
t
)
=>
t
,
None
if
self
.err_count_since_creation
()
!=
0
=>
self
.tcx
()
.types.err
,
None
=>
{
self
.tcx
()
.sess
.bug
(
&
format!
(
"no type for node {}: {} in fcx {}"
,
id
,
self
.tcx
()
.map
.node_to_string
(
id
),
self
.tag
()));
bug!
(
"no type for node {}: {} in fcx {}"
,
id
,
self
.tcx
()
.map
.node_to_string
(
id
),
self
.tag
());
}
}
}
...
...
@@ -2386,8 +2383,7 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
fty
.sig
.0
.output
}
_
=>
{
fcx
.tcx
()
.sess
.span_bug
(
callee_expr
.span
,
"method without bare fn type"
);
span_bug!
(
callee_expr
.span
,
"method without bare fn type"
);
}
}
}
...
...
@@ -3139,7 +3135,7 @@ fn check_expr_struct_fields<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
let
tcx
=
fcx
.ccx.tcx
;
let
substs
=
match
adt_ty
.sty
{
ty
::
TyStruct
(
_
,
substs
)
|
ty
::
TyEnum
(
_
,
substs
)
=>
substs
,
_
=>
tcx
.sess
.span_bug
(
span
,
"non-ADT passed to check_expr_struct_fields"
)
_
=>
span_bug!
(
span
,
"non-ADT passed to check_expr_struct_fields"
)
};
let
mut
remaining_fields
=
FnvHashMap
();
...
...
@@ -3400,8 +3396,7 @@ fn check_expr_struct<'a, 'tcx>(fcx: &FnCtxt<'a,'tcx>,
depth
:
path
.segments
.len
()
}
}
else
{
tcx
.sess
.span_bug
(
expr
.span
,
&
format!
(
"unbound path {:?}"
,
expr
))
span_bug!
(
expr
.span
,
"unbound path {:?}"
,
expr
)
};
if
let
Some
((
opt_ty
,
segments
,
def
))
=
...
...
@@ -4224,7 +4219,7 @@ fn type_scheme_and_predicates_for_def<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
Def
::
Label
(
..
)
|
Def
::
SelfTy
(
..
)
|
Def
::
Err
=>
{
fcx
.ccx.tcx.sess
.span_bug
(
sp
,
&
format!
(
"expected value, found {:?}"
,
defn
)
);
span_bug!
(
sp
,
"expected value, found {:?}"
,
defn
);
}
}
}
...
...
@@ -4485,11 +4480,10 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
let
impl_ty
=
fcx
.instantiate_type_scheme
(
span
,
&
substs
,
&
impl_scheme
.ty
);
if
fcx
.mk_subty
(
false
,
TypeOrigin
::
Misc
(
span
),
self_ty
,
impl_ty
)
.is_err
()
{
fcx
.tcx
()
.sess
.span_bug
(
span
,
&
format!
(
span_bug!
(
span
,
"instantiate_path: (UFCS) {:?} was a subtype of {:?} but now is not?"
,
self_ty
,
impl_ty
)
)
;
impl_ty
);
}
}
...
...
src/librustc_typeck/check/op.rs
浏览文件 @
35e16036
...
...
@@ -270,8 +270,9 @@ fn name_and_trait_def_id(fcx: &FnCtxt,
hir
::
BiShr
=>
(
"shr_assign"
,
lang
.shr_assign_trait
()),
hir
::
BiLt
|
hir
::
BiLe
|
hir
::
BiGe
|
hir
::
BiGt
|
hir
::
BiEq
|
hir
::
BiNe
|
hir
::
BiAnd
|
hir
::
BiOr
=>
{
fcx
.tcx
()
.sess
.span_bug
(
op
.span
,
&
format!
(
"impossible assignment operation: {}="
,
hir_util
::
binop_to_string
(
op
.node
)))
span_bug!
(
op
.span
,
"impossible assignment operation: {}="
,
hir_util
::
binop_to_string
(
op
.node
))
}
}
}
else
{
...
...
@@ -293,7 +294,7 @@ fn name_and_trait_def_id(fcx: &FnCtxt,
hir
::
BiEq
=>
(
"eq"
,
lang
.eq_trait
()),
hir
::
BiNe
=>
(
"ne"
,
lang
.eq_trait
()),
hir
::
BiAnd
|
hir
::
BiOr
=>
{
fcx
.tcx
()
.sess
.span_bug
(
op
.span
,
"&& and || are not overloadable"
)
span_bug!
(
op
.span
,
"&& and || are not overloadable"
)
}
}
}
...
...
src/librustc_typeck/check/regionck.rs
浏览文件 @
35e16036
...
...
@@ -298,8 +298,7 @@ fn visit_fn_body(&mut self,
match
fn_sig_map
.get
(
&
id
)
{
Some
(
f
)
=>
f
.clone
(),
None
=>
{
self
.tcx
()
.sess
.bug
(
&
format!
(
"No fn-sig entry for id={}"
,
id
));
bug!
(
"No fn-sig entry for id={}"
,
id
);
}
}
};
...
...
@@ -446,8 +445,8 @@ fn resolve_regions_and_report_errors(&self) {
let
subject_node_id
=
match
self
.subject
{
Subject
(
s
)
=>
s
,
SubjectNode
::
None
=>
{
self
.tcx
()
.sess
.bug
(
"cannot resolve_regions_and_report_errors
\
without subject node"
);
bug!
(
"cannot resolve_regions_and_report_errors
\
without subject node"
);
}
};
...
...
@@ -886,9 +885,10 @@ fn constrain_callee(rcx: &mut Rcx,
// this should not happen, but it does if the program is
// erroneous
//
//
tcx.sess.span_bug
(
//
bug!
(
// callee_expr.span,
// format!("Calling non-function: {}", callee_ty));
// "Calling non-function: {}",
// callee_ty);
}
}
}
...
...
@@ -986,10 +986,10 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
let
(
m
,
r
)
=
match
self_ty
.sty
{
ty
::
TyRef
(
r
,
ref
m
)
=>
(
m
.mutbl
,
r
),
_
=>
{
rcx
.tcx
()
.sess
.span_bug
(
span_bug!
(
deref_expr
.span
,
&
format!
(
"bad overloaded deref type {:?}"
,
method
.ty
)
)
"bad overloaded deref type {:?}"
,
method
.ty
)
}
};
...
...
@@ -1014,7 +1014,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
return_type
,
r_deref_expr
);
return_type
}
ty
::
FnDiverging
=>
unreachable
!
()
ty
::
FnDiverging
=>
bug
!
()
}
}
None
=>
derefd_ty
...
...
@@ -1057,12 +1057,10 @@ fn check_safety_of_rvalue_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 't
}
ty
::
ReStatic
=>
{}
region
=>
{
rcx
.tcx
()
.sess
.span_bug
(
span
,
&
format!
(
"unexpected rvalue region in rvalue
\
destructor safety checking: `{:?}`"
,
region
));
span_bug!
(
span
,
"unexpected rvalue region in rvalue
\
destructor safety checking: `{:?}`"
,
region
);
}
}
}
...
...
@@ -1394,10 +1392,7 @@ fn link_reborrowed_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
infer
::
ReborrowUpvar
(
span
,
*
upvar_id
)
}
_
=>
{
rcx
.tcx
()
.sess
.span_bug
(
span
,
&
format!
(
"Illegal upvar id: {:?}"
,
upvar_id
));
span_bug!
(
span
,
"Illegal upvar id: {:?}"
,
upvar_id
);
}
}
}
...
...
src/librustc_typeck/check/upvar.rs
浏览文件 @
35e16036
...
...
@@ -209,10 +209,10 @@ fn analyze_closure(&mut self,
let
closure_substs
=
match
self
.fcx
.node_ty
(
id
)
.sty
{
ty
::
TyClosure
(
_
,
ref
substs
)
=>
substs
,
ref
t
=>
{
s
elf
.fcx
.tcx
()
.sess
.span_bug
(
s
pan_bug!
(
span
,
&
format!
(
"type of closure expr {:?} is not a closure {:?}"
,
id
,
t
)
);
"type of closure expr {:?} is not a closure {:?}"
,
id
,
t
);
}
};
...
...
src/librustc_typeck/check/wfcheck.rs
浏览文件 @
35e16036
...
...
@@ -257,7 +257,7 @@ fn check_item_fn(&mut self,
let
bare_fn_ty
=
match
item_ty
.sty
{
ty
::
TyFnDef
(
_
,
_
,
ref
bare_fn_ty
)
=>
bare_fn_ty
,
_
=>
{
this
.tcx
()
.sess
.span_bug
(
item
.span
,
"Fn item without fn type"
);
span_bug!
(
item
.span
,
"Fn item without fn type"
);
}
};
...
...
@@ -473,7 +473,7 @@ fn param_ty(&self,
let
name
=
match
space
{
TypeSpace
=>
ast_generics
.ty_params
[
index
]
.name
,
SelfSpace
=>
special_idents
::
type_self
.name
,
FnSpace
=>
self
.tcx
()
.sess
.bug
(
"Fn space occupied?"
),
FnSpace
=>
bug!
(
"Fn space occupied?"
),
};
ty
::
ParamTy
{
space
:
space
,
idx
:
index
as
u32
,
name
:
name
}
...
...
@@ -489,7 +489,7 @@ fn ty_param_span(&self,
match
space
{
TypeSpace
=>
ast_generics
.ty_params
[
index
]
.span
,
SelfSpace
=>
item
.span
,
FnSpace
=>
s
elf
.tcx
()
.sess
.span_bug
(
item
.span
,
"Fn space occupied?"
),
FnSpace
=>
s
pan_bug!
(
item
.span
,
"Fn space occupied?"
),
}
}
...
...
src/librustc_typeck/coherence/mod.rs
浏览文件 @
35e16036
...
...
@@ -77,10 +77,10 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
TyInfer
(
..
)
|
TyClosure
(
..
)
=>
{
// `ty` comes from a user declaration so we should only expect types
// that the user can type
inference_context
.tcx.sess
.span_bug
(
span_bug!
(
span
,
&
format!
(
"coherence encountered unexpected type searching for base type: {}"
,
ty
)
);
"coherence encountered unexpected type searching for base type: {}"
,
ty
);
}
}
}
...
...
@@ -219,9 +219,7 @@ fn create_impl_from_item(&self, item: &Item) -> Vec<ImplOrTraitItemId> {
})
.collect
()
}
_
=>
{
self
.crate_context.tcx.sess
.span_bug
(
item
.span
,
"can't convert a non-impl
\
to an impl"
);
span_bug!
(
item
.span
,
"can't convert a non-impl to an impl"
);
}
}
}
...
...
@@ -263,13 +261,12 @@ fn populate_destructors(&self) {
"the Drop trait may only be implemented on structures"
);
}
_
=>
{
tcx
.sess
.bug
(
"didn't find impl in ast
\
map"
);
bug!
(
"didn't find impl in ast map"
);
}
}
}
else
{
tcx
.sess
.bug
(
"found external impl of Drop trait on
\
s
omething other than a struct"
);
bug!
(
"found external impl of Drop trait on
\
:
omething other than a struct"
);
}
}
}
...
...
src/librustc_typeck/collect.rs
浏览文件 @
35e16036
...
...
@@ -274,7 +274,7 @@ fn get_trait_def(&self, trait_id: DefId)
if
let
Some
(
trait_id
)
=
tcx
.map
.as_local_node_id
(
trait_id
)
{
let
item
=
match
tcx
.map
.get
(
trait_id
)
{
hir_map
::
NodeItem
(
item
)
=>
item
,
_
=>
tcx
.sess
.bug
(
&
format!
(
"get_trait_def({:?}): not an item"
,
trait_id
)
)
_
=>
bug!
(
"get_trait_def({:?}): not an item"
,
trait_id
)
};
trait_def_of_item
(
self
,
&
item
)
...
...
@@ -1165,13 +1165,13 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt,
let
superpredicates
=
superpredicates
.unwrap_or_else
(||
{
let
item
=
match
ccx
.tcx.map
.get
(
trait_node_id
)
{
hir_map
::
NodeItem
(
item
)
=>
item
,
_
=>
ccx
.tcx.sess
.bug
(
&
format!
(
"trait_node_id {} is not an item"
,
trait_node_id
)
)
_
=>
bug!
(
"trait_node_id {} is not an item"
,
trait_node_id
)
};
let
(
generics
,
bounds
)
=
match
item
.node
{
hir
::
ItemTrait
(
_
,
ref
generics
,
ref
supertraits
,
_
)
=>
(
generics
,
supertraits
),
_
=>
tcx
.sess
.span_bug
(
item
.span
,
"ensure_super_predicates_step invoked on non-trait"
),
_
=>
span_bug!
(
item
.span
,
"ensure_super_predicates_step invoked on non-trait"
),
};
// In-scope when converting the superbounds for `Trait` are
...
...
@@ -1237,7 +1237,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
let
(
unsafety
,
generics
,
items
)
=
match
it
.node
{
hir
::
ItemTrait
(
unsafety
,
ref
generics
,
_
,
ref
items
)
=>
(
unsafety
,
generics
,
items
),
_
=>
tcx
.sess
.span_bug
(
it
.span
,
"trait_def_of_item invoked on non-trait"
),
_
=>
span_bug!
(
it
.span
,
"trait_def_of_item invoked on non-trait"
),
};
let
paren_sugar
=
tcx
.has_attr
(
def_id
,
"rustc_paren_sugar"
);
...
...
@@ -1317,12 +1317,12 @@ fn trait_defines_associated_type_named(ccx: &CrateCtxt,
{
let
item
=
match
ccx
.tcx.map
.get
(
trait_node_id
)
{
hir_map
::
NodeItem
(
item
)
=>
item
,
_
=>
ccx
.tcx.sess
.bug
(
&
format!
(
"trait_node_id {} is not an item"
,
trait_node_id
)
)
_
=>
bug!
(
"trait_node_id {} is not an item"
,
trait_node_id
)
};
let
trait_items
=
match
item
.node
{
hir
::
ItemTrait
(
_
,
_
,
_
,
ref
trait_items
)
=>
trait_items
,
_
=>
ccx
.tcx.sess
.bug
(
&
format!
(
"trait_node_id {} is not a trait"
,
trait_node_id
)
)
_
=>
bug!
(
"trait_node_id {} is not a trait"
,
trait_node_id
)
};
trait_items
.iter
()
.any
(|
trait_item
|
{
...
...
@@ -1342,9 +1342,10 @@ fn convert_trait_predicates<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, it: &hir::Item)
let
(
generics
,
items
)
=
match
it
.node
{
hir
::
ItemTrait
(
_
,
ref
generics
,
_
,
ref
items
)
=>
(
generics
,
items
),
ref
s
=>
{
tcx
.sess
.span_bug
(
span_bug!
(
it
.span
,
&
format!
(
"trait_def_of_item invoked on {:?}"
,
s
));
"trait_def_of_item invoked on {:?}"
,
s
);
}
};
...
...
@@ -1421,9 +1422,8 @@ fn type_scheme_of_def_id<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
type_scheme_of_foreign_item
(
ccx
,
&
foreign_item
,
abi
)
}
x
=>
{
ccx
.tcx.sess
.bug
(
&
format!
(
"unexpected sort of node
\
in get_item_type_scheme(): {:?}"
,
x
));
bug!
(
"unexpected sort of node in get_item_type_scheme(): {:?}"
,
x
);
}
}
}
else
{
...
...
@@ -1489,10 +1489,10 @@ fn compute_type_scheme_of_item<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
hir
::
ItemForeignMod
(
..
)
|
hir
::
ItemExternCrate
(
..
)
|
hir
::
ItemUse
(
..
)
=>
{
tcx
.sess
.span_bug
(
span_bug!
(
it
.span
,
&
format!
(
"compute_type_scheme_of_item: unexpected item type: {:?}"
,
it
.node
)
);
"compute_type_scheme_of_item: unexpected item type: {:?}"
,
it
.node
);
}
}
}
...
...
@@ -1528,10 +1528,10 @@ fn convert_typed_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
hir
::
ItemImpl
(
..
)
|
hir
::
ItemMod
(
..
)
|
hir
::
ItemForeignMod
(
..
)
=>
{
tcx
.sess
.span_bug
(
span_bug!
(
it
.span
,
&
format!
(
"compute_type_scheme_of_item: unexpected item type: {:?}"
,
it
.node
)
);
"compute_type_scheme_of_item: unexpected item type: {:?}"
,
it
.node
);
}
};
...
...
@@ -1836,9 +1836,9 @@ fn ty_generic_predicates<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>,
&
hir
::
WherePredicate
::
EqPredicate
(
ref
eq_pred
)
=>
{
// FIXME(#20041)
tcx
.sess
.span_bug
(
eq_pred
.span
,
"Equality constraints are not yet
\
implemented (#20041)"
)
span_bug!
(
eq_pred
.span
,
"Equality constraints are not yet
\
implemented (#20041)"
)
}
}
}
...
...
src/librustc_typeck/lib.rs
浏览文件 @
35e16036
...
...
@@ -88,7 +88,7 @@
extern
crate
arena
;
extern
crate
fmt_macros
;
extern
crate
rustc
;
#[macro_use]
extern
crate
rustc
;
extern
crate
rustc_platform_intrinsics
as
intrinsics
;
extern
crate
rustc_front
;
extern
crate
rustc_back
;
...
...
@@ -258,9 +258,9 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
});
}
_
=>
{
tcx
.sess
.span_bug
(
main_span
,
&
format!
(
"main has a non-function type: found `{}`"
,
main_t
)
);
span_bug!
(
main_span
,
"main has a non-function type: found `{}`"
,
main_t
);
}
}
}
...
...
@@ -310,9 +310,9 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
}
_
=>
{
tcx
.sess
.span_bug
(
start_span
,
&
format!
(
"start has a non-function type: found `{}`"
,
start_t
)
);
span_bug!
(
start_span
,
"start has a non-function type: found `{}`"
,
start_t
);
}
}
}
...
...
@@ -325,7 +325,7 @@ fn check_for_entry_fn(ccx: &CrateCtxt) {
Some
(
config
::
EntryMain
)
=>
check_main_fn_ty
(
ccx
,
id
,
sp
),
Some
(
config
::
EntryStart
)
=>
check_start_fn_ty
(
ccx
,
id
,
sp
),
Some
(
config
::
EntryNone
)
=>
{}
None
=>
tcx
.sess
.bug
(
"entry function without a type"
)
None
=>
bug!
(
"entry function without a type"
)
},
None
=>
{}
}
...
...
src/librustc_typeck/variance/constraints.rs
浏览文件 @
35e16036
...
...
@@ -135,9 +135,8 @@ fn inferred_index(&self, param_id: ast::NodeId) -> InferredIndex {
match
self
.terms_cx.inferred_map
.get
(
&
param_id
)
{
Some
(
&
index
)
=>
index
,
None
=>
{
self
.tcx
()
.sess
.bug
(
&
format!
(
"no inferred index entry for {}"
,
self
.tcx
()
.map
.node_to_string
(
param_id
)));
bug!
(
"no inferred index entry for {}"
,
self
.tcx
()
.map
.node_to_string
(
param_id
));
}
}
}
...
...
@@ -148,7 +147,7 @@ fn find_binding_for_lifetime(&self, param_id: ast::NodeId) -> ast::NodeId {
match
tcx
.named_region_map
.get
(
&
param_id
)
{
Some
(
&
rl
::
DefEarlyBoundRegion
(
_
,
_
,
lifetime_decl_id
))
=>
lifetime_decl_id
,
Some
(
_
)
=>
panic
!
(
"should not encounter non early-bound cases"
),
Some
(
_
)
=>
bug
!
(
"should not encounter non early-bound cases"
),
// The lookup should only fail when `param_id` is
// itself a lifetime binding: use it as the decl_id.
...
...
@@ -173,13 +172,13 @@ fn is_to_be_inferred(&self, param_id: ast::NodeId) -> bool {
assert
!
(
is_lifetime
(
&
tcx
.map
,
param_id
));
let
parent_id
=
tcx
.map
.get_parent
(
decl_id
);
let
parent
=
tcx
.map
.find
(
parent_id
)
.unwrap_or_else
(
||
panic
!
(
"tcx.map missing entry for id: {}"
,
parent_id
));
||
bug
!
(
"tcx.map missing entry for id: {}"
,
parent_id
));
let
is_inferred
;
macro_rules!
cannot_happen
{
()
=>
{
{
panic
!
(
"invalid parent: {} for {}"
,
tcx
.map
.node_to_string
(
parent_id
),
tcx
.map
.node_to_string
(
param_id
));
bug
!
(
"invalid parent: {} for {}"
,
tcx
.map
.node_to_string
(
parent_id
),
tcx
.map
.node_to_string
(
param_id
));
}
}
}
match
parent
{
...
...
@@ -328,7 +327,7 @@ fn add_constraints_from_ty(&mut self,
}
ty
::
TyClosure
(
..
)
=>
{
self
.tcx
()
.sess
.bug
(
"Unexpected closure type in variance computation"
);
bug!
(
"Unexpected closure type in variance computation"
);
}
ty
::
TyRef
(
region
,
ref
mt
)
=>
{
...
...
@@ -440,9 +439,8 @@ fn add_constraints_from_ty(&mut self,
}
ty
::
TyInfer
(
..
)
=>
{
self
.tcx
()
.sess
.bug
(
&
format!
(
"unexpected type encountered in
\
variance inference: {}"
,
ty
));
bug!
(
"unexpected type encountered in
\
variance inference: {}"
,
ty
);
}
}
}
...
...
@@ -525,11 +523,9 @@ fn add_constraints_from_region(&mut self,
ty
::
ReSkolemized
(
..
)
|
ty
::
ReEmpty
=>
{
// We don't expect to see anything but 'static or bound
// regions when visiting member types or method types.
self
.tcx
()
.sess
.bug
(
&
format!
(
"unexpected region encountered in variance
\
inference: {:?}"
,
region
));
bug!
(
"unexpected region encountered in variance
\
inference: {:?}"
,
region
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录