Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
104fe1c4
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,发现更多精彩内容 >>
提交
104fe1c4
编写于
5月 11, 2016
作者:
J
Jonathan Turner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updating a few more errors with labels
上级
f3054ce1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
26 deletion
+46
-26
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+46
-26
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
104fe1c4
...
...
@@ -200,11 +200,13 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
match
resolution_error
{
ResolutionError
::
TypeParametersFromOuterFunction
=>
{
struct_span_err!
(
resolver
.session
,
span
,
E0401
,
"can't use type parameters from outer function; try using a local
\
type parameter instead"
)
let
mut
err
=
struct_span_err!
(
resolver
.session
,
span
,
E0401
,
"can't use type parameters from outer function;
\
try using a local type parameter instead"
);
err
=
err
.span_label
(
span
,
&
format!
(
"use of type variable from outer function"
));
err
}
ResolutionError
::
OuterTypeParameterContext
=>
{
struct_span_err!
(
resolver
.session
,
...
...
@@ -230,6 +232,7 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
"trait `{}` is not in scope"
,
name
);
show_candidates
(
&
mut
err
,
&
candidates
);
err
=
err
.span_label
(
span
,
&
format!
(
"`{}` is not in scope"
,
name
));
err
}
ResolutionError
::
UndeclaredAssociatedType
=>
{
...
...
@@ -278,10 +281,12 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
pattern_number
)
}
ResolutionError
::
SelfUsedOutsideImplOrTrait
=>
{
struct_span_err!
(
resolver
.session
,
span
,
E0411
,
"use of `Self` outside of an impl or trait"
)
let
mut
err
=
struct_span_err!
(
resolver
.session
,
span
,
E0411
,
"use of `Self` outside of an impl or trait"
);
err
=
err
.span_label
(
span
,
&
format!
(
"Used outside of impl or trait"
));
err
}
ResolutionError
::
UseOfUndeclared
(
kind
,
name
,
candidates
)
=>
{
let
mut
err
=
struct_span_err!
(
resolver
.session
,
...
...
@@ -291,44 +296,52 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
kind
,
name
);
show_candidates
(
&
mut
err
,
&
candidates
);
err
=
err
.span_label
(
span
,
&
format!
(
"undefined or not in scope"
));
err
}
ResolutionError
::
DeclarationShadowsEnumVariantOrUnitLikeStruct
(
name
)
=>
{
struct_span_err!
(
resolver
.session
,
let
mut
err
=
struct_span_err!
(
resolver
.session
,
span
,
E0413
,
"
declaration of `{}` shadow
s an enum variant
\
"
`{}` cannot be named the same a
s an enum variant
\
or unit-like struct in scope"
,
name
)
name
);
err
=
err
.span_label
(
span
,
&
format!
(
"has same name as enum variant or unit-like struct"
));
err
}
ResolutionError
::
ConstantForIrrefutableBinding
(
name
)
=>
{
let
mut
err
=
struct_span_err!
(
resolver
.session
,
span
,
E0414
,
"variable bindings cannot shadow constants"
);
err
.span_note
(
span
,
"there already is a constant in scope sharing the same
\
name as this pattern"
);
"let variables cannot be named the same as const variables"
);
err
=
err
.span_label
(
span
,
&
format!
(
"cannot be named the same as a const variable"
));
if
let
Some
(
binding
)
=
resolver
.current_module
.resolve_name_in_lexical_scope
(
name
,
ValueNS
)
{
let
participle
=
if
binding
.is_import
()
{
"imported"
}
else
{
"defined"
};
err
.span_note
(
binding
.span
,
&
format!
(
"constant {} here"
,
participle
));
err
=
err
.span_label
(
binding
.span
,
&
format!
(
"a constant `{}` is {} here"
,
name
,
participle
));
}
err
}
ResolutionError
::
IdentifierBoundMoreThanOnceInParameterList
(
identifier
)
=>
{
struct_span_err!
(
resolver
.session
,
let
mut
err
=
struct_span_err!
(
resolver
.session
,
span
,
E0415
,
"identifier `{}` is bound more than once in this parameter list"
,
identifier
)
identifier
);
err
=
err
.span_label
(
span
,
&
format!
(
"used as parameter more than once"
));
err
}
ResolutionError
::
IdentifierBoundMoreThanOnceInSamePattern
(
identifier
)
=>
{
struct_span_err!
(
resolver
.session
,
let
mut
err
=
struct_span_err!
(
resolver
.session
,
span
,
E0416
,
"identifier `{}` is bound more than once in the same pattern"
,
identifier
)
identifier
);
err
=
err
.span_label
(
span
,
&
format!
(
"used in a pattern more than once"
));
err
}
ResolutionError
::
StaticVariableReference
(
binding
)
=>
{
let
mut
err
=
struct_span_err!
(
resolver
.session
,
...
...
@@ -336,9 +349,10 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
E0417
,
"static variables cannot be referenced in a
\
pattern, use a `const` instead"
);
err
=
err
.span_label
(
span
,
&
format!
(
"static variable used in pattern"
));
if
binding
.span
!=
codemap
::
DUMMY_SP
{
let
participle
=
if
binding
.is_import
()
{
"imported"
}
else
{
"defined"
};
err
.span_note
(
binding
.span
,
&
format!
(
"static variable {} here"
,
participle
));
err
=
err
.span_label
(
binding
.span
,
&
format!
(
"static variable {} here"
,
participle
));
}
err
}
...
...
@@ -1804,7 +1818,9 @@ fn resolve_trait_reference(&mut self,
// If it's a typedef, give a note
if
let
Def
::
TyAlias
(
..
)
=
path_res
.base_def
{
err
.note
(
"`type` aliases cannot be used for traits"
);
let
trait_name
=
trait_path
.segments
.last
()
.unwrap
()
.identifier.name
;
err
=
err
.span_label
(
trait_path
.span
,
&
format!
(
"`{}` is not a trait"
,
trait_name
));
let
definition_site
=
{
let
segments
=
&
trait_path
.segments
;
...
...
@@ -1816,7 +1832,8 @@ fn resolve_trait_reference(&mut self,
};
if
definition_site
!=
codemap
::
DUMMY_SP
{
err
.span_note
(
definition_site
,
"type defined here"
);
err
=
err
.span_label
(
definition_site
,
&
format!
(
"note: type aliases cannot be used for traits"
));
}
}
err
.emit
();
...
...
@@ -3462,12 +3479,15 @@ fn report_conflict(&self,
_
=>
match
(
old_binding
.is_import
(),
binding
.is_import
())
{
(
false
,
false
)
=>
struct_span_err!
(
self
.session
,
span
,
E0428
,
"{}"
,
msg
),
(
true
,
true
)
=>
struct_span_err!
(
self
.session
,
span
,
E0252
,
"{}"
,
msg
),
_
=>
struct_span_err!
(
self
.session
,
span
,
E0255
,
"{}"
,
msg
),
_
=>
{
let
e
=
struct_span_err!
(
self
.session
,
span
,
E0255
,
"{}"
,
msg
);
e
.span_label
(
span
,
&
format!
(
"`{}` was already imported"
,
name
))
}
},
};
if
old_binding
.span
!=
codemap
::
DUMMY_SP
{
err
.span_note
(
old_binding
.span
,
&
format!
(
"previous {} of `{}` here"
,
noun
,
name
));
err
=
err
.span_label
(
old_binding
.span
,
&
format!
(
"previous {} of `{}` here"
,
noun
,
name
));
}
err
.emit
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录