Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f9b58591
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,发现更多精彩内容 >>
提交
f9b58591
编写于
1月 10, 2021
作者:
V
Vadim Petrochenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resolve: Simplify built-in macro table
上级
34628e5b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
19 deletion
+15
-19
compiler/rustc_builtin_macros/src/lib.rs
compiler/rustc_builtin_macros/src/lib.rs
+4
-10
compiler/rustc_expand/src/base.rs
compiler/rustc_expand/src/base.rs
+1
-1
compiler/rustc_interface/src/passes.rs
compiler/rustc_interface/src/passes.rs
+1
-1
compiler/rustc_resolve/src/lib.rs
compiler/rustc_resolve/src/lib.rs
+2
-2
compiler/rustc_resolve/src/macros.rs
compiler/rustc_resolve/src/macros.rs
+7
-5
未找到文件。
compiler/rustc_builtin_macros/src/lib.rs
浏览文件 @
f9b58591
...
...
@@ -14,10 +14,9 @@
use
crate
::
deriving
::
*
;
use
rustc_expand
::
base
::{
MacroExpanderFn
,
ResolverExpand
,
SyntaxExtension
,
SyntaxExtension
Kind
};
use
rustc_expand
::
base
::{
MacroExpanderFn
,
ResolverExpand
,
SyntaxExtensionKind
};
use
rustc_expand
::
proc_macro
::
BangProcMacro
;
use
rustc_span
::
edition
::
Edition
;
use
rustc_span
::
symbol
::{
sym
,
Ident
};
use
rustc_span
::
symbol
::
sym
;
mod
asm
;
mod
assert
;
...
...
@@ -44,13 +43,8 @@
pub
mod
standard_library_imports
;
pub
mod
test_harness
;
pub
fn
register_builtin_macros
(
resolver
:
&
mut
dyn
ResolverExpand
,
edition
:
Edition
)
{
let
mut
register
=
|
name
,
kind
|
{
resolver
.register_builtin_macro
(
Ident
::
with_dummy_span
(
name
),
SyntaxExtension
::
default
(
kind
,
edition
),
)
};
pub
fn
register_builtin_macros
(
resolver
:
&
mut
dyn
ResolverExpand
)
{
let
mut
register
=
|
name
,
kind
|
resolver
.register_builtin_macro
(
name
,
kind
);
macro
register_bang
(
$
(
$
name
:
ident
:
$
f
:
expr
,)
*
)
{
$
(
register
(
sym
::
$
name
,
SyntaxExtensionKind
::
LegacyBang
(
Box
::
new
(
$
f
as
MacroExpanderFn
)));)
*
}
...
...
compiler/rustc_expand/src/base.rs
浏览文件 @
f9b58591
...
...
@@ -868,7 +868,7 @@ pub trait ResolverExpand {
fn
resolve_dollar_crates
(
&
mut
self
);
fn
visit_ast_fragment_with_placeholders
(
&
mut
self
,
expn_id
:
ExpnId
,
fragment
:
&
AstFragment
);
fn
register_builtin_macro
(
&
mut
self
,
ident
:
Ident
,
ext
:
SyntaxExtension
);
fn
register_builtin_macro
(
&
mut
self
,
name
:
Symbol
,
ext
:
SyntaxExtensionKind
);
fn
expansion_for_ast_pass
(
&
mut
self
,
...
...
compiler/rustc_interface/src/passes.rs
浏览文件 @
f9b58591
...
...
@@ -236,7 +236,7 @@ fn configure_and_expand_inner<'a>(
pre_expansion_lint
(
sess
,
lint_store
,
&
krate
);
let
mut
resolver
=
Resolver
::
new
(
sess
,
&
krate
,
crate_name
,
metadata_loader
,
&
resolver_arenas
);
rustc_builtin_macros
::
register_builtin_macros
(
&
mut
resolver
,
sess
.edition
()
);
rustc_builtin_macros
::
register_builtin_macros
(
&
mut
resolver
);
krate
=
sess
.time
(
"crate_injection"
,
||
{
let
alt_std_name
=
sess
.opts.alt_std_name
.as_ref
()
.map
(|
s
|
Symbol
::
intern
(
s
));
...
...
compiler/rustc_resolve/src/lib.rs
浏览文件 @
f9b58591
...
...
@@ -33,7 +33,7 @@
use
rustc_data_structures
::
ptr_key
::
PtrKey
;
use
rustc_data_structures
::
sync
::
Lrc
;
use
rustc_errors
::{
struct_span_err
,
Applicability
,
DiagnosticBuilder
};
use
rustc_expand
::
base
::
SyntaxExtension
;
use
rustc_expand
::
base
::
{
SyntaxExtension
,
SyntaxExtensionKind
}
;
use
rustc_hir
::
def
::
Namespace
::
*
;
use
rustc_hir
::
def
::{
self
,
CtorOf
,
DefKind
,
NonMacroAttrKind
,
PartialRes
};
use
rustc_hir
::
def_id
::{
CrateNum
,
DefId
,
DefIdMap
,
LocalDefId
,
CRATE_DEF_INDEX
};
...
...
@@ -870,7 +870,7 @@ pub struct ExternPreludeEntry<'a> {
/// Used for better errors for E0773
enum
BuiltinMacroState
{
NotYetSeen
(
SyntaxExtension
),
NotYetSeen
(
SyntaxExtension
Kind
),
AlreadySeen
(
Span
),
}
...
...
compiler/rustc_resolve/src/macros.rs
浏览文件 @
f9b58591
...
...
@@ -14,7 +14,8 @@
use
rustc_data_structures
::
ptr_key
::
PtrKey
;
use
rustc_data_structures
::
sync
::
Lrc
;
use
rustc_errors
::
struct_span_err
;
use
rustc_expand
::
base
::{
Indeterminate
,
InvocationRes
,
ResolverExpand
,
SyntaxExtension
};
use
rustc_expand
::
base
::{
Indeterminate
,
InvocationRes
,
ResolverExpand
};
use
rustc_expand
::
base
::{
SyntaxExtension
,
SyntaxExtensionKind
};
use
rustc_expand
::
compile_declarative_macro
;
use
rustc_expand
::
expand
::{
AstFragment
,
Invocation
,
InvocationKind
};
use
rustc_feature
::
is_builtin_attr_name
;
...
...
@@ -176,10 +177,11 @@ fn visit_ast_fragment_with_placeholders(&mut self, expansion: ExpnId, fragment:
parent_scope
.module.unexpanded_invocations
.borrow_mut
()
.remove
(
&
expansion
);
}
fn
register_builtin_macro
(
&
mut
self
,
ident
:
Ident
,
ext
:
SyntaxExtension
)
{
if
self
.builtin_macros
.insert
(
ident
.
name
,
BuiltinMacroState
::
NotYetSeen
(
ext
))
.is_some
()
{
fn
register_builtin_macro
(
&
mut
self
,
name
:
Symbol
,
ext
:
SyntaxExtensionKind
)
{
if
self
.builtin_macros
.insert
(
name
,
BuiltinMacroState
::
NotYetSeen
(
ext
))
.is_some
()
{
self
.session
.span_err
(
ident
.span
,
&
format!
(
"built-in macro `{}` was already defined"
,
ident
));
.diagnostic
()
.bug
(
&
format!
(
"built-in macro `{}` was already registered"
,
name
));
}
}
...
...
@@ -1096,7 +1098,7 @@ fn prohibit_imported_non_macro_attrs(
// while still taking everything else from the source code.
// If we already loaded this builtin macro, give a better error message than 'no such builtin macro'.
match
mem
::
replace
(
builtin_macro
,
BuiltinMacroState
::
AlreadySeen
(
item
.span
))
{
BuiltinMacroState
::
NotYetSeen
(
ext
)
=>
result
.kind
=
ext
.kind
,
BuiltinMacroState
::
NotYetSeen
(
ext
)
=>
result
.kind
=
ext
,
BuiltinMacroState
::
AlreadySeen
(
span
)
=>
{
struct_span_err!
(
self
.session
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录