Auto merge of #46922 - kennytm:rollup, r=kennytm

Rollup of 14 pull requests

- Successful merges: #46636, #46780, #46784, #46809, #46814, #46820, #46839, #46847, #46858, #46878, #46884, #46890, #46898, #46918
- Failed merges:
This commit is contained in:
bors 2017-12-21 23:01:27 +00:00
commit ba2741594b
40 changed files with 453 additions and 329 deletions

View file

@ -35,20 +35,24 @@ The error levels that you can have are:
## Summary of Header Commands
Header commands specify something about the entire test file as a
whole, instead of just a few lines inside the test.
whole. They are normally put right after the copyright comment, e.g.:
```Rust
// Copyright blah blah blah
// except according to those terms.
// ignore-test This doesn't actually work
```
### Ignoring tests
These are used to ignore the test in some situations, which means the test won't
be compiled or run.
* `ignore-X` where `X` is a target detail or stage will ignore the test accordingly (see below)
* `ignore-pretty` will not compile the pretty-printed test (this is done to test the pretty-printer, but might not always work)
* `ignore-test` always ignores the test
* `ignore-lldb` and `ignore-gdb` will skip the debuginfo tests
* `min-{gdb,lldb}-version`
* `should-fail` indicates that the test should fail; used for "meta testing",
where we test the compiletest program itself to check that it will generate
errors in appropriate scenarios. This header is ignored for pretty-printer tests.
* `gate-test-X` where `X` is a feature marks the test as "gate test" for feature X.
Such tests are supposed to ensure that the compiler errors when usage of a gated
feature is attempted without the proper `#![feature(X)]` tag.
Each unstable lang feature is required to have a gate test.
* `ignore-lldb` and `ignore-gdb` will skip a debuginfo test on that debugger.
Some examples of `X` in `ignore-X`:
@ -58,6 +62,22 @@ Some examples of `X` in `ignore-X`:
* Pointer width: `32bit`, `64bit`.
* Stage: `stage0`, `stage1`, `stage2`.
### Other Header Commands
* `min-{gdb,lldb}-version`
* `min-llvm-version`
* `must-compile-successfully` for UI tests, indicates that the test is supposed
to compile, as opposed to the default where the test is supposed to error out.
* `compile-flags` passes extra command-line args to the compiler,
e.g. `compile-flags -g` which forces debuginfo to be enabled.
* `should-fail` indicates that the test should fail; used for "meta testing",
where we test the compiletest program itself to check that it will generate
errors in appropriate scenarios. This header is ignored for pretty-printer tests.
* `gate-test-X` where `X` is a feature marks the test as "gate test" for feature X.
Such tests are supposed to ensure that the compiler errors when usage of a gated
feature is attempted without the proper `#![feature(X)]` tag.
Each unstable lang feature is required to have a gate test.
## Revisions
Certain classes of tests support "revisions" (as of the time of this
@ -109,6 +129,12 @@ fails, we will print out the current output, but it is also saved in
printed as part of the test failure message), so you can run `diff` and
so forth.
Normally, the test-runner checks that UI tests fail compilation. If you want
to do a UI test for code that *compiles* (e.g. to test warnings, or if you
have a collection of tests, only some of which error out), you can use the
`// must-compile-successfully` header command to have the test runner instead
check that the test compiles successfully.
### Editing and updating the reference files
If you have changed the compiler's output intentionally, or you are

View file

@ -0,0 +1,16 @@
// Copyright 2012-2015 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(external_doc)]
#[doc(include = "not-a-file.md")] //~ ERROR: couldn't read
pub struct SomeStruct;
fn main() {}

View file

@ -0,0 +1,14 @@
// Copyright 2017 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.
fn main() {
struct Foo;
(1 .. 2).find(|_| Foo(0) == 0); //~ ERROR expected function, found `main::Foo`
}

View file

@ -8,7 +8,7 @@ ifneq ($(shell uname),FreeBSD)
ifndef IS_WINDOWS
all:
$(RUSTC) --emit dep-info main.rs
$(CGREP) "input.txt" "input.bin" < $(TMPDIR)/main.d
$(CGREP) "input.txt" "input.bin" "input.md" < $(TMPDIR)/main.d
else
all:

