Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
351a5fd2
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,发现更多精彩内容 >>
提交
351a5fd2
编写于
6月 27, 2014
作者:
J
John Clements
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added unit and standalone test for 15221, extra debugging output
上级
e100d26d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
48 addition
and
5 deletion
+48
-5
src/libsyntax/ext/expand.rs
src/libsyntax/ext/expand.rs
+26
-5
src/test/run-pass/issue-15221.rs
src/test/run-pass/issue-15221.rs
+22
-0
未找到文件。
src/libsyntax/ext/expand.rs
浏览文件 @
351a5fd2
...
...
@@ -54,7 +54,6 @@ pub fn expand_expr(e: Gc<ast::Expr>, fld: &mut MacroExpander) -> Gc<ast::Expr> {
}
let
extname
=
pth
.segments
.get
(
0
)
.identifier
;
let
extnamestr
=
token
::
get_ident
(
extname
);
// leaving explicit deref here to highlight unbox op:
let
marked_after
=
match
fld
.extsbox
.find
(
&
extname
.name
)
{
None
=>
{
fld
.cx
.span_err
(
...
...
@@ -1294,6 +1293,19 @@ fn z() {match 8 {x => bad_macro!(x)}}",
0
)
}
// FIXME #15221, somehow pats aren't getting labeled correctly?
// should expand into
// fn main(){let g1_1 = 13; g1_1}}
#[test]
fn
pat_expand_issue_15221
(){
run_renaming_test
(
&
(
"macro_rules! inner ( ($e:pat ) => ($e))
macro_rules! outer ( ($e:pat ) => (inner!($e)))
fn main() { let outer!(g) = 13; g;}"
,
vec!
(
vec!
(
0
)),
true
),
0
)
}
// create a really evil test case where a $x appears inside a binding of $x
// but *shouldnt* bind because it was inserted by a different macro....
// can't write this test case until we have macro-generating macros.
...
...
@@ -1343,9 +1355,13 @@ fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
.ctxt
,
invalid_name
);
if
!
(
varref_name
==
binding_name
)
{
let
varref_idents
:
Vec
<
ast
::
Ident
>
=
varref
.segments
.iter
()
.map
(|
s
|
s
.identifier
)
.collect
();
println!
(
"uh oh, should match but doesn't:"
);
println!
(
"varref #{
:?}: {:?}"
,
idx
,
varref
);
println!
(
"binding #{
:?}: {:?
}"
,
binding_idx
,
*
bindings
.get
(
binding_idx
));
println!
(
"varref #{
}: {}"
,
idx
,
varref_idents
);
println!
(
"binding #{
}: {
}"
,
binding_idx
,
*
bindings
.get
(
binding_idx
));
mtwt
::
with_sctable
(|
x
|
mtwt
::
display_sctable
(
x
));
}
assert_eq!
(
varref_name
,
binding_name
);
...
...
@@ -1360,11 +1376,15 @@ fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
==
binding_name
);
// temp debugging:
if
fail
{
let
varref_idents
:
Vec
<
ast
::
Ident
>
=
varref
.segments
.iter
()
.map
(|
s
|
s
.identifier
)
.collect
();
println!
(
"failure on test {}"
,
test_idx
);
println!
(
"text of test case:
\"
{}
\"
"
,
teststr
);
println!
(
""
);
println!
(
"uh oh, matches but shouldn't:"
);
println!
(
"varref: {
:?}"
,
varref
);
println!
(
"varref: {
}"
,
varref_idents
);
// good lord, you can't make a path with 0 segments, can you?
let
string
=
token
::
get_ident
(
varref
.segments
.get
(
0
)
...
...
@@ -1372,7 +1392,7 @@ fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
println!
(
"varref's first segment's uint: {}, and string:
\"
{}
\"
"
,
varref
.segments
.get
(
0
)
.identifier.name
,
string
.get
());
println!
(
"binding: {
:?
}"
,
*
bindings
.get
(
binding_idx
));
println!
(
"binding: {}"
,
*
bindings
.get
(
binding_idx
));
mtwt
::
with_sctable
(|
x
|
mtwt
::
display_sctable
(
x
));
}
assert
!
(
!
fail
);
...
...
@@ -1442,5 +1462,6 @@ fn crate_idents(){
assert_eq!
(
idents
,
strs_to_idents
(
vec!
(
"a"
,
"b"
,
"None"
,
"i"
,
"i"
,
"z"
,
"y"
)));
}
//
}
src/test/run-pass/issue-15221.rs
0 → 100644
浏览文件 @
351a5fd2
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(macro_rules)]
macro_rules!
inner_bind
(
(
$p:pat
,
$id:ident
)
=>
({
let
$p
=
13
;
$id
}))
macro_rules!
outer_bind
(
(
$p:pat
,
$id:ident
)
=>
(
inner_bind!
(
$p
,
$id
)))
fn
main
()
{
outer_bind!
(
g1
,
g1
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录