Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
892a05d6
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,发现更多精彩内容 >>
未验证
提交
892a05d6
编写于
10月 22, 2016
作者:
S
Srinivas Reddy Thatiparthy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
run rustfmt on librustc_metadata folder
上级
affc3b75
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
363 addition
and
342 deletion
+363
-342
src/librustc_metadata/encoder.rs
src/librustc_metadata/encoder.rs
+149
-169
src/librustc_metadata/index.rs
src/librustc_metadata/index.rs
+9
-7
src/librustc_metadata/index_builder.rs
src/librustc_metadata/index_builder.rs
+5
-5
src/librustc_metadata/lib.rs
src/librustc_metadata/lib.rs
+4
-2
src/librustc_metadata/locator.rs
src/librustc_metadata/locator.rs
+164
-125
src/librustc_metadata/schema.rs
src/librustc_metadata/schema.rs
+32
-34
未找到文件。
src/librustc_metadata/encoder.rs
浏览文件 @
892a05d6
此差异已折叠。
点击以展开。
src/librustc_metadata/index.rs
浏览文件 @
892a05d6
...
...
@@ -28,9 +28,7 @@ pub struct Index {
impl
Index
{
pub
fn
new
(
max_index
:
usize
)
->
Index
{
Index
{
positions
:
vec!
[
u32
::
MAX
;
max_index
]
}
Index
{
positions
:
vec!
[
u32
::
MAX
;
max_index
]
}
}
pub
fn
record
(
&
mut
self
,
def_id
:
DefId
,
entry
:
Lazy
<
Entry
>
)
{
...
...
@@ -46,7 +44,9 @@ pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry>) {
assert
!
(
self
.positions
[
item
]
==
u32
::
MAX
,
"recorded position for item {:?} twice, first at {:?} and now at {:?}"
,
item
,
self
.positions
[
item
],
position
);
item
,
self
.positions
[
item
],
position
);
self
.positions
[
item
]
=
position
.to_le
();
}
...
...
@@ -67,7 +67,8 @@ pub fn lookup(&self, bytes: &[u8], def_index: DefIndex) -> Option<Lazy<Entry<'tc
let
index
=
def_index
.as_usize
();
debug!
(
"Index::lookup: index={:?} words.len={:?}"
,
index
,
words
.len
());
index
,
words
.len
());
let
position
=
u32
::
from_le
(
words
[
index
]);
if
position
==
u32
::
MAX
{
...
...
@@ -79,8 +80,9 @@ pub fn lookup(&self, bytes: &[u8], def_index: DefIndex) -> Option<Lazy<Entry<'tc
}
}
pub
fn
iter_enumerated
<
'a
>
(
&
self
,
bytes
:
&
'a
[
u8
])
->
impl
Iterator
<
Item
=
(
DefIndex
,
Lazy
<
Entry
<
'tcx
>>
)
>
+
'a
{
pub
fn
iter_enumerated
<
'a
>
(
&
self
,
bytes
:
&
'a
[
u8
])
->
impl
Iterator
<
Item
=
(
DefIndex
,
Lazy
<
Entry
<
'tcx
>>
)
>
+
'a
{
let
words
=
&
bytes_to_words
(
&
bytes
[
self
.position
..
])[
..
self
.len
];
words
.iter
()
.enumerate
()
.filter_map
(|(
index
,
&
position
)|
{
if
position
==
u32
::
MAX
{
...
...
src/librustc_metadata/index_builder.rs
浏览文件 @
892a05d6
...
...
@@ -138,11 +138,11 @@ pub trait DepGraphRead {
}
impl
DepGraphRead
for
DefId
{
fn
read
(
&
self
,
_
tcx
:
TyCtxt
)
{
}
fn
read
(
&
self
,
_
tcx
:
TyCtxt
)
{}
}
impl
DepGraphRead
for
ast
::
NodeId
{
fn
read
(
&
self
,
_
tcx
:
TyCtxt
)
{
}
fn
read
(
&
self
,
_
tcx
:
TyCtxt
)
{}
}
impl
<
T
>
DepGraphRead
for
Option
<
T
>
...
...
@@ -179,8 +179,8 @@ fn read(&self, tcx: TyCtxt) {
}
}
}
read_tuple!
(
A
,
B
);
read_tuple!
(
A
,
B
,
C
);
read_tuple!
(
A
,
B
);
read_tuple!
(
A
,
B
,
C
);
macro_rules!
read_hir
{
(
$t:ty
)
=>
{
...
...
@@ -208,7 +208,7 @@ fn read(&self, tcx: TyCtxt) {
pub
struct
Untracked
<
T
>
(
pub
T
);
impl
<
T
>
DepGraphRead
for
Untracked
<
T
>
{
fn
read
(
&
self
,
_
tcx
:
TyCtxt
)
{
}
fn
read
(
&
self
,
_
tcx
:
TyCtxt
)
{}
}
/// Newtype that can be used to package up misc data extracted from a
...
...
src/librustc_metadata/lib.rs
浏览文件 @
892a05d6
...
...
@@ -30,8 +30,10 @@
#![feature(specialization)]
#![feature(staged_api)]
#[macro_use]
extern
crate
log
;
#[macro_use]
extern
crate
syntax
;
#[macro_use]
extern
crate
log
;
#[macro_use]
extern
crate
syntax
;
extern
crate
syntax_pos
;
extern
crate
flate
;
extern
crate
serialize
as
rustc_serialize
;
// used by deriving
...
...
src/librustc_metadata/locator.rs
浏览文件 @
892a05d6
此差异已折叠。
点击以展开。
src/librustc_metadata/schema.rs
浏览文件 @
892a05d6
...
...
@@ -27,7 +27,8 @@
use
std
::
marker
::
PhantomData
;
pub
fn
rustc_version
()
->
String
{
format!
(
"rustc {}"
,
option_env!
(
"CFG_VERSION"
)
.unwrap_or
(
"unknown version"
))
format!
(
"rustc {}"
,
option_env!
(
"CFG_VERSION"
)
.unwrap_or
(
"unknown version"
))
}
/// Metadata encoding version.
...
...
@@ -41,11 +42,8 @@ pub fn rustc_version() -> String {
/// as a length of 0 by old compilers.
///
/// This header is followed by the position of the `CrateRoot`.
pub
const
METADATA_HEADER
:
&
'static
[
u8
;
12
]
=
&
[
0
,
0
,
0
,
0
,
b
'r'
,
b
'u'
,
b
's'
,
b
't'
,
0
,
0
,
0
,
METADATA_VERSION
];
pub
const
METADATA_HEADER
:
&
'static
[
u8
;
12
]
=
&
[
0
,
0
,
0
,
0
,
b
'r'
,
b
'u'
,
b
's'
,
b
't'
,
0
,
0
,
0
,
METADATA_VERSION
];
/// The shorthand encoding uses an enum's variant index `usize`
/// and is offset by this value so it never matches a real variant.
...
...
@@ -70,14 +68,14 @@ pub fn rustc_version() -> String {
#[must_use]
pub
struct
Lazy
<
T
>
{
pub
position
:
usize
,
_
marker
:
PhantomData
<
T
>
_
marker
:
PhantomData
<
T
>
,
}
impl
<
T
>
Lazy
<
T
>
{
pub
fn
with_position
(
position
:
usize
)
->
Lazy
<
T
>
{
Lazy
{
position
:
position
,
_
marker
:
PhantomData
_
marker
:
PhantomData
,
}
}
...
...
@@ -90,7 +88,9 @@ pub fn min_size() -> usize {
impl
<
T
>
Copy
for
Lazy
<
T
>
{}
impl
<
T
>
Clone
for
Lazy
<
T
>
{
fn
clone
(
&
self
)
->
Self
{
*
self
}
fn
clone
(
&
self
)
->
Self
{
*
self
}
}
impl
<
T
>
serialize
::
UseSpecializedEncodable
for
Lazy
<
T
>
{}
...
...
@@ -112,7 +112,7 @@ impl<T> serialize::UseSpecializedDecodable for Lazy<T> {}
pub
struct
LazySeq
<
T
>
{
pub
len
:
usize
,
pub
position
:
usize
,
_
marker
:
PhantomData
<
T
>
_
marker
:
PhantomData
<
T
>
,
}
impl
<
T
>
LazySeq
<
T
>
{
...
...
@@ -124,7 +124,7 @@ pub fn with_position_and_length(position: usize, len: usize) -> LazySeq<T> {
LazySeq
{
len
:
len
,
position
:
position
,
_
marker
:
PhantomData
_
marker
:
PhantomData
,
}
}
...
...
@@ -136,7 +136,9 @@ pub fn min_size(length: usize) -> usize {
impl
<
T
>
Copy
for
LazySeq
<
T
>
{}
impl
<
T
>
Clone
for
LazySeq
<
T
>
{
fn
clone
(
&
self
)
->
Self
{
*
self
}
fn
clone
(
&
self
)
->
Self
{
*
self
}
}
impl
<
T
>
serialize
::
UseSpecializedEncodable
for
LazySeq
<
T
>
{}
...
...
@@ -155,7 +157,7 @@ pub enum LazyState {
/// Inside a metadata node, with a previous `Lazy` or `LazySeq`.
/// The position is a conservative estimate of where that
/// previous `Lazy` / `LazySeq` would end (see their comments).
Previous
(
usize
)
Previous
(
usize
)
,
}
#[derive(RustcEncodable,
RustcDecodable)]
...
...
@@ -185,13 +187,13 @@ pub struct CrateRoot {
pub
struct
CrateDep
{
pub
name
:
ast
::
Name
,
pub
hash
:
hir
::
svh
::
Svh
,
pub
explicitly_linked
:
bool
pub
explicitly_linked
:
bool
,
}
#[derive(RustcEncodable,
RustcDecodable)]
pub
struct
TraitImpls
{
pub
trait_id
:
(
u32
,
DefIndex
),
pub
impls
:
LazySeq
<
DefIndex
>
pub
impls
:
LazySeq
<
DefIndex
>
,
}
#[derive(RustcEncodable,
RustcDecodable)]
...
...
@@ -199,7 +201,7 @@ pub struct MacroDef {
pub
name
:
ast
::
Name
,
pub
attrs
:
Vec
<
ast
::
Attribute
>
,
pub
span
:
Span
,
pub
body
:
String
pub
body
:
String
,
}
#[derive(RustcEncodable,
RustcDecodable)]
...
...
@@ -219,7 +221,7 @@ pub struct Entry<'tcx> {
pub
predicates
:
Option
<
Lazy
<
ty
::
GenericPredicates
<
'tcx
>>>
,
pub
ast
:
Option
<
Lazy
<
astencode
::
Ast
<
'tcx
>>>
,
pub
mir
:
Option
<
Lazy
<
mir
::
repr
::
Mir
<
'tcx
>>>
pub
mir
:
Option
<
Lazy
<
mir
::
repr
::
Mir
<
'tcx
>>>
,
}
#[derive(Copy,
Clone,
RustcEncodable,
RustcDecodable)]
...
...
@@ -245,18 +247,18 @@ pub enum EntryKind<'tcx> {
DefaultImpl
(
Lazy
<
ImplData
<
'tcx
>>
),
Method
(
Lazy
<
MethodData
<
'tcx
>>
),
AssociatedType
(
AssociatedContainer
),
AssociatedConst
(
AssociatedContainer
)
AssociatedConst
(
AssociatedContainer
)
,
}
#[derive(RustcEncodable,
RustcDecodable)]
pub
struct
ModData
{
pub
reexports
:
LazySeq
<
def
::
Export
>
pub
reexports
:
LazySeq
<
def
::
Export
>
,
}
#[derive(RustcEncodable,
RustcDecodable)]
pub
struct
FnData
{
pub
constness
:
hir
::
Constness
,
pub
arg_names
:
LazySeq
<
ast
::
Name
>
pub
arg_names
:
LazySeq
<
ast
::
Name
>
,
}
#[derive(RustcEncodable,
RustcDecodable)]
...
...
@@ -266,7 +268,7 @@ pub struct VariantData {
/// If this is a struct's only variant, this
/// is the index of the "struct ctor" item.
pub
struct_ctor
:
Option
<
DefIndex
>
pub
struct_ctor
:
Option
<
DefIndex
>
,
}
#[derive(RustcEncodable,
RustcDecodable)]
...
...
@@ -275,7 +277,7 @@ pub struct TraitData<'tcx> {
pub
paren_sugar
:
bool
,
pub
has_default_impl
:
bool
,
pub
trait_ref
:
Lazy
<
ty
::
TraitRef
<
'tcx
>>
,
pub
super_predicates
:
Lazy
<
ty
::
GenericPredicates
<
'tcx
>>
pub
super_predicates
:
Lazy
<
ty
::
GenericPredicates
<
'tcx
>>
,
}
#[derive(RustcEncodable,
RustcDecodable)]
...
...
@@ -283,7 +285,7 @@ pub struct ImplData<'tcx> {
pub
polarity
:
hir
::
ImplPolarity
,
pub
parent_impl
:
Option
<
DefId
>
,
pub
coerce_unsized_kind
:
Option
<
ty
::
adjustment
::
CustomCoerceUnsized
>
,
pub
trait_ref
:
Option
<
Lazy
<
ty
::
TraitRef
<
'tcx
>>>
pub
trait_ref
:
Option
<
Lazy
<
ty
::
TraitRef
<
'tcx
>>>
,
}
/// Describes whether the container of an associated item
...
...
@@ -294,21 +296,17 @@ pub enum AssociatedContainer {
TraitRequired
,
TraitWithDefault
,
ImplDefault
,
ImplFinal
ImplFinal
,
}
impl
AssociatedContainer
{
pub
fn
with_def_id
(
&
self
,
def_id
:
DefId
)
->
ty
::
ImplOrTraitItemContainer
{
match
*
self
{
AssociatedContainer
::
TraitRequired
|
AssociatedContainer
::
TraitWithDefault
=>
{
ty
::
TraitContainer
(
def_id
)
}
AssociatedContainer
::
TraitWithDefault
=>
ty
::
TraitContainer
(
def_id
),
AssociatedContainer
::
ImplDefault
|
AssociatedContainer
::
ImplFinal
=>
{
ty
::
ImplContainer
(
def_id
)
}
AssociatedContainer
::
ImplFinal
=>
ty
::
ImplContainer
(
def_id
),
}
}
...
...
@@ -318,7 +316,7 @@ pub fn has_body(&self) -> bool {
AssociatedContainer
::
TraitWithDefault
|
AssociatedContainer
::
ImplDefault
|
AssociatedContainer
::
ImplFinal
=>
true
AssociatedContainer
::
ImplFinal
=>
true
,
}
}
...
...
@@ -328,7 +326,7 @@ pub fn defaultness(&self) -> hir::Defaultness {
AssociatedContainer
::
TraitWithDefault
|
AssociatedContainer
::
ImplDefault
=>
hir
::
Defaultness
::
Default
,
AssociatedContainer
::
ImplFinal
=>
hir
::
Defaultness
::
Final
AssociatedContainer
::
ImplFinal
=>
hir
::
Defaultness
::
Final
,
}
}
}
...
...
@@ -337,11 +335,11 @@ pub fn defaultness(&self) -> hir::Defaultness {
pub
struct
MethodData
<
'tcx
>
{
pub
fn_data
:
FnData
,
pub
container
:
AssociatedContainer
,
pub
explicit_self
:
Lazy
<
ty
::
ExplicitSelfCategory
<
'tcx
>>
pub
explicit_self
:
Lazy
<
ty
::
ExplicitSelfCategory
<
'tcx
>>
,
}
#[derive(RustcEncodable,
RustcDecodable)]
pub
struct
ClosureData
<
'tcx
>
{
pub
kind
:
ty
::
ClosureKind
,
pub
ty
:
Lazy
<
ty
::
ClosureTy
<
'tcx
>>
pub
ty
:
Lazy
<
ty
::
ClosureTy
<
'tcx
>>
,
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录