Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1d5829d8
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
1d5829d8
编写于
11月 15, 2018
作者:
P
Pietro Albini
提交者:
GitHub
11月 15, 2018
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #55750 - oli-obk:node_id_x, r=michaelwoerister
Make `NodeId` and `HirLocalId` `newtype_index`
上级
756870a2
22039597
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
75 addition
and
100 deletion
+75
-100
src/librustc/dep_graph/dep_node.rs
src/librustc/dep_graph/dep_node.rs
+3
-3
src/librustc/hir/intravisit.rs
src/librustc/hir/intravisit.rs
+2
-3
src/librustc/hir/lowering.rs
src/librustc/hir/lowering.rs
+2
-2
src/librustc/hir/map/hir_id_validator.rs
src/librustc/hir/map/hir_id_validator.rs
+3
-3
src/librustc/hir/mod.rs
src/librustc/hir/mod.rs
+16
-29
src/librustc/ich/impls_hir.rs
src/librustc/ich/impls_hir.rs
+9
-2
src/librustc/session/mod.rs
src/librustc/session/mod.rs
+2
-2
src/librustc_driver/pretty.rs
src/librustc_driver/pretty.rs
+5
-5
src/librustc_driver/test.rs
src/librustc_driver/test.rs
+5
-5
src/librustc_resolve/resolve_imports.rs
src/librustc_resolve/resolve_imports.rs
+1
-1
src/librustdoc/passes/collect_intra_doc_links.rs
src/librustdoc/passes/collect_intra_doc_links.rs
+6
-6
src/libsyntax/ast.rs
src/libsyntax/ast.rs
+18
-37
src/libsyntax/lib.rs
src/libsyntax/lib.rs
+2
-1
src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs
...st/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs
+1
-1
未找到文件。
src/librustc/dep_graph/dep_node.rs
浏览文件 @
1d5829d8
...
...
@@ -63,7 +63,7 @@
use
mir
::
interpret
::
GlobalId
;
use
hir
::
def_id
::{
CrateNum
,
DefId
,
DefIndex
,
CRATE_DEF_INDEX
};
use
hir
::
map
::
DefPathHash
;
use
hir
::
{
HirId
,
ItemLocalId
}
;
use
hir
::
HirId
;
use
ich
::{
Fingerprint
,
StableHashingContext
};
use
rustc_data_structures
::
stable_hasher
::{
StableHasher
,
HashStable
};
...
...
@@ -790,11 +790,11 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for HirId {
fn
to_fingerprint
(
&
self
,
tcx
:
TyCtxt
<
'_
,
'_
,
'_
>
)
->
Fingerprint
{
let
HirId
{
owner
,
local_id
:
ItemLocalId
(
local_id
)
,
local_id
,
}
=
*
self
;
let
def_path_hash
=
tcx
.def_path_hash
(
DefId
::
local
(
owner
));
let
local_id
=
Fingerprint
::
from_smaller_hash
(
local_id
as
u64
);
let
local_id
=
Fingerprint
::
from_smaller_hash
(
local_id
.as_u32
()
.into
()
);
def_path_hash
.0
.combine
(
local_id
)
}
...
...
src/librustc/hir/intravisit.rs
浏览文件 @
1d5829d8
...
...
@@ -49,7 +49,6 @@
use
super
::
itemlikevisit
::
DeepVisitor
;
use
std
::
cmp
;
use
std
::
u32
;
#[derive(Copy,
Clone)]
pub
enum
FnKind
<
'a
>
{
...
...
@@ -1152,8 +1151,8 @@ pub struct IdRange {
impl
IdRange
{
pub
fn
max
()
->
IdRange
{
IdRange
{
min
:
NodeId
::
from_u32
(
u32
::
MAX
)
,
max
:
NodeId
::
from_u32
(
u32
::
MIN
),
min
:
NodeId
::
MAX
,
max
:
NodeId
::
from_u32
(
0
),
}
}
...
...
src/librustc/hir/lowering.rs
浏览文件 @
1d5829d8
...
...
@@ -588,7 +588,7 @@ fn lower_node_id(&mut self, ast_node_id: NodeId) -> LoweredNodeId {
*
local_id_counter
+=
1
;
hir
::
HirId
{
owner
:
def_index
,
local_id
:
hir
::
ItemLocalId
(
local_id
),
local_id
:
hir
::
ItemLocalId
::
from_u32
(
local_id
),
}
})
}
...
...
@@ -616,7 +616,7 @@ fn lower_node_id_with_owner(&mut self, ast_node_id: NodeId, owner: NodeId) -> Lo
hir
::
HirId
{
owner
:
def_index
,
local_id
:
hir
::
ItemLocalId
(
local_id
),
local_id
:
hir
::
ItemLocalId
::
from_u32
(
local_id
),
}
})
}
...
...
src/librustc/hir/map/hir_id_validator.rs
浏览文件 @
1d5829d8
...
...
@@ -101,7 +101,7 @@ fn check<F: FnOnce(&mut HirIdValidator<'a, 'hir>)>(&mut self,
if
max
!=
self
.hir_ids_seen
.len
()
-
1
{
// Collect the missing ItemLocalIds
let
missing
:
Vec
<
_
>
=
(
0
..
max
as
u32
+
1
)
.filter
(|
&
i
|
!
self
.hir_ids_seen
.contains_key
(
&
ItemLocalId
(
i
)))
.filter
(|
&
i
|
!
self
.hir_ids_seen
.contains_key
(
&
ItemLocalId
::
from_u32
(
i
)))
.collect
();
// Try to map those to something more useful
...
...
@@ -110,7 +110,7 @@ fn check<F: FnOnce(&mut HirIdValidator<'a, 'hir>)>(&mut self,
for
local_id
in
missing
{
let
hir_id
=
HirId
{
owner
:
owner_def_index
,
local_id
:
ItemLocalId
(
local_id
as
u32
),
local_id
:
ItemLocalId
::
from_u32
(
local_id
),
};
trace!
(
"missing hir id {:#?}"
,
hir_id
);
...
...
@@ -124,7 +124,7 @@ fn check<F: FnOnce(&mut HirIdValidator<'a, 'hir>)>(&mut self,
.enumerate
()
.find
(|
&
(
_
,
&
entry
)|
hir_id
==
entry
)
.expect
(
"no node_to_hir_id entry"
);
let
node_id
=
NodeId
::
new
(
node_id
);
let
node_id
=
NodeId
::
from_usize
(
node_id
);
missing_items
.push
(
format!
(
"[local_id: {}, node:{}]"
,
local_id
,
self
.hir_map
.node_to_string
(
node_id
)));
...
...
src/librustc/hir/mod.rs
浏览文件 @
1d5829d8
...
...
@@ -37,7 +37,6 @@
use
ty
::
AdtKind
;
use
ty
::
query
::
Providers
;
use
rustc_data_structures
::
indexed_vec
;
use
rustc_data_structures
::
sync
::{
ParallelIterator
,
par_iter
,
Send
,
Sync
,
scope
};
use
rustc_data_structures
::
thin_vec
::
ThinVec
;
...
...
@@ -121,40 +120,28 @@ fn default_decode<D: Decoder>(d: &mut D) -> Result<HirId, D::Error> {
}
}
/// An `ItemLocalId` uniquely identifies something within a given "item-like",
/// that is within a hir::Item, hir::TraitItem, or hir::ImplItem. There is no
/// guarantee that the numerical value of a given `ItemLocalId` corresponds to
/// the node's position within the owning item in any way, but there is a
/// guarantee that the `LocalItemId`s within an owner occupy a dense range of
/// integers starting at zero, so a mapping that maps all or most nodes within
/// an "item-like" to something else can be implement by a `Vec` instead of a
/// tree or hash map.
#[derive(Copy,
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Debug,
RustcEncodable,
RustcDecodable)]
pub
struct
ItemLocalId
(
pub
u32
);
impl
ItemLocalId
{
pub
fn
as_usize
(
&
self
)
->
usize
{
self
.0
as
usize
// hack to ensure that we don't try to access the private parts of `ItemLocalId` in this module
mod
item_local_id_inner
{
use
rustc_data_structures
::
indexed_vec
::
Idx
;
/// An `ItemLocalId` uniquely identifies something within a given "item-like",
/// that is within a hir::Item, hir::TraitItem, or hir::ImplItem. There is no
/// guarantee that the numerical value of a given `ItemLocalId` corresponds to
/// the node's position within the owning item in any way, but there is a
/// guarantee that the `LocalItemId`s within an owner occupy a dense range of
/// integers starting at zero, so a mapping that maps all or most nodes within
/// an "item-like" to something else can be implement by a `Vec` instead of a
/// tree or hash map.
newtype_index!
{
pub
struct
ItemLocalId
{
..
}
}
}
impl
indexed_vec
::
Idx
for
ItemLocalId
{
fn
new
(
idx
:
usize
)
->
Self
{
debug_assert!
((
idx
as
u32
)
as
usize
==
idx
);
ItemLocalId
(
idx
as
u32
)
}
fn
index
(
self
)
->
usize
{
self
.0
as
usize
}
}
pub
use
self
::
item_local_id_inner
::
ItemLocalId
;
/// The `HirId` corresponding to CRATE_NODE_ID and CRATE_DEF_INDEX
pub
const
CRATE_HIR_ID
:
HirId
=
HirId
{
owner
:
CRATE_DEF_INDEX
,
local_id
:
ItemLocalId
(
0
)
local_id
:
ItemLocalId
::
from_u32_const
(
0
)
};
pub
const
DUMMY_HIR_ID
:
HirId
=
HirId
{
...
...
@@ -162,7 +149,7 @@ fn index(self) -> usize {
local_id
:
DUMMY_ITEM_LOCAL_ID
,
};
pub
const
DUMMY_ITEM_LOCAL_ID
:
ItemLocalId
=
ItemLocalId
(
!
0
)
;
pub
const
DUMMY_ITEM_LOCAL_ID
:
ItemLocalId
=
ItemLocalId
::
MAX
;
#[derive(Clone,
RustcEncodable,
RustcDecodable,
Copy)]
pub
struct
Label
{
...
...
src/librustc/ich/impls_hir.rs
浏览文件 @
1d5829d8
...
...
@@ -79,7 +79,14 @@ fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> DefPathHash {
}
}
impl_stable_hash_for!
(
tuple_struct
hir
::
ItemLocalId
{
index
});
impl
<
'a
>
HashStable
<
StableHashingContext
<
'a
>>
for
hir
::
ItemLocalId
{
#[inline]
fn
hash_stable
<
W
:
StableHasherResult
>
(
&
self
,
hcx
:
&
mut
StableHashingContext
<
'a
>
,
hasher
:
&
mut
StableHasher
<
W
>
)
{
self
.as_u32
()
.hash_stable
(
hcx
,
hasher
);
}
}
impl
<
'a
>
ToStableHashKey
<
StableHashingContext
<
'a
>>
for
hir
::
ItemLocalId
{
...
...
@@ -800,7 +807,7 @@ fn hash_stable<W: StableHasherResult>(&self,
.iter
()
.map
(|
id
|
{
let
(
def_path_hash
,
local_id
)
=
id
.id
.to_stable_hash_key
(
hcx
);
debug_assert_eq!
(
local_id
,
hir
::
ItemLocalId
(
0
));
debug_assert_eq!
(
local_id
,
hir
::
ItemLocalId
::
from_u32
(
0
));
def_path_hash
.0
})
.fold
(
Fingerprint
::
ZERO
,
|
a
,
b
|
{
a
.combine_commutative
(
b
)
...
...
src/librustc/session/mod.rs
浏览文件 @
1d5829d8
...
...
@@ -393,7 +393,7 @@ pub fn reserve_node_ids(&self, count: usize) -> ast::NodeId {
match
id
.as_usize
()
.checked_add
(
count
)
{
Some
(
next
)
=>
{
self
.next_node_id
.set
(
ast
::
NodeId
::
new
(
next
));
self
.next_node_id
.set
(
ast
::
NodeId
::
from_usize
(
next
));
}
None
=>
bug!
(
"Input too large, ran out of node ids!"
),
}
...
...
@@ -1160,7 +1160,7 @@ pub fn build_session_(
recursion_limit
:
Once
::
new
(),
type_length_limit
:
Once
::
new
(),
const_eval_stack_frame_limit
:
100
,
next_node_id
:
OneThread
::
new
(
Cell
::
new
(
NodeId
::
new
(
1
))),
next_node_id
:
OneThread
::
new
(
Cell
::
new
(
NodeId
::
from_u32
(
1
))),
allocator_kind
:
Once
::
new
(),
injected_panic_runtime
:
Once
::
new
(),
imported_macro_spans
:
OneThread
::
new
(
RefCell
::
new
(
FxHashMap
::
default
())),
...
...
src/librustc_driver/pretty.rs
浏览文件 @
1d5829d8
...
...
@@ -425,7 +425,7 @@ fn post(&self, s: &mut pprust_hir::State, node: pprust_hir::AnnNode) -> io::Resu
pprust_hir
::
AnnNode
::
Item
(
item
)
=>
{
s
.s
.space
()
?
;
s
.synth_comment
(
format!
(
"node_id: {} hir local_id: {}"
,
item
.id
,
item
.hir_id.local_id
.
0
))
item
.id
,
item
.hir_id.local_id
.
as_u32
()
))
}
pprust_hir
::
AnnNode
::
SubItem
(
id
)
=>
{
s
.s
.space
()
?
;
...
...
@@ -434,18 +434,18 @@ fn post(&self, s: &mut pprust_hir::State, node: pprust_hir::AnnNode) -> io::Resu
pprust_hir
::
AnnNode
::
Block
(
blk
)
=>
{
s
.s
.space
()
?
;
s
.synth_comment
(
format!
(
"block node_id: {} hir local_id: {}"
,
blk
.id
,
blk
.hir_id.local_id
.
0
))
blk
.id
,
blk
.hir_id.local_id
.
as_u32
()
))
}
pprust_hir
::
AnnNode
::
Expr
(
expr
)
=>
{
s
.s
.space
()
?
;
s
.synth_comment
(
format!
(
"node_id: {} hir local_id: {}"
,
expr
.id
,
expr
.hir_id.local_id
.
0
))
?
;
expr
.id
,
expr
.hir_id.local_id
.
as_u32
()
))
?
;
s
.pclose
()
}
pprust_hir
::
AnnNode
::
Pat
(
pat
)
=>
{
s
.s
.space
()
?
;
s
.synth_comment
(
format!
(
"pat node_id: {} hir local_id: {}"
,
pat
.id
,
pat
.hir_id.local_id
.
0
))
pat
.id
,
pat
.hir_id.local_id
.
as_u32
()
))
}
}
}
...
...
@@ -566,7 +566,7 @@ impl FromStr for UserIdentifiedItem {
type
Err
=
();
fn
from_str
(
s
:
&
str
)
->
Result
<
UserIdentifiedItem
,
()
>
{
Ok
(
s
.parse
()
.map
(
ast
::
NodeId
::
new
)
.map
(
ast
::
NodeId
::
from_u32
)
.map
(
ItemViaNode
)
.unwrap_or_else
(|
_
|
ItemViaPath
(
s
.split
(
"::"
)
.map
(|
s
|
s
.to_string
())
.collect
())))
}
...
...
src/librustc_driver/test.rs
浏览文件 @
1d5829d8
...
...
@@ -232,20 +232,20 @@ pub fn create_simple_region_hierarchy(&mut self) {
// children of 1, etc
let
dscope
=
region
::
Scope
{
id
:
hir
::
ItemLocalId
(
1
),
id
:
hir
::
ItemLocalId
::
from_u32
(
1
),
data
:
region
::
ScopeData
::
Destruction
,
};
self
.region_scope_tree
.record_scope_parent
(
dscope
,
None
);
self
.create_region_hierarchy
(
&
RH
{
id
:
hir
::
ItemLocalId
(
1
),
id
:
hir
::
ItemLocalId
::
from_u32
(
1
),
sub
:
&
[
RH
{
id
:
hir
::
ItemLocalId
(
10
),
id
:
hir
::
ItemLocalId
::
from_u32
(
10
),
sub
:
&
[],
},
RH
{
id
:
hir
::
ItemLocalId
(
11
),
id
:
hir
::
ItemLocalId
::
from_u32
(
11
),
sub
:
&
[],
},
],
...
...
@@ -400,7 +400,7 @@ pub fn t_rptr_late_bound_with_debruijn(
pub
fn
t_rptr_scope
(
&
self
,
id
:
u32
)
->
Ty
<
'tcx
>
{
let
r
=
ty
::
ReScope
(
region
::
Scope
{
id
:
hir
::
ItemLocalId
(
id
),
id
:
hir
::
ItemLocalId
::
from_u32
(
id
),
data
:
region
::
ScopeData
::
Node
,
});
self
.infcx
...
...
src/librustc_resolve/resolve_imports.rs
浏览文件 @
1d5829d8
...
...
@@ -663,7 +663,7 @@ struct UniformPathsCanaryResults<'a> {
let
mut
errors
=
false
;
let
mut
seen_spans
=
FxHashSet
::
default
();
let
mut
error_vec
=
Vec
::
new
();
let
mut
prev_root_id
:
NodeId
=
NodeId
::
new
(
0
);
let
mut
prev_root_id
:
NodeId
=
NodeId
::
from_u32
(
0
);
for
i
in
0
..
self
.determined_imports
.len
()
{
let
import
=
self
.determined_imports
[
i
];
let
error
=
self
.finalize_import
(
import
);
...
...
src/librustdoc/passes/collect_intra_doc_links.rs
浏览文件 @
1d5829d8
...
...
@@ -243,7 +243,7 @@ fn add_test(&mut self, _: String, _: LangString, _: usize) {
if
tests
.found_tests
==
0
{
let
mut
diag
=
cx
.tcx
.struct_span_lint_node
(
lint
::
builtin
::
MISSING_DOC_CODE_EXAMPLES
,
NodeId
::
new
(
0
),
NodeId
::
from_u32
(
0
),
span_of_attrs
(
&
item
.attrs
),
"Missing code example in this documentation"
);
diag
.emit
();
...
...
@@ -281,14 +281,14 @@ fn fold_item(&mut self, mut item: Item) -> Option<Item> {
let
current_item
=
match
item
.inner
{
ModuleItem
(
..
)
=>
{
if
item
.attrs.inner_docs
{
if
item_node_id
.unwrap
()
!=
NodeId
::
new
(
0
)
{
if
item_node_id
.unwrap
()
!=
NodeId
::
from_u32
(
0
)
{
item
.name
.clone
()
}
else
{
None
}
}
else
{
match
parent_node
.or
(
self
.mod_ids
.last
()
.cloned
())
{
Some
(
parent
)
if
parent
!=
NodeId
::
new
(
0
)
=>
{
Some
(
parent
)
if
parent
!=
NodeId
::
from_u32
(
0
)
=>
{
//FIXME: can we pull the parent module's name from elsewhere?
Some
(
self
.cx.tcx.hir
.name
(
parent
)
.to_string
())
}
...
...
@@ -538,13 +538,13 @@ fn resolution_failure(
);
diag
=
cx
.tcx
.struct_span_lint_node
(
lint
::
builtin
::
INTRA_DOC_LINK_RESOLUTION_FAILURE
,
NodeId
::
new
(
0
),
NodeId
::
from_u32
(
0
),
sp
,
&
msg
);
diag
.span_label
(
sp
,
"cannot be resolved, ignoring"
);
}
else
{
diag
=
cx
.tcx
.struct_span_lint_node
(
lint
::
builtin
::
INTRA_DOC_LINK_RESOLUTION_FAILURE
,
NodeId
::
new
(
0
),
NodeId
::
from_u32
(
0
),
sp
,
&
msg
);
...
...
@@ -564,7 +564,7 @@ fn resolution_failure(
diag
}
else
{
cx
.tcx
.struct_span_lint_node
(
lint
::
builtin
::
INTRA_DOC_LINK_RESOLUTION_FAILURE
,
NodeId
::
new
(
0
),
NodeId
::
from_u32
(
0
),
sp
,
&
msg
)
};
...
...
src/libsyntax/ast.rs
浏览文件 @
1d5829d8
...
...
@@ -18,7 +18,6 @@
use
ext
::
hygiene
::{
Mark
,
SyntaxContext
};
use
print
::
pprust
;
use
ptr
::
P
;
use
rustc_data_structures
::
indexed_vec
;
use
rustc_data_structures
::
indexed_vec
::
Idx
;
#[cfg(target_arch
=
"x86_64"
)]
use
rustc_data_structures
::
static_assert
;
...
...
@@ -33,7 +32,6 @@
use
rustc_data_structures
::
sync
::
Lrc
;
use
serialize
::{
self
,
Decoder
,
Encoder
};
use
std
::
fmt
;
use
std
::
u32
;
pub
use
rustc_target
::
abi
::
FloatTy
;
...
...
@@ -215,71 +213,54 @@ pub struct ParenthesisedArgs {
pub
output
:
Option
<
P
<
Ty
>>
,
}
#[derive(Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Debug)]
pub
struct
NodeId
(
u32
);
impl
NodeId
{
pub
fn
new
(
x
:
usize
)
->
NodeId
{
assert
!
(
x
<
(
u32
::
MAX
as
usize
));
NodeId
(
x
as
u32
)
}
pub
fn
from_u32
(
x
:
u32
)
->
NodeId
{
NodeId
(
x
)
}
pub
fn
as_usize
(
&
self
)
->
usize
{
self
.0
as
usize
// hack to ensure that we don't try to access the private parts of `NodeId` in this module
mod
node_id_inner
{
use
rustc_data_structures
::
indexed_vec
::
Idx
;
newtype_index!
{
pub
struct
NodeId
{
ENCODABLE
=
custom
DEBUG_FORMAT
=
"NodeId({})"
}
}
}
pub
fn
as_u32
(
&
self
)
->
u32
{
self
.0
}
pub
use
self
::
node_id_inner
::
NodeId
;
impl
NodeId
{
pub
fn
placeholder_from_mark
(
mark
:
Mark
)
->
Self
{
NodeId
(
mark
.as_u32
())
NodeId
::
from_u32
(
mark
.as_u32
())
}
pub
fn
placeholder_to_mark
(
self
)
->
Mark
{
Mark
::
from_u32
(
self
.
0
)
Mark
::
from_u32
(
self
.
as_u32
()
)
}
}
impl
fmt
::
Display
for
NodeId
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
)
->
fmt
::
Result
{
fmt
::
Display
::
fmt
(
&
self
.
0
,
f
)
fmt
::
Display
::
fmt
(
&
self
.
as_u32
()
,
f
)
}
}
impl
serialize
::
UseSpecializedEncodable
for
NodeId
{
fn
default_encode
<
S
:
Encoder
>
(
&
self
,
s
:
&
mut
S
)
->
Result
<
(),
S
::
Error
>
{
s
.emit_u32
(
self
.
0
)
s
.emit_u32
(
self
.
as_u32
()
)
}
}
impl
serialize
::
UseSpecializedDecodable
for
NodeId
{
fn
default_decode
<
D
:
Decoder
>
(
d
:
&
mut
D
)
->
Result
<
NodeId
,
D
::
Error
>
{
d
.read_u32
()
.map
(
NodeId
)
}
}
impl
indexed_vec
::
Idx
for
NodeId
{
fn
new
(
idx
:
usize
)
->
Self
{
NodeId
::
new
(
idx
)
}
fn
index
(
self
)
->
usize
{
self
.as_usize
()
d
.read_u32
()
.map
(
NodeId
::
from_u32
)
}
}
/// Node id used to represent the root of the crate.
pub
const
CRATE_NODE_ID
:
NodeId
=
NodeId
(
0
);
pub
const
CRATE_NODE_ID
:
NodeId
=
NodeId
::
from_u32_const
(
0
);
/// When parsing and doing expansions, we initially give all AST nodes this AST
/// node value. Then later, in the renumber pass, we renumber them to have
/// small, positive ids.
pub
const
DUMMY_NODE_ID
:
NodeId
=
NodeId
(
!
0
)
;
pub
const
DUMMY_NODE_ID
:
NodeId
=
NodeId
::
MAX
;
/// A modifier on a bound, currently this is only used for `?Sized`, where the
/// modifier is `Maybe`. Negative bounds should also be handled here.
...
...
src/libsyntax/lib.rs
浏览文件 @
1d5829d8
...
...
@@ -26,6 +26,7 @@
#![feature(rustc_diagnostic_macros)]
#![feature(slice_sort_by_cached_key)]
#![feature(str_escape)]
#![feature(step_trait)]
#![feature(try_trait)]
#![feature(unicode_internals)]
...
...
@@ -37,7 +38,7 @@
#[macro_use]
extern
crate
log
;
pub
extern
crate
rustc_errors
as
errors
;
extern
crate
syntax_pos
;
extern
crate
rustc_data_structures
;
#[macro_use]
extern
crate
rustc_data_structures
;
extern
crate
rustc_target
;
#[macro_use]
extern
crate
scoped_tls
;
#[macro_use]
...
...
src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs
浏览文件 @
1d5829d8
...
...
@@ -43,7 +43,7 @@ fn expand_mbe_matches(cx: &mut ExtCtxt, _: Span, args: &[TokenTree])
&
[],
Edition
::
Edition2015
,
// not used...
NodeId
::
new
(
0
));
NodeId
::
from_u32
(
0
));
let
map
=
match
TokenTree
::
parse
(
cx
,
&
mbe_matcher
,
args
.iter
()
.cloned
()
.collect
())
{
Success
(
map
)
=>
map
,
Failure
(
_
,
tok
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录