Skip to content

Commit 3d2191a

Browse files
committed
---
yaml --- r: 81327 b: refs/heads/snap-stage3 c: 1d6c011 h: refs/heads/master i: 81325: a1cb5ec 81323: fdf7985 81319: e549bd5 81311: 43edf3e v: v3
1 parent fc03bfd commit 3d2191a

File tree

6 files changed

+263
-144
lines changed

6 files changed

+263
-144
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: bbbafc4e466e8026d30b9c47d1f104fd44815bef
4+
refs/heads/snap-stage3: 1d6c01148c7e0b96105e7553f4e935e31be906d5
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/etc/emacs/rust-mode-tests.el

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,35 @@ This is some more text. Fee fie fo fum. Humpty dumpty sat on a wall.
196196
*very very very long string
197197
*/"))
198198

199+
(ert-deftest fill-paragraph-single-line-style-with-code-before ()
200+
(test-fill-paragraph
201+
"fn foo() { }
202+
/// This is my comment. This is more of my comment. This is even more."
203+
"fn foo() { }
204+
/// This is my comment. This is
205+
/// more of my comment. This is
206+
/// even more." 14))
207+
208+
(ert-deftest fill-paragraph-single-line-style-with-code-after ()
209+
(test-fill-paragraph
210+
"/// This is my comment. This is more of my comment. This is even more.
211+
fn foo() { }"
212+
"/// This is my comment. This is
213+
/// more of my comment. This is
214+
/// even more.
215+
fn foo() { }" 1 73))
216+
217+
(ert-deftest fill-paragraph-single-line-style-code-before-and-after ()
218+
(test-fill-paragraph
219+
"fn foo() { }
220+
/// This is my comment. This is more of my comment. This is even more.
221+
fn bar() { }"
222+
"fn foo() { }
223+
/// This is my comment. This is
224+
/// more of my comment. This is
225+
/// even more.
226+
fn bar() { }" 14 67))
227+
199228
(defun test-auto-fill (initial position inserted expected)
200229
(rust-test-manip-code
201230
initial

branches/snap-stage3/src/etc/emacs/rust-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@
300300
(let
301301
((fill-paragraph-function
302302
(if (not (eq fill-paragraph-function 'rust-fill-paragraph))
303-
fill-paragraph-function)))
303+
fill-paragraph-function))
304+
(fill-paragraph-handle-comment t))
304305
(apply 'fill-paragraph args)
305306
t))))))
306307

branches/snap-stage3/src/libstd/rt/io/process.rs

Lines changed: 2 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -140,145 +140,5 @@ impl Drop for Process {
140140
}
141141
}
142142

143-
#[cfg(test)]
144-
mod tests {
145-
use prelude::*;
146-
use super::*;
147-
148-
use rt::io::{Reader, Writer};
149-
use rt::io::pipe::*;
150-
use str;
151-
152-
#[test]
153-
#[cfg(unix, not(android))]
154-
#[ignore] // FIXME(#9341)
155-
fn smoke() {
156-
let io = ~[];
157-
let args = ProcessConfig {
158-
program: "/bin/sh",
159-
args: [~"-c", ~"true"],
160-
env: None,
161-
cwd: None,
162-
io: io,
163-
};
164-
let p = Process::new(args);
165-
assert!(p.is_some());
166-
let mut p = p.unwrap();
167-
assert_eq!(p.wait(), 0);
168-
}
169-
170-
#[test]
171-
#[cfg(unix, not(android))]
172-
#[ignore] // FIXME(#9341)
173-
fn smoke_failure() {
174-
let io = ~[];
175-
let args = ProcessConfig {
176-
program: "if-this-is-a-binary-then-the-world-has-ended",
177-
args: [],
178-
env: None,
179-
cwd: None,
180-
io: io,
181-
};
182-
let p = Process::new(args);
183-
assert!(p.is_some());
184-
let mut p = p.unwrap();
185-
assert!(p.wait() != 0);
186-
}
187-
188-
#[test]
189-
#[cfg(unix, not(android))]
190-
#[ignore] // FIXME(#9341)
191-
fn exit_reported_right() {
192-
let io = ~[];
193-
let args = ProcessConfig {
194-
program: "/bin/sh",
195-
args: [~"-c", ~"exit 1"],
196-
env: None,
197-
cwd: None,
198-
io: io,
199-
};
200-
let p = Process::new(args);
201-
assert!(p.is_some());
202-
let mut p = p.unwrap();
203-
assert_eq!(p.wait(), 1);
204-
}
205-
206-
fn read_all(input: &mut Reader) -> ~str {
207-
let mut ret = ~"";
208-
let mut buf = [0, ..1024];
209-
loop {
210-
match input.read(buf) {
211-
None | Some(0) => { break }
212-
Some(n) => { ret = ret + str::from_utf8(buf.slice_to(n)); }
213-
}
214-
}
215-
return ret;
216-
}
217-
218-
fn run_output(args: ProcessConfig) -> ~str {
219-
let p = Process::new(args);
220-
assert!(p.is_some());
221-
let mut p = p.unwrap();
222-
assert!(p.io[0].is_none());
223-
assert!(p.io[1].is_some());
224-
let ret = read_all(p.io[1].get_mut_ref() as &mut Reader);
225-
assert_eq!(p.wait(), 0);
226-
return ret;
227-
}
228-
229-
#[test]
230-
#[cfg(unix, not(android))]
231-
#[ignore] // FIXME(#9341)
232-
fn stdout_works() {
233-
let pipe = PipeStream::new().unwrap();
234-
let io = ~[Ignored, CreatePipe(pipe, false, true)];
235-
let args = ProcessConfig {
236-
program: "/bin/sh",
237-
args: [~"-c", ~"echo foobar"],
238-
env: None,
239-
cwd: None,
240-
io: io,
241-
};
242-
assert_eq!(run_output(args), ~"foobar\n");
243-
}
244-
245-
#[test]
246-
#[cfg(unix, not(android))]
247-
#[ignore] // FIXME(#9341)
248-
fn set_cwd_works() {
249-
let pipe = PipeStream::new().unwrap();
250-
let io = ~[Ignored, CreatePipe(pipe, false, true)];
251-
let cwd = Some("/");
252-
let args = ProcessConfig {
253-
program: "/bin/sh",
254-
args: [~"-c", ~"pwd"],
255-
env: None,
256-
cwd: cwd,
257-
io: io,
258-
};
259-
assert_eq!(run_output(args), ~"/\n");
260-
}
261-
262-
#[test]
263-
#[cfg(unix, not(android))]
264-
#[ignore] // FIXME(#9341)
265-
fn stdin_works() {
266-
let input = PipeStream::new().unwrap();
267-
let output = PipeStream::new().unwrap();
268-
let io = ~[CreatePipe(input, true, false),
269-
CreatePipe(output, false, true)];
270-
let args = ProcessConfig {
271-
program: "/bin/sh",
272-
args: [~"-c", ~"read line; echo $line"],
273-
env: None,
274-
cwd: None,
275-
io: io,
276-
};
277-
let mut p = Process::new(args).expect("didn't create a proces?!");
278-
p.io[0].get_mut_ref().write("foobar".as_bytes());
279-
p.io[0] = None; // close stdin;
280-
let out = read_all(p.io[1].get_mut_ref() as &mut Reader);
281-
assert_eq!(p.wait(), 0);
282-
assert_eq!(out, ~"foobar\n");
283-
}
284-
}
143+
// Tests for this module can be found in the rtio-processes run-pass test, along
144+
// with the justification for why it's not located here.

branches/snap-stage3/src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,79 @@ pub fn add_new_extension(cx: @ExtCtxt,
185185
_ => cx.span_bug(sp, "wrong-structured rhs")
186186
};
187187

188+
// Given `lhses` and `rhses`, this is the new macro we create
189+
fn generic_extension(cx: @ExtCtxt,
190+
sp: Span,
191+
name: Ident,
192+
arg: &[ast::token_tree],
193+
lhses: &[@named_match],
194+
rhses: &[@named_match])
195+
-> MacResult {
196+
if cx.trace_macros() {
197+
println!("{}! \\{ {} \\}",
198+
cx.str_of(name),
199+
print::pprust::tt_to_str(
200+
&ast::tt_delim(@mut arg.to_owned()),
201+
get_ident_interner()));
202+
}
203+
204+
// Which arm's failure should we report? (the one furthest along)
205+
let mut best_fail_spot = dummy_sp();
206+
let mut best_fail_msg = ~"internal error: ran no matchers";
207+
208+
let s_d = cx.parse_sess().span_diagnostic;
209+
210+
for (i, lhs) in lhses.iter().enumerate() { // try each arm's matchers
211+
match *lhs {
212+
@matched_nonterminal(nt_matchers(ref mtcs)) => {
213+
// `none` is because we're not interpolating
214+
let arg_rdr = new_tt_reader(
215+
s_d,
216+
None,
217+
arg.to_owned()
218+
) as @mut reader;
219+
match parse(cx.parse_sess(), cx.cfg(), arg_rdr, *mtcs) {
220+
success(named_matches) => {
221+
let rhs = match rhses[i] {
222+
// okay, what's your transcriber?
223+
@matched_nonterminal(nt_tt(@ref tt)) => {
224+
match (*tt) {
225+
// cut off delimiters; don't parse 'em
226+
tt_delim(ref tts) => {
227+
(*tts).slice(1u,(*tts).len()-1u).to_owned()
228+
}
229+
_ => cx.span_fatal(
230+
sp, "macro rhs must be delimited")
231+
}
232+
},
233+
_ => cx.span_bug(sp, "bad thing in rhs")
234+
};
235+
// rhs has holes ( `$id` and `$(...)` that need filled)
236+
let trncbr = new_tt_reader(s_d, Some(named_matches),
237+
rhs);
238+
let p = @Parser(cx.parse_sess(),
239+
cx.cfg(),
240+
trncbr as @mut reader);
241+
242+
// Let the context choose how to interpret the result.
243+
// Weird, but useful for X-macros.
244+
return MRAny(@ParserAnyMacro {
245+
parser: p
246+
} as @AnyMacro);
247+
}
248+
failure(sp, ref msg) => if sp.lo >= best_fail_spot.lo {
249+
best_fail_spot = sp;
250+
best_fail_msg = (*msg).clone();
251+
},
252+
error(sp, ref msg) => cx.span_fatal(sp, (*msg))
253+
}
254+
}
255+
_ => cx.bug("non-matcher found in parsed lhses")
256+
}
257+
}
258+
cx.span_fatal(best_fail_spot, best_fail_msg);
259+
}
260+
188261
let exp = @MacroRulesSyntaxExpanderTTFun {
189262
name: name,
190263
lhses: lhses,

0 commit comments

Comments
 (0)