Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8dfb8906
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,发现更多精彩内容 >>
提交
8dfb8906
编写于
9月 16, 2015
作者:
B
bors
浏览文件
操作
浏览文件
下载
差异文件
Auto merge of #28353 - GuillaumeGomez:error_codes, r=Manishearth
r? @Manishearth This is a work in progress.
上级
1fe126af
e6f6da11
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
295 addition
and
148 deletion
+295
-148
src/librustc/diagnostics.rs
src/librustc/diagnostics.rs
+153
-2
src/librustc/lint/context.rs
src/librustc/lint/context.rs
+6
-5
src/librustc/metadata/creader.rs
src/librustc/metadata/creader.rs
+15
-11
src/librustc/metadata/loader.rs
src/librustc/metadata/loader.rs
+25
-22
src/librustc/metadata/macro_import.rs
src/librustc/metadata/macro_import.rs
+13
-7
src/librustc/middle/check_const.rs
src/librustc/middle/check_const.rs
+9
-9
src/librustc/middle/check_match.rs
src/librustc/middle/check_match.rs
+3
-3
src/librustc/middle/check_no_asm.rs
src/librustc/middle/check_no_asm.rs
+2
-2
src/librustc/middle/infer/error_reporting.rs
src/librustc/middle/infer/error_reporting.rs
+59
-81
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
浏览文件 @
8dfb8906
...
...
@@ -1886,7 +1886,117 @@ fn foo<'a>(arg: &Box<SomeTrait+'a>) { ... }
contain references (with a maximum lifetime of `'a`).
[1]: https://github.com/rust-lang/rfcs/pull/1156
"##
"##
,
E0454
:
r##"
A link name was given with an empty name. Erroneous code example:
```
#[link(name = "")] extern {} // error: #[link(name = "")] given with empty name
```
The rust compiler cannot link to an external library if you don't give it its
name. Example:
```
#[link(name = "some_lib")] extern {} // ok!
```
"##
,
E0458
:
r##"
An unknown "kind" was specified for a link attribute. Erroneous code example:
```
#[link(kind = "wonderful_unicorn")] extern {}
// error: unknown kind: `wonderful_unicorn`
```
Please specify a valid "kind" value, from one of the following:
* static
* dylib
* framework
"##
,
E0459
:
r##"
A link was used without a name parameter. Erroneous code example:
```
#[link(kind = "dylib")] extern {}
// error: #[link(...)] specified without `name = "foo"`
```
Please add the name parameter to allow the rust compiler to find the library
you want. Example:
```
#[link(kind = "dylib", name = "some_lib")] extern {} // ok!
```
"##
,
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.
"##
,
}
...
...
@@ -1914,5 +2024,46 @@ fn foo<'a>(arg: &Box<SomeTrait+'a>) { ... }
E0314
,
// closure outlives stack frame
E0315
,
// cannot invoke closure outside of its lifetime
E0316
,
// nested quantification of lifetimes
E0400
// overloaded derefs are not allowed in constants
E0400
,
// overloaded derefs are not allowed in constants
E0452
,
// malformed lint attribute
E0453
,
// overruled by outer forbid
E0455
,
// native frameworks are only available on OSX targets
E0456
,
// plugin `..` is not available for triple `..`
E0457
,
// plugin `..` only found in rlib format, but must be available...
E0460
,
// found possibly newer version of crate `..`
E0461
,
// couldn't find crate `..` with expected target triple ..
E0462
,
// found staticlib `..` instead of rlib or dylib
E0463
,
// can't find crate for `..`
E0464
,
// multiple matching crates for `..`
E0465
,
// multiple .. candidates for `..` found
E0466
,
// bad macro import
E0467
,
// bad macro reexport
E0468
,
// an `extern crate` loading macros must be at the crate root
E0469
,
// imported macro not found
E0470
,
// reexported macro not found
E0471
,
// constant evaluation error: ..
E0472
,
// asm! is unsupported on this target
E0473
,
// dereference of reference outside its lifetime
E0474
,
// captured variable `..` does not outlive the enclosing closure
E0475
,
// index of slice outside its lifetime
E0476
,
// lifetime of the source pointer does not outlive lifetime bound...
E0477
,
// the type `..` does not fulfill the required lifetime...
E0478
,
// lifetime bound not satisfied
E0479
,
// the type `..` (provided as the value of a type parameter) is...
E0480
,
// lifetime of method receiver does not outlive the method call
E0481
,
// lifetime of function argument does not outlive the function call
E0482
,
// lifetime of return value does not outlive the function call
E0483
,
// lifetime of operand does not outlive the operation
E0484
,
// reference is not valid at the time of borrow
E0485
,
// automatically reference is not valid at the time of borrow
E0486
,
// type of expression contains references that are not valid during...
E0487
,
// unsafe use of destructor: destructor might be called while...
E0488
,
// lifetime of variable does not enclose its declaration
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/lint/context.rs
浏览文件 @
8dfb8906
...
...
@@ -433,7 +433,8 @@ fn with_lint_attrs<F>(&mut self,
for
result
in
gather_attrs
(
attrs
)
{
let
v
=
match
result
{
Err
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"malformed lint attribute"
);
span_err!
(
self
.tcx.sess
,
span
,
E0452
,
"malformed lint attribute"
);
continue
;
}
Ok
((
lint_name
,
level
,
span
))
=>
{
...
...
@@ -462,10 +463,10 @@ fn with_lint_attrs<F>(&mut self,
let
now
=
self
.lints
.get_level_source
(
lint_id
)
.0
;
if
now
==
Forbid
&&
level
!=
Forbid
{
let
lint_name
=
lint_id
.as_str
();
s
elf
.tcx.sess
.span_err
(
span
,
&
format!
(
"{}({}) overruled by outer forbid({})"
,
level
.as_str
(),
lint_name
,
lint_name
)
);
s
pan_err!
(
self
.tcx.sess
,
span
,
E0453
,
"{}({}) overruled by outer forbid({})"
,
level
.as_str
(),
lint_name
,
lint_name
);
}
else
if
now
!=
level
{
let
src
=
self
.lints
.get_level_source
(
lint_id
)
.1
;
self
.level_stack
.push
((
lint_id
,
(
now
,
src
)));
...
...
src/librustc/metadata/creader.rs
浏览文件 @
8dfb8906
...
...
@@ -119,8 +119,8 @@ fn register_native_lib(sess: &Session,
if
name
.is_empty
()
{
match
span
{
Some
(
span
)
=>
{
s
ess
.span_err
(
span
,
"#[link(name =
\"\"
)] given with
\
empty name"
);
s
pan_err!
(
sess
,
span
,
E0454
,
"#[link(name =
\"\"
)] given with
empty name"
);
}
None
=>
{
sess
.err
(
"empty library name given via `-l`"
);
...
...
@@ -132,7 +132,10 @@ fn register_native_lib(sess: &Session,
if
kind
==
cstore
::
NativeFramework
&&
!
is_osx
{
let
msg
=
"native frameworks are only available on OSX targets"
;
match
span
{
Some
(
span
)
=>
sess
.span_err
(
span
,
msg
),
Some
(
span
)
=>
{
span_err!
(
sess
,
span
,
E0455
,
"{}"
,
msg
)
}
None
=>
sess
.err
(
msg
),
}
}
...
...
@@ -514,7 +517,7 @@ pub fn find_plugin_registrar(&mut self, span: Span, name: &str)
name
,
config
::
host_triple
(),
self
.sess.opts.target_triple
);
s
elf
.sess
.span_err
(
span
,
&
message
[
..
]);
s
pan_err!
(
self
.sess
,
span
,
E0456
,
"{}"
,
&
message
[
..
]);
self
.sess
.abort_if_errors
();
}
...
...
@@ -524,10 +527,10 @@ pub fn find_plugin_registrar(&mut self, span: Span, name: &str)
match
(
ekrate
.dylib
.as_ref
(),
registrar
)
{
(
Some
(
dylib
),
Some
(
reg
))
=>
Some
((
dylib
.to_path_buf
(),
reg
)),
(
None
,
Some
(
_
))
=>
{
let
message
=
format!
(
"plugin `{}` only found in rlib format,
\
but must be available in dylib format"
,
name
);
self
.sess
.span_err
(
span
,
&
message
[
..
]
);
span_err!
(
self
.sess
,
span
,
E0457
,
"plugin `{}` only found in rlib format, but must be available
\
in dylib format"
,
name
);
// No need to abort because the loading code will just ignore this
// empty dylib.
None
...
...
@@ -760,7 +763,8 @@ fn process_foreign_mod(&mut self, i: &hir::Item, fm: &hir::ForeignMod) {
Some
(
"dylib"
)
=>
cstore
::
NativeUnknown
,
Some
(
"framework"
)
=>
cstore
::
NativeFramework
,
Some
(
k
)
=>
{
self
.sess
.span_err
(
m
.span
,
&
format!
(
"unknown kind: `{}`"
,
k
));
span_err!
(
self
.sess
,
m
.span
,
E0458
,
"unknown kind: `{}`"
,
k
);
cstore
::
NativeUnknown
}
None
=>
cstore
::
NativeUnknown
...
...
@@ -771,8 +775,8 @@ fn process_foreign_mod(&mut self, i: &hir::Item, fm: &hir::ForeignMod) {
let
n
=
match
n
{
Some
(
n
)
=>
n
,
None
=>
{
s
elf
.sess
.span_err
(
m
.span
,
"#[link(...)] specified without
\
`name =
\"
foo
\"
`"
);
s
pan_err!
(
self
.sess
,
m
.span
,
E0459
,
"#[link(...)] specified without
`name =
\"
foo
\"
`"
);
InternedString
::
new
(
"foo"
)
}
};
...
...
src/librustc/metadata/loader.rs
浏览文件 @
8dfb8906
...
...
@@ -308,23 +308,28 @@ pub fn load_library_crate(&mut self) -> Library {
}
pub
fn
report_load_errs
(
&
mut
self
)
{
let
message
=
if
!
self
.rejected_via_hash
.is_empty
()
{
format!
(
"found possibly newer version of crate `{}`"
,
self
.ident
)
let
add
=
match
self
.root
{
&
None
=>
String
::
new
(),
&
Some
(
ref
r
)
=>
format!
(
" which `{}` depends on"
,
r
.ident
)
};
if
!
self
.rejected_via_hash
.is_empty
()
{
span_err!
(
self
.sess
,
self
.span
,
E0460
,
"found possibly newer version of crate `{}`{}"
,
self
.ident
,
add
);
}
else
if
!
self
.rejected_via_triple
.is_empty
()
{
format!
(
"couldn't find crate `{}` with expected target triple {}"
,
self
.ident
,
self
.triple
)
span_err!
(
self
.sess
,
self
.span
,
E0461
,
"couldn't find crate `{}` with expected target triple {}{}"
,
self
.ident
,
self
.triple
,
add
);
}
else
if
!
self
.rejected_via_kind
.is_empty
()
{
format!
(
"found staticlib `{}` instead of rlib or dylib"
,
self
.ident
)
span_err!
(
self
.sess
,
self
.span
,
E0462
,
"found staticlib `{}` instead of rlib or dylib{}"
,
self
.ident
,
add
);
}
else
{
format!
(
"can't find crate for `{}`"
,
self
.ident
)
};
let
message
=
match
self
.root
{
&
None
=>
message
,
&
Some
(
ref
r
)
=>
format!
(
"{} which `{}` depends on"
,
message
,
r
.ident
)
};
self
.sess
.span_err
(
self
.span
,
&
message
[
..
]);
span_err!
(
self
.sess
,
self
.span
,
E0463
,
"can't find crate for `{}`{}"
,
self
.ident
,
add
);
}
if
!
self
.rejected_via_triple
.is_empty
()
{
let
mismatches
=
self
.rejected_via_triple
.iter
();
...
...
@@ -473,9 +478,9 @@ fn find_library_crate(&mut self) -> Option<Library> {
0
=>
None
,
1
=>
Some
(
libraries
.into_iter
()
.next
()
.unwrap
()),
_
=>
{
s
elf
.sess
.span_err
(
self
.span
,
&
format!
(
"multiple matching crates for `{}`"
,
self
.crate_name
)
);
s
pan_err!
(
self
.sess
,
self
.span
,
E0464
,
"multiple matching crates for `{}`"
,
self
.crate_name
);
self
.sess
.note
(
"candidates:"
);
for
lib
in
&
libraries
{
match
lib
.dylib
{
...
...
@@ -543,11 +548,9 @@ fn extract_one(&mut self, m: HashMap<PathBuf, PathKind>, flavor: &str,
}
};
if
ret
.is_some
()
{
self
.sess
.span_err
(
self
.span
,
&
format!
(
"multiple {} candidates for `{}`
\
found"
,
flavor
,
self
.crate_name
));
span_err!
(
self
.sess
,
self
.span
,
E0465
,
"multiple {} candidates for `{}` found"
,
flavor
,
self
.crate_name
);
self
.sess
.span_note
(
self
.span
,
&
format!
(
r"candidate #1: {}"
,
ret
.as_ref
()
.unwrap
()
.0
...
...
src/librustc/metadata/macro_import.rs
浏览文件 @
8dfb8906
...
...
@@ -40,6 +40,10 @@ fn new(sess: &'a Session) -> MacroLoader<'a> {
}
}
pub
fn
call_bad_macro_reexport
(
a
:
&
Session
,
b
:
Span
)
{
span_err!
(
a
,
b
,
E0467
,
"bad macro reexport"
);
}
/// Read exported macros.
pub
fn
read_macro_defs
(
sess
:
&
Session
,
krate
:
&
ast
::
Crate
)
->
Vec
<
ast
::
MacroDef
>
{
let
mut
loader
=
MacroLoader
::
new
(
sess
);
...
...
@@ -90,7 +94,7 @@ fn visit_item(&mut self, item: &ast::Item) {
if
let
ast
::
MetaWord
(
ref
name
)
=
attr
.node
{
sel
.insert
(
name
.clone
(),
attr
.span
);
}
else
{
s
elf
.sess
.span_err
(
attr
.span
,
"bad macro import"
);
s
pan_err!
(
self
.sess
,
attr
.span
,
E0466
,
"bad macro import"
);
}
}
}
...
...
@@ -99,7 +103,7 @@ fn visit_item(&mut self, item: &ast::Item) {
let
names
=
match
attr
.meta_item_list
()
{
Some
(
names
)
=>
names
,
None
=>
{
self
.sess
.span_err
(
attr
.span
,
"bad macro reexport"
);
call_bad_macro_reexport
(
self
.sess
,
attr
.span
);
continue
;
}
};
...
...
@@ -108,7 +112,7 @@ fn visit_item(&mut self, item: &ast::Item) {
if
let
ast
::
MetaWord
(
ref
name
)
=
attr
.node
{
reexport
.insert
(
name
.clone
(),
attr
.span
);
}
else
{
self
.sess
.span_err
(
attr
.span
,
"bad macro reexport"
);
call_bad_macro_reexport
(
self
.sess
,
attr
.span
);
}
}
}
...
...
@@ -140,8 +144,8 @@ fn load_macros<'b>(&mut self,
}
if
!
self
.span_whitelist
.contains
(
&
vi
.span
)
{
s
elf
.sess
.span_err
(
vi
.span
,
"an `extern crate` loading macros must be at
\
the crate root"
);
s
pan_err!
(
self
.sess
,
vi
.span
,
E0468
,
"an `extern crate` loading macros must be at
the crate root"
);
return
;
}
...
...
@@ -166,14 +170,16 @@ fn load_macros<'b>(&mut self,
if
let
Some
(
sel
)
=
import
.as_ref
()
{
for
(
name
,
span
)
in
sel
{
if
!
seen
.contains
(
&
name
)
{
self
.sess
.span_err
(
*
span
,
"imported macro not found"
);
span_err!
(
self
.sess
,
*
span
,
E0469
,
"imported macro not found"
);
}
}
}
for
(
name
,
span
)
in
&
reexport
{
if
!
seen
.contains
(
&
name
)
{
self
.sess
.span_err
(
*
span
,
"reexported macro not found"
);
span_err!
(
self
.sess
,
*
span
,
E0470
,
"reexported macro not found"
);
}
}
}
...
...
src/librustc/middle/check_const.rs
浏览文件 @
8dfb8906
...
...
@@ -499,9 +499,9 @@ 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
,
"cannot borrow a constant which contains
\
interior mutability, create a static instead"
);
s
pan_err!
(
self
.tcx.sess
,
ex
.span
,
E0492
,
"cannot borrow a constant which contains
\
interior mutability, create a static instead"
);
}
}
// If the reference has to be 'static, avoid in-place initialization
...
...
@@ -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
(
));
}
}
_
=>
{}
...
...
@@ -909,9 +909,9 @@ 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
,
"cannot refer to the interior of another
\
static, use a constant instead"
);
s
pan_err!
(
self
.tcx.sess
,
borrow_span
,
E0494
,
"cannot refer to the interior of another
\
static, use a constant instead"
);
}
break
;
}
...
...
src/librustc/middle/check_match.rs
浏览文件 @
8dfb8906
...
...
@@ -282,9 +282,9 @@ fn check_for_static_nan(cx: &MatchCheckCtxt, pat: &Pat) {
Err
(
err
)
=>
{
let
subspan
=
p
.span.lo
<=
err
.span.lo
&&
err
.span.hi
<=
p
.span.hi
;
cx
.tcx.sess
.span_err
(
err
.span
,
&
format!
(
"constant evaluation error: {}"
,
err
.description
()
));
span_err!
(
cx
.tcx.sess
,
err
.span
,
E0471
,
"constant evaluation error: {}"
,
err
.description
(
));
if
!
subspan
{
cx
.tcx.sess
.span_note
(
p
.span
,
"in pattern here"
)
...
...
src/librustc/middle/check_no_asm.rs
浏览文件 @
8dfb8906
...
...
@@ -32,8 +32,8 @@ struct CheckNoAsm<'a> {
impl
<
'a
,
'v
>
Visitor
<
'v
>
for
CheckNoAsm
<
'a
>
{
fn
visit_expr
(
&
mut
self
,
e
:
&
ast
::
Expr
)
{
match
e
.node
{
ast
::
ExprInlineAsm
(
_
)
=>
s
elf
.sess
.span_err
(
e
.span
,
"asm! is unsupported on this target"
),
ast
::
ExprInlineAsm
(
_
)
=>
s
pan_err!
(
self
.sess
,
e
.span
,
E0472
,
"asm! is unsupported on this target"
),
_
=>
{},
}
visit
::
walk_expr
(
self
,
e
)
...
...
src/librustc/middle/infer/error_reporting.rs
浏览文件 @
8dfb8906
...
...
@@ -718,20 +718,17 @@ fn report_concrete_failure(&self,
""
);
}
infer
::
DerefPointer
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"dereference of reference outside its lifetime"
);
span_err!
(
self
.tcx.sess
,
span
,
E0473
,
"dereference of reference outside its lifetime"
);
self
.tcx
.note_and_explain_region
(
"the reference is only valid for "
,
sup
,
""
);
}
infer
::
FreeVariable
(
span
,
id
)
=>
{
self
.tcx.sess
.span_err
(
span
,
&
format!
(
"captured variable `{}` does not
\
outlive the enclosing closure"
,
self
.tcx
.local_var_name_str
(
id
)));
span_err!
(
self
.tcx.sess
,
span
,
E0474
,
"captured variable `{}` does not outlive the enclosing closure"
,
self
.tcx
.local_var_name_str
(
id
));
self
.tcx
.note_and_explain_region
(
"captured variable is valid for "
,
sup
,
...
...
@@ -742,18 +739,17 @@ fn report_concrete_failure(&self,
""
);
}
infer
::
IndexSlice
(
span
)
=>
{
s
elf
.tcx.sess
.span_err
(
span
,
"index of slice outside its lifetime"
);
s
pan_err!
(
self
.tcx.sess
,
span
,
E0475
,
"index of slice outside its lifetime"
);
self
.tcx
.note_and_explain_region
(
"the slice is only valid for "
,
sup
,
""
);
}
infer
::
RelateObjectBound
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"lifetime of the source pointer does not outlive
\
lifetime bound of the object type"
);
span_err!
(
self
.tcx.sess
,
span
,
E0476
,
"lifetime of the source pointer does not outlive
\
lifetime bound of the object type"
);
self
.tcx
.note_and_explain_region
(
"object type is valid for "
,
sub
,
...
...
@@ -764,20 +760,17 @@ fn report_concrete_failure(&self,
""
);
}
infer
::
RelateParamBound
(
span
,
ty
)
=>
{
self
.tcx.sess
.span_err
(
span
,
&
format!
(
"the type `{}` does not fulfill the
\
required lifetime"
,
self
.ty_to_string
(
ty
)));
span_err!
(
self
.tcx.sess
,
span
,
E0477
,
"the type `{}` does not fulfill the required lifetime"
,
self
.ty_to_string
(
ty
));
self
.tcx
.note_and_explain_region
(
"type must outlive "
,
sub
,
""
);
}
infer
::
RelateRegionParamBound
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"lifetime bound not satisfied"
);
span_err!
(
self
.tcx.sess
,
span
,
E0478
,
"lifetime bound not satisfied"
);
self
.tcx
.note_and_explain_region
(
"lifetime parameter instantiated with "
,
sup
,
...
...
@@ -788,92 +781,82 @@ fn report_concrete_failure(&self,
""
);
}
infer
::
RelateDefaultParamBound
(
span
,
ty
)
=>
{
self
.tcx.sess
.span_err
(
span
,
&
format!
(
"the type `{}` (provided as the value of
\
a type parameter) is not valid at this point"
,
self
.ty_to_string
(
ty
)));
span_err!
(
self
.tcx.sess
,
span
,
E0479
,
"the type `{}` (provided as the value of
\
a type parameter) is not valid at this point"
,
self
.ty_to_string
(
ty
));
self
.tcx
.note_and_explain_region
(
"type must outlive "
,
sub
,
""
);
}
infer
::
CallRcvr
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"lifetime of method receiver does not outlive
\
the method call"
);
span_err!
(
self
.tcx.sess
,
span
,
E0480
,
"lifetime of method receiver does not outlive
\
the method call"
);
self
.tcx
.note_and_explain_region
(
"the receiver is only valid for "
,
sup
,
""
);
}
infer
::
CallArg
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"lifetime of function argument does not outlive
\
the function call"
);
span_err!
(
self
.tcx.sess
,
span
,
E0481
,
"lifetime of function argument does not outlive
\
the function call"
);
self
.tcx
.note_and_explain_region
(
"the function argument is only valid for "
,
sup
,
""
);
}
infer
::
CallReturn
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"lifetime of return value does not outlive
\
the function call"
);
span_err!
(
self
.tcx.sess
,
span
,
E0482
,
"lifetime of return value does not outlive
\
the function call"
);
self
.tcx
.note_and_explain_region
(
"the return value is only valid for "
,
sup
,
""
);
}
infer
::
Operand
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"lifetime of operand does not outlive
\
the operation"
);
span_err!
(
self
.tcx.sess
,
span
,
E0483
,
"lifetime of operand does not outlive
\
the operation"
);
self
.tcx
.note_and_explain_region
(
"the operand is only valid for "
,
sup
,
""
);
}
infer
::
AddrOf
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"reference is not valid
\
at the time of borrow"
);
span_err!
(
self
.tcx.sess
,
span
,
E0484
,
"reference is not valid at the time of borrow"
);
self
.tcx
.note_and_explain_region
(
"the borrow is only valid for "
,
sup
,
""
);
}
infer
::
AutoBorrow
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"automatically reference is not valid
\
at the time of borrow"
);
span_err!
(
self
.tcx.sess
,
span
,
E0485
,
"automatically reference is not valid
\
at the time of borrow"
);
self
.tcx
.note_and_explain_region
(
"the automatic borrow is only valid for "
,
sup
,
""
);
}
infer
::
ExprTypeIsNotInScope
(
t
,
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
&
format!
(
"type of expression contains references
\
that are not valid during the expression: `{}`"
,
self
.ty_to_string
(
t
)));
span_err!
(
self
.tcx.sess
,
span
,
E0486
,
"type of expression contains references
\
that are not valid during the expression: `{}`"
,
self
.ty_to_string
(
t
));
self
.tcx
.note_and_explain_region
(
"type is only valid for "
,
sup
,
""
);
}
infer
::
SafeDestructor
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"unsafe use of destructor: destructor might be called
\
while references are dead"
);
span_err!
(
self
.tcx.sess
,
span
,
E0487
,
"unsafe use of destructor: destructor might be called
\
while references are dead"
);
// FIXME (22171): terms "super/subregion" are suboptimal
self
.tcx
.note_and_explain_region
(
"superregion: "
,
...
...
@@ -885,37 +868,33 @@ fn report_concrete_failure(&self,
""
);
}
infer
::
BindingTypeIsNotValidAtDecl
(
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
"lifetime of variable does not enclose its declaration"
);
span_err!
(
self
.tcx.sess
,
span
,
E0488
,
"lifetime of variable does not enclose its declaration"
);
self
.tcx
.note_and_explain_region
(
"the variable is only valid for "
,
sup
,
""
);
}
infer
::
ParameterInScope
(
_
,
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
&
format!
(
"type/lifetime parameter not in scope here"
));
span_err!
(
self
.tcx.sess
,
span
,
E0489
,
"type/lifetime parameter not in scope here"
);
self
.tcx
.note_and_explain_region
(
"the parameter is only valid for "
,
sub
,
""
);
}
infer
::
DataBorrowed
(
ty
,
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
&
format!
(
"a value of type `{}` is borrowed for too long"
,
self
.ty_to_string
(
ty
)));
span_err!
(
self
.tcx.sess
,
span
,
E0490
,
"a value of type `{}` is borrowed for too long"
,
self
.ty_to_string
(
ty
));
self
.tcx
.note_and_explain_region
(
"the type is valid for "
,
sub
,
""
);
self
.tcx
.note_and_explain_region
(
"but the borrow lasts for "
,
sup
,
""
);
}
infer
::
ReferenceOutlivesReferent
(
ty
,
span
)
=>
{
self
.tcx.sess
.span_err
(
span
,
&
format!
(
"in type `{}`, reference has a longer lifetime
\
than the data it references"
,
self
.ty_to_string
(
ty
)));
span_err!
(
self
.tcx.sess
,
span
,
E0491
,
"in type `{}`, reference has a longer lifetime
\
than the data it references"
,
self
.ty_to_string
(
ty
));
self
.tcx
.note_and_explain_region
(
"the pointer is valid for "
,
sub
,
...
...
@@ -1648,11 +1627,10 @@ fn report_inference_failure(&self,
}
};
self
.tcx.sess
.span_err
(
var_origin
.span
(),
&
format!
(
"cannot infer an appropriate lifetime{}
\
due to conflicting requirements"
,
var_description
));
span_err!
(
self
.tcx.sess
,
var_origin
.span
(),
E0495
,
"cannot infer an appropriate lifetime{}
\
due to conflicting requirements"
,
var_description
);
}
fn
note_region_origin
(
&
self
,
origin
:
&
SubregionOrigin
<
'tcx
>
)
{
...
...
@@ -1779,7 +1757,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
"...so that return value is valid for the call"
);
}
infer
::
Operand
(
span
)
=>
{
self
.tcx.sess
.span_
err
(
self
.tcx.sess
.span_
note
(
span
,
"...so that operand is valid for operation"
);
}
...
...
src/librustc/middle/resolve_lifetime.rs
浏览文件 @
8dfb8906
...
...
@@ -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
\
{} name that is already in scope"
,
shadower
.kind
.desc
(),
name
,
orig
.kind
.desc
()
));
s
pan_err!
(
sess
,
shadower
.span
,
E0496
,
"{} name `{}` shadows a
\
{} name that is already in scope"
,
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
浏览文件 @
8dfb8906
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录