Skip to content

Commit b6cf028

Browse files
committed
root testsuite: build and run original test from Issue 15750.
1 parent 51ff6c0 commit b6cf028

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FILES= test.bin
2+
3+
all: $(patsubst %.rs,%.dot,$(FILES))
4+
5+
RUSTC_LIB=$(RUSTC) --crate-type=lib
6+
7+
RUSTC ?= objdir-dbg/x86_64-apple-darwin/stage2/rustc
8+
9+
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
10+
$(filter $(subst *,%,$2),$d))
11+
12+
objdir-dbg/x86_64-apple-darwin/stage2/rustc: src/etc/rustc-wrapper.macosx.sh objdir-dbg/x86_64-apple-darwin/stage2/bin/rustc Makefile $(call rwildcard,src/,*.rs)
13+
cd objdir-dbg && make-rustc-stage2 --no-libs
14+
cp $< $@
15+
chmod +x $@
16+
17+
RUST_LOG=rustc::middle::borrowck,rustc::middle::ty,rustc::middle::typeck,rustc::middle::expr_use_visitor,rustc::middle::region,rustc::middle::trans
18+
19+
%.dylib: %.rs Makefile objdir-dbg/x86_64-apple-darwin/stage2/rustc
20+
$(RUSTC) $<
21+
22+
%.bin: %.rs Makefile objdir-dbg/x86_64-apple-darwin/stage2/rustc
23+
$(RUSTC) $< -L. -o $@
24+
25+
test.bin: plugin.dylib
26+
27+
%.dot: %.rs Makefile objdir-dbg/x86_64-apple-darwin/stage2/rustc
28+
$(RUSTC) -Z flowgraph-print-all --pretty flowgraph=% $< -o $@
29+
30+
%.pp: %.rs Makefile objdir-dbg/x86_64-apple-darwin/stage2/rustc
31+
$(RUSTC) --pretty expanded,identified $< -o $@
32+
33+
%.log: %.rs Makefile objdir-dbg/x86_64-apple-darwin/stage2/rustc
34+
RUST_LOG=$(RUST_LOG) RUST_BACKTRACE=1 $(RUSTC_LIB) $< 2> $@

plugin.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![crate_type="dylib"]
2+
#![feature(plugin_registrar, quote)]
3+
4+
// Taken from issue #15750
5+
6+
extern crate syntax;
7+
extern crate rustc;
8+
9+
use rustc::plugin::Registry;
10+
11+
use syntax::codemap::Span;
12+
use syntax::ext::base::{ExtCtxt, MacResult, MacExpr};
13+
use syntax::parse;
14+
use syntax::ast;
15+
16+
fn expand(cx: &mut ExtCtxt, _span: Span, tts: &[ast::TokenTree])
17+
-> Box<MacResult> {
18+
// Parse an expression and emit it unchanged.
19+
let mut parser = parse::new_parser_from_tts(cx.parse_sess(),
20+
cx.cfg(), Vec::from_slice(tts));
21+
let expr = parser.parse_expr();
22+
MacExpr::new(quote_expr!(&mut *cx, $expr))
23+
}
24+
25+
#[plugin_registrar]
26+
pub fn plugin_registrar(reg: &mut Registry) {
27+
reg.register_macro("mymacro", expand);
28+
}

src/etc/rustc-wrapper.macosx.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DIR=$(dirname $0)
2+
CMD="DYLD_LIBRARY_PATH=$DIR/lib:$DYLD_LIBRARY_PATH exec $DIR/bin/rustc $@"
3+
# echo $CMD
4+
eval "$CMD"

test.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(phase)]
2+
3+
// Taken from Issue #15750
4+
5+
#[phase(plugin)]
6+
extern crate plugin;
7+
8+
fn main() {
9+
let x = 3;
10+
println!("{}", mymacro!(x));
11+
}

0 commit comments

Comments
 (0)