View file

@ -0,0 +1 @@
# Hello, world!

View file

@ -8,6 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(external_doc)]
#[doc(include="input.md")]
pub struct SomeStruct;
pub fn main() {
const INPUT_TXT: &'static str = include_str!("input.txt");
const INPUT_BIN: &'static [u8] = include_bytes!("input.bin");

View file

@ -71,5 +71,5 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
let (sess, cstore) = basic_sess(sysroot);
let control = CompileController::basic();
let input = Input::Str { name: FileName::Anon, input: code };
let _ = compile_input(&sess, &cstore, &input, &None, &Some(output), None, &control);
let _ = compile_input(&sess, &cstore, &None, &input, &None, &Some(output), None, &control);
}

View file

@ -0,0 +1,10 @@
-include ../tools.mk
all:
cp foo.rs $(TMPDIR)/foo
$(RUSTC) $(TMPDIR)/foo 2>&1 \
| $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable"
$(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1
cp foo.rs $(TMPDIR)/foo.rs
$(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \
| $(CGREP) -e "the input file \".*foo.rs\" would be overwritten by the generated executable"

View file

@ -0,0 +1,11 @@
// Copyright 2017 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.
fn main() {}

View file

@ -7,8 +7,8 @@ all:
cp foo.rs $(TMPDIR)/.foo.bar
$(RUSTC) $(TMPDIR)/.foo.bar 2>&1 \
| $(CGREP) -e "invalid character.*in crate name:"
cp foo.rs $(TMPDIR)/+foo+bar
$(RUSTC) $(TMPDIR)/+foo+bar 2>&1 \
cp foo.rs $(TMPDIR)/+foo+bar.rs
$(RUSTC) $(TMPDIR)/+foo+bar.rs 2>&1 \
| $(CGREP) -e "invalid character.*in crate name:"
cp foo.rs $(TMPDIR)/-foo.rs
$(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \

View file

@ -19,7 +19,9 @@ impl<T: Copy> Clone for Packed<T> {
fn sanity_check_size<T: Copy>(one: T) {
let two = [one, one];
let stride = (&two[1] as *const _ as usize) - (&two[0] as *const _ as usize);
assert_eq!(stride, std::mem::size_of_val(&one));
let (size, align) = (std::mem::size_of::<T>(), std::mem::align_of::<T>());
assert_eq!(stride, size);
assert_eq!(size % align, 0);
}
fn main() {
@ -32,5 +34,12 @@ fn main() {
// In #46769, `Option<(Packed<&()>, bool)>` was found to have
// pointer alignment, without actually being aligned in size.
// E.g. on 64-bit platforms, it had alignment `8` but size `9`.
sanity_check_size(Some((Packed(&()), true)));
type PackedRefAndBool<'a> = (Packed<&'a ()>, bool);
sanity_check_size::<Option<PackedRefAndBool>>(Some((Packed(&()), true)));
// Make sure we don't pay for the enum optimization in size,
// e.g. we shouldn't need extra padding after the packed data.
assert_eq!(std::mem::align_of::<Option<PackedRefAndBool>>(), 1);
assert_eq!(std::mem::size_of::<Option<PackedRefAndBool>>(),
std::mem::size_of::<PackedRefAndBool>());
}

View file

@ -9,6 +9,7 @@
// except according to those terms.
#![feature(external_doc)]
#![deny(missing_doc)]
#[doc(include="external-cross-doc.md")]
pub struct NeedMoreDocs;

View file

@ -0,0 +1,45 @@
// Copyright 2017 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.
#![crate_name = "foo"]
use std::ops::{Deref, DerefMut};
#[derive(Debug, Clone)]
pub struct Title {
name: String,
}
#[derive(Debug, Clone)]
pub struct TitleList {
pub members: Vec<Title>,
}
impl TitleList {
pub fn new() -> Self {
TitleList { members: Vec::new() }
}
}
impl Deref for TitleList {
type Target = Vec<Title>;
fn deref(&self) -> &Self::Target {
&self.members
}
}
// @has foo/struct.TitleList.html
// @has - '//*[@class="sidebar-title"]' 'Methods from Deref<Target=Vec<Title>>'
impl DerefMut for TitleList {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.members
}
}