Skip to content

Explain test case, rename anchor const for readability #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ impl<T> Mutex<T> {
// execution contexts (e.g. interrupts)
unsafe impl<T> Sync for Mutex<T> where T: Send {}

/// In this test, the compiler will implicitly assign the produced reference's lifetime to cs
/// (consequently, it is checked that the caller provides a sufficiently long-lived cs). However,
/// the mutex itself is short-lived, and this tests that the &self does actually live as long as
/// the critical section (which here it does not, causing compilation failure):
///
/// ``` compile_fail
/// fn bad(cs: bare_metal::CriticalSection) -> &u32 {
/// let x = bare_metal::Mutex::new(42u32);
Expand All @@ -94,4 +99,4 @@ unsafe impl<T> Sync for Mutex<T> where T: Send {}
/// ```
#[allow(dead_code)]
#[doc(hidden)]
const GH_6: () = ();
const DOCTEST_ANCHOR: () = ();