Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e6f6da11
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,发现更多精彩内容 >>
提交
e6f6da11
编写于
9月 14, 2015
作者:
G
Guillaume Gomez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
End of adding error codes in librustc
上级
7358a5e8
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
92 addition
and
20 deletion
+92
-20
src/librustc/diagnostics.rs
src/librustc/diagnostics.rs
+69
-0
src/librustc/middle/check_const.rs
src/librustc/middle/check_const.rs
+9
-9
src/librustc/middle/infer/error_reporting.rs
src/librustc/middle/infer/error_reporting.rs
+4
-5
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/resolve_lifetime.rs
+4
-4
src/librustc/plugin/load.rs
src/librustc/plugin/load.rs
+6
-2
未找到文件。
src/librustc/diagnostics.rs
浏览文件 @
e6f6da11
...
...
@@ -1933,6 +1933,71 @@ fn foo<'a>(arg: &Box<SomeTrait+'a>) { ... }
```
"##
,
E0493
:
r##"
A type with a destructor was assigned to an invalid type of variable. Erroneous
code example:
```
struct Foo {
a: u32
}
impl Drop for Foo {
fn drop(&mut self) {}
}
const F : Foo = Foo { a : 0 };
// error: constants are not allowed to have destructors
static S : Foo = Foo { a : 0 };
// error: statics are not allowed to have destructors
```
To solve this issue, please use a type which does allow the usage of type with
destructors.
"##
,
E0494
:
r##"
A reference of an interior static was assigned to another const/static.
Erroneous code example:
```
struct Foo {
a: u32
}
static S : Foo = Foo { a : 0 };
static A : &'static u32 = &S.a;
// error: cannot refer to the interior of another static, use a
// constant instead
```
The "base" variable has to be a const if you want another static/const variable
to refer to one of its fields. Example:
```
struct Foo {
a: u32
}
const S : Foo = Foo { a : 0 };
static A : &'static u32 = &S.a; // ok!
```
"##
,
E0497
:
r##"
A stability attribute was used outside of the standard library. Erroneous code
example:
```
#[stable] // error: stability attributes may not be used outside of the
// standard library
fn foo() {}
```
It is not possible to use stability attributes outside of the standard library.
Also, for now, it is not possible to write deprecation messages either.
"##
,
}
...
...
@@ -1996,4 +2061,8 @@ fn foo<'a>(arg: &Box<SomeTrait+'a>) { ... }
E0489
,
// type/lifetime parameter not in scope here
E0490
,
// a value of type `..` is borrowed for too long
E0491
,
// in type `..`, reference has a longer lifetime than the data it...
E0492
,
// cannot borrow a constant which contains interior mutability
E0495
,
// cannot infer an appropriate lifetime due to conflicting requirements
E0496
,
// .. name `..` shadows a .. name that is already in scope
E0498
,
// malformed plugin attribute
}
src/librustc/middle/check_const.rs
浏览文件 @
e6f6da11
...
...
@@ -499,7 +499,7 @@ fn visit_expr(&mut self, ex: &hir::Expr) {
if
self
.qualif
.intersects
(
ConstQualif
::
MUTABLE_MEM
)
&&
tc
.interior_unsafe
()
{
outer
=
outer
|
ConstQualif
::
NOT_CONST
;
if
self
.mode
!=
Mode
::
Var
{
s
elf
.tcx.sess
.span_err
(
ex
.span
,
s
pan_err!
(
self
.tcx.sess
,
ex
.span
,
E0492
,
"cannot borrow a constant which contains
\
interior mutability, create a static instead"
);
}
...
...
@@ -548,9 +548,9 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
ty
::
TyEnum
(
def
,
_
)
if
def
.has_dtor
()
=>
{
v
.add_qualif
(
ConstQualif
::
NEEDS_DROP
);
if
v
.mode
!=
Mode
::
Var
{
v
.tcx.sess
.span_err
(
e
.span
,
&
format!
(
"{}s are not allowed to have destructors"
,
v
.msg
()
));
span_err!
(
v
.tcx.sess
,
e
.span
,
E0493
,
"{}s are not allowed to have destructors"
,
v
.msg
(
));
}
}
_
=>
{}
...
...
@@ -904,7 +904,7 @@ fn borrow(&mut self,
// Borrowed statics can specifically *only* have their address taken,
// not any number of other borrows such as borrowing fields, reading
// elements of an array, etc.
s
elf
.tcx.sess
.span_err
(
borrow_span
,
s
pan_err!
(
self
.tcx.sess
,
borrow_span
,
E0494
,
"cannot refer to the interior of another
\
static, use a constant instead"
);
}
...
...
src/librustc/middle/infer/error_reporting.rs
浏览文件 @
e6f6da11
...
...
@@ -1626,11 +1626,10 @@ fn report_inference_failure(&self,
}
};
self
.tcx.sess
.span_err
(
var_origin
.span
(),
&
format!
(
"cannot infer an appropriate lifetime{}
\
span_err!
(
self
.tcx.sess
,
var_origin
.span
(),
E0495
,
"cannot infer an appropriate lifetime{}
\
due to conflicting requirements"
,
var_description
)
);
var_description
);
}
fn
note_region_origin
(
&
self
,
origin
:
&
SubregionOrigin
<
'tcx
>
)
{
...
...
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
e6f6da11
...
...
@@ -357,10 +357,10 @@ fn signal_shadowing_problem(
sess
:
&
Session
,
name
:
ast
::
Name
,
orig
:
Original
,
shadower
:
Shadower
)
{
if
let
(
ShadowKind
::
Lifetime
,
ShadowKind
::
Lifetime
)
=
(
orig
.kind
,
shadower
.kind
)
{
// lifetime/lifetime shadowing is an error
s
ess
.span_err
(
shadower
.span
,
&
format!
(
"{} name `{}` shadows a
\
s
pan_err!
(
sess
,
shadower
.span
,
E0496
,
"{} name `{}` shadows a
\
{} name that is already in scope"
,
shadower
.kind
.desc
(),
name
,
orig
.kind
.desc
()
));
shadower
.kind
.desc
(),
name
,
orig
.kind
.desc
(
));
}
else
{
// shadowing involving a label is only a warning, due to issues with
// labels and lifetimes not being macro-hygienic.
...
...
src/librustc/plugin/load.rs
浏览文件 @
e6f6da11
...
...
@@ -39,6 +39,10 @@ struct PluginLoader<'a> {
plugins
:
Vec
<
PluginRegistrar
>
,
}
fn
call_malformed_plugin_attribute
(
a
:
&
Session
,
b
:
Span
)
{
span_err!
(
a
,
b
,
E0498
,
"malformed plugin attribute"
);
}
/// Read plugin metadata and dynamically load registrar functions.
pub
fn
load_plugins
(
sess
:
&
Session
,
krate
:
&
ast
::
Crate
,
addl_plugins
:
Option
<
Vec
<
String
>>
)
->
Vec
<
PluginRegistrar
>
{
...
...
@@ -52,14 +56,14 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate,
let
plugins
=
match
attr
.meta_item_list
()
{
Some
(
xs
)
=>
xs
,
None
=>
{
sess
.span_err
(
attr
.span
,
"malformed plugin attribute"
);
call_malformed_plugin_attribute
(
sess
,
attr
.span
);
continue
;
}
};
for
plugin
in
plugins
{
if
plugin
.value_str
()
.is_some
()
{
sess
.span_err
(
attr
.span
,
"malformed plugin attribute"
);
call_malformed_plugin_attribute
(
sess
,
attr
.span
);
continue
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录