Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
dcdab2df
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,发现更多精彩内容 >>
提交
dcdab2df
编写于
10月 22, 2016
作者:
J
Jeffrey Seyfried
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix label scopes.
上级
b5f6d7ec
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
19 deletion
+16
-19
src/librustc_resolve/lib.rs
src/librustc_resolve/lib.rs
+13
-19
src/test/compile-fail/resolve-label.rs
src/test/compile-fail/resolve-label.rs
+3
-0
未找到文件。
src/librustc_resolve/lib.rs
浏览文件 @
dcdab2df
...
...
@@ -55,7 +55,7 @@
use
syntax
::
ext
::
hygiene
::{
Mark
,
SyntaxContext
};
use
syntax
::
ast
::{
self
,
FloatTy
};
use
syntax
::
ast
::{
CRATE_NODE_ID
,
Name
,
NodeId
,
Ident
,
IntTy
,
UintTy
};
use
syntax
::
ast
::{
CRATE_NODE_ID
,
Name
,
NodeId
,
Ident
,
SpannedIdent
,
IntTy
,
UintTy
};
use
syntax
::
ext
::
base
::
SyntaxExtension
;
use
syntax
::
parse
::
token
::{
self
,
keywords
};
use
syntax
::
util
::
lev_distance
::
find_best_match_for_name
;
...
...
@@ -2278,7 +2278,7 @@ fn resolve_type(&mut self, ty: &Ty) {
}
fn
fresh_binding
(
&
mut
self
,
ident
:
&
ast
::
SpannedIdent
,
ident
:
&
SpannedIdent
,
pat_id
:
NodeId
,
outer_pat_id
:
NodeId
,
pat_src
:
PatternSource
,
...
...
@@ -2842,11 +2842,11 @@ fn find_best_match(&mut self, name: &str) -> SuggestionType {
}
SuggestionType
::
NotFound
}
fn
resolve_labeled_block
(
&
mut
self
,
label
:
Option
<
Ident
>
,
id
:
NodeId
,
block
:
&
Block
)
{
fn
resolve_labeled_block
(
&
mut
self
,
label
:
Option
<
Spanned
Ident
>
,
id
:
NodeId
,
block
:
&
Block
)
{
if
let
Some
(
label
)
=
label
{
let
def
=
Def
::
Label
(
id
);
self
.with_label_rib
(|
this
|
{
this
.label_ribs
.last_mut
()
.unwrap
()
.bindings
.insert
(
label
,
def
);
this
.label_ribs
.last_mut
()
.unwrap
()
.bindings
.insert
(
label
.node
,
def
);
this
.visit_block
(
block
);
});
}
else
{
...
...
@@ -3039,19 +3039,6 @@ fn resolve_expr(&mut self, expr: &Expr, parent: Option<&Expr>) {
visit
::
walk_expr
(
self
,
expr
);
}
ExprKind
::
Loop
(
_
,
Some
(
label
))
|
ExprKind
::
While
(
..
,
Some
(
label
))
=>
{
self
.with_label_rib
(|
this
|
{
let
def
=
Def
::
Label
(
expr
.id
);
{
let
rib
=
this
.label_ribs
.last_mut
()
.unwrap
();
rib
.bindings
.insert
(
label
.node
,
def
);
}
visit
::
walk_expr
(
this
,
expr
);
})
}
ExprKind
::
Break
(
Some
(
label
))
|
ExprKind
::
Continue
(
Some
(
label
))
=>
{
match
self
.search_label
(
label
.node
)
{
None
=>
{
...
...
@@ -3081,12 +3068,19 @@ fn resolve_expr(&mut self, expr: &Expr, parent: Option<&Expr>) {
optional_else
.as_ref
()
.map
(|
expr
|
self
.visit_expr
(
expr
));
}
ExprKind
::
Loop
(
ref
block
,
label
)
=>
self
.resolve_labeled_block
(
label
,
expr
.id
,
&
block
),
ExprKind
::
While
(
ref
subexpression
,
ref
block
,
label
)
=>
{
self
.visit_expr
(
subexpression
);
self
.resolve_labeled_block
(
label
,
expr
.id
,
&
block
);
}
ExprKind
::
WhileLet
(
ref
pattern
,
ref
subexpression
,
ref
block
,
label
)
=>
{
self
.visit_expr
(
subexpression
);
self
.value_ribs
.push
(
Rib
::
new
(
NormalRibKind
));
self
.resolve_pattern
(
pattern
,
PatternSource
::
WhileLet
,
&
mut
FnvHashMap
());
self
.resolve_labeled_block
(
label
.map
(|
l
|
l
.node
)
,
expr
.id
,
block
);
self
.resolve_labeled_block
(
label
,
expr
.id
,
block
);
self
.value_ribs
.pop
();
}
...
...
@@ -3096,7 +3090,7 @@ fn resolve_expr(&mut self, expr: &Expr, parent: Option<&Expr>) {
self
.value_ribs
.push
(
Rib
::
new
(
NormalRibKind
));
self
.resolve_pattern
(
pattern
,
PatternSource
::
For
,
&
mut
FnvHashMap
());
self
.resolve_labeled_block
(
label
.map
(|
l
|
l
.node
)
,
expr
.id
,
block
);
self
.resolve_labeled_block
(
label
,
expr
.id
,
block
);
self
.value_ribs
.pop
();
}
...
...
src/test/compile-fail/resolve-label.rs
浏览文件 @
dcdab2df
...
...
@@ -16,6 +16,9 @@ fn g() {
}
}
}
// issue #37353
loop
{
'w
:
while
break
'w
{
}
}
//~ ERROR use of undeclared label
}
fn
main
()
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录