Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
dfb7a811
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
dfb7a811
编写于
11月 07, 2014
作者:
A
Alexis Beingessner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fallout from deprecating find_copy and get_copy
上级
64efd265
变更
29
隐藏空白更改
内联
并排
Showing
29 changed file
with
92 addition
and
94 deletion
+92
-94
src/librustc/lint/builtin.rs
src/librustc/lint/builtin.rs
+2
-2
src/librustc/metadata/encoder.rs
src/librustc/metadata/encoder.rs
+1
-1
src/librustc/metadata/tydecode.rs
src/librustc/metadata/tydecode.rs
+1
-1
src/librustc/middle/astencode.rs
src/librustc/middle/astencode.rs
+1
-2
src/librustc/middle/borrowck/move_data.rs
src/librustc/middle/borrowck/move_data.rs
+2
-2
src/librustc/middle/check_match.rs
src/librustc/middle/check_match.rs
+4
-4
src/librustc/middle/const_eval.rs
src/librustc/middle/const_eval.rs
+3
-3
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/expr_use_visitor.rs
+2
-3
src/librustc/middle/liveness.rs
src/librustc/middle/liveness.rs
+3
-3
src/librustc/middle/privacy.rs
src/librustc/middle/privacy.rs
+7
-7
src/librustc/middle/resolve.rs
src/librustc/middle/resolve.rs
+10
-10
src/librustc/middle/stability.rs
src/librustc/middle/stability.rs
+1
-1
src/librustc/middle/trans/_match.rs
src/librustc/middle/trans/_match.rs
+2
-2
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/base.rs
+2
-2
src/librustc/middle/trans/common.rs
src/librustc/middle/trans/common.rs
+2
-2
src/librustc/middle/trans/consts.rs
src/librustc/middle/trans/consts.rs
+6
-6
src/librustc/middle/trans/context.rs
src/librustc/middle/trans/context.rs
+1
-1
src/librustc/middle/trans/debuginfo.rs
src/librustc/middle/trans/debuginfo.rs
+9
-9
src/librustc/middle/trans/expr.rs
src/librustc/middle/trans/expr.rs
+2
-2
src/librustc/middle/trans/meth.rs
src/librustc/middle/trans/meth.rs
+1
-1
src/librustc/middle/trans/type_of.rs
src/librustc/middle/trans/type_of.rs
+1
-1
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+12
-12
src/librustc/middle/typeck/check/_match.rs
src/librustc/middle/typeck/check/_match.rs
+4
-4
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+3
-3
src/librustc/middle/typeck/check/regionck.rs
src/librustc/middle/typeck/check/regionck.rs
+5
-5
src/librustc/middle/typeck/coherence/mod.rs
src/librustc/middle/typeck/coherence/mod.rs
+2
-2
src/librustc/middle/typeck/infer/region_inference/mod.rs
src/librustc/middle/typeck/infer/region_inference/mod.rs
+1
-1
src/libstd/collections/hash/map.rs
src/libstd/collections/hash/map.rs
+1
-1
src/libsyntax/ext/tt/transcribe.rs
src/libsyntax/ext/tt/transcribe.rs
+1
-1
未找到文件。
src/librustc/lint/builtin.rs
浏览文件 @
dfb7a811
...
...
@@ -391,7 +391,7 @@ struct ImproperCTypesVisitor<'a, 'tcx: 'a> {
impl
<
'a
,
'tcx
>
ImproperCTypesVisitor
<
'a
,
'tcx
>
{
fn
check_def
(
&
mut
self
,
sp
:
Span
,
ty_id
:
ast
::
NodeId
,
path_id
:
ast
::
NodeId
)
{
match
self
.cx.tcx.def_map
.borrow
()
.get_copy
(
&
path_id
)
{
match
self
.cx.tcx.def_map
.borrow
()
[
path_id
]
.clone
(
)
{
def
::
DefPrimTy
(
ast
::
TyInt
(
ast
::
TyI
))
=>
{
self
.cx
.span_lint
(
IMPROPER_CTYPES
,
sp
,
"found rust type `int` in foreign module, while
\
...
...
@@ -866,7 +866,7 @@ fn method_context(cx: &Context, m: &ast::Method) -> MethodContext {
node
:
m
.id
};
match
cx
.tcx.impl_or_trait_items
.borrow
()
.
find_copy
(
&
did
)
{
match
cx
.tcx.impl_or_trait_items
.borrow
()
.
get
(
&
did
)
.cloned
(
)
{
None
=>
cx
.sess
()
.span_bug
(
m
.span
,
"missing method descriptor?!"
),
Some
(
md
)
=>
{
match
md
{
...
...
src/librustc/metadata/encoder.rs
浏览文件 @
dfb7a811
...
...
@@ -1863,7 +1863,7 @@ fn visit_item(&mut self, item: &Item) {
match
item
.node
{
ItemImpl
(
_
,
Some
(
ref
trait_ref
),
_
,
_
)
=>
{
let
def_map
=
&
self
.ecx.tcx.def_map
;
let
trait_def
=
def_map
.borrow
()
.get_copy
(
&
trait_ref
.ref_id
);
let
trait_def
=
def_map
.borrow
()
[
trait_ref
.ref_id
]
.clone
(
);
let
def_id
=
trait_def
.def_id
();
// Load eagerly if this is an implementation of the Drop trait
...
...
src/librustc/metadata/tydecode.rs
浏览文件 @
dfb7a811
...
...
@@ -440,7 +440,7 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
pos
:
pos
,
len
:
len
};
match
st
.tcx.rcache
.borrow
()
.
find_copy
(
&
key
)
{
match
st
.tcx.rcache
.borrow
()
.
get
(
&
key
)
.cloned
(
)
{
Some
(
tt
)
=>
return
tt
,
None
=>
{}
}
...
...
src/librustc/middle/astencode.rs
浏览文件 @
dfb7a811
...
...
@@ -1200,8 +1200,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
var_id
:
var_id
,
closure_expr_id
:
id
};
let
upvar_borrow
=
tcx
.upvar_borrow_map
.borrow
()
.get_copy
(
&
upvar_id
);
let
upvar_borrow
=
tcx
.upvar_borrow_map
.borrow
()[
upvar_id
]
.clone
();
var_id
.encode
(
rbml_w
);
upvar_borrow
.encode
(
rbml_w
);
})
...
...
src/librustc/middle/borrowck/move_data.rs
浏览文件 @
dfb7a811
...
...
@@ -295,7 +295,7 @@ pub fn move_path(&self,
fn
existing_move_path
(
&
self
,
lp
:
&
Rc
<
LoanPath
>
)
->
Option
<
MovePathIndex
>
{
self
.path_map
.borrow
()
.
find_copy
(
lp
)
self
.path_map
.borrow
()
.
get
(
lp
)
.cloned
(
)
}
fn
existing_base_paths
(
&
self
,
lp
:
&
Rc
<
LoanPath
>
)
...
...
@@ -312,7 +312,7 @@ fn add_existing_base_paths(&self, lp: &Rc<LoanPath>,
* paths of `lp` to `result`, but does not add new move paths
*/
match
self
.path_map
.borrow
()
.
find_copy
(
lp
)
{
match
self
.path_map
.borrow
()
.
get
(
lp
)
.cloned
(
)
{
Some
(
index
)
=>
{
self
.each_base_path
(
index
,
|
p
|
{
result
.push
(
p
);
...
...
src/librustc/middle/check_match.rs
浏览文件 @
dfb7a811
...
...
@@ -360,7 +360,7 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> {
fn
fold_pat
(
&
mut
self
,
pat
:
P
<
Pat
>
)
->
P
<
Pat
>
{
match
pat
.node
{
PatIdent
(
..
)
|
PatEnum
(
..
)
=>
{
let
def
=
self
.tcx.def_map
.borrow
()
.
find_copy
(
&
pat
.id
);
let
def
=
self
.tcx.def_map
.borrow
()
.
get
(
&
pat
.id
)
.cloned
(
);
match
def
{
Some
(
DefConst
(
did
))
=>
match
lookup_const_by_id
(
self
.tcx
,
did
)
{
Some
(
const_expr
)
=>
{
...
...
@@ -753,7 +753,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
Some
(
Vec
::
from_elem
(
arity
,
DUMMY_WILD_PAT
)),
&
PatIdent
(
_
,
_
,
_
)
=>
{
let
opt_def
=
cx
.tcx.def_map
.borrow
()
.
find_copy
(
&
pat_id
);
let
opt_def
=
cx
.tcx.def_map
.borrow
()
.
get
(
&
pat_id
)
.cloned
(
);
match
opt_def
{
Some
(
DefConst
(
..
))
=>
cx
.tcx.sess
.span_bug
(
pat_span
,
"const pattern should've
\
...
...
@@ -768,7 +768,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
}
&
PatEnum
(
_
,
ref
args
)
=>
{
let
def
=
cx
.tcx.def_map
.borrow
()
.get_copy
(
&
pat_id
);
let
def
=
cx
.tcx.def_map
.borrow
()
[
pat_id
]
.clone
(
);
match
def
{
DefConst
(
..
)
=>
cx
.tcx.sess
.span_bug
(
pat_span
,
"const pattern should've
\
...
...
@@ -786,7 +786,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
&
PatStruct
(
_
,
ref
pattern_fields
,
_
)
=>
{
// Is this a struct or an enum variant?
let
def
=
cx
.tcx.def_map
.borrow
()
.get_copy
(
&
pat_id
);
let
def
=
cx
.tcx.def_map
.borrow
()
[
pat_id
]
.clone
(
);
let
class_id
=
match
def
{
DefConst
(
..
)
=>
cx
.tcx.sess
.span_bug
(
pat_span
,
"const pattern should've
\
...
...
src/librustc/middle/const_eval.rs
浏览文件 @
dfb7a811
...
...
@@ -85,7 +85,7 @@ pub fn join_all<It: Iterator<constness>>(mut cs: It) -> constness {
}
fn
lookup_const
<
'a
>
(
tcx
:
&
'a
ty
::
ctxt
,
e
:
&
Expr
)
->
Option
<&
'a
Expr
>
{
let
opt_def
=
tcx
.def_map
.borrow
()
.
find_copy
(
&
e
.id
);
let
opt_def
=
tcx
.def_map
.borrow
()
.
get
(
&
e
.id
)
.cloned
(
);
match
opt_def
{
Some
(
def
::
DefConst
(
def_id
))
=>
{
lookup_const_by_id
(
tcx
,
def_id
)
...
...
@@ -321,7 +321,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr) -> P<Pat> {
PatTup
(
exprs
.iter
()
.map
(|
expr
|
const_expr_to_pat
(
tcx
,
&**
expr
))
.collect
()),
ExprCall
(
ref
callee
,
ref
args
)
=>
{
let
def
=
tcx
.def_map
.borrow
()
.get_copy
(
&
callee
.id
);
let
def
=
tcx
.def_map
.borrow
()
[
callee
.id
]
.clone
(
);
match
tcx
.def_map
.borrow_mut
()
.entry
(
expr
.id
)
{
Vacant
(
entry
)
=>
{
entry
.set
(
def
);
}
_
=>
{}
...
...
@@ -353,7 +353,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr) -> P<Pat> {
}
ExprPath
(
ref
path
)
=>
{
let
opt_def
=
tcx
.def_map
.borrow
()
.
find_copy
(
&
expr
.id
);
let
opt_def
=
tcx
.def_map
.borrow
()
.
get
(
&
expr
.id
)
.cloned
(
);
match
opt_def
{
Some
(
def
::
DefStruct
(
..
))
=>
PatStruct
(
path
.clone
(),
vec!
[],
false
),
...
...
src/librustc/middle/expr_use_visitor.rs
浏览文件 @
dfb7a811
...
...
@@ -850,7 +850,7 @@ fn walk_pat(&mut self, cmt_discr: mc::cmt, pat: &ast::Pat) {
// Each match binding is effectively an assignment to the
// binding being produced.
let
def
=
def_map
.borrow
()
.get_copy
(
&
pat
.id
);
let
def
=
def_map
.borrow
()
[
pat
.id
]
.clone
(
);
match
mc
.cat_def
(
pat
.id
,
pat
.span
,
pat_ty
,
def
)
{
Ok
(
binding_cmt
)
=>
{
delegate
.mutate
(
pat
.id
,
pat
.span
,
binding_cmt
,
Init
);
...
...
@@ -957,8 +957,7 @@ fn walk_by_ref_captures(&mut self,
// inferred by regionbk
let
upvar_id
=
ty
::
UpvarId
{
var_id
:
id_var
,
closure_expr_id
:
closure_expr
.id
};
let
upvar_borrow
=
self
.tcx
()
.upvar_borrow_map
.borrow
()
.get_copy
(
&
upvar_id
);
let
upvar_borrow
=
self
.tcx
()
.upvar_borrow_map
.borrow
()[
upvar_id
]
.clone
();
self
.delegate
.borrow
(
closure_expr
.id
,
closure_expr
.span
,
...
...
src/librustc/middle/liveness.rs
浏览文件 @
dfb7a811
...
...
@@ -449,7 +449,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
match
expr
.node
{
// live nodes required for uses or definitions of variables:
ExprPath
(
_
)
=>
{
let
def
=
ir
.tcx.def_map
.borrow
()
.get_copy
(
&
expr
.id
);
let
def
=
ir
.tcx.def_map
.borrow
()
[
expr
.id
]
.clone
(
);
debug!
(
"expr {}: path that leads to {}"
,
expr
.id
,
def
);
match
def
{
DefLocal
(
..
)
=>
ir
.add_live_node_for_node
(
expr
.id
,
ExprNode
(
expr
.span
)),
...
...
@@ -1316,7 +1316,7 @@ fn write_lvalue(&mut self, expr: &Expr, succ: LiveNode, acc: uint)
fn
access_path
(
&
mut
self
,
expr
:
&
Expr
,
succ
:
LiveNode
,
acc
:
uint
)
->
LiveNode
{
match
self
.ir.tcx.def_map
.borrow
()
.get_copy
(
&
expr
.id
)
{
match
self
.ir.tcx.def_map
.borrow
()
[
expr
.id
]
.clone
(
)
{
DefLocal
(
nid
)
=>
{
let
ln
=
self
.live_node
(
expr
.id
,
expr
.span
);
if
acc
!=
0u
{
...
...
@@ -1582,7 +1582,7 @@ fn check_ret(&self,
fn
check_lvalue
(
&
mut
self
,
expr
:
&
Expr
)
{
match
expr
.node
{
ExprPath
(
_
)
=>
{
match
self
.ir.tcx.def_map
.borrow
()
.get_copy
(
&
expr
.id
)
{
match
self
.ir.tcx.def_map
.borrow
()
[
expr
.id
]
.clone
(
)
{
DefLocal
(
nid
)
=>
{
// Assignment to an immutable variable or argument: only legal
// if there is no later assignment. If this local is actually
...
...
src/librustc/middle/privacy.rs
浏览文件 @
dfb7a811
...
...
@@ -245,7 +245,7 @@ fn visit_item(&mut self, item: &ast::Item) {
ast
::
ItemImpl
(
_
,
_
,
ref
ty
,
ref
impl_items
)
=>
{
let
public_ty
=
match
ty
.node
{
ast
::
TyPath
(
_
,
_
,
id
)
=>
{
match
self
.tcx.def_map
.borrow
()
.get_copy
(
&
id
)
{
match
self
.tcx.def_map
.borrow
()
[
id
]
.clone
(
)
{
def
::
DefPrimTy
(
..
)
=>
true
,
def
=>
{
let
did
=
def
.def_id
();
...
...
@@ -313,7 +313,7 @@ fn visit_item(&mut self, item: &ast::Item) {
ast
::
ItemTy
(
ref
ty
,
_
)
if
public_first
=>
{
match
ty
.node
{
ast
::
TyPath
(
_
,
_
,
id
)
=>
{
match
self
.tcx.def_map
.borrow
()
.get_copy
(
&
id
)
{
match
self
.tcx.def_map
.borrow
()
[
id
]
.clone
(
)
{
def
::
DefPrimTy
(
..
)
|
def
::
DefTyParam
(
..
)
=>
{},
def
=>
{
let
did
=
def
.def_id
();
...
...
@@ -620,7 +620,7 @@ fn ensure_public(&self, span: Span, to_check: ast::DefId,
ast
::
TyPath
(
_
,
_
,
id
)
=>
id
,
_
=>
return
Some
((
err_span
,
err_msg
,
None
)),
};
let
def
=
self
.tcx.def_map
.borrow
()
.get_copy
(
&
id
);
let
def
=
self
.tcx.def_map
.borrow
()
[
id
]
.clone
(
);
let
did
=
def
.def_id
();
assert
!
(
is_local
(
did
));
match
self
.tcx.map
.get
(
did
.node
)
{
...
...
@@ -706,7 +706,7 @@ fn check_static_method(&mut self,
// Checks that a path is in scope.
fn
check_path
(
&
mut
self
,
span
:
Span
,
path_id
:
ast
::
NodeId
,
path
:
&
ast
::
Path
)
{
debug!
(
"privacy - path {}"
,
self
.nodestr
(
path_id
));
let
orig_def
=
self
.tcx.def_map
.borrow
()
.get_copy
(
&
path_id
);
let
orig_def
=
self
.tcx.def_map
.borrow
()
[
path_id
]
.clone
(
);
let
ck
=
|
tyname
:
&
str
|
{
let
ck_public
=
|
def
:
ast
::
DefId
|
{
let
name
=
token
::
get_ident
(
path
.segments
...
...
@@ -789,7 +789,7 @@ fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) {
// def map is not. Therefore the names we work out below will not always
// be accurate and we can get slightly wonky error messages (but type
// checking is always correct).
match
self
.tcx.def_map
.borrow
()
.get_copy
(
&
path_id
)
{
match
self
.tcx.def_map
.borrow
()
[
path_id
]
.clone
(
)
{
def
::
DefStaticMethod
(
..
)
=>
ck
(
"static method"
),
def
::
DefFn
(
..
)
=>
ck
(
"function"
),
def
::
DefStatic
(
..
)
=>
ck
(
"static"
),
...
...
@@ -873,7 +873,7 @@ fn visit_expr(&mut self, expr: &ast::Expr) {
}
}
ty
::
ty_enum
(
_
,
_
)
=>
{
match
self
.tcx.def_map
.borrow
()
.get_copy
(
&
expr
.id
)
{
match
self
.tcx.def_map
.borrow
()
[
expr
.id
]
.clone
(
)
{
def
::
DefVariant
(
_
,
variant_id
,
_
)
=>
{
for
field
in
fields
.iter
()
{
self
.check_field
(
expr
.span
,
variant_id
,
...
...
@@ -1254,7 +1254,7 @@ struct CheckTypeForPrivatenessVisitor<'a, 'b: 'a, 'tcx: 'b> {
impl
<
'a
,
'tcx
>
VisiblePrivateTypesVisitor
<
'a
,
'tcx
>
{
fn
path_is_private_type
(
&
self
,
path_id
:
ast
::
NodeId
)
->
bool
{
let
did
=
match
self
.tcx.def_map
.borrow
()
.
find_copy
(
&
path_id
)
{
let
did
=
match
self
.tcx.def_map
.borrow
()
.
get
(
&
path_id
)
.cloned
(
)
{
// `int` etc. (None doesn't seem to occur.)
None
|
Some
(
def
::
DefPrimTy
(
..
))
=>
return
false
,
Some
(
def
)
=>
def
.def_id
()
...
...
src/librustc/middle/resolve.rs
浏览文件 @
dfb7a811
...
...
@@ -1097,7 +1097,7 @@ fn add_child(&self,
sp
);
// Add or reuse the child.
let
child
=
module_
.children
.borrow
()
.
find_copy
(
&
name
);
let
child
=
module_
.children
.borrow
()
.
get
(
&
name
)
.cloned
(
);
match
child
{
None
=>
{
let
child
=
Rc
::
new
(
NameBindings
::
new
());
...
...
@@ -1381,7 +1381,7 @@ fn build_reduced_graph_for_item(&mut self,
let
mod_name
=
path
.segments
.last
()
.unwrap
()
.identifier.name
;
let
parent_opt
=
parent
.module
()
.children
.borrow
()
.
find_copy
(
&
mod_name
);
.
get
(
&
mod_name
)
.cloned
(
);
let
new_parent
=
match
parent_opt
{
// It already exists
Some
(
ref
child
)
if
child
.get_module_if_available
()
...
...
@@ -2676,7 +2676,7 @@ fn get_binding(this: &mut Resolver,
BoundResult
(
..
)
=>
{}
_
=>
{
match
containing_module
.external_module_children
.borrow_mut
()
.
find_copy
(
&
source
)
{
.
get
(
&
source
)
.cloned
(
)
{
None
=>
{}
// Continue.
Some
(
module
)
=>
{
debug!
(
"(resolving single import) found external
\
...
...
@@ -3191,7 +3191,7 @@ fn resolve_module_path_from_root(&mut self,
fn
search_parent_externals
(
needle
:
Name
,
module
:
&
Rc
<
Module
>
)
->
Option
<
Rc
<
Module
>>
{
module
.external_module_children
.borrow
()
.
find_copy
(
&
needle
)
.
get
(
&
needle
)
.cloned
(
)
.map
(|
_
|
module
.clone
())
.or_else
(||
{
match
module
.parent_link
.clone
()
{
...
...
@@ -3478,7 +3478,7 @@ fn resolve_item_in_lexical_scope(&mut self,
// Search for external modules.
if
namespace
==
TypeNS
{
match
module_
.external_module_children
.borrow
()
.
find_copy
(
&
name
)
{
match
module_
.external_module_children
.borrow
()
.
get
(
&
name
)
.cloned
(
)
{
None
=>
{}
Some
(
module
)
=>
{
let
name_bindings
=
...
...
@@ -3763,7 +3763,7 @@ fn resolve_name_in_module(&mut self,
// Finally, search through external children.
if
namespace
==
TypeNS
{
match
module_
.external_module_children
.borrow
()
.
find_copy
(
&
name
)
{
match
module_
.external_module_children
.borrow
()
.
get
(
&
name
)
.cloned
(
)
{
None
=>
{}
Some
(
module
)
=>
{
let
name_bindings
=
...
...
@@ -4043,7 +4043,7 @@ fn upvarify(&self,
// item, it's ok
match
def
{
DefTyParam
(
_
,
did
,
_
)
if
{
self
.def_map
.borrow
()
.
find_copy
(
&
did
.node
)
self
.def_map
.borrow
()
.
get
(
&
did
.node
)
.cloned
(
)
==
Some
(
DefTyParamBinder
(
item_id
))
}
=>
{}
// ok
DefSelfTy
(
did
)
if
did
==
item_id
=>
{}
// ok
...
...
@@ -4096,7 +4096,7 @@ fn upvarify(&self,
// item, it's ok
match
def
{
DefTyParam
(
_
,
did
,
_
)
if
{
self
.def_map
.borrow
()
.
find_copy
(
&
did
.node
)
self
.def_map
.borrow
()
.
get
(
&
did
.node
)
.cloned
(
)
==
Some
(
DefTyParamBinder
(
item_id
))
}
=>
{}
// ok
DefSelfTy
(
did
)
if
did
==
item_id
=>
{}
// ok
...
...
@@ -4148,7 +4148,7 @@ fn search_ribs(&self,
// FIXME #4950: Try caching?
for
(
i
,
rib
)
in
ribs
.iter
()
.enumerate
()
.rev
()
{
match
rib
.bindings
.
find_copy
(
&
name
)
{
match
rib
.bindings
.
get
(
&
name
)
.cloned
(
)
{
Some
(
def_like
)
=>
{
return
self
.upvarify
(
ribs
[
i
+
1
..
],
def_like
,
span
);
}
...
...
@@ -5440,7 +5440,7 @@ fn resolve_definition_of_name_in_module(&mut self,
// Finally, search through external children.
if
namespace
==
TypeNS
{
match
containing_module
.external_module_children
.borrow
()
.
find_copy
(
&
name
)
{
.
get
(
&
name
)
.cloned
(
)
{
None
=>
{}
Some
(
module
)
=>
{
match
module
.def_id
.get
()
{
...
...
src/librustc/middle/stability.rs
浏览文件 @
dfb7a811
...
...
@@ -139,7 +139,7 @@ pub fn lookup(tcx: &ty::ctxt, id: DefId) -> Option<Stability> {
lookup
(
tcx
,
trait_method_id
)
}
_
if
is_local
(
id
)
=>
{
tcx
.stability
.borrow
()
.local
.
find_copy
(
&
id
.node
)
tcx
.stability
.borrow
()
.local
.
get
(
&
id
.node
)
.cloned
(
)
}
_
=>
{
let
stab
=
csearch
::
get_stability
(
&
tcx
.sess.cstore
,
id
);
...
...
src/librustc/middle/trans/_match.rs
浏览文件 @
dfb7a811
...
...
@@ -568,7 +568,7 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
ast
::
PatLit
(
ref
l
)
=>
ConstantValue
(
ConstantExpr
(
&**
l
)),
ast
::
PatIdent
(
..
)
|
ast
::
PatEnum
(
..
)
|
ast
::
PatStruct
(
..
)
=>
{
// This is either an enum variant or a variable binding.
let
opt_def
=
tcx
.def_map
.borrow
()
.
find_copy
(
&
cur
.id
);
let
opt_def
=
tcx
.def_map
.borrow
()
.
get
(
&
cur
.id
)
.cloned
(
);
match
opt_def
{
Some
(
def
::
DefVariant
(
enum_id
,
var_id
,
_
))
=>
{
let
variant
=
ty
::
enum_variant_with_id
(
tcx
,
enum_id
,
var_id
);
...
...
@@ -1642,7 +1642,7 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
}
ast
::
PatEnum
(
_
,
ref
sub_pats
)
=>
{
let
opt_def
=
bcx
.tcx
()
.def_map
.borrow
()
.
find_copy
(
&
pat
.id
);
let
opt_def
=
bcx
.tcx
()
.def_map
.borrow
()
.
get
(
&
pat
.id
)
.cloned
(
);
match
opt_def
{
Some
(
def
::
DefVariant
(
enum_id
,
var_id
,
_
))
=>
{
let
repr
=
adt
::
represent_node
(
bcx
,
pat
.id
);
...
...
src/librustc/middle/trans/base.rs
浏览文件 @
dfb7a811
...
...
@@ -2274,7 +2274,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
static"
);
}
let
v
=
ccx
.static_values
()
.borrow
()
.get_copy
(
&
item
.id
);
let
v
=
ccx
.static_values
()
.borrow
()
[
item
.id
]
.clone
(
);
unsafe
{
if
!
(
llvm
::
LLVMConstIntGetZExtValue
(
v
)
!=
0
)
{
ccx
.sess
()
.span_fatal
(
expr
.span
,
"static assertion failed"
);
...
...
@@ -2666,7 +2666,7 @@ fn contains_null(s: &str) -> bool {
pub
fn
get_item_val
(
ccx
:
&
CrateContext
,
id
:
ast
::
NodeId
)
->
ValueRef
{
debug!
(
"get_item_val(id=`{}`)"
,
id
);
match
ccx
.item_vals
()
.borrow
()
.
find_copy
(
&
id
)
{
match
ccx
.item_vals
()
.borrow
()
.
get
(
&
id
)
.cloned
(
)
{
Some
(
v
)
=>
return
v
,
None
=>
{}
}
...
...
src/librustc/middle/trans/common.rs
浏览文件 @
dfb7a811
...
...
@@ -526,12 +526,12 @@ fn unboxed_closures<'a>(&'a self)
}
fn
upvar_borrow
(
&
self
,
upvar_id
:
ty
::
UpvarId
)
->
ty
::
UpvarBorrow
{
self
.tcx
()
.upvar_borrow_map
.borrow
()
.get_copy
(
&
upvar_id
)
self
.tcx
()
.upvar_borrow_map
.borrow
()
[
upvar_id
]
.clone
(
)
}
fn
capture_mode
(
&
self
,
closure_expr_id
:
ast
::
NodeId
)
->
ast
::
CaptureClause
{
self
.tcx
()
.capture_modes
.borrow
()
.get_copy
(
&
closure_expr_id
)
self
.tcx
()
.capture_modes
.borrow
()
[
closure_expr_id
]
.clone
(
)
}
}
...
...
src/librustc/middle/trans/consts.rs
浏览文件 @
dfb7a811
...
...
@@ -185,7 +185,7 @@ pub fn get_const_val(cx: &CrateContext,
}
}
cx
.const_values
()
.borrow
()
.get_copy
(
&
def_id
.node
)
cx
.const_values
()
.borrow
()
[
def_id
.node
]
.clone
(
)
}
pub
fn
const_expr
(
cx
:
&
CrateContext
,
e
:
&
ast
::
Expr
)
->
(
ValueRef
,
ty
::
t
)
{
...
...
@@ -193,7 +193,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, ty::t) {
let
mut
llconst
=
llconst
;
let
ety
=
ty
::
expr_ty
(
cx
.tcx
(),
e
);
let
mut
ety_adjusted
=
ty
::
expr_ty_adjusted
(
cx
.tcx
(),
e
);
let
opt_adj
=
cx
.tcx
()
.adjustments
.borrow
()
.
find_copy
(
&
e
.id
);
let
opt_adj
=
cx
.tcx
()
.adjustments
.borrow
()
.
get
(
&
e
.id
)
.cloned
(
);
match
opt_adj
{
None
=>
{
}
Some
(
adj
)
=>
{
...
...
@@ -552,7 +552,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
_
=>
break
,
}
}
let
opt_def
=
cx
.tcx
()
.def_map
.borrow
()
.
find_copy
(
&
cur
.id
);
let
opt_def
=
cx
.tcx
()
.def_map
.borrow
()
.
get
(
&
cur
.id
)
.cloned
(
);
match
opt_def
{
Some
(
def
::
DefStatic
(
def_id
,
_
))
=>
{
let
ty
=
ty
::
expr_ty
(
cx
.tcx
(),
e
);
...
...
@@ -627,7 +627,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
// Assert that there are no type parameters in this path.
assert
!
(
pth
.segments
.iter
()
.all
(|
seg
|
!
seg
.parameters
.has_types
()));
let
opt_def
=
cx
.tcx
()
.def_map
.borrow
()
.
find_copy
(
&
e
.id
);
let
opt_def
=
cx
.tcx
()
.def_map
.borrow
()
.
get
(
&
e
.id
)
.cloned
(
);
match
opt_def
{
Some
(
def
::
DefFn
(
def_id
,
_
))
=>
{
if
!
ast_util
::
is_local
(
def_id
)
{
...
...
@@ -661,7 +661,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
}
}
ast
::
ExprCall
(
ref
callee
,
ref
args
)
=>
{
let
opt_def
=
cx
.tcx
()
.def_map
.borrow
()
.
find_copy
(
&
callee
.id
);
let
opt_def
=
cx
.tcx
()
.def_map
.borrow
()
.
get
(
&
callee
.id
)
.cloned
(
);
match
opt_def
{
Some
(
def
::
DefStruct
(
_
))
=>
{
let
ety
=
ty
::
expr_ty
(
cx
.tcx
(),
e
);
...
...
@@ -703,7 +703,7 @@ pub fn trans_static(ccx: &CrateContext, m: ast::Mutability, id: ast::NodeId) {
let
g
=
base
::
get_item_val
(
ccx
,
id
);
// At this point, get_item_val has already translated the
// constant's initializer to determine its LLVM type.
let
v
=
ccx
.static_values
()
.borrow
()
.get_copy
(
&
id
);
let
v
=
ccx
.static_values
()
.borrow
()
[
id
]
.clone
(
);
// boolean SSA values are i1, but they have to be stored in i8 slots,
// otherwise some LLVM optimization passes don't work as expected
let
v
=
if
llvm
::
LLVMTypeOf
(
v
)
==
Type
::
i1
(
ccx
)
.to_ref
()
{
...
...
src/librustc/middle/trans/context.rs
浏览文件 @
dfb7a811
...
...
@@ -519,7 +519,7 @@ pub fn tydesc_type(&self) -> Type {
}
pub
fn
get_intrinsic
(
&
self
,
key
:
&
&
'static
str
)
->
ValueRef
{
match
self
.intrinsics
()
.borrow
()
.
find_copy
(
key
)
{
match
self
.intrinsics
()
.borrow
()
.
get
(
key
)
.cloned
(
)
{
Some
(
v
)
=>
return
v
,
_
=>
{}
}
...
...
src/librustc/middle/trans/debuginfo.rs
浏览文件 @
dfb7a811
...
...
@@ -301,11 +301,11 @@ fn register_unique_id_with_metadata(&mut self,
}
fn
find_metadata_for_type
(
&
self
,
type_
:
ty
::
t
)
->
Option
<
DIType
>
{
self
.type_to_metadata
.
find_copy
(
&
type_
)
self
.type_to_metadata
.
get
(
&
type_
)
.cloned
(
)
}
fn
find_metadata_for_unique_id
(
&
self
,
unique_type_id
:
UniqueTypeId
)
->
Option
<
DIType
>
{
self
.unique_id_to_metadata
.
find_copy
(
&
unique_type_id
)
self
.unique_id_to_metadata
.
get
(
&
unique_type_id
)
.cloned
(
)
}
// Get the string representation of a UniqueTypeId. This method will fail if
...
...
@@ -341,7 +341,7 @@ fn get_unique_type_id_of_type(&mut self, cx: &CrateContext, type_: ty::t) -> Uni
// unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
// gc box -> {GC_BOX<:pointee-uid:>}
match
self
.type_to_unique_id
.
find_copy
(
&
type_
)
{
match
self
.type_to_unique_id
.
get
(
&
type_
)
.cloned
(
)
{
Some
(
unique_type_id
)
=>
return
unique_type_id
,
None
=>
{
/* generate one */
}
};
...
...
@@ -497,7 +497,7 @@ fn from_def_id_and_substs(type_map: &mut TypeMap,
// First, find out the 'real' def_id of the type. Items inlined from
// other crates have to be mapped back to their source.
let
source_def_id
=
if
def_id
.krate
==
ast
::
LOCAL_CRATE
{
match
cx
.external_srcs
()
.borrow
()
.
find_copy
(
&
def_id
.node
)
{
match
cx
.external_srcs
()
.borrow
()
.
get
(
&
def_id
.node
)
.cloned
(
)
{
Some
(
source_def_id
)
=>
{
// The given def_id identifies the inlined copy of a
// type definition, let's take the source of the copy.
...
...
@@ -851,7 +851,7 @@ pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) {
pat_util
::
pat_bindings
(
def_map
,
&*
local
.pat
,
|
_
,
node_id
,
span
,
path1
|
{
let
var_ident
=
path1
.node
;
let
datum
=
match
bcx
.fcx.lllocals
.borrow
()
.
find_copy
(
&
node_id
)
{
let
datum
=
match
bcx
.fcx.lllocals
.borrow
()
.
get
(
&
node_id
)
.cloned
(
)
{
Some
(
datum
)
=>
datum
,
None
=>
{
bcx
.sess
()
.span_bug
(
span
,
...
...
@@ -1014,7 +1014,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
let
scope_metadata
=
bcx
.fcx.debug_context
.get_ref
(
cx
,
arg
.pat.span
)
.fn_metadata
;
pat_util
::
pat_bindings
(
def_map
,
&*
arg
.pat
,
|
_
,
node_id
,
span
,
path1
|
{
let
llarg
=
match
bcx
.fcx.lllocals
.borrow
()
.
find_copy
(
&
node_id
)
{
let
llarg
=
match
bcx
.fcx.lllocals
.borrow
()
.
get
(
&
node_id
)
.cloned
(
)
{
Some
(
v
)
=>
v
,
None
=>
{
bcx
.sess
()
.span_bug
(
span
,
...
...
@@ -1706,7 +1706,7 @@ fn scope_metadata(fcx: &FunctionContext,
let
scope_map
=
&
fcx
.debug_context
.get_ref
(
fcx
.ccx
,
error_reporting_span
)
.scope_map
;
match
scope_map
.borrow
()
.
find_copy
(
&
node_id
)
{
match
scope_map
.borrow
()
.
get
(
&
node_id
)
.cloned
(
)
{
Some
(
scope_metadata
)
=>
scope_metadata
,
None
=>
{
let
node
=
fcx
.ccx
.tcx
()
.map
.get
(
node_id
);
...
...
@@ -2415,7 +2415,7 @@ fn prepare_enum_metadata(cx: &CrateContext,
// this cache.
let
cached_discriminant_type_metadata
=
debug_context
(
cx
)
.created_enum_disr_types
.borrow
()
.
find_copy
(
&
enum_def_id
);
.
get
(
&
enum_def_id
)
.cloned
(
);
match
cached_discriminant_type_metadata
{
Some
(
discriminant_type_metadata
)
=>
discriminant_type_metadata
,
None
=>
{
...
...
@@ -3982,7 +3982,7 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree
current_key
.push
(
name
);
let
existing_node
=
debug_context
(
cx
)
.namespace_map
.borrow
()
.
find_copy
(
&
current_key
);
.
get
(
&
current_key
)
.cloned
(
);
let
current_node
=
match
existing_node
{
Some
(
existing_node
)
=>
existing_node
,
None
=>
{
...
...
src/librustc/middle/trans/expr.rs
浏览文件 @
dfb7a811
...
...
@@ -184,7 +184,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let
mut
bcx
=
bcx
;
let
mut
datum
=
datum
;
let
adjustment
=
match
bcx
.tcx
()
.adjustments
.borrow
()
.
find_copy
(
&
expr
.id
)
{
let
adjustment
=
match
bcx
.tcx
()
.adjustments
.borrow
()
.
get
(
&
expr
.id
)
.cloned
(
)
{
None
=>
{
return
DatumBlock
::
new
(
bcx
,
datum
);
}
...
...
@@ -1293,7 +1293,7 @@ pub fn with_field_tys<R>(tcx: &ty::ctxt,
ty
.repr
(
tcx
))
.as_slice
());
}
Some
(
node_id
)
=>
{
let
def
=
tcx
.def_map
.borrow
()
.get_copy
(
&
node_id
);
let
def
=
tcx
.def_map
.borrow
()
[
node_id
]
.clone
(
);
match
def
{
def
::
DefVariant
(
enum_id
,
variant_id
,
_
)
=>
{
let
variant_info
=
ty
::
enum_variant_with_id
(
...
...
src/librustc/middle/trans/meth.rs
浏览文件 @
dfb7a811
...
...
@@ -301,7 +301,7 @@ pub fn trans_static_method_callee(bcx: Block,
fn
method_with_name
(
ccx
:
&
CrateContext
,
impl_id
:
ast
::
DefId
,
name
:
ast
::
Name
)
->
ast
::
DefId
{
match
ccx
.impl_method_cache
()
.borrow
()
.
find_copy
(
&
(
impl_id
,
name
)
)
{
match
ccx
.impl_method_cache
()
.borrow
()
.
get
(
&
(
impl_id
,
name
))
.cloned
(
)
{
Some
(
m
)
=>
return
m
,
None
=>
{}
}
...
...
src/librustc/middle/trans/type_of.rs
浏览文件 @
dfb7a811
...
...
@@ -175,7 +175,7 @@ pub fn type_of_fn_from_ty(cx: &CrateContext, fty: ty::t) -> Type {
// recursive types. For example, enum types rely on this behavior.
pub
fn
sizing_type_of
(
cx
:
&
CrateContext
,
t
:
ty
::
t
)
->
Type
{
match
cx
.llsizingtypes
()
.borrow
()
.
find_copy
(
&
t
)
{
match
cx
.llsizingtypes
()
.borrow
()
.
get
(
&
t
)
.cloned
(
)
{
Some
(
t
)
=>
return
t
,
None
=>
()
}
...
...
src/librustc/middle/ty.rs
浏览文件 @
dfb7a811
...
...
@@ -3194,7 +3194,7 @@ pub fn node_id_to_trait_ref(cx: &ctxt, id: ast::NodeId) -> Rc<ty::TraitRef> {
}
pub
fn
try_node_id_to_type
(
cx
:
&
ctxt
,
id
:
ast
::
NodeId
)
->
Option
<
t
>
{
cx
.node_types
.borrow
()
.
find_copy
(
&
id
)
cx
.node_types
.borrow
()
.
get
(
&
id
)
.cloned
(
)
}
pub
fn
node_id_to_type
(
cx
:
&
ctxt
,
id
:
ast
::
NodeId
)
->
t
{
...
...
@@ -4055,7 +4055,7 @@ fn lookup_locally_or_in_crate_store<V:Clone>(
* the crate loading code (and cache the result for the future).
*/
match
map
.
find_copy
(
&
def_id
)
{
match
map
.
get
(
&
def_id
)
.cloned
(
)
{
Some
(
v
)
=>
{
return
v
;
}
None
=>
{
}
}
...
...
@@ -4077,7 +4077,7 @@ pub fn trait_item(cx: &ctxt, trait_did: ast::DefId, idx: uint)
pub
fn
trait_items
(
cx
:
&
ctxt
,
trait_did
:
ast
::
DefId
)
->
Rc
<
Vec
<
ImplOrTraitItem
>>
{
let
mut
trait_items
=
cx
.trait_items_cache
.borrow_mut
();
match
trait_items
.
find_copy
(
&
trait_did
)
{
match
trait_items
.
get
(
&
trait_did
)
.cloned
(
)
{
Some
(
trait_items
)
=>
trait_items
,
None
=>
{
let
def_ids
=
ty
::
trait_item_def_ids
(
cx
,
trait_did
);
...
...
@@ -4627,7 +4627,7 @@ pub fn unboxed_closure_upvars(tcx: &ctxt, closure_id: ast::DefId, substs: &Subst
// This may change if abstract return types of some sort are
// implemented.
assert
!
(
closure_id
.krate
==
ast
::
LOCAL_CRATE
);
let
capture_mode
=
tcx
.capture_modes
.borrow
()
.get_copy
(
&
closure_id
.node
);
let
capture_mode
=
tcx
.capture_modes
.borrow
()
[
closure_id
.node
]
.clone
(
);
match
tcx
.freevars
.borrow
()
.get
(
&
closure_id
.node
)
{
None
=>
vec!
[],
Some
(
ref
freevars
)
=>
{
...
...
@@ -4636,10 +4636,10 @@ pub fn unboxed_closure_upvars(tcx: &ctxt, closure_id: ast::DefId, substs: &Subst
let
freevar_ty
=
node_id_to_type
(
tcx
,
freevar_def_id
.node
);
let
mut
freevar_ty
=
freevar_ty
.subst
(
tcx
,
substs
);
if
capture_mode
==
ast
::
CaptureByRef
{
let
borrow
=
tcx
.upvar_borrow_map
.borrow
()
.get_copy
(
&
ty
::
UpvarId
{
let
borrow
=
tcx
.upvar_borrow_map
.borrow
()
[
ty
::
UpvarId
{
var_id
:
freevar_def_id
.node
,
closure_expr_id
:
closure_id
.node
});
}
]
.clone
(
);
freevar_ty
=
mk_rptr
(
tcx
,
borrow
.region
,
ty
::
mt
{
ty
:
freevar_ty
,
mutbl
:
borrow
.kind
.to_mutbl_lossy
()
...
...
@@ -4738,7 +4738,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeNormalizer<'a, 'tcx> {
fn
tcx
(
&
self
)
->
&
ctxt
<
'tcx
>
{
let
TypeNormalizer
(
c
)
=
*
self
;
c
}
fn
fold_ty
(
&
mut
self
,
t
:
ty
::
t
)
->
ty
::
t
{
match
self
.tcx
()
.normalized_cache
.borrow
()
.
find_copy
(
&
t
)
{
match
self
.tcx
()
.normalized_cache
.borrow
()
.
get
(
&
t
)
.cloned
(
)
{
None
=>
{}
Some
(
u
)
=>
return
u
}
...
...
@@ -4902,7 +4902,7 @@ fn push_region_bounds(region_bounds: &[ty::Region],
pub
fn
get_tydesc_ty
(
tcx
:
&
ctxt
)
->
Result
<
t
,
String
>
{
tcx
.lang_items
.require
(
TyDescStructLangItem
)
.map
(|
tydesc_lang_item
|
{
tcx
.intrinsic_defs
.borrow
()
.
find_copy
(
&
tydesc_lang_item
)
tcx
.intrinsic_defs
.borrow
()
.
get
(
&
tydesc_lang_item
)
.cloned
(
)
.expect
(
"Failed to resolve TyDesc"
)
})
}
...
...
@@ -5053,7 +5053,7 @@ pub fn impl_of_method(tcx: &ctxt, def_id: ast::DefId)
ImplContainer
(
def_id
)
=>
Some
(
def_id
),
};
}
match
tcx
.impl_or_trait_items
.borrow
()
.
find_copy
(
&
def_id
)
{
match
tcx
.impl_or_trait_items
.borrow
()
.
get
(
&
def_id
)
.cloned
(
)
{
Some
(
trait_item
)
=>
{
match
trait_item
.container
()
{
TraitContainer
(
_
)
=>
None
,
...
...
@@ -5071,7 +5071,7 @@ pub fn trait_of_item(tcx: &ctxt, def_id: ast::DefId) -> Option<ast::DefId> {
if
def_id
.krate
!=
LOCAL_CRATE
{
return
csearch
::
get_trait_of_item
(
&
tcx
.sess.cstore
,
def_id
,
tcx
);
}
match
tcx
.impl_or_trait_items
.borrow
()
.
find_copy
(
&
def_id
)
{
match
tcx
.impl_or_trait_items
.borrow
()
.
get
(
&
def_id
)
.cloned
(
)
{
Some
(
impl_or_trait_item
)
=>
{
match
impl_or_trait_item
.container
()
{
TraitContainer
(
def_id
)
=>
Some
(
def_id
),
...
...
@@ -5461,12 +5461,12 @@ fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<ast::NodeId> {
}
fn
upvar_borrow
(
&
self
,
upvar_id
:
ty
::
UpvarId
)
->
ty
::
UpvarBorrow
{
self
.upvar_borrow_map
.borrow
()
.get_copy
(
&
upvar_id
)
self
.upvar_borrow_map
.borrow
()
[
upvar_id
]
.clone
(
)
}
fn
capture_mode
(
&
self
,
closure_expr_id
:
ast
::
NodeId
)
->
ast
::
CaptureClause
{
self
.capture_modes
.borrow
()
.get_copy
(
&
closure_expr_id
)
self
.capture_modes
.borrow
()
[
closure_expr_id
]
.clone
(
)
}
fn
unboxed_closures
<
'a
>
(
&
'a
self
)
...
...
src/librustc/middle/typeck/check/_match.rs
浏览文件 @
dfb7a811
...
...
@@ -71,7 +71,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
demand
::
eqtype
(
fcx
,
pat
.span
,
expected
,
lhs_ty
);
}
ast
::
PatEnum
(
..
)
|
ast
::
PatIdent
(
..
)
if
pat_is_const
(
&
tcx
.def_map
,
pat
)
=>
{
let
const_did
=
tcx
.def_map
.borrow
()
.get_copy
(
&
pat
.id
)
.def_id
();
let
const_did
=
tcx
.def_map
.borrow
()
[
pat
.id
]
.clone
(
)
.def_id
();
let
const_pty
=
ty
::
lookup_item_type
(
tcx
,
const_did
);
fcx
.write_ty
(
pat
.id
,
const_pty
.ty
);
demand
::
suptype
(
fcx
,
pat
.span
,
expected
,
const_pty
.ty
);
...
...
@@ -296,7 +296,7 @@ pub fn check_pat_struct(pcx: &pat_ctxt, pat: &ast::Pat,
let
fcx
=
pcx
.fcx
;
let
tcx
=
pcx
.fcx.ccx.tcx
;
let
def
=
tcx
.def_map
.borrow
()
.get_copy
(
&
pat
.id
);
let
def
=
tcx
.def_map
.borrow
()
[
pat
.id
]
.clone
(
);
let
def_type
=
ty
::
lookup_item_type
(
tcx
,
def
.def_id
());
let
(
enum_def_id
,
variant_def_id
)
=
match
ty
::
get
(
def_type
.ty
)
.sty
{
ty
::
ty_struct
(
struct_def_id
,
_
)
=>
...
...
@@ -341,7 +341,7 @@ pub fn check_pat_enum(pcx: &pat_ctxt, pat: &ast::Pat,
let
fcx
=
pcx
.fcx
;
let
tcx
=
pcx
.fcx.ccx.tcx
;
let
def
=
tcx
.def_map
.borrow
()
.get_copy
(
&
pat
.id
);
let
def
=
tcx
.def_map
.borrow
()
[
pat
.id
]
.clone
(
);
let
enum_def
=
def
.variant_def_ids
()
.map_or_else
(||
def
.def_id
(),
|(
enum_def
,
_
)|
enum_def
);
...
...
@@ -449,7 +449,7 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt,
}
Vacant
(
vacant
)
=>
{
vacant
.set
(
span
);
field_type_map
.
find_copy
(
&
field
.ident.name
)
field_type_map
.
get
(
&
field
.ident.name
)
.cloned
(
)
.unwrap_or_else
(||
{
span_err!
(
tcx
.sess
,
span
,
E0026
,
"struct `{}` does not have a field named `{}`"
,
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
dfb7a811
...
...
@@ -309,7 +309,7 @@ fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<ast::NodeId> {
self
.tcx
()
.temporary_scope
(
rvalue_id
)
}
fn
upvar_borrow
(
&
self
,
upvar_id
:
ty
::
UpvarId
)
->
ty
::
UpvarBorrow
{
self
.inh.upvar_borrow_map
.borrow
()
.get_copy
(
&
upvar_id
)
self
.inh.upvar_borrow_map
.borrow
()
[
upvar_id
]
.clone
(
)
}
fn
capture_mode
(
&
self
,
closure_expr_id
:
ast
::
NodeId
)
->
ast
::
CaptureClause
{
...
...
@@ -450,7 +450,7 @@ fn visit_local(&mut self, local: &ast::Local) {
debug!
(
"Local variable {} is assigned type {}"
,
self
.fcx
.pat_to_string
(
&*
local
.pat
),
self
.fcx
.infcx
()
.ty_to_string
(
self
.fcx.inh.locals
.borrow
()
.get_copy
(
&
local
.id
)));
self
.fcx.inh.locals
.borrow
()
[
local
.id
]
.clone
(
)));
visit
::
walk_local
(
self
,
local
);
}
...
...
@@ -467,7 +467,7 @@ fn visit_pat(&mut self, p: &ast::Pat) {
debug!
(
"Pattern binding {} is assigned to {} with type {}"
,
token
::
get_ident
(
path1
.node
),
self
.fcx
.infcx
()
.ty_to_string
(
self
.fcx.inh.locals
.borrow
()
.get_copy
(
&
p
.id
)),
self
.fcx.inh.locals
.borrow
()
[
p
.id
]
.clone
(
)),
var_ty
.repr
(
self
.fcx
.tcx
()));
}
_
=>
{}
...
...
src/librustc/middle/typeck/check/regionck.rs
浏览文件 @
dfb7a811
...
...
@@ -479,12 +479,12 @@ fn temporary_scope(&self, id: ast::NodeId) -> Option<ast::NodeId> {
}
fn
upvar_borrow
(
&
self
,
id
:
ty
::
UpvarId
)
->
ty
::
UpvarBorrow
{
self
.fcx.inh.upvar_borrow_map
.borrow
()
.get_copy
(
&
id
)
self
.fcx.inh.upvar_borrow_map
.borrow
()
[
id
]
.clone
(
)
}
fn
capture_mode
(
&
self
,
closure_expr_id
:
ast
::
NodeId
)
->
ast
::
CaptureClause
{
self
.tcx
()
.capture_modes
.borrow
()
.get_copy
(
&
closure_expr_id
)
self
.tcx
()
.capture_modes
.borrow
()
[
closure_expr_id
]
.clone
(
)
}
fn
unboxed_closures
<
'a
>
(
&
'a
self
)
...
...
@@ -871,7 +871,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
});
}
ty
::
ty_unboxed_closure
(
_
,
region
,
_
)
=>
{
if
tcx
.capture_modes
.borrow
()
.get_copy
(
&
expr
.id
)
==
ast
::
CaptureByRef
{
if
tcx
.capture_modes
.borrow
()
[
expr
.id
]
.clone
(
)
==
ast
::
CaptureByRef
{
ty
::
with_freevars
(
tcx
,
expr
.id
,
|
freevars
|
{
if
!
freevars
.is_empty
()
{
// Variables being referenced must be constrained and registered
...
...
@@ -896,7 +896,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
})
}
ty
::
ty_unboxed_closure
(
..
)
=>
{
if
tcx
.capture_modes
.borrow
()
.get_copy
(
&
expr
.id
)
==
ast
::
CaptureByRef
{
if
tcx
.capture_modes
.borrow
()
[
expr
.id
]
.clone
(
)
==
ast
::
CaptureByRef
{
ty
::
with_freevars
(
tcx
,
expr
.id
,
|
freevars
|
{
propagate_upupvar_borrow_kind
(
rcx
,
expr
,
freevars
);
});
...
...
@@ -1847,7 +1847,7 @@ fn link_upvar_borrow_kind_for_nested_closures(rcx: &mut Rcx,
inner_upvar_id
,
outer_upvar_id
);
let
mut
upvar_borrow_map
=
rcx
.fcx.inh.upvar_borrow_map
.borrow_mut
();
let
inner_borrow
=
upvar_borrow_map
.get_copy
(
&
inner_upvar_id
);
let
inner_borrow
=
upvar_borrow_map
[
inner_upvar_id
]
.clone
(
);
match
upvar_borrow_map
.get_mut
(
&
outer_upvar_id
)
{
Some
(
outer_borrow
)
=>
{
adjust_upvar_borrow_kind
(
rcx
,
outer_upvar_id
,
outer_borrow
,
inner_borrow
.kind
);
...
...
src/librustc/middle/typeck/coherence/mod.rs
浏览文件 @
dfb7a811
...
...
@@ -317,7 +317,7 @@ fn add_trait_impl(&self, base_def_id: DefId, impl_def_id: DefId) {
fn
get_self_type_for_implementation
(
&
self
,
impl_did
:
DefId
)
->
Polytype
{
self
.crate_context.tcx.tcache
.borrow
()
.get_copy
(
&
impl_did
)
self
.crate_context.tcx.tcache
.borrow
()
[
impl_did
]
.clone
(
)
}
// Converts an implementation in the AST to a vector of items.
...
...
@@ -428,7 +428,7 @@ fn populate_destructor_table(&self) {
};
let
impl_items
=
tcx
.impl_items
.borrow
();
let
trait_impls
=
match
tcx
.trait_impls
.borrow
()
.
find_copy
(
&
drop_trait
)
{
let
trait_impls
=
match
tcx
.trait_impls
.borrow
()
.
get
(
&
drop_trait
)
.cloned
(
)
{
None
=>
return
,
// No types with (new-style) dtors present.
Some
(
found_impls
)
=>
found_impls
};
...
...
src/librustc/middle/typeck/infer/region_inference/mod.rs
浏览文件 @
dfb7a811
...
...
@@ -1520,7 +1520,7 @@ fn process_edges(this: &RegionVarBindings,
ConstrainVarSubReg
(
_
,
region
)
=>
{
state
.result
.push
(
RegionAndOrigin
{
region
:
region
,
origin
:
this
.constraints
.borrow
()
.get_copy
(
&
edge
.data
)
origin
:
this
.constraints
.borrow
()
[
edge
.data
]
.clone
(
)
});
}
}
...
...
src/libstd/collections/hash/map.rs
浏览文件 @
dfb7a811
...
...
@@ -37,7 +37,6 @@
};
// FIXME(conventions): update capacity management to match other collections (no auto-shrink)
// FIXME(conventions): axe find_copy/get_copy in favour of Option.cloned (also implement that)
const
INITIAL_LOG2_CAP
:
uint
=
5
;
pub
const
INITIAL_CAPACITY
:
uint
=
1
<<
INITIAL_LOG2_CAP
;
// 2^5
...
...
@@ -1826,6 +1825,7 @@ fn test_find() {
}
#[test]
#[allow(deprecated)]
fn
test_find_copy
()
{
let
mut
m
=
HashMap
::
new
();
assert
!
(
m
.get
(
&
1
i
)
.is_none
());
...
...
src/libsyntax/ext/tt/transcribe.rs
浏览文件 @
dfb7a811
...
...
@@ -94,7 +94,7 @@ fn lookup_cur_matched_by_matched(r: &TtReader, start: Rc<NamedMatch>) -> Rc<Name
}
fn
lookup_cur_matched
(
r
:
&
TtReader
,
name
:
Ident
)
->
Option
<
Rc
<
NamedMatch
>>
{
let
matched_opt
=
r
.interpolations
.
find_copy
(
&
name
);
let
matched_opt
=
r
.interpolations
.
get
(
&
name
)
.cloned
(
);
matched_opt
.map
(|
s
|
lookup_cur_matched_by_matched
(
r
,
s
))
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录