Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
8b71e0bb
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,发现更多精彩内容 >>
未验证
提交
8b71e0bb
编写于
9月 02, 2017
作者:
B
bjorn3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Better trace-macro and less span_err_fatal
上级
8bb7dba9
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
15 addition
and
41 deletion
+15
-41
src/libsyntax/ext/base.rs
src/libsyntax/ext/base.rs
+3
-1
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+2
-1
src/test/ui/macros/trace_faulty_macros.rs
src/test/ui/macros/trace_faulty_macros.rs
+6
-6
src/test/ui/macros/trace_faulty_macros.stderr
src/test/ui/macros/trace_faulty_macros.stderr
+4
-33
未找到文件。
src/libsyntax/ext/base.rs
浏览文件 @
8b71e0bb
...
...
@@ -792,7 +792,7 @@ pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! {
pub
fn
span_bug
(
&
self
,
sp
:
Span
,
msg
:
&
str
)
->
!
{
self
.parse_sess.span_diagnostic
.span_bug
(
sp
,
msg
);
}
pub
fn
trace_macros_diag
(
&
self
)
{
pub
fn
trace_macros_diag
(
&
mut
self
)
{
for
(
sp
,
notes
)
in
self
.expansions
.iter
()
{
let
mut
db
=
self
.parse_sess.span_diagnostic
.span_note_diag
(
*
sp
,
"trace_macro"
);
for
note
in
notes
{
...
...
@@ -800,6 +800,8 @@ pub fn trace_macros_diag(&self) {
}
db
.emit
();
}
// Fixme: does this result in errors?
self
.expansions
.clear
();
}
pub
fn
bug
(
&
self
,
msg
:
&
str
)
->
!
{
self
.parse_sess.span_diagnostic
.bug
(
msg
);
...
...
src/libsyntax/ext/expand.rs
浏览文件 @
8b71e0bb
...
...
@@ -384,7 +384,7 @@ fn expand_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) -> Expan
if
self
.cx.current_expansion.depth
>
self
.cx.ecfg.recursion_limit
{
let
info
=
self
.cx.current_expansion.mark
.expn_info
()
.unwrap
();
let
suggested_limit
=
self
.cx.ecfg.recursion_limit
*
2
;
let
mut
err
=
self
.cx
.struct_span_
fatal
(
info
.call_site
,
let
mut
err
=
self
.cx
.struct_span_
err
(
info
.call_site
,
&
format!
(
"recursion limit reached while expanding the macro `{}`"
,
info
.callee
.name
()));
err
.help
(
&
format!
(
...
...
@@ -640,6 +640,7 @@ fn parse_expansion(&mut self, toks: TokenStream, kind: ExpansionKind, path: &Pat
Ok
(
expansion
)
=>
expansion
,
Err
(
mut
err
)
=>
{
err
.emit
();
self
.cx
.trace_macros_diag
();
return
kind
.dummy
(
span
);
}
};
...
...
src/test/ui/macros/trace_faulty_macros.rs
浏览文件 @
8b71e0bb
...
...
@@ -18,13 +18,13 @@
};
}
macro_rules!
nested_
pat_macro
{
macro_rules!
pat_macro
{
()
=>
{
nested_pat_macro!
(
inner
);
pat_macro!
(
A
{
a
:
a
,
b
:
0
,
c
:
_
,
..
});
};
(
$a:pat
)
=>
{
$a
};
(
inner
)
=>
{
a
|
b
|
1
...
3
|
_
}
}
macro_rules!
my_recursive_macro
{
...
...
@@ -41,11 +41,11 @@
fn
main
()
{
my_faulty_macro!
();
nested_pat_macro!
();
my_recursive_macro!
();
test!
();
non_exisiting!
();
derive!
(
Debug
);
let
a
=
pat_macro!
();
}
#[my_macro]
...
...
src/test/ui/macros/trace_faulty_macros.stderr
浏览文件 @
8b71e0bb
...
...
@@ -17,30 +17,21 @@ note: trace_macro
= note: to `my_faulty_macro ! ( bcd ) ;`
= note: expanding `my_faulty_macro! { bcd }`
error: expected expression, found `_`
--> $DIR/trace_faulty_macros.rs:26:27
|
26 | a | b | 1 ... 3 | _
| ^
...
44 | nested_pat_macro!();
| -------------------- in this macro invocation
error: recursion limit reached while expanding the macro `my_recursive_macro`
--> $DIR/trace_faulty_macros.rs:32:9
|
32 | my_recursive_macro!();
| ^^^^^^^^^^^^^^^^^^^^^^
...
4
5
| my_recursive_macro!();
4
4
| my_recursive_macro!();
| ---------------------- in this macro invocation
|
= help: consider adding a `#![recursion_limit="8"]` attribute to your crate
note: trace_macro
--> $DIR/trace_faulty_macros.rs:4
5
:5
--> $DIR/trace_faulty_macros.rs:4
4
:5
|
4
5
| my_recursive_macro!();
4
4
| my_recursive_macro!();
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: expanding `my_recursive_macro! { }`
...
...
@@ -54,24 +45,4 @@ note: trace_macro
= note: expanding `my_recursive_macro! { }`
= note: to `my_recursive_macro ! ( ) ;`
note: trace_macro
--> $DIR/trace_faulty_macros.rs:43:5
|
43 | my_faulty_macro!();
| ^^^^^^^^^^^^^^^^^^^
|
= note: expanding `my_faulty_macro! { }`
= note: to `my_faulty_macro ! ( bcd ) ;`
= note: expanding `my_faulty_macro! { bcd }`
note: trace_macro
--> $DIR/trace_faulty_macros.rs:44:5
|
44 | nested_pat_macro!();
| ^^^^^^^^^^^^^^^^^^^^
|
= note: expanding `nested_pat_macro! { }`
= note: to `nested_pat_macro ! ( inner ) ;`
= note: expanding `nested_pat_macro! { inner }`
= note: to `a | b | 1 ... 3 | _`
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录