about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-02-09 05:58:29 +0000
committerbors <bors@rust-lang.org>2017-02-09 05:58:29 +0000
commitfd2f8a4536cb9b45abd72b8ff977ad48618602b3 (patch)
tree1a4ac51c16de92345ef062bc86eda21c87e5d57b /src/test
parent29dece1c8bbebf7ae8034ef0826b119281730937 (diff)
parent1e3e904101087c11612f97bc604941e5ee85b86e (diff)
downloadrust-fd2f8a4536cb9b45abd72b8ff977ad48618602b3.tar.gz
rust-fd2f8a4536cb9b45abd72b8ff977ad48618602b3.zip
Auto merge of #39677 - frewsxcv:rollup, r=frewsxcv
Rollup of 9 pull requests

- Successful merges: #37928, #38699, #39589, #39598, #39599, #39641, #39649, #39653, #39671
- Failed merges:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/feature-gate-sanitizer-runtime.rs13
-rw-r--r--src/test/compile-fail/issue-27433.rs15
-rw-r--r--src/test/run-make/sanitizer-address/Makefile11
-rw-r--r--src/test/run-make/sanitizer-address/overflow.rs14
-rw-r--r--src/test/run-make/sanitizer-dylib/Makefile8
-rw-r--r--src/test/run-make/sanitizer-dylib/hello.rs13
-rw-r--r--src/test/run-make/sanitizer-invalid-target/Makefile4
-rw-r--r--src/test/run-make/sanitizer-invalid-target/hello.rs13
-rw-r--r--src/test/run-make/sanitizer-leak/Makefile10
-rw-r--r--src/test/run-make/sanitizer-leak/leak.rs16
-rw-r--r--src/test/run-make/sanitizer-memory/Makefile10
-rw-r--r--src/test/run-make/sanitizer-memory/uninit.rs16
-rw-r--r--src/test/run-make/sanitizer-thread/Makefile10
-rw-r--r--src/test/run-make/sanitizer-thread/racy.rs21
-rw-r--r--src/test/rustdoc/impl-disambiguation.rs40
15 files changed, 214 insertions, 0 deletions
diff --git a/src/test/compile-fail/feature-gate-sanitizer-runtime.rs b/src/test/compile-fail/feature-gate-sanitizer-runtime.rs
new file mode 100644
index 00000000000..a18641d8246
--- /dev/null
+++ b/src/test/compile-fail/feature-gate-sanitizer-runtime.rs
@@ -0,0 +1,13 @@
+// Copyright 2016 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.
+
+#![sanitizer_runtime] //~ ERROR the `#[sanitizer_runtime]` attribute is
+
+fn main() {}
diff --git a/src/test/compile-fail/issue-27433.rs b/src/test/compile-fail/issue-27433.rs
new file mode 100644
index 00000000000..78d96398b95
--- /dev/null
+++ b/src/test/compile-fail/issue-27433.rs
@@ -0,0 +1,15 @@
+// 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() {
+    let foo = 42u32;
+    const FOO : u32 = foo;
+                   //~^ ERROR attempt to use a non-constant value in a constant
+}
diff --git a/src/test/run-make/sanitizer-address/Makefile b/src/test/run-make/sanitizer-address/Makefile
new file mode 100644
index 00000000000..5931145f3a4
--- /dev/null
+++ b/src/test/run-make/sanitizer-address/Makefile
@@ -0,0 +1,11 @@
+-include ../tools.mk
+
+# NOTE the address sanitizer only supports x86_64 linux
+ifdef SANITIZER_SUPPORT
+all:
+	$(RUSTC) -g -Z sanitizer=address -Z print-link-args overflow.rs | grep -q librustc_asan
+	$(TMPDIR)/overflow 2>&1 | grep -q stack-buffer-overflow
+else
+all:
+
+endif
diff --git a/src/test/run-make/sanitizer-address/overflow.rs b/src/test/run-make/sanitizer-address/overflow.rs
new file mode 100644
index 00000000000..e35c3873f7e
--- /dev/null
+++ b/src/test/run-make/sanitizer-address/overflow.rs
@@ -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() {
+    let xs = [0, 1, 2, 3];
+    let y = unsafe { *xs.as_ptr().offset(4) };
+}
diff --git a/src/test/run-make/sanitizer-dylib/Makefile b/src/test/run-make/sanitizer-dylib/Makefile
new file mode 100644
index 00000000000..835d5b0d9d8
--- /dev/null
+++ b/src/test/run-make/sanitizer-dylib/Makefile
@@ -0,0 +1,8 @@
+-include ../tools.mk
+
+ifeq ($(TARGET),x86_64-unknown-linux-gnu)
+all:
+	$(RUSTC) -Z sanitizer=leak --crate-type dylib --target $(TARGET) hello.rs 2>&1 | grep -q 'Only executables and rlibs can be compiled with `-Z sanitizer`'
+else
+all:
+endif
diff --git a/src/test/run-make/sanitizer-dylib/hello.rs b/src/test/run-make/sanitizer-dylib/hello.rs
new file mode 100644
index 00000000000..41782851a1a
--- /dev/null
+++ b/src/test/run-make/sanitizer-dylib/hello.rs
@@ -0,0 +1,13 @@
+// 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() {
+    println!("Hello, world!");
+}
diff --git a/src/test/run-make/sanitizer-invalid-target/Makefile b/src/test/run-make/sanitizer-invalid-target/Makefile
new file mode 100644
index 00000000000..6a1ce8bab2f
--- /dev/null
+++ b/src/test/run-make/sanitizer-invalid-target/Makefile
@@ -0,0 +1,4 @@
+-include ../tools.mk
+
+all:
+	$(RUSTC) -Z sanitizer=leak --target i686-unknown-linux-gnu hello.rs 2>&1 | grep -q 'Sanitizers only work with the `x86_64-unknown-linux-gnu` target'
diff --git a/src/test/run-make/sanitizer-invalid-target/hello.rs b/src/test/run-make/sanitizer-invalid-target/hello.rs
new file mode 100644
index 00000000000..e9e46b7702a
--- /dev/null
+++ b/src/test/run-make/sanitizer-invalid-target/hello.rs
@@ -0,0 +1,13 @@
+// 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.
+
+#![feature(no_core)]
+#![no_core]
+#![no_main]
diff --git a/src/test/run-make/sanitizer-leak/Makefile b/src/test/run-make/sanitizer-leak/Makefile
new file mode 100644
index 00000000000..f02d948fdc8
--- /dev/null
+++ b/src/test/run-make/sanitizer-leak/Makefile
@@ -0,0 +1,10 @@
+-include ../tools.mk
+
+ifdef SANITIZER_SUPPORT
+all:
+	$(RUSTC) -C opt-level=1 -g -Z sanitizer=leak -Z print-link-args leak.rs | grep -q librustc_lsan
+	$(TMPDIR)/leak 2>&1 | grep -q 'detected memory leaks'
+else
+all:
+
+endif
diff --git a/src/test/run-make/sanitizer-leak/leak.rs b/src/test/run-make/sanitizer-leak/leak.rs
new file mode 100644
index 00000000000..279da6aaae7
--- /dev/null
+++ b/src/test/run-make/sanitizer-leak/leak.rs
@@ -0,0 +1,16 @@
+// 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.
+
+use std::mem;
+
+fn main() {
+    let xs = vec![1, 2, 3, 4];
+    mem::forget(xs);
+}
diff --git a/src/test/run-make/sanitizer-memory/Makefile b/src/test/run-make/sanitizer-memory/Makefile
new file mode 100644
index 00000000000..08682e5975e
--- /dev/null
+++ b/src/test/run-make/sanitizer-memory/Makefile
@@ -0,0 +1,10 @@
+-include ../tools.mk
+
+ifdef SANITIZER_SUPPORT
+all:
+	$(RUSTC) -g -Z sanitizer=memory -Z print-link-args uninit.rs | grep -q librustc_msan
+	$(TMPDIR)/uninit 2>&1 | grep -q use-of-uninitialized-value
+else
+all:
+
+endif
diff --git a/src/test/run-make/sanitizer-memory/uninit.rs b/src/test/run-make/sanitizer-memory/uninit.rs
new file mode 100644
index 00000000000..8350c7de3ac
--- /dev/null
+++ b/src/test/run-make/sanitizer-memory/uninit.rs
@@ -0,0 +1,16 @@
+// 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.
+
+use std::mem;
+
+fn main() {
+    let xs: [u8; 4] = unsafe { mem::uninitialized() };
+    let y = xs[0] + xs[1];
+}
diff --git a/src/test/run-make/sanitizer-thread/Makefile b/src/test/run-make/sanitizer-thread/Makefile
new file mode 100644
index 00000000000..8bb89a241cb
--- /dev/null
+++ b/src/test/run-make/sanitizer-thread/Makefile
@@ -0,0 +1,10 @@
+-include ../tools.mk
+
+ifdef SANITIZER_SUPPORT
+all:
+	$(RUSTC) -g -Z sanitizer=thread -Z print-link-args racy.rs | grep -q librustc_tsan
+	$(TMPDIR)/racy 2>&1 | grep -q 'data race'
+else
+all:
+
+endif
diff --git a/src/test/run-make/sanitizer-thread/racy.rs b/src/test/run-make/sanitizer-thread/racy.rs
new file mode 100644
index 00000000000..dc929e004a4
--- /dev/null
+++ b/src/test/run-make/sanitizer-thread/racy.rs
@@ -0,0 +1,21 @@
+// 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.
+
+use std::thread;
+
+static mut ANSWER: i32 = 0;
+
+fn main() {
+    let t1 = thread::spawn(|| unsafe { ANSWER = 42 });
+    unsafe {
+        ANSWER = 24;
+    }
+    t1.join().ok();
+}
diff --git a/src/test/rustdoc/impl-disambiguation.rs b/src/test/rustdoc/impl-disambiguation.rs
new file mode 100644
index 00000000000..afe1daf5983
--- /dev/null
+++ b/src/test/rustdoc/impl-disambiguation.rs
@@ -0,0 +1,40 @@
+// 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"]
+
+pub trait Foo {}
+
+pub struct Bar<T> { field: T }
+
+// @has foo/trait.Foo.html '//*[@class="item-list"]//code' \
+//     "impl Foo for Bar<u8>"
+impl Foo for Bar<u8> {}
+// @has foo/trait.Foo.html '//*[@class="item-list"]//code' \
+//     "impl Foo for Bar<u16>"
+impl Foo for Bar<u16> {}
+// @has foo/trait.Foo.html '//*[@class="item-list"]//code' \
+//     "impl<'a> Foo for &'a Bar<u8>"
+impl<'a> Foo for &'a Bar<u8> {}
+
+pub mod mod1 {
+    pub struct Baz {}
+}
+
+pub mod mod2 {
+    pub enum Baz {}
+}
+
+// @has foo/trait.Foo.html '//*[@class="item-list"]//code' \
+//     "impl Foo for foo::mod1::Baz"
+impl Foo for mod1::Baz {}
+// @has foo/trait.Foo.html '//*[@class="item-list"]//code' \
+//     "impl<'a> Foo for &'a foo::mod2::Baz"
+impl<'a> Foo for &'a mod2::Baz {}