Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
fe8a413f
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,发现更多精彩内容 >>
提交
fe8a413f
编写于
9月 18, 2014
作者:
A
Alexis Beingessner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handling fallout from entry api
上级
8e58f308
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
99 addition
and
44 deletion
+99
-44
src/librustc/driver/config.rs
src/librustc/driver/config.rs
+6
-2
src/librustc/lint/builtin.rs
src/librustc/lint/builtin.rs
+6
-2
src/librustc/metadata/creader.rs
src/librustc/metadata/creader.rs
+5
-1
src/librustc/metadata/loader.rs
src/librustc/metadata/loader.rs
+7
-3
src/librustc/middle/const_eval.rs
src/librustc/middle/const_eval.rs
+5
-1
src/librustc/middle/resolve.rs
src/librustc/middle/resolve.rs
+15
-9
src/librustc/middle/ty.rs
src/librustc/middle/ty.rs
+5
-3
src/librustc/middle/typeck/check/mod.rs
src/librustc/middle/typeck/check/mod.rs
+8
-4
src/librustc/middle/typeck/check/regionmanip.rs
src/librustc/middle/typeck/check/regionmanip.rs
+5
-1
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+13
-7
src/librustdoc/lib.rs
src/librustdoc/lib.rs
+5
-1
src/libsyntax/ext/mtwt.rs
src/libsyntax/ext/mtwt.rs
+9
-7
src/libtest/stats.rs
src/libtest/stats.rs
+5
-1
src/liburl/lib.rs
src/liburl/lib.rs
+5
-2
未找到文件。
src/librustc/driver/config.rs
浏览文件 @
fe8a413f
...
...
@@ -31,6 +31,7 @@
use
syntax
::
parse
::
token
::
InternedString
;
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
getopts
::{
optopt
,
optmulti
,
optflag
,
optflagopt
};
use
getopts
;
use
std
::
cell
::{
RefCell
};
...
...
@@ -808,8 +809,11 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
Some
(
s
)
=>
s
,
None
=>
early_error
(
"--extern value must be of the format `foo=bar`"
),
};
let
locs
=
externs
.find_or_insert
(
name
.to_string
(),
Vec
::
new
());
locs
.push
(
location
.to_string
());
match
externs
.entry
(
name
.to_string
())
{
Vacant
(
entry
)
=>
{
entry
.set
(
vec!
[
location
.to_string
()]);
},
Occupied
(
mut
entry
)
=>
{
entry
.get_mut
()
.push
(
location
.to_string
());
},
}
}
let
crate_name
=
matches
.opt_str
(
"crate-name"
);
...
...
src/librustc/lint/builtin.rs
浏览文件 @
fe8a413f
...
...
@@ -36,6 +36,7 @@
use
std
::
cmp
;
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
std
::
slice
;
use
std
::{
i8
,
i16
,
i32
,
i64
,
u8
,
u16
,
u32
,
u64
,
f32
,
f64
};
use
syntax
::
abi
;
...
...
@@ -1204,6 +1205,7 @@ impl UnusedMut {
fn
check_unused_mut_pat
(
&
self
,
cx
:
&
Context
,
pats
:
&
[
P
<
ast
::
Pat
>
])
{
// collect all mutable pattern and group their NodeIDs by their Identifier to
// avoid false warnings in match arms with multiple patterns
let
mut
mutables
=
HashMap
::
new
();
for
p
in
pats
.iter
()
{
pat_util
::
pat_bindings
(
&
cx
.tcx.def_map
,
&**
p
,
|
mode
,
id
,
_
,
path1
|
{
...
...
@@ -1211,8 +1213,10 @@ fn check_unused_mut_pat(&self, cx: &Context, pats: &[P<ast::Pat>]) {
match
mode
{
ast
::
BindByValue
(
ast
::
MutMutable
)
=>
{
if
!
token
::
get_ident
(
ident
)
.get
()
.starts_with
(
"_"
)
{
mutables
.insert_or_update_with
(
ident
.name
.uint
(),
vec!
(
id
),
|
_
,
old
|
{
old
.push
(
id
);
});
match
mutables
.entry
(
ident
.name
.uint
())
{
Vacant
(
entry
)
=>
{
entry
.set
(
vec!
[
id
]);
},
Occupied
(
mut
entry
)
=>
{
entry
.get_mut
()
.push
(
id
);
},
}
}
}
_
=>
{
...
...
src/librustc/metadata/creader.rs
浏览文件 @
fe8a413f
...
...
@@ -24,6 +24,7 @@
use
std
::
rc
::
Rc
;
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
syntax
::
ast
;
use
syntax
::
abi
;
use
syntax
::
attr
;
...
...
@@ -82,7 +83,10 @@ fn dump_crates(cstore: &CStore) {
fn
warn_if_multiple_versions
(
diag
:
&
SpanHandler
,
cstore
:
&
CStore
)
{
let
mut
map
=
HashMap
::
new
();
cstore
.iter_crate_data
(|
cnum
,
data
|
{
map
.find_or_insert_with
(
data
.name
(),
|
_
|
Vec
::
new
())
.push
(
cnum
);
match
map
.entry
(
data
.name
())
{
Vacant
(
entry
)
=>
{
entry
.set
(
vec!
[
cnum
]);
},
Occupied
(
mut
entry
)
=>
{
entry
.get_mut
()
.push
(
cnum
);
},
}
});
for
(
name
,
dupes
)
in
map
.into_iter
()
{
...
...
src/librustc/metadata/loader.rs
浏览文件 @
fe8a413f
...
...
@@ -237,6 +237,7 @@
use
std
::
string
;
use
std
::
collections
::{
HashMap
,
HashSet
};
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
flate
;
use
time
;
...
...
@@ -428,15 +429,18 @@ fn find_library_crate(&mut self) -> Option<Library> {
return
FileDoesntMatch
};
info!
(
"lib candidate: {}"
,
path
.display
());
let
slot
=
candidates
.find_or_insert_with
(
hash
.to_string
(),
|
_
|
{
(
HashSet
::
new
(),
HashSet
::
new
())
});
let
slot
=
match
candidates
.entry
(
hash
.to_string
())
{
Occupied
(
entry
)
=>
entry
.into_mut
(),
Vacant
(
entry
)
=>
entry
.set
((
HashSet
::
new
(),
HashSet
::
new
())),
};
let
(
ref
mut
rlibs
,
ref
mut
dylibs
)
=
*
slot
;
if
rlib
{
rlibs
.insert
(
fs
::
realpath
(
path
)
.unwrap
());
}
else
{
dylibs
.insert
(
fs
::
realpath
(
path
)
.unwrap
());
}
FileMatches
});
...
...
src/librustc/middle/const_eval.rs
浏览文件 @
fe8a413f
...
...
@@ -28,6 +28,7 @@
use
syntax
::{
ast
,
ast_map
,
ast_util
};
use
std
::
rc
::
Rc
;
use
std
::
collections
::
hashmap
::
Vacant
;
//
// This pass classifies expressions by their constant-ness.
...
...
@@ -321,7 +322,10 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr) -> P<Pat> {
ExprCall
(
ref
callee
,
ref
args
)
=>
{
let
def
=
tcx
.def_map
.borrow
()
.get_copy
(
&
callee
.id
);
tcx
.def_map
.borrow_mut
()
.find_or_insert
(
expr
.id
,
def
);
match
tcx
.def_map
.borrow_mut
()
.entry
(
expr
.id
)
{
Vacant
(
entry
)
=>
{
entry
.set
(
def
);
}
_
=>
{}
};
let
path
=
match
def
{
def
::
DefStruct
(
def_id
)
=>
def_to_path
(
tcx
,
def_id
),
def
::
DefVariant
(
_
,
variant_did
,
_
)
=>
def_to_path
(
tcx
,
variant_did
),
...
...
src/librustc/middle/resolve.rs
浏览文件 @
fe8a413f
...
...
@@ -58,6 +58,7 @@
use
syntax
::
visit
::
Visitor
;
use
std
::
collections
::{
HashMap
,
HashSet
};
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
std
::
cell
::{
Cell
,
RefCell
};
use
std
::
gc
::
GC
;
use
std
::
mem
::
replace
;
...
...
@@ -2813,10 +2814,13 @@ fn merge_import_resolution(&mut self,
let
is_public
=
import_directive
.is_public
;
let
mut
import_resolutions
=
module_
.import_resolutions
.borrow_mut
();
let
dest_import_resolution
=
import_resolutions
.find_or_insert_with
(
name
,
|
_
|
{
// Create a new import resolution from this child.
ImportResolution
::
new
(
id
,
is_public
)
});
let
dest_import_resolution
=
match
import_resolutions
.entry
(
name
)
{
Occupied
(
entry
)
=>
entry
.into_mut
(),
Vacant
(
entry
)
=>
{
// Create a new import resolution from this child.
entry
.set
(
ImportResolution
::
new
(
id
,
is_public
))
}
};
debug!
(
"(resolving glob import) writing resolution `{}` in `{}`
\
to `{}`"
,
...
...
@@ -5991,19 +5995,21 @@ fn record_def(&mut self, node_id: NodeId, (def, lp): (Def, LastPrivate)) {
assert
!
(
match
lp
{
LastImport
{
..
}
=>
false
,
_
=>
true
},
"Import should only be used for `use` directives"
);
self
.last_private
.insert
(
node_id
,
lp
);
self
.def_map
.borrow_mut
()
.insert_or_update_with
(
node_id
,
def
,
|
_
,
old_value
|
{
match
self
.def_map
.borrow_mut
()
.entry
(
node_id
)
{
// Resolve appears to "resolve" the same ID multiple
// times, so here is a sanity check it at least comes to
// the same conclusion! - nmatsakis
if
def
!=
*
old_value
{
Occupied
(
entry
)
=>
if
def
!=
*
entry
.get
()
{
self
.session
.bug
(
format!
(
"node_id {:?} resolved first to {:?} and
\
then {:?}"
,
node_id
,
*
old_value
,
*
entry
.get
()
,
def
)
.as_slice
());
}
});
},
Vacant
(
entry
)
=>
{
entry
.set
(
def
);
},
}
}
fn
enforce_default_binding_mode
(
&
mut
self
,
...
...
src/librustc/middle/ty.rs
浏览文件 @
fe8a413f
...
...
@@ -50,6 +50,7 @@
use
std
::
ops
;
use
std
::
rc
::
Rc
;
use
std
::
collections
::{
HashMap
,
HashSet
};
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
arena
::
TypedArena
;
use
syntax
::
abi
;
use
syntax
::
ast
::{
CrateNum
,
DefId
,
FnStyle
,
Ident
,
ItemTrait
,
LOCAL_CRATE
};
...
...
@@ -4641,9 +4642,10 @@ pub fn lookup_field_type(tcx: &ctxt,
node_id_to_type
(
tcx
,
id
.node
)
}
else
{
let
mut
tcache
=
tcx
.tcache
.borrow_mut
();
let
pty
=
tcache
.find_or_insert_with
(
id
,
|
_
|
{
csearch
::
get_field_type
(
tcx
,
struct_id
,
id
)
});
let
pty
=
match
tcache
.entry
(
id
)
{
Occupied
(
entry
)
=>
entry
.into_mut
(),
Vacant
(
entry
)
=>
entry
.set
(
csearch
::
get_field_type
(
tcx
,
struct_id
,
id
)),
};
pty
.ty
};
t
.subst
(
tcx
,
substs
)
...
...
src/librustc/middle/typeck/check/mod.rs
浏览文件 @
fe8a413f
...
...
@@ -122,6 +122,7 @@
use
std
::
cell
::{
Cell
,
RefCell
};
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
std
::
mem
::
replace
;
use
std
::
rc
::
Rc
;
use
std
::
slice
;
...
...
@@ -2017,11 +2018,14 @@ pub fn register_region_obligation(&self,
*/
let
mut
region_obligations
=
self
.inh.region_obligations
.borrow_mut
();
let
v
=
region_obligations
.find_or_insert_with
(
self
.body_id
,
|
_
|
Vec
::
new
());
v
.push
(
RegionObligation
{
sub_region
:
r
,
let
region_obligation
=
RegionObligation
{
sub_region
:
r
,
sup_type
:
ty
,
origin
:
origin
});
origin
:
origin
};
match
region_obligations
.entry
(
self
.body_id
)
{
Vacant
(
entry
)
=>
{
entry
.set
(
vec!
[
region_obligation
]);
},
Occupied
(
mut
entry
)
=>
{
entry
.get_mut
()
.push
(
region_obligation
);
},
}
}
pub
fn
add_obligations_for_parameters
(
&
self
,
...
...
src/librustc/middle/typeck/check/regionmanip.rs
浏览文件 @
fe8a413f
...
...
@@ -18,6 +18,7 @@
use
syntax
::
ast
;
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
util
::
ppaux
::
Repr
;
// Helper functions related to manipulating region types.
...
...
@@ -35,7 +36,10 @@ pub fn replace_late_bound_regions_in_fn_sig(
debug!
(
"region r={}"
,
r
.to_string
());
match
r
{
ty
::
ReLateBound
(
s
,
br
)
if
s
==
fn_sig
.binder_id
=>
{
*
map
.find_or_insert_with
(
br
,
|
_
|
mapf
(
br
))
*
match
map
.entry
(
br
)
{
Vacant
(
entry
)
=>
entry
.set
(
mapf
(
br
)),
Occupied
(
entry
)
=>
entry
.into_mut
(),
}
}
_
=>
r
}
...
...
src/librustdoc/html/render.rs
浏览文件 @
fe8a413f
...
...
@@ -34,6 +34,7 @@
//! both occur before the crate is rendered.
use
std
::
collections
::{
HashMap
,
HashSet
};
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
std
::
fmt
;
use
std
::
io
::
fs
::
PathExtensions
;
use
std
::
io
::{
fs
,
File
,
BufferedWriter
,
MemWriter
,
BufferedReader
};
...
...
@@ -801,9 +802,10 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
clean
::
ImplItem
(
ref
i
)
=>
{
match
i
.trait_
{
Some
(
clean
::
ResolvedPath
{
did
,
..
})
=>
{
let
v
=
self
.implementors
.find_or_insert_with
(
did
,
|
_
|
{
Vec
::
new
()
});
let
v
=
match
self
.implementors
.entry
(
did
)
{
Vacant
(
entry
)
=>
entry
.set
(
Vec
::
with_capacity
(
1
)),
Occupied
(
entry
)
=>
entry
.into_mut
(),
};
v
.push
(
Implementor
{
def_id
:
item
.def_id
,
generics
:
i
.generics
.clone
(),
...
...
@@ -998,9 +1000,10 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
match
did
{
Some
(
did
)
=>
{
let
v
=
self
.impls
.find_or_insert_with
(
did
,
|
_
|
{
Vec
::
new
()
});
let
v
=
match
self
.impls
.entry
(
did
)
{
Vacant
(
entry
)
=>
entry
.set
(
Vec
::
with_capacity
(
1
)),
Occupied
(
entry
)
=>
entry
.into_mut
(),
};
v
.push
(
Impl
{
impl_
:
i
,
dox
:
dox
,
...
...
@@ -2141,7 +2144,10 @@ fn build_sidebar(m: &clean::Module) -> HashMap<String, Vec<String>> {
None
=>
continue
,
Some
(
ref
s
)
=>
s
.to_string
(),
};
let
v
=
map
.find_or_insert_with
(
short
.to_string
(),
|
_
|
Vec
::
new
());
let
v
=
match
map
.entry
(
short
.to_string
())
{
Vacant
(
entry
)
=>
entry
.set
(
Vec
::
with_capacity
(
1
)),
Occupied
(
entry
)
=>
entry
.into_mut
(),
};
v
.push
(
myname
);
}
...
...
src/librustdoc/lib.rs
浏览文件 @
fe8a413f
...
...
@@ -31,6 +31,7 @@
use
std
::
io
;
use
std
::
io
::{
File
,
MemWriter
};
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
serialize
::{
json
,
Decodable
,
Encodable
};
use
externalfiles
::
ExternalHtml
;
...
...
@@ -340,7 +341,10 @@ fn parse_externs(matches: &getopts::Matches) -> Result<core::Externs, String> {
return
Err
(
"--extern value must be of the format `foo=bar`"
.to_string
());
}
};
let
locs
=
externs
.find_or_insert
(
name
.to_string
(),
Vec
::
new
());
let
locs
=
match
externs
.entry
(
name
.to_string
())
{
Vacant
(
entry
)
=>
entry
.set
(
Vec
::
with_capacity
(
1
)),
Occupied
(
entry
)
=>
entry
.into_mut
(),
};
locs
.push
(
location
.to_string
());
}
Ok
(
externs
)
...
...
src/libsyntax/ext/mtwt.rs
浏览文件 @
fe8a413f
...
...
@@ -20,6 +20,7 @@
use
std
::
cell
::
RefCell
;
use
std
::
rc
::
Rc
;
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
/// The SCTable contains a table of SyntaxContext_'s. It
/// represents a flattened tree structure, to avoid having
...
...
@@ -65,10 +66,10 @@ pub fn apply_mark(m: Mrk, ctxt: SyntaxContext) -> SyntaxContext {
/// Extend a syntax context with a given mark and sctable (explicit memoization)
fn
apply_mark_internal
(
m
:
Mrk
,
ctxt
:
SyntaxContext
,
table
:
&
SCTable
)
->
SyntaxContext
{
let
key
=
(
ctxt
,
m
);
let
new_ctxt
=
|
_
:
&
(
SyntaxContext
,
Mrk
)|
idx_push
(
&
mut
*
table
.table
.borrow_mut
(),
Mark
(
m
,
ctxt
));
*
table
.mark_memo
.borrow_mut
()
.find_or_insert_with
(
key
,
new_ctxt
)
*
match
table
.mark_memo
.borrow_mut
()
.entry
(
key
)
{
Vacant
(
entry
)
=>
entry
.set
(
idx_push
(
&
mut
*
table
.table
.borrow_mut
(),
Mark
(
m
,
ctxt
))),
Occupied
(
entry
)
=>
entry
.into_mut
(),
}
}
/// Extend a syntax context with a given rename
...
...
@@ -83,10 +84,11 @@ fn apply_rename_internal(id: Ident,
ctxt
:
SyntaxContext
,
table
:
&
SCTable
)
->
SyntaxContext
{
let
key
=
(
ctxt
,
id
,
to
);
let
new_ctxt
=
|
_
:
&
(
SyntaxContext
,
Ident
,
Name
)|
idx_push
(
&
mut
*
table
.table
.borrow_mut
(),
Rename
(
id
,
to
,
ctxt
));
*
table
.rename_memo
.borrow_mut
()
.find_or_insert_with
(
key
,
new_ctxt
)
*
match
table
.rename_memo
.borrow_mut
()
.entry
(
key
)
{
Vacant
(
entry
)
=>
entry
.set
(
idx_push
(
&
mut
*
table
.table
.borrow_mut
(),
Rename
(
id
,
to
,
ctxt
))),
Occupied
(
entry
)
=>
entry
.into_mut
(),
}
}
/// Apply a list of renamings to a context
...
...
src/libtest/stats.rs
浏览文件 @
fe8a413f
...
...
@@ -11,6 +11,7 @@
#![allow(missing_doc)]
use
std
::
collections
::
hashmap
;
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
std
::
fmt
::
Show
;
use
std
::
hash
::
Hash
;
use
std
::
io
;
...
...
@@ -443,7 +444,10 @@ pub fn write_boxplot<T: Float + Show + FromPrimitive>(
pub
fn
freq_count
<
T
:
Iterator
<
U
>
,
U
:
Eq
+
Hash
>
(
mut
iter
:
T
)
->
hashmap
::
HashMap
<
U
,
uint
>
{
let
mut
map
:
hashmap
::
HashMap
<
U
,
uint
>
=
hashmap
::
HashMap
::
new
();
for
elem
in
iter
{
map
.insert_or_update_with
(
elem
,
1
,
|
_
,
count
|
*
count
+=
1
);
match
map
.entry
(
elem
)
{
Occupied
(
mut
entry
)
=>
{
*
entry
.get_mut
()
+=
1
;
},
Vacant
(
entry
)
=>
{
entry
.set
(
1
);
},
}
}
map
}
...
...
src/liburl/lib.rs
浏览文件 @
fe8a413f
...
...
@@ -23,6 +23,7 @@
#![feature(default_type_params)]
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
hashmap
::{
Occupied
,
Vacant
};
use
std
::
fmt
;
use
std
::
from_str
::
FromStr
;
use
std
::
hash
;
...
...
@@ -342,8 +343,10 @@ fn maybe_push_value(map: &mut HashMap<String, Vec<String>>,
key
:
String
,
value
:
String
)
{
if
key
.len
()
>
0
&&
value
.len
()
>
0
{
let
values
=
map
.find_or_insert_with
(
key
,
|
_
|
vec!
());
values
.push
(
value
);
match
map
.entry
(
key
)
{
Vacant
(
entry
)
=>
{
entry
.set
(
vec!
[
value
]);
},
Occupied
(
mut
entry
)
=>
{
entry
.get_mut
()
.push
(
value
);
},
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录