Skip to content
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

Adjusted some doctests in libcore to use should_panic. #73302

Merged
merged 1 commit into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
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
26 changes: 8 additions & 18 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,18 +778,13 @@ impl<T: ?Sized> RefCell<T> {
///
/// An example of panic:
///
/// ```
/// ```should_panic
/// use std::cell::RefCell;
/// use std::thread;
///
/// let result = thread::spawn(move || {
/// let c = RefCell::new(5);
/// let m = c.borrow_mut();
///
/// let b = c.borrow(); // this causes a panic
/// }).join();
/// let c = RefCell::new(5);
///
/// assert!(result.is_err());
/// let m = c.borrow_mut();
/// let b = c.borrow(); // this causes a panic
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down Expand Up @@ -858,18 +853,13 @@ impl<T: ?Sized> RefCell<T> {
///
/// An example of panic:
///
/// ```
/// ```should_panic
/// use std::cell::RefCell;
/// use std::thread;
///
/// let result = thread::spawn(move || {
/// let c = RefCell::new(5);
/// let m = c.borrow();
///
/// let b = c.borrow_mut(); // this causes a panic
/// }).join();
/// let c = RefCell::new(5);
/// let m = c.borrow();
///
/// assert!(result.is_err());
/// let b = c.borrow_mut(); // this causes a panic
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down
11 changes: 3 additions & 8 deletions src/libcore/char/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,16 +278,11 @@ impl fmt::Display for CharTryFromError {
///
/// Passing a large radix, causing a panic:
///
/// ```
/// use std::thread;
/// ```should_panic
/// use std::char;
///
/// let result = thread::spawn(|| {
/// // this panics
/// let c = char::from_digit(1, 37);
/// }).join();
///
/// assert!(result.is_err());
/// // this panics
/// let c = char::from_digit(1, 37);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
62 changes: 17 additions & 45 deletions src/libcore/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,11 @@ impl char {
///
/// Passing a large radix, causing a panic:
///
/// ```
/// use std::thread;
/// ```should_panic
/// use std::char;
///
/// let result = thread::spawn(|| {
/// // this panics
/// let c = char::from_digit(1, 37);
/// }).join();
///
/// assert!(result.is_err());
/// // this panics
/// char::from_digit(1, 37);
/// ```
#[unstable(feature = "assoc_char_funcs", reason = "recently added", issue = "71763")]
#[inline]
Expand Down Expand Up @@ -282,15 +277,9 @@ impl char {
///
/// Passing a large radix, causing a panic:
///
/// ```
/// use std::thread;
///
/// let result = thread::spawn(|| {
/// // this panics
/// '1'.is_digit(37);
/// }).join();
///
/// assert!(result.is_err());
/// ```should_panic
/// // this panics
/// '1'.is_digit(37);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down Expand Up @@ -337,14 +326,9 @@ impl char {
///
/// Passing a large radix, causing a panic:
///
/// ```
/// use std::thread;
///
/// let result = thread::spawn(|| {
/// '1'.to_digit(37);
/// }).join();
///
/// assert!(result.is_err());
/// ```should_panic
/// // this panics
/// '1'.to_digit(37);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
Expand Down Expand Up @@ -646,17 +630,11 @@ impl char {
///
/// A buffer that's too small:
///
/// ```
/// use std::thread;
///
/// let result = thread::spawn(|| {
/// let mut b = [0; 1];
///
/// // this panics
/// 'ß'.encode_utf8(&mut b);
/// }).join();
/// ```should_panic
/// let mut b = [0; 1];
///
/// assert!(result.is_err());
/// // this panics
/// 'ß'.encode_utf8(&mut b);
/// ```
#[stable(feature = "unicode_encode_char", since = "1.15.0")]
#[inline]
Expand Down Expand Up @@ -687,17 +665,11 @@ impl char {
///
/// A buffer that's too small:
///
/// ```
/// use std::thread;
///
/// let result = thread::spawn(|| {
/// let mut b = [0; 1];
///
/// // this panics
/// '𝕊'.encode_utf16(&mut b);
/// }).join();
/// ```should_panic
/// let mut b = [0; 1];
///
/// assert!(result.is_err());
/// // this panics
/// '𝕊'.encode_utf16(&mut b);
/// ```
#[stable(feature = "unicode_encode_char", since = "1.15.0")]
#[inline]
Expand Down