Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f68029ec
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
f68029ec
编写于
1月 18, 2015
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make fatal errors work with codes, add to typeck
上级
0c5225c5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
50 addition
and
26 deletion
+50
-26
src/librustc/session/mod.rs
src/librustc/session/mod.rs
+3
-0
src/librustc_typeck/astconv.rs
src/librustc_typeck/astconv.rs
+21
-23
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+1
-1
src/librustc_typeck/diagnostics.rs
src/librustc_typeck/diagnostics.rs
+12
-1
src/librustc_typeck/lib.rs
src/librustc_typeck/lib.rs
+1
-1
src/libsyntax/diagnostic.rs
src/libsyntax/diagnostic.rs
+4
-0
src/libsyntax/diagnostics/macros.rs
src/libsyntax/diagnostics/macros.rs
+8
-0
未找到文件。
src/librustc/session/mod.rs
浏览文件 @
f68029ec
...
@@ -69,6 +69,9 @@ impl Session {
...
@@ -69,6 +69,9 @@ impl Session {
pub
fn
span_fatal
(
&
self
,
sp
:
Span
,
msg
:
&
str
)
->
!
{
pub
fn
span_fatal
(
&
self
,
sp
:
Span
,
msg
:
&
str
)
->
!
{
self
.diagnostic
()
.span_fatal
(
sp
,
msg
)
self
.diagnostic
()
.span_fatal
(
sp
,
msg
)
}
}
pub
fn
span_fatal_with_code
(
&
self
,
sp
:
Span
,
msg
:
&
str
,
code
:
&
str
)
->
!
{
self
.diagnostic
()
.span_fatal_with_code
(
sp
,
msg
,
code
)
}
pub
fn
fatal
(
&
self
,
msg
:
&
str
)
->
!
{
pub
fn
fatal
(
&
self
,
msg
:
&
str
)
->
!
{
self
.diagnostic
()
.handler
()
.fatal
(
msg
)
self
.diagnostic
()
.handler
()
.fatal
(
msg
)
}
}
...
...
src/librustc_typeck/astconv.rs
浏览文件 @
f68029ec
...
@@ -339,22 +339,22 @@ fn create_substs_for_ast_path<'tcx>(
...
@@ -339,22 +339,22 @@ fn create_substs_for_ast_path<'tcx>(
}
else
{
}
else
{
"expected"
"expected"
};
};
this
.tcx
()
.sess
.span_fatal
(
span
,
span_fatal!
(
this
.tcx
()
.sess
,
span
,
E0243
,
&
format!
(
"wrong number of type arguments: {} {}, found {}"
,
"wrong number of type arguments: {} {}, found {}"
,
expected
,
expected
,
required_ty_param_count
,
required_ty_param_count
,
supplied_ty_param_count
)
[])
;
supplied_ty_param_count
);
}
else
if
supplied_ty_param_count
>
formal_ty_param_count
{
}
else
if
supplied_ty_param_count
>
formal_ty_param_count
{
let
expected
=
if
required_ty_param_count
<
formal_ty_param_count
{
let
expected
=
if
required_ty_param_count
<
formal_ty_param_count
{
"expected at most"
"expected at most"
}
else
{
}
else
{
"expected"
"expected"
};
};
this
.tcx
()
.sess
.span_fatal
(
span
,
span_fatal!
(
this
.tcx
()
.sess
,
span
,
E0244
,
&
format!
(
"wrong number of type arguments: {} {}, found {}"
,
"wrong number of type arguments: {} {}, found {}"
,
expected
,
expected
,
formal_ty_param_count
,
formal_ty_param_count
,
supplied_ty_param_count
)
[])
;
supplied_ty_param_count
);
}
}
let
mut
substs
=
Substs
::
new_type
(
types
,
regions
);
let
mut
substs
=
Substs
::
new_type
(
types
,
regions
);
...
@@ -557,10 +557,9 @@ pub fn instantiate_trait_ref<'tcx>(
...
@@ -557,10 +557,9 @@ pub fn instantiate_trait_ref<'tcx>(
trait_ref
trait_ref
}
}
_
=>
{
_
=>
{
this
.tcx
()
.sess
.span_fatal
(
span_fatal!
(
this
.tcx
()
.sess
,
ast_trait_ref
.path.span
,
E0245
,
ast_trait_ref
.path.span
,
"`{}` is not a trait"
,
&
format!
(
"`{}` is not a trait"
,
ast_trait_ref
.path
.user_string
(
this
.tcx
()));
ast_trait_ref
.path
.user_string
(
this
.tcx
()))[]);
}
}
}
}
}
}
...
@@ -1036,7 +1035,7 @@ pub fn ast_ty_to_ty<'tcx>(
...
@@ -1036,7 +1035,7 @@ pub fn ast_ty_to_ty<'tcx>(
match
ast_ty_to_ty_cache
.get
(
&
ast_ty
.id
)
{
match
ast_ty_to_ty_cache
.get
(
&
ast_ty
.id
)
{
Some
(
&
ty
::
atttce_resolved
(
ty
))
=>
return
ty
,
Some
(
&
ty
::
atttce_resolved
(
ty
))
=>
return
ty
,
Some
(
&
ty
::
atttce_unresolved
)
=>
{
Some
(
&
ty
::
atttce_unresolved
)
=>
{
tcx
.sess
.span_fatal
(
ast_ty
.span
,
span_fatal!
(
tcx
.sess
,
ast_ty
.span
,
E0246
,
"illegal recursive type; insert an enum
\
"illegal recursive type; insert an enum
\
or struct in the cycle, if this is
\
or struct in the cycle, if this is
\
desired"
);
desired"
);
...
@@ -1136,9 +1135,9 @@ pub fn ast_ty_to_ty<'tcx>(
...
@@ -1136,9 +1135,9 @@ pub fn ast_ty_to_ty<'tcx>(
ty
::
mk_self_type
(
tcx
)
ty
::
mk_self_type
(
tcx
)
}
}
def
::
DefMod
(
id
)
=>
{
def
::
DefMod
(
id
)
=>
{
tcx
.sess
.span_fatal
(
ast_ty
.span
,
span_fatal!
(
tcx
.sess
,
ast_ty
.span
,
E0247
,
&
format!
(
"found module name used as a type: {}"
,
"found module name used as a type: {}"
,
tcx
.map
.node_to_string
(
id
.node
))
[])
;
tcx
.map
.node_to_string
(
id
.node
));
}
}
def
::
DefPrimTy
(
_
)
=>
{
def
::
DefPrimTy
(
_
)
=>
{
panic!
(
"DefPrimTy arm missed in previous ast_ty_to_prim_ty call"
);
panic!
(
"DefPrimTy arm missed in previous ast_ty_to_prim_ty call"
);
...
@@ -1164,10 +1163,10 @@ pub fn ast_ty_to_ty<'tcx>(
...
@@ -1164,10 +1163,10 @@ pub fn ast_ty_to_ty<'tcx>(
associated_path_def_to_ty
(
this
,
ast_ty
,
provenance
,
assoc_ident
.name
)
associated_path_def_to_ty
(
this
,
ast_ty
,
provenance
,
assoc_ident
.name
)
}
}
_
=>
{
_
=>
{
tcx
.sess
.span_fatal
(
ast_ty
.span
,
span_fatal!
(
tcx
.sess
,
ast_ty
.span
,
E0248
,
&
format!
(
"found value name used
\
"found value name used
\
as a type: {:?}"
,
as a type: {:?}"
,
a_def
)
[])
;
a_def
);
}
}
}
}
}
}
...
@@ -1185,17 +1184,16 @@ pub fn ast_ty_to_ty<'tcx>(
...
@@ -1185,17 +1184,16 @@ pub fn ast_ty_to_ty<'tcx>(
ty
::
mk_vec
(
tcx
,
ast_ty_to_ty
(
this
,
rscope
,
&**
ty
),
ty
::
mk_vec
(
tcx
,
ast_ty_to_ty
(
this
,
rscope
,
&**
ty
),
Some
(
i
as
uint
)),
Some
(
i
as
uint
)),
_
=>
{
_
=>
{
tcx
.sess
.span_fatal
(
span_fatal!
(
tcx
.sess
,
ast_ty
.span
,
E0249
,
ast_ty
.span
,
"expected constant expr for array length"
);
"expected constant expr for array length"
);
}
}
}
}
}
}
Err
(
ref
r
)
=>
{
Err
(
ref
r
)
=>
{
tcx
.sess
.span_fatal
(
span_fatal!
(
tcx
.sess
,
ast_ty
.span
,
E0250
,
ast_ty
.span
,
"expected constant expr for array
\
&
format!
(
"expected constant expr for array
\
length: {}"
,
length: {}"
,
*
r
)
[])
;
*
r
);
}
}
}
}
}
}
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
f68029ec
...
@@ -5224,7 +5224,7 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
...
@@ -5224,7 +5224,7 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
"get_tydesc"
=>
{
"get_tydesc"
=>
{
let
tydesc_ty
=
match
ty
::
get_tydesc_ty
(
ccx
.tcx
)
{
let
tydesc_ty
=
match
ty
::
get_tydesc_ty
(
ccx
.tcx
)
{
Ok
(
t
)
=>
t
,
Ok
(
t
)
=>
t
,
Err
(
s
)
=>
{
tcx
.sess
.span_fatal
(
it
.span
,
&
s
[]);
}
Err
(
s
)
=>
{
span_fatal!
(
tcx
.sess
,
it
.span
,
E0240
,
"{}"
,
&
s
[]);
}
};
};
let
td_ptr
=
ty
::
mk_ptr
(
ccx
.tcx
,
ty
::
mt
{
let
td_ptr
=
ty
::
mk_ptr
(
ccx
.tcx
,
ty
::
mt
{
ty
:
tydesc_ty
,
ty
:
tydesc_ty
,
...
...
src/librustc_typeck/diagnostics.rs
浏览文件 @
f68029ec
...
@@ -160,7 +160,18 @@
...
@@ -160,7 +160,18 @@
E0236
,
// no lang item for range syntax
E0236
,
// no lang item for range syntax
E0237
,
// no lang item for range syntax
E0237
,
// no lang item for range syntax
E0238
,
// parenthesized parameters may only be used with a trait
E0238
,
// parenthesized parameters may only be used with a trait
E0239
// `next` method of `Iterator` trait has unexpected type
E0239
,
// `next` method of `Iterator` trait has unexpected type
E0240
,
E0241
,
E0242
,
// internal error looking up a definition
E0243
,
// wrong number of type arguments
E0244
,
// wrong number of type arguments
E0245
,
// not a trait
E0246
,
// illegal recursive type
E0247
,
// found module name used as a type
E0248
,
// found value name used as a type
E0249
,
// expected constant expr for array length
E0250
// expected constant expr for array length
}
}
__
build_diagnostic_array!
{
DIAGNOSTICS
}
__
build_diagnostic_array!
{
DIAGNOSTICS
}
...
...
src/librustc_typeck/lib.rs
浏览文件 @
f68029ec
...
@@ -162,7 +162,7 @@ fn lookup_def_tcx(tcx:&ty::ctxt, sp: Span, id: ast::NodeId) -> def::Def {
...
@@ -162,7 +162,7 @@ fn lookup_def_tcx(tcx:&ty::ctxt, sp: Span, id: ast::NodeId) -> def::Def {
match
tcx
.def_map
.borrow
()
.get
(
&
id
)
{
match
tcx
.def_map
.borrow
()
.get
(
&
id
)
{
Some
(
x
)
=>
x
.clone
(),
Some
(
x
)
=>
x
.clone
(),
_
=>
{
_
=>
{
tcx
.sess
.span_fatal
(
sp
,
"internal error looking up a definition"
)
span_fatal!
(
tcx
.sess
,
sp
,
E0242
,
"internal error looking up a definition"
)
}
}
}
}
}
}
...
...
src/libsyntax/diagnostic.rs
浏览文件 @
f68029ec
...
@@ -92,6 +92,10 @@ pub fn span_fatal(&self, sp: Span, msg: &str) -> ! {
...
@@ -92,6 +92,10 @@ pub fn span_fatal(&self, sp: Span, msg: &str) -> ! {
self
.handler
.emit
(
Some
((
&
self
.cm
,
sp
)),
msg
,
Fatal
);
self
.handler
.emit
(
Some
((
&
self
.cm
,
sp
)),
msg
,
Fatal
);
panic!
(
FatalError
);
panic!
(
FatalError
);
}
}
pub
fn
span_fatal_with_code
(
&
self
,
sp
:
Span
,
msg
:
&
str
,
code
:
&
str
)
->
!
{
self
.handler
.emit_with_code
(
Some
((
&
self
.cm
,
sp
)),
msg
,
code
,
Fatal
);
panic!
(
FatalError
);
}
pub
fn
span_err
(
&
self
,
sp
:
Span
,
msg
:
&
str
)
{
pub
fn
span_err
(
&
self
,
sp
:
Span
,
msg
:
&
str
)
{
self
.handler
.emit
(
Some
((
&
self
.cm
,
sp
)),
msg
,
Error
);
self
.handler
.emit
(
Some
((
&
self
.cm
,
sp
)),
msg
,
Error
);
self
.handler
.bump_err_count
();
self
.handler
.bump_err_count
();
...
...
src/libsyntax/diagnostics/macros.rs
浏览文件 @
f68029ec
...
@@ -14,6 +14,14 @@
...
@@ -14,6 +14,14 @@
(
$code:tt
)
=>
(
__
register_diagnostic!
{
$code
})
(
$code:tt
)
=>
(
__
register_diagnostic!
{
$code
})
}
}
#[macro_export]
macro_rules!
span_fatal
{
(
$session:expr
,
$span:expr
,
$code:ident
,
$
(
$message:tt
)
*
)
=>
({
__
diagnostic_used!
(
$code
);
$session
.span_fatal_with_code
(
$span
,
format!
(
$
(
$message
)
*
)
.as_slice
(),
stringify!
(
$code
))
})
}
#[macro_export]
#[macro_export]
macro_rules!
span_err
{
macro_rules!
span_err
{
(
$session:expr
,
$span:expr
,
$code:ident
,
$
(
$message:tt
)
*
)
=>
({
(
$session:expr
,
$span:expr
,
$code:ident
,
$
(
$message:tt
)
*
)
=>
({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录