about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-10-25 14:31:20 +0200
committerGitHub <noreply@github.com>2018-10-25 14:31:20 +0200
commitb3e57dbdf62f13ef49f54315e353f2f9ed4df66e (patch)
tree3bd212ad10dbd4530e574aff8242acbf0cb1aa05
parent1220e1354ae100fded1e2c76ccf158e4b6a9d7ee (diff)
parentbe2075c6614532b6b58bef455c3ff89ecf2ef625 (diff)
downloadrust-b3e57dbdf62f13ef49f54315e353f2f9ed4df66e.tar.gz
rust-b3e57dbdf62f13ef49f54315e353f2f9ed4df66e.zip
Rollup merge of #55306 - pnkfelix:issue-54478-regression-test-jemalloc-ctl, r=nikomatsakis
Regression test for #54478.

This is a regression test for #54478.

I confirmed that it fails on:
rustdoc 1.30.0-beta.12 (96a229824 2018-10-04)
and passes on:
rustdoc 1.31.0-nightly (f99911a4a 2018-10-23)

Fix #54478
-rw-r--r--src/test/rustdoc/issue-54478-demo-allocator.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/test/rustdoc/issue-54478-demo-allocator.rs b/src/test/rustdoc/issue-54478-demo-allocator.rs
new file mode 100644
index 00000000000..4811f363bc9
--- /dev/null
+++ b/src/test/rustdoc/issue-54478-demo-allocator.rs
@@ -0,0 +1,42 @@
+// Issue #54478: regression test showing that we can demonstrate
+// `#[global_allocator]` in code blocks built by `rustdoc`.
+//
+// ## Background
+//
+// Changes in lang-item visibility injected failures that were only
+// exposed when compiling with `-C prefer-dynamic`. But `rustdoc` used
+// `-C prefer-dynamic` (and had done so for years, for reasons we did
+// not document at that time).
+//
+// Rather than try to revise the visbility semanics, we instead
+// decided to change `rustdoc` to behave more like the compiler's
+// default setting, by leaving off `-C prefer-dynamic`.
+
+// compile-flags:--test
+
+//! This is a doc comment
+//!
+//! ```rust
+//! use std::alloc::*;
+//!
+//! #[global_allocator]
+//! static ALLOC: A = A;
+//!
+//! static mut HIT: bool = false;
+//!
+//! struct A;
+//!
+//! unsafe impl GlobalAlloc for A {
+//!     unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
+//!         HIT = true;
+//!         System.alloc(layout)
+//!     }
+//!     unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
+//!         System.dealloc(ptr, layout);
+//!     }
+//! }
+//!
+//! fn main() {
+//!     assert!(unsafe { HIT });
+//! }
+//! ```