Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
558a07b8
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,发现更多精彩内容 >>
提交
558a07b8
编写于
3月 07, 2019
作者:
L
ljedrz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hir: remove NodeId from PatKind
上级
78f91e39
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
48 addition
and
53 deletion
+48
-53
src/librustc/hir/intravisit.rs
src/librustc/hir/intravisit.rs
+2
-2
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+3
-4
src/librustc/hir/map/mod.rs
src/librustc/hir/map/mod.rs
+1
-1
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+2
-2
src/librustc/hir/pat_util.rs
src/librustc/hir/pat_util.rs
+3
-3
src/librustc/hir/print.rs
src/librustc/hir/print.rs
+1
-1
src/librustc/ich/impls_hir.rs
src/librustc/ich/impls_hir.rs
+1
-1
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/expr_use_visitor.rs
+1
-1
src/librustc/middle/liveness.rs
src/librustc/middle/liveness.rs
+1
-1
src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs
src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs
+1
-1
src/librustc_lint/builtin.rs
src/librustc_lint/builtin.rs
+1
-1
src/librustc_lint/nonstandard_style.rs
src/librustc_lint/nonstandard_style.rs
+1
-1
src/librustc_metadata/encoder.rs
src/librustc_metadata/encoder.rs
+1
-1
src/librustc_mir/borrow_check/mutability_errors.rs
src/librustc_mir/borrow_check/mutability_errors.rs
+0
-1
src/librustc_mir/build/matches/mod.rs
src/librustc_mir/build/matches/mod.rs
+9
-10
src/librustc_mir/build/mod.rs
src/librustc_mir/build/mod.rs
+9
-10
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/expr.rs
+1
-1
src/librustc_mir/hair/mod.rs
src/librustc_mir/hair/mod.rs
+1
-2
src/librustc_mir/hair/pattern/check_match.rs
src/librustc_mir/hair/pattern/check_match.rs
+2
-2
src/librustc_mir/hair/pattern/mod.rs
src/librustc_mir/hair/pattern/mod.rs
+3
-3
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/lib.rs
+1
-1
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/_match.rs
+1
-1
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/mod.rs
+1
-1
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+1
-1
未找到文件。
src/librustc/hir/intravisit.rs
浏览文件 @
558a07b8
...
...
@@ -697,8 +697,8 @@ pub fn walk_pat<'v, V: Visitor<'v>>(visitor: &mut V, pattern: &'v Pat) {
PatKind
::
Ref
(
ref
subpattern
,
_
)
=>
{
visitor
.visit_pat
(
subpattern
)
}
PatKind
::
Binding
(
_
,
canonical_id
,
_
hir_id
,
ident
,
ref
optional_subpattern
)
=>
{
visitor
.visit_def_mention
(
Def
::
Local
(
canonical
_id
));
PatKind
::
Binding
(
_
,
_
hir_id
,
ident
,
ref
optional_subpattern
)
=>
{
// visitor.visit_def_mention(Def::Local(hir
_id));
visitor
.visit_ident
(
ident
);
walk_list!
(
visitor
,
visit_pat
,
optional_subpattern
);
}
...
...
src/librustc/hir/lowering.rs
浏览文件 @
558a07b8
...
...
@@ -3679,11 +3679,10 @@ fn lower_pat(&mut self, p: &Pat) -> P<hir::Pat> {
Some
(
Def
::
Local
(
id
))
=>
id
,
_
=>
p
.id
,
};
let
hir_id
=
self
.lower_node_id
(
canonical_id
)
.hir_id
;
hir
::
PatKind
::
Binding
(
self
.lower_binding_mode
(
binding_mode
),
canonical_id
,
hir_id
,
self
.lower_node_id
(
canonical_id
)
.hir_id
,
ident
,
sub
.as_ref
()
.map
(|
x
|
self
.lower_pat
(
x
)),
)
...
...
@@ -4985,7 +4984,7 @@ fn pat_ident_binding_mode(
(
P
(
hir
::
Pat
{
hir_id
,
node
:
hir
::
PatKind
::
Binding
(
bm
,
node_id
,
hir_id
,
ident
.with_span_pos
(
span
),
None
),
node
:
hir
::
PatKind
::
Binding
(
bm
,
hir_id
,
ident
.with_span_pos
(
span
),
None
),
span
,
}),
node_id
...
...
src/librustc/hir/map/mod.rs
浏览文件 @
558a07b8
...
...
@@ -1016,7 +1016,7 @@ pub fn name(&self, id: NodeId) -> Name {
Node
::
Field
(
f
)
=>
f
.ident.name
,
Node
::
Lifetime
(
lt
)
=>
lt
.name
.ident
()
.name
,
Node
::
GenericParam
(
param
)
=>
param
.name
.ident
()
.name
,
Node
::
Binding
(
&
Pat
{
node
:
PatKind
::
Binding
(
_
,
_
,
_
,
l
,
_
),
..
})
=>
l
.name
,
Node
::
Binding
(
&
Pat
{
node
:
PatKind
::
Binding
(
_
,
_
,
l
,
_
),
..
})
=>
l
.name
,
Node
::
StructCtor
(
_
)
=>
self
.name
(
self
.get_parent
(
id
)),
_
=>
bug!
(
"no name for {}"
,
self
.node_to_string
(
id
))
}
...
...
src/librustc/hir/mod.rs
浏览文件 @
558a07b8
...
...
@@ -936,10 +936,10 @@ pub enum PatKind {
Wild
,
/// A fresh binding `ref mut binding @ OPT_SUBPATTERN`.
/// The `
Node
Id` is the canonical ID for the variable being bound,
/// The `
Hir
Id` is the canonical ID for the variable being bound,
/// (e.g., in `Ok(x) | Err(x)`, both `x` use the same canonical ID),
/// which is the pattern ID of the first `x`.
Binding
(
BindingAnnotation
,
NodeId
,
HirId
,
Ident
,
Option
<
P
<
Pat
>>
),
Binding
(
BindingAnnotation
,
HirId
,
Ident
,
Option
<
P
<
Pat
>>
),
/// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
/// The `bool` is `true` in the presence of a `..`.
...
...
src/librustc/hir/pat_util.rs
浏览文件 @
558a07b8
...
...
@@ -70,7 +70,7 @@ pub fn each_binding<F>(&self, mut f: F)
where
F
:
FnMut
(
hir
::
BindingAnnotation
,
HirId
,
Span
,
ast
::
Ident
),
{
self
.walk
(|
p
|
{
if
let
PatKind
::
Binding
(
binding_mode
,
_
,
_
,
ident
,
_
)
=
p
.node
{
if
let
PatKind
::
Binding
(
binding_mode
,
_
,
ident
,
_
)
=
p
.node
{
f
(
binding_mode
,
p
.hir_id
,
p
.span
,
ident
);
}
true
...
...
@@ -110,8 +110,8 @@ pub fn contains_bindings_or_wild(&self) -> bool {
pub
fn
simple_ident
(
&
self
)
->
Option
<
ast
::
Ident
>
{
match
self
.node
{
PatKind
::
Binding
(
hir
::
BindingAnnotation
::
Unannotated
,
_
,
_
,
ident
,
None
)
|
PatKind
::
Binding
(
hir
::
BindingAnnotation
::
Mutable
,
_
,
_
,
ident
,
None
)
=>
Some
(
ident
),
PatKind
::
Binding
(
hir
::
BindingAnnotation
::
Unannotated
,
_
,
ident
,
None
)
|
PatKind
::
Binding
(
hir
::
BindingAnnotation
::
Mutable
,
_
,
ident
,
None
)
=>
Some
(
ident
),
_
=>
None
,
}
}
...
...
src/librustc/hir/print.rs
浏览文件 @
558a07b8
...
...
@@ -1765,7 +1765,7 @@ pub fn print_pat(&mut self, pat: &hir::Pat) -> io::Result<()> {
// is that it doesn't matter
match
pat
.node
{
PatKind
::
Wild
=>
self
.s
.word
(
"_"
)
?
,
PatKind
::
Binding
(
binding_mode
,
_
,
_
,
ident
,
ref
sub
)
=>
{
PatKind
::
Binding
(
binding_mode
,
_
,
ident
,
ref
sub
)
=>
{
match
binding_mode
{
hir
::
BindingAnnotation
::
Ref
=>
{
self
.word_nbsp
(
"ref"
)
?
;
...
...
src/librustc/ich/impls_hir.rs
浏览文件 @
558a07b8
...
...
@@ -448,7 +448,7 @@ fn hash_stable<W: StableHasherResult>(&self,
impl_stable_hash_for!
(
enum
hir
::
PatKind
{
Wild
,
Binding
(
binding_mode
,
var
,
hir_id
,
name
,
sub
),
Binding
(
binding_mode
,
hir_id
,
name
,
sub
),
Struct
(
path
,
field_pats
,
dotdot
),
TupleStruct
(
path
,
field_pats
,
dotdot
),
Path
(
path
),
...
...
src/librustc/middle/expr_use_visitor.rs
浏览文件 @
558a07b8
...
...
@@ -860,7 +860,7 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt<'tcx>, pat: &hir::Pat, match_mode: Mat
// Each match binding is effectively an assignment to the
// binding being produced.
let
def
=
Def
::
Local
(
canonical_id
);
let
def
=
Def
::
Local
(
mc
.tcx
.hir
()
.hir_to_node_id
(
canonical_id
)
);
if
let
Ok
(
ref
binding_cmt
)
=
mc
.cat_def
(
pat
.hir_id
,
pat
.span
,
pat_ty
,
def
)
{
delegate
.mutate
(
pat
.hir_id
,
pat
.span
,
binding_cmt
,
MutateMode
::
Init
);
}
...
...
src/librustc/middle/liveness.rs
浏览文件 @
558a07b8
...
...
@@ -407,7 +407,7 @@ fn add_from_pat<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, pat: &P<hir::Pat>) {
while
let
Some
(
pat
)
=
pats
.pop_front
()
{
use
crate
::
hir
::
PatKind
::
*
;
match
pat
.node
{
Binding
(
_
,
_
,
_
,
_
,
ref
inner_pat
)
=>
{
Binding
(
_
,
_
,
_
,
ref
inner_pat
)
=>
{
pats
.extend
(
inner_pat
.iter
());
}
Struct
(
_
,
ref
fields
,
_
)
=>
{
...
...
src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs
浏览文件 @
558a07b8
...
...
@@ -98,7 +98,7 @@ pub fn gather_move_from_pat<'a, 'c, 'tcx: 'c>(bccx: &BorrowckCtxt<'a, 'tcx>,
cmt
:
&
'c
mc
::
cmt_
<
'tcx
>
)
{
let
source
=
get_pattern_source
(
bccx
.tcx
,
move_pat
);
let
pat_span_path_opt
=
match
move_pat
.node
{
PatKind
::
Binding
(
_
,
_
,
_
,
ident
,
_
)
=>
{
PatKind
::
Binding
(
_
,
_
,
ident
,
_
)
=>
{
Some
(
MovePlace
{
span
:
move_pat
.span
,
name
:
ident
.name
,
...
...
src/librustc_lint/builtin.rs
浏览文件 @
558a07b8
...
...
@@ -198,7 +198,7 @@ fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat) {
// (Issue #49588)
continue
;
}
if
let
PatKind
::
Binding
(
_
,
_
,
_
,
ident
,
None
)
=
fieldpat
.node.pat.node
{
if
let
PatKind
::
Binding
(
_
,
_
,
ident
,
None
)
=
fieldpat
.node.pat.node
{
if
cx
.tcx
.find_field_index
(
ident
,
&
variant
)
==
Some
(
cx
.tcx
.field_index
(
fieldpat
.node.hir_id
,
cx
.tables
))
{
let
mut
err
=
cx
.struct_span_lint
(
NON_SHORTHAND_FIELD_PATTERNS
,
...
...
src/librustc_lint/nonstandard_style.rs
浏览文件 @
558a07b8
...
...
@@ -358,7 +358,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem)
}
fn
check_pat
(
&
mut
self
,
cx
:
&
LateContext
<
'_
,
'_
>
,
p
:
&
hir
::
Pat
)
{
if
let
&
PatKind
::
Binding
(
_
,
_
,
_
,
ident
,
_
)
=
&
p
.node
{
if
let
&
PatKind
::
Binding
(
_
,
_
,
ident
,
_
)
=
&
p
.node
{
self
.check_snake_case
(
cx
,
"variable"
,
&
ident
);
}
}
...
...
src/librustc_metadata/encoder.rs
浏览文件 @
558a07b8
...
...
@@ -978,7 +978,7 @@ fn encode_fn_arg_names_for_body(&mut self, body_id: hir::BodyId)
let
body
=
self
.tcx
.hir
()
.body
(
body_id
);
self
.lazy_seq
(
body
.arguments
.iter
()
.map
(|
arg
|
{
match
arg
.pat.node
{
PatKind
::
Binding
(
_
,
_
,
_
,
ident
,
_
)
=>
ident
.name
,
PatKind
::
Binding
(
_
,
_
,
ident
,
_
)
=>
ident
.name
,
_
=>
keywords
::
Invalid
.name
(),
}
}))
...
...
src/librustc_mir/borrow_check/mutability_errors.rs
浏览文件 @
558a07b8
...
...
@@ -314,7 +314,6 @@ pub(super) fn report_mutability_error(
if
let
hir
::
PatKind
::
Binding
(
hir
::
BindingAnnotation
::
Unannotated
,
_
,
_
,
upvar_ident
,
_
,
)
=
pat
.node
...
...
src/librustc_mir/build/matches/mod.rs
浏览文件 @
558a07b8
...
...
@@ -10,12 +10,13 @@
use
crate
::
build
::{
BlockAnd
,
BlockAndExtension
,
Builder
};
use
crate
::
build
::{
GuardFrame
,
GuardFrameLocal
,
LocalsForNode
};
use
crate
::
hair
::{
self
,
*
};
use
rustc
::
hir
::
HirId
;
use
rustc
::
mir
::
*
;
use
rustc
::
ty
::{
self
,
CanonicalUserTypeAnnotation
,
Ty
};
use
rustc
::
ty
::
layout
::
VariantIdx
;
use
rustc_data_structures
::
bit_set
::
BitSet
;
use
rustc_data_structures
::
fx
::{
FxHashMap
,
FxHashSet
};
use
syntax
::
ast
::
{
Name
,
NodeId
}
;
use
syntax
::
ast
::
Name
;
use
syntax_pos
::
Span
;
// helper functions, broken out by category:
...
...
@@ -530,7 +531,7 @@ pub fn declare_bindings(
pub
fn
storage_live_binding
(
&
mut
self
,
block
:
BasicBlock
,
var
:
Node
Id
,
var
:
Hir
Id
,
span
:
Span
,
for_guard
:
ForGuard
,
)
->
Place
<
'tcx
>
{
...
...
@@ -545,17 +546,15 @@ pub fn storage_live_binding(
);
let
place
=
Place
::
Base
(
PlaceBase
::
Local
(
local_id
));
let
var_ty
=
self
.local_decls
[
local_id
]
.ty
;
let
hir_id
=
self
.hir
.tcx
()
.hir
()
.node_to_hir_id
(
var
);
let
region_scope
=
self
.hir.region_scope_tree
.var_scope
(
hir_id
.local_id
);
let
region_scope
=
self
.hir.region_scope_tree
.var_scope
(
var
.local_id
);
self
.schedule_drop
(
span
,
region_scope
,
&
place
,
var_ty
,
DropKind
::
Storage
);
place
}
pub
fn
schedule_drop_for_binding
(
&
mut
self
,
var
:
Node
Id
,
span
:
Span
,
for_guard
:
ForGuard
)
{
pub
fn
schedule_drop_for_binding
(
&
mut
self
,
var
:
Hir
Id
,
span
:
Span
,
for_guard
:
ForGuard
)
{
let
local_id
=
self
.var_local_id
(
var
,
for_guard
);
let
var_ty
=
self
.local_decls
[
local_id
]
.ty
;
let
hir_id
=
self
.hir
.tcx
()
.hir
()
.node_to_hir_id
(
var
);
let
region_scope
=
self
.hir.region_scope_tree
.var_scope
(
hir_id
.local_id
);
let
region_scope
=
self
.hir.region_scope_tree
.var_scope
(
var
.local_id
);
self
.schedule_drop
(
span
,
region_scope
,
...
...
@@ -576,7 +575,7 @@ pub(super) fn visit_bindings(
Mutability
,
Name
,
BindingMode
,
Node
Id
,
Hir
Id
,
Span
,
Ty
<
'tcx
>
,
UserTypeProjections
<
'tcx
>
,
...
...
@@ -703,7 +702,7 @@ struct Binding<'tcx> {
span
:
Span
,
source
:
Place
<
'tcx
>
,
name
:
Name
,
var_id
:
Node
Id
,
var_id
:
Hir
Id
,
var_ty
:
Ty
<
'tcx
>
,
mutability
:
Mutability
,
binding_mode
:
BindingMode
,
...
...
@@ -1694,7 +1693,7 @@ fn declare_binding(
mutability
:
Mutability
,
name
:
Name
,
mode
:
BindingMode
,
var_id
:
Node
Id
,
var_id
:
Hir
Id
,
var_ty
:
Ty
<
'tcx
>
,
user_ty
:
UserTypeProjections
<
'tcx
>
,
has_guard
:
ArmHasGuard
,
...
...
src/librustc_mir/build/mod.rs
浏览文件 @
558a07b8
...
...
@@ -13,13 +13,12 @@
use
rustc
::
mir
::
visit
::{
MutVisitor
,
TyContext
};
use
rustc
::
ty
::{
self
,
Ty
,
TyCtxt
};
use
rustc
::
ty
::
subst
::
SubstsRef
;
use
rustc
::
util
::
nodemap
::
Node
Map
;
use
rustc
::
util
::
nodemap
::
HirId
Map
;
use
rustc_target
::
spec
::
PanicStrategy
;
use
rustc_data_structures
::
indexed_vec
::{
IndexVec
,
Idx
};
use
std
::
mem
;
use
std
::
u32
;
use
rustc_target
::
spec
::
abi
::
Abi
;
use
syntax
::
ast
;
use
syntax
::
attr
::{
self
,
UnwindAttr
};
use
syntax
::
symbol
::
keywords
;
use
syntax_pos
::
Span
;
...
...
@@ -376,7 +375,7 @@ struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
/// Maps `NodeId`s of variable bindings to the `Local`s created for them.
/// (A match binding can have two locals; the 2nd is for the arm's guard.)
var_indices
:
Node
Map
<
LocalsForNode
>
,
var_indices
:
HirId
Map
<
LocalsForNode
>
,
local_decls
:
IndexVec
<
Local
,
LocalDecl
<
'tcx
>>
,
canonical_user_type_annotations
:
ty
::
CanonicalUserTypeAnnotations
<
'tcx
>
,
upvar_decls
:
Vec
<
UpvarDecl
>
,
...
...
@@ -392,11 +391,11 @@ struct Builder<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
}
impl
<
'a
,
'gcx
,
'tcx
>
Builder
<
'a
,
'gcx
,
'tcx
>
{
fn
is_bound_var_in_guard
(
&
self
,
id
:
ast
::
Node
Id
)
->
bool
{
fn
is_bound_var_in_guard
(
&
self
,
id
:
hir
::
Hir
Id
)
->
bool
{
self
.guard_context
.iter
()
.any
(|
frame
|
frame
.locals
.iter
()
.any
(|
local
|
local
.id
==
id
))
}
fn
var_local_id
(
&
self
,
id
:
ast
::
Node
Id
,
for_guard
:
ForGuard
)
->
Local
{
fn
var_local_id
(
&
self
,
id
:
hir
::
Hir
Id
,
for_guard
:
ForGuard
)
->
Local
{
self
.var_indices
[
&
id
]
.local_id
(
for_guard
)
}
}
...
...
@@ -471,11 +470,11 @@ enum LocalsForNode {
#[derive(Debug)]
struct
GuardFrameLocal
{
id
:
ast
::
Node
Id
,
id
:
hir
::
Hir
Id
,
}
impl
GuardFrameLocal
{
fn
new
(
id
:
ast
::
Node
Id
,
_
binding_mode
:
BindingMode
)
->
Self
{
fn
new
(
id
:
hir
::
Hir
Id
,
_
binding_mode
:
BindingMode
)
->
Self
{
GuardFrameLocal
{
id
:
id
,
}
...
...
@@ -650,7 +649,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>,
mutability
:
Mutability
::
Not
,
};
if
let
Some
(
Node
::
Binding
(
pat
))
=
tcx_hir
.find
(
var_node_id
)
{
if
let
hir
::
PatKind
::
Binding
(
_
,
_
,
_
,
ident
,
_
)
=
pat
.node
{
if
let
hir
::
PatKind
::
Binding
(
_
,
_
,
ident
,
_
)
=
pat
.node
{
decl
.debug_name
=
ident
.name
;
if
let
Some
(
&
bm
)
=
hir
.tables
.pat_binding_modes
()
.get
(
pat
.hir_id
)
{
if
bm
==
ty
::
BindByValue
(
hir
::
MutMutable
)
{
...
...
@@ -855,8 +854,8 @@ fn args_and_body(&mut self,
let
mut
name
=
None
;
if
let
Some
(
pat
)
=
pattern
{
match
pat
.node
{
hir
::
PatKind
::
Binding
(
hir
::
BindingAnnotation
::
Unannotated
,
_
,
_
,
ident
,
_
)
|
hir
::
PatKind
::
Binding
(
hir
::
BindingAnnotation
::
Mutable
,
_
,
_
,
ident
,
_
)
=>
{
hir
::
PatKind
::
Binding
(
hir
::
BindingAnnotation
::
Unannotated
,
_
,
ident
,
_
)
|
hir
::
PatKind
::
Binding
(
hir
::
BindingAnnotation
::
Mutable
,
_
,
ident
,
_
)
=>
{
name
=
Some
(
ident
.name
);
}
_
=>
(),
...
...
src/librustc_mir/hair/cx/expr.rs
浏览文件 @
558a07b8
...
...
@@ -992,7 +992,7 @@ fn convert_var<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
let
temp_lifetime
=
cx
.region_scope_tree
.temporary_scope
(
expr
.hir_id.local_id
);
match
def
{
Def
::
Local
(
id
)
=>
ExprKind
::
VarRef
{
id
},
Def
::
Local
(
id
)
=>
ExprKind
::
VarRef
{
id
:
cx
.tcx
.hir
()
.node_to_hir_id
(
id
)
},
Def
::
Upvar
(
var_id
,
index
,
closure_expr_id
)
=>
{
debug!
(
"convert_var(upvar({:?}, {:?}, {:?}))"
,
...
...
src/librustc_mir/hair/mod.rs
浏览文件 @
558a07b8
...
...
@@ -12,7 +12,6 @@
use
rustc
::
ty
::{
AdtDef
,
UpvarSubsts
,
Ty
,
Const
,
LazyConst
,
UserType
};
use
rustc
::
ty
::
layout
::
VariantIdx
;
use
rustc
::
hir
;
use
syntax
::
ast
;
use
syntax_pos
::
Span
;
use
self
::
cx
::
Cx
;
...
...
@@ -230,7 +229,7 @@ pub enum ExprKind<'tcx> {
index
:
ExprRef
<
'tcx
>
,
},
VarRef
{
id
:
ast
::
Node
Id
,
id
:
hir
::
Hir
Id
,
},
/// first argument, used for self in a closure
SelfRef
,
...
...
src/librustc_mir/hair/pattern/check_match.rs
浏览文件 @
558a07b8
...
...
@@ -315,7 +315,7 @@ fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
fn
check_for_bindings_named_same_as_variants
(
cx
:
&
MatchVisitor
<
'_
,
'_
>
,
pat
:
&
Pat
)
{
pat
.walk
(|
p
|
{
if
let
PatKind
::
Binding
(
_
,
_
,
_
,
ident
,
None
)
=
p
.node
{
if
let
PatKind
::
Binding
(
_
,
_
,
ident
,
None
)
=
p
.node
{
if
let
Some
(
&
bm
)
=
cx
.tables
.pat_binding_modes
()
.get
(
p
.hir_id
)
{
if
bm
!=
ty
::
BindByValue
(
hir
::
MutImmutable
)
{
// Nothing to check.
...
...
@@ -590,7 +590,7 @@ fn check_legality_of_move_bindings(
for
pat
in
pats
{
pat
.walk
(|
p
|
{
if
let
PatKind
::
Binding
(
_
,
_
,
_
,
_
,
ref
sub
)
=
p
.node
{
if
let
PatKind
::
Binding
(
_
,
_
,
_
,
ref
sub
)
=
p
.node
{
if
let
Some
(
&
bm
)
=
cx
.tables
.pat_binding_modes
()
.get
(
p
.hir_id
)
{
match
bm
{
ty
::
BindByValue
(
..
)
=>
{
...
...
src/librustc_mir/hair/pattern/mod.rs
浏览文件 @
558a07b8
...
...
@@ -126,7 +126,7 @@ pub enum PatternKind<'tcx> {
mutability
:
Mutability
,
name
:
ast
::
Name
,
mode
:
BindingMode
,
var
:
ast
::
Node
Id
,
var
:
hir
::
Hir
Id
,
ty
:
Ty
<
'tcx
>
,
subpattern
:
Option
<
Pattern
<
'tcx
>>
,
},
...
...
@@ -559,7 +559,7 @@ fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> {
}
}
PatKind
::
Binding
(
_
,
id
,
_
,
ident
,
ref
sub
)
=>
{
PatKind
::
Binding
(
_
,
id
,
ident
,
ref
sub
)
=>
{
let
var_ty
=
self
.tables
.node_type
(
pat
.hir_id
);
if
let
ty
::
Error
=
var_ty
.sty
{
// Avoid ICE
...
...
@@ -1090,7 +1090,7 @@ fn super_fold_with<F: PatternFolder<$lt_tcx>>(&self, _: &mut F) -> Self {
}
CloneImpls!
{
<
'tcx
>
Span
,
Field
,
Mutability
,
ast
::
Name
,
ast
::
Node
Id
,
usize
,
ty
::
Const
<
'tcx
>
,
Span
,
Field
,
Mutability
,
ast
::
Name
,
hir
::
Hir
Id
,
usize
,
ty
::
Const
<
'tcx
>
,
Region
<
'tcx
>
,
Ty
<
'tcx
>
,
BindingMode
,
&
'tcx
AdtDef
,
SubstsRef
<
'tcx
>
,
&
'tcx
Kind
<
'tcx
>
,
UserType
<
'tcx
>
,
UserTypeProjection
<
'tcx
>
,
PatternTypeProjection
<
'tcx
>
...
...
src/librustc_save_analysis/lib.rs
浏览文件 @
558a07b8
...
...
@@ -647,7 +647,7 @@ pub fn get_path_def(&self, id: NodeId) -> HirDef {
Node
::
Binding
(
&
hir
::
Pat
{
node
:
hir
::
PatKind
::
Binding
(
_
,
canonical_id
,
..
),
..
})
=>
HirDef
::
Local
(
canonical_id
),
})
=>
HirDef
::
Local
(
self
.tcx
.hir
()
.hir_to_node_id
(
canonical_id
)
),
Node
::
Ty
(
ty
)
=>
if
let
hir
::
Ty
{
node
:
hir
::
TyKind
::
Path
(
ref
qpath
),
...
...
src/librustc_typeck/check/_match.rs
浏览文件 @
558a07b8
...
...
@@ -227,7 +227,7 @@ pub fn check_pat_walk(
self
.demand_eqtype_pat
(
pat
.span
,
expected
,
rhs_ty
,
match_discrim_span
);
common_type
}
PatKind
::
Binding
(
ba
,
_
,
var_id
,
_
,
ref
sub
)
=>
{
PatKind
::
Binding
(
ba
,
var_id
,
_
,
ref
sub
)
=>
{
let
bm
=
if
ba
==
hir
::
BindingAnnotation
::
Unannotated
{
def_bm
}
else
{
...
...
src/librustc_typeck/check/mod.rs
浏览文件 @
558a07b8
...
...
@@ -1004,7 +1004,7 @@ fn visit_local(&mut self, local: &'gcx hir::Local) {
// Add pattern bindings.
fn
visit_pat
(
&
mut
self
,
p
:
&
'gcx
hir
::
Pat
)
{
if
let
PatKind
::
Binding
(
_
,
_
,
_
,
ident
,
_
)
=
p
.node
{
if
let
PatKind
::
Binding
(
_
,
_
,
ident
,
_
)
=
p
.node
{
let
var_ty
=
self
.assign
(
p
.span
,
p
.hir_id
,
None
);
let
node_id
=
self
.fcx.tcx
.hir
()
.hir_to_node_id
(
p
.hir_id
);
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
558a07b8
...
...
@@ -3869,7 +3869,7 @@ fn name_from_pat(p: &hir::Pat) -> String {
match
p
.node
{
PatKind
::
Wild
=>
"_"
.to_string
(),
PatKind
::
Binding
(
_
,
_
,
_
,
ident
,
_
)
=>
ident
.to_string
(),
PatKind
::
Binding
(
_
,
_
,
ident
,
_
)
=>
ident
.to_string
(),
PatKind
::
TupleStruct
(
ref
p
,
..
)
|
PatKind
::
Path
(
ref
p
)
=>
qpath_to_string
(
p
),
PatKind
::
Struct
(
ref
name
,
ref
fields
,
etc
)
=>
{
format!
(
"{} {{ {}{} }}"
,
qpath_to_string
(
name
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录