review: fix nits and move panic safety tests to the correct place
This commit is contained in:
parent
5be843fc54
commit
a61b9638bb
@ -1,3 +1,4 @@
|
||||
use std::cell::Cell;
|
||||
use std::mem::MaybeUninit;
|
||||
use std::ptr::NonNull;
|
||||
|
||||
@ -52,8 +53,6 @@ fn box_clone_from_ptr_stability() {
|
||||
|
||||
#[test]
|
||||
fn box_deref_lval() {
|
||||
use std::cell::Cell;
|
||||
|
||||
let x = Box::new(Cell::new(5));
|
||||
x.set(1000);
|
||||
assert_eq!(x.get(), 1000);
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![deny(warnings)]
|
||||
#![allow(unused_must_use)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::fmt::{self, Write};
|
||||
@ -241,15 +240,15 @@ fn test_format_macro_interface() {
|
||||
#[test]
|
||||
fn test_write() {
|
||||
let mut buf = String::new();
|
||||
write!(&mut buf, "{}", 3);
|
||||
let _ = write!(&mut buf, "{}", 3);
|
||||
{
|
||||
let w = &mut buf;
|
||||
write!(w, "{foo}", foo = 4);
|
||||
write!(w, "{}", "hello");
|
||||
writeln!(w, "{}", "line");
|
||||
writeln!(w, "{foo}", foo = "bar");
|
||||
w.write_char('☃');
|
||||
w.write_str("str");
|
||||
let _ = write!(w, "{foo}", foo = 4);
|
||||
let _ = write!(w, "{}", "hello");
|
||||
let _ = writeln!(w, "{}", "line");
|
||||
let _ = writeln!(w, "{foo}", foo = "bar");
|
||||
let _ = w.write_char('☃');
|
||||
let _ = w.write_str("str");
|
||||
}
|
||||
|
||||
t!(buf, "34helloline\nbar\n☃str");
|
||||
@ -273,9 +272,9 @@ fn test_format_args() {
|
||||
let mut buf = String::new();
|
||||
{
|
||||
let w = &mut buf;
|
||||
write!(w, "{}", format_args!("{}", 1));
|
||||
write!(w, "{}", format_args!("test"));
|
||||
write!(w, "{}", format_args!("{test}", test = 3));
|
||||
let _ = write!(w, "{}", format_args!("{}", 1));
|
||||
let _ = write!(w, "{}", format_args!("test"));
|
||||
let _ = write!(w, "{}", format_args!("{test}", test = 3));
|
||||
}
|
||||
let s = buf;
|
||||
t!(s, "1test3");
|
||||
|
@ -2238,5 +2238,6 @@ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
|
||||
}
|
||||
}
|
||||
|
||||
// If you expected tests to be here, look instead at the ui/ifmt.rs test,
|
||||
// If you expected tests to be here, look instead at the core/tests/fmt.rs file,
|
||||
// it's a lot easier than creating all of the rt::Piece structures here.
|
||||
// There are also tests in the alloc crate, for those that need allocations.
|
||||
|
@ -78,7 +78,6 @@
|
||||
mod num;
|
||||
mod ops;
|
||||
mod option;
|
||||
mod panic_safe;
|
||||
mod pattern;
|
||||
mod ptr;
|
||||
mod result;
|
||||
|
@ -1,3 +1,4 @@
|
||||
use core::cell::Cell;
|
||||
use core::clone::Clone;
|
||||
use core::mem;
|
||||
use core::ops::DerefMut;
|
||||
@ -375,8 +376,6 @@ fn option_const() {
|
||||
|
||||
#[test]
|
||||
fn test_unwrap_drop() {
|
||||
use std::cell::Cell;
|
||||
|
||||
struct Dtor<'a> {
|
||||
x: &'a Cell<isize>,
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
use core::cell::Cell;
|
||||
use core::result::Result::{Err, Ok};
|
||||
|
||||
#[test]
|
||||
@ -1983,8 +1984,6 @@ fn test_is_sorted() {
|
||||
|
||||
#[test]
|
||||
fn test_slice_run_destructors() {
|
||||
use core::cell::Cell;
|
||||
|
||||
// Make sure that destructors get run on slice literals
|
||||
struct Foo<'a> {
|
||||
x: &'a Cell<isize>,
|
||||
|
@ -411,3 +411,6 @@ pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
|
||||
pub fn resume_unwind(payload: Box<dyn Any + Send>) -> ! {
|
||||
panicking::rust_panic_without_hook(payload)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
@ -1,9 +1,9 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::panic::{AssertUnwindSafe, UnwindSafe};
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex, RwLock};
|
||||
use crate::cell::RefCell;
|
||||
use crate::panic::{AssertUnwindSafe, UnwindSafe};
|
||||
use crate::rc::Rc;
|
||||
use crate::sync::{Arc, Mutex, RwLock};
|
||||
|
||||
struct Foo {
|
||||
a: i32,
|
||||
@ -12,7 +12,7 @@ struct Foo {
|
||||
fn assert<T: UnwindSafe + ?Sized>() {}
|
||||
|
||||
#[test]
|
||||
fn test_panic_safety_traits() {
|
||||
fn panic_safety_traits() {
|
||||
assert::<i32>();
|
||||
assert::<&i32>();
|
||||
assert::<*mut i32>();
|
Loading…
Reference in New Issue
Block a user