Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6bf1aa6f
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,发现更多精彩内容 >>
提交
6bf1aa6f
编写于
9月 27, 2018
作者:
A
Alexander Regueiro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added help message for feature gate.
上级
44151953
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
14 deletion
+35
-14
src/librustc_mir/hair/pattern/check_match.rs
src/librustc_mir/hair/pattern/check_match.rs
+1
-1
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+29
-9
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/method/probe.rs
+5
-4
未找到文件。
src/librustc_mir/hair/pattern/check_match.rs
浏览文件 @
6bf1aa6f
...
...
@@ -539,7 +539,7 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor,
.emit
();
}
else
if
has_guard
&&
!
cx
.tcx
.allow_bind_by_move_patterns_with_guards
()
{
let
mut
err
=
struct_span_err!
(
cx
.tcx.sess
,
p
.span
,
E0008
,
"cannot bind by-move into a pattern guard"
);
"cannot bind by-move into a pattern guard"
);
err
.span_label
(
p
.span
,
"moves value into pattern guard"
);
if
cx
.tcx.sess.opts.unstable_features
.is_nightly_build
()
&&
cx
.tcx
.use_mir_borrowck
()
{
err
.help
(
"add #![feature(bind_by_move_pattern_guards)] to the
\
...
...
src/librustc_resolve/lib.rs
浏览文件 @
6bf1aa6f
...
...
@@ -42,8 +42,9 @@
use
rustc
::
hir
::
def
::
*
;
use
rustc
::
hir
::
def
::
Namespace
::
*
;
use
rustc
::
hir
::
def_id
::{
CRATE_DEF_INDEX
,
LOCAL_CRATE
,
DefId
};
use
rustc
::
ty
;
use
rustc
::
hir
::{
Freevar
,
FreevarMap
,
TraitCandidate
,
TraitMap
,
GlobMap
};
use
rustc
::
session
::
config
::
nightly_options
;
use
rustc
::
ty
;
use
rustc
::
util
::
nodemap
::{
NodeMap
,
NodeSet
,
FxHashMap
,
FxHashSet
,
DefIdMap
};
use
rustc_metadata
::
creader
::
CrateLoader
;
...
...
@@ -1381,6 +1382,9 @@ pub struct Resolver<'a, 'b: 'a> {
/// The current self type if inside an impl (used for better errors).
current_self_type
:
Option
<
Ty
>
,
/// The current self item if inside an ADT (used for better errors).
current_self_item
:
Option
<
NodeId
>
,
/// The idents for the primitive types.
primitive_type_table
:
PrimitiveTypeTable
,
...
...
@@ -1710,6 +1714,7 @@ pub fn new(session: &'a Session,
current_trait_ref
:
None
,
current_self_type
:
None
,
current_self_item
:
None
,
primitive_type_table
:
PrimitiveTypeTable
::
new
(),
...
...
@@ -2186,15 +2191,17 @@ fn search_label<P, R>(&self, mut ident: Ident, pred: P) -> Option<R>
}
fn
resolve_adt
(
&
mut
self
,
item
:
&
Item
,
generics
:
&
Generics
)
{
self
.with_type_parameter_rib
(
HasTypeParameters
(
generics
,
ItemRibKind
),
|
this
|
{
let
item_def_id
=
this
.definitions
.local_def_id
(
item
.id
);
if
this
.session
.features_untracked
()
.self_in_typedefs
{
this
.with_self_rib
(
Def
::
SelfTy
(
None
,
Some
(
item_def_id
)),
|
this
|
{
self
.with_current_self_item
(
item
,
|
this
|
{
this
.with_type_parameter_rib
(
HasTypeParameters
(
generics
,
ItemRibKind
),
|
this
|
{
let
item_def_id
=
this
.definitions
.local_def_id
(
item
.id
);
if
this
.session
.features_untracked
()
.self_in_typedefs
{
this
.with_self_rib
(
Def
::
SelfTy
(
None
,
Some
(
item_def_id
)),
|
this
|
{
visit
::
walk_item
(
this
,
item
);
});
}
else
{
visit
::
walk_item
(
this
,
item
);
});
}
else
{
visit
::
walk_item
(
this
,
item
);
}
}
});
});
}
...
...
@@ -2435,6 +2442,15 @@ fn with_current_self_type<T, F>(&mut self, self_type: &Ty, f: F) -> T
result
}
fn
with_current_self_item
<
T
,
F
>
(
&
mut
self
,
self_item
:
&
Item
,
f
:
F
)
->
T
where
F
:
FnOnce
(
&
mut
Resolver
)
->
T
{
let
previous_value
=
replace
(
&
mut
self
.current_self_item
,
Some
(
self_item
.id
));
let
result
=
f
(
self
);
self
.current_self_item
=
previous_value
;
result
}
/// This is called to resolve a trait reference from an `impl` (i.e. `impl Trait for Foo`)
fn
with_optional_trait_ref
<
T
,
F
>
(
&
mut
self
,
opt_trait_ref
:
Option
<&
TraitRef
>
,
f
:
F
)
->
T
where
F
:
FnOnce
(
&
mut
Resolver
,
Option
<
DefId
>
)
->
T
...
...
@@ -3004,6 +3020,10 @@ fn smart_resolve_path_fragment(&mut self,
"traits and impls"
};
err
.span_label
(
span
,
format!
(
"`Self` is only available in {}"
,
available_in
));
if
this
.current_self_item
.is_some
()
&&
nightly_options
::
is_nightly_build
()
{
err
.help
(
"add #![feature(self_in_typedefs)] to the crate attributes
\
to enable"
);
}
return
(
err
,
Vec
::
new
());
}
if
is_self_value
(
path
,
ns
)
{
...
...
src/librustc_typeck/check/method/probe.rs
浏览文件 @
6bf1aa6f
...
...
@@ -17,6 +17,9 @@
use
hir
::
def_id
::
DefId
;
use
hir
::
def
::
Def
;
use
namespace
::
Namespace
;
use
rustc
::
hir
;
use
rustc
::
lint
;
use
rustc
::
session
::
config
::
nightly_options
;
use
rustc
::
ty
::
subst
::{
Subst
,
Substs
};
use
rustc
::
traits
::{
self
,
ObligationCause
};
use
rustc
::
ty
::{
self
,
Ty
,
ToPolyTraitRef
,
ToPredicate
,
TraitRef
,
TypeFoldable
};
...
...
@@ -28,8 +31,6 @@
use
syntax
::
ast
;
use
syntax
::
util
::
lev_distance
::{
lev_distance
,
find_best_match_for_name
};
use
syntax_pos
::{
Span
,
symbol
::
Symbol
};
use
rustc
::
hir
;
use
rustc
::
lint
;
use
std
::
mem
;
use
std
::
ops
::
Deref
;
use
std
::
rc
::
Rc
;
...
...
@@ -1073,9 +1074,9 @@ fn emit_unstable_name_collision_hint(
self
.tcx
.item_path_str
(
stable_pick
.item.def_id
),
));
if
::
rustc
::
session
::
config
::
nightly_options
::
is_nightly_build
()
{
if
nightly_options
::
is_nightly_build
()
{
for
(
candidate
,
feature
)
in
unstable_candidates
{
diag
.
note
(
&
format!
(
diag
.
help
(
&
format!
(
"add #![feature({})] to the crate attributes to enable `{}`"
,
feature
,
self
.tcx
.item_path_str
(
candidate
.item.def_id
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录