Skip to content

Commit d307d8a

Browse files
committed
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 (96a2298 2018-10-04) and passes on: rustdoc 1.31.0-nightly (f99911a 2018-10-23) Fix #54478
2 parents 3b2ea2b + be2075c commit d307d8a

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Issue #54478: regression test showing that we can demonstrate
2+
// `#[global_allocator]` in code blocks built by `rustdoc`.
3+
//
4+
// ## Background
5+
//
6+
// Changes in lang-item visibility injected failures that were only
7+
// exposed when compiling with `-C prefer-dynamic`. But `rustdoc` used
8+
// `-C prefer-dynamic` (and had done so for years, for reasons we did
9+
// not document at that time).
10+
//
11+
// Rather than try to revise the visbility semanics, we instead
12+
// decided to change `rustdoc` to behave more like the compiler's
13+
// default setting, by leaving off `-C prefer-dynamic`.
14+
15+
// compile-flags:--test
16+
17+
//! This is a doc comment
18+
//!
19+
//! ```rust
20+
//! use std::alloc::*;
21+
//!
22+
//! #[global_allocator]
23+
//! static ALLOC: A = A;
24+
//!
25+
//! static mut HIT: bool = false;
26+
//!
27+
//! struct A;
28+
//!
29+
//! unsafe impl GlobalAlloc for A {
30+
//! unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
31+
//! HIT = true;
32+
//! System.alloc(layout)
33+
//! }
34+
//! unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
35+
//! System.dealloc(ptr, layout);
36+
//! }
37+
//! }
38+
//!
39+
//! fn main() {
40+
//! assert!(unsafe { HIT });
41+
//! }
42+
//! ```

0 commit comments

Comments
 (0)