Skip to content

Commit 623ac32

Browse files
committed
---
yaml --- r: 148445 b: refs/heads/try2 c: bf89b68 h: refs/heads/master i: 148443: f71208a v: v3
1 parent 832fe96 commit 623ac32

File tree

13 files changed

+103
-19
lines changed

13 files changed

+103
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 509283d149bb81cad728b2c1b81f7ab8ceb206e1
8+
refs/heads/try2: bf89b68a3702e10b18e84ef37c3aa19f13418731
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/guide-testing.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
3333
# Unit testing in Rust
3434

3535
Rust has built in support for simple unit testing. Functions can be
36-
marked as unit tests using the 'test' attribute.
36+
marked as unit tests using the `test` attribute.
3737

3838
~~~
3939
#[test]
@@ -44,13 +44,13 @@ fn return_none_if_empty() {
4444

4545
A test function's signature must have no arguments and no return
4646
value. To run the tests in a crate, it must be compiled with the
47-
'--test' flag: `rustc myprogram.rs --test -o myprogram-tests`. Running
47+
`--test` flag: `rustc myprogram.rs --test -o myprogram-tests`. Running
4848
the resulting executable will run all the tests in the crate. A test
4949
is considered successful if its function returns; if the task running
5050
the test fails, through a call to `fail!`, a failed `check` or
5151
`assert`, or some other (`assert_eq`, ...) means, then the test fails.
5252

53-
When compiling a crate with the '--test' flag '--cfg test' is also
53+
When compiling a crate with the `--test` flag `--cfg test` is also
5454
implied, so that tests can be conditionally compiled.
5555

5656
~~~
@@ -64,17 +64,17 @@ mod tests {
6464
~~~
6565

6666
Additionally `#[test]` items behave as if they also have the
67-
`#[cfg(test)]` attribute, and will not be compiled when the --test flag
67+
`#[cfg(test)]` attribute, and will not be compiled when the `--test` flag
6868
is not used.
6969

70-
Tests that should not be run can be annotated with the 'ignore'
70+
Tests that should not be run can be annotated with the `ignore`
7171
attribute. The existence of these tests will be noted in the test
7272
runner output, but the test will not be run. Tests can also be ignored
7373
by configuration so, for example, to ignore a test on windows you can
7474
write `#[ignore(cfg(target_os = "win32"))]`.
7575

7676
Tests that are intended to fail can be annotated with the
77-
'should_fail' attribute. The test will be run, and if it causes its
77+
`should_fail` attribute. The test will be run, and if it causes its
7878
task to fail then the test will be counted as successful; otherwise it
7979
will be counted as a failure. For example:
8080

@@ -87,11 +87,11 @@ fn test_out_of_bounds_failure() {
8787
}
8888
~~~
8989

90-
A test runner built with the '--test' flag supports a limited set of
90+
A test runner built with the `--test` flag supports a limited set of
9191
arguments to control which tests are run: the first free argument
9292
passed to a test runner specifies a filter used to narrow down the set
93-
of tests being run; the '--ignored' flag tells the test runner to run
94-
only tests with the 'ignore' attribute.
93+
of tests being run; the `--ignored` flag tells the test runner to run
94+
only tests with the `ignore` attribute.
9595

9696
## Parallelism
9797

branches/try2/src/compiletest/runtest.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,15 @@ actual:\n\
237237

238238
fn make_typecheck_args(config: &config, props: &TestProps, testfile: &Path) -> ProcArgs {
239239
let aux_dir = aux_output_dir_name(config, testfile);
240+
let target = if props.force_host {
241+
config.host.as_slice()
242+
} else {
243+
config.target.as_slice()
244+
};
240245
// FIXME (#9639): This needs to handle non-utf8 paths
241246
let mut args = ~[~"-",
242247
~"--no-trans", ~"--lib",
248+
~"--target=" + target,
243249
~"-L", config.build_base.as_str().unwrap().to_owned(),
244250
~"-L",
245251
aux_dir.as_str().unwrap().to_owned()];

branches/try2/src/libextra/base64.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ impl<'a> FromBase64 for &'a str {
237237
}
238238

239239
for (idx, byte) in it {
240-
if (byte as char) != '=' {
241-
return Err(InvalidBase64Character(self.char_at(idx), idx));
240+
match byte as char {
241+
'='|'\r'|'\n' => continue,
242+
_ => return Err(InvalidBase64Character(self.char_at(idx), idx)),
242243
}
243244
}
244245

@@ -310,6 +311,8 @@ mod test {
310311
fn test_from_base64_newlines() {
311312
assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap(),
312313
"foobar".as_bytes().to_owned());
314+
assert_eq!("Zm9vYg==\r\n".from_base64().unwrap(),
315+
"foob".as_bytes().to_owned());
313316
}
314317

315318
#[test]

branches/try2/src/librustc/middle/lang_items.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,27 @@ use std::hashmap::HashMap;
3333
use std::iter::Enumerate;
3434
use std::vec;
3535

36+
37+
// Get the last "argument" (has to be done recursively to avoid phoney local ambiguity error)
38+
macro_rules! last {
39+
( $first:expr, $( $remainder:expr, )+ ) => ( last!( $( $remainder, )+ ) );
40+
( $first:expr, ) => ( $first )
41+
}
42+
3643
// The actual lang items defined come at the end of this file in one handy table.
3744
// So you probably just want to nip down to the end.
3845
macro_rules! lets_do_this {
46+
// secondary rule to allow us to use `$num` as both an expression
47+
// and a pattern.
48+
(
49+
$( $num:tt, $variant:ident, $name:expr, $method:ident; )*
50+
) => {
51+
lets_do_this!(count = 1 + last!($($num,)*),
52+
$($num, $variant, $name, $method; )*)
53+
};
54+
3955
(
40-
There are $num_lang_items:expr lang items.
41-
$( $num:pat, $variant:ident, $name:expr, $method:ident; )*
56+
count = $num_lang_items:expr, $( $num:pat, $variant:ident, $name:expr, $method:ident; )*
4257
) => {
4358

4459
pub enum LangItem {
@@ -207,8 +222,6 @@ pub fn collect_language_items(crate: &ast::Crate,
207222
}
208223

209224
lets_do_this! {
210-
There are 40 lang items.
211-
212225
// ID, Variant name, Name, Method name;
213226
0, FreezeTraitLangItem, "freeze", freeze_trait;
214227
1, SendTraitLangItem, "send", send_trait;
@@ -261,4 +274,3 @@ lets_do_this! {
261274
38, ExchangeHeapLangItem, "exchange_heap", exchange_heap;
262275
39, GcLangItem, "gc", gc;
263276
}
264-

branches/try2/src/librustc/middle/ty.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,6 +2287,12 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
22872287
::util::ppaux::ty_to_str(cx, ty));
22882288

22892289
let r = match get(ty).sty {
2290+
// fixed length vectors need special treatment compared to
2291+
// normal vectors, since they don't necessarily have the
2292+
// possibilty to have length zero.
2293+
ty_vec(_, vstore_fixed(0)) => false, // don't need no contents
2294+
ty_vec(mt, vstore_fixed(_)) => type_requires(cx, seen, r_ty, mt.ty),
2295+
22902296
ty_nil |
22912297
ty_bot |
22922298
ty_bool |

branches/try2/src/libsyntax/ext/base.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ impl<'a> ExtCtxt<'a> {
412412
self.print_backtrace();
413413
self.parse_sess.span_diagnostic.span_bug(sp, msg);
414414
}
415+
pub fn span_note(&self, sp: Span, msg: &str) {
416+
self.print_backtrace();
417+
self.parse_sess.span_diagnostic.span_note(sp, msg);
418+
}
415419
pub fn bug(&self, msg: &str) -> ! {
416420
self.print_backtrace();
417421
self.parse_sess.span_diagnostic.handler().bug(msg);

branches/try2/src/libsyntax/ext/quote.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> ~[@ast::Stmt] {
530530
match *tt {
531531

532532
ast::TTTok(sp, ref tok) => {
533-
let e_sp = cx.expr_ident(sp, id_ext("sp"));
533+
let e_sp = cx.expr_ident(sp, id_ext("_sp"));
534534
let e_tok = cx.expr_call_ident(sp,
535535
id_ext("TTTok"),
536536
~[e_sp, mk_token(cx, sp, tok)]);
@@ -628,7 +628,7 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
628628
~[]);
629629

630630
let stmt_let_sp = cx.stmt_let(sp, false,
631-
id_ext("sp"),
631+
id_ext("_sp"),
632632
e_sp);
633633

634634
let stmt_let_tt = cx.stmt_let(sp, true,

branches/try2/src/test/compile-fail/macro-crate-unexported-macro.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// aux-build:macro_crate_test.rs
1212
// xfail-stage1
13+
// xfail-android
1314

1415
#[feature(phase)];
1516

branches/try2/src/test/compile-fail/phase-syntax-doesnt-resolve.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// aux-build:macro_crate_test.rs
1212
// xfail-stage1
13+
// xfail-android
1314

1415
#[feature(phase)];
1516

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// issue #11659, the compiler needs to know that a fixed length vector
12+
// always requires instantiable contents to instantiable itself
13+
// (unlike a ~[] vector which can have length zero).
14+
15+
// ~ to avoid infinite size.
16+
struct Uninstantiable { //~ ERROR cannot be instantiated without an instance of itself
17+
p: ~[Uninstantiable, .. 1]
18+
}
19+
20+
struct Instantiable { p: ~[Instantiable, .. 0] }
21+
22+
23+
fn main() {
24+
let _ = None::<Uninstantiable>;
25+
let _ = Instantiable { p: ~([]) };
26+
}

branches/try2/src/test/run-pass-fulldeps/macro-crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// aux-build:macro_crate_test.rs
1212
// xfail-stage1
1313
// xfail-fast
14+
// xfail-android
1415

1516
#[feature(phase)];
1617

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// xfail-fast
12+
13+
#[deny(unused_variable)];
14+
15+
extern mod syntax;
16+
17+
use syntax::ext::base::ExtCtxt;
18+
19+
fn test(cx: &mut ExtCtxt) {
20+
let foo = 10i;
21+
let _e = quote_expr!(cx, $foo);
22+
}
23+
24+
pub fn main() { }

0 commit comments

Comments
 (0)