Skip to content

Commit

Permalink
Rollup merge of rust-lang#55306 - pnkfelix:issue-54478-regression-tes…
Browse files Browse the repository at this point in the history
…t-jemalloc-ctl, r=nikomatsakis

Regression test for rust-lang#54478.

This is a regression test for rust-lang#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 rust-lang#54478
  • Loading branch information
kennytm committed Oct 25, 2018
2 parents 3b2ea2b + be2075c commit d307d8a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/test/rustdoc/issue-54478-demo-allocator.rs
Original file line number Diff line number Diff line change
@@ -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 });
//! }
//! ```

0 comments on commit d307d8a

Please sign in to comment.