Enforce #![deny(bare_trait_objects)] in src/libcore
This commit is contained in:
parent
46804ef0ce
commit
8646a17143
|
@ -120,7 +120,7 @@ impl<T: 'static + ?Sized > Any for T {
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl fmt::Debug for Any {
|
||||
impl fmt::Debug for dyn Any {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.pad("Any")
|
||||
}
|
||||
|
@ -130,20 +130,20 @@ impl fmt::Debug for Any {
|
|||
// hence used with `unwrap`. May eventually no longer be needed if
|
||||
// dispatch works with upcasting.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl fmt::Debug for Any + Send {
|
||||
impl fmt::Debug for dyn Any + Send {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.pad("Any")
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "any_send_sync_methods", since = "1.28.0")]
|
||||
impl fmt::Debug for Any + Send + Sync {
|
||||
impl fmt::Debug for dyn Any + Send + Sync {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.pad("Any")
|
||||
}
|
||||
}
|
||||
|
||||
impl Any {
|
||||
impl dyn Any {
|
||||
/// Returns `true` if the boxed type is the same as `T`.
|
||||
///
|
||||
/// # Examples
|
||||
|
@ -203,7 +203,7 @@ impl Any {
|
|||
pub fn downcast_ref<T: Any>(&self) -> Option<&T> {
|
||||
if self.is::<T>() {
|
||||
unsafe {
|
||||
Some(&*(self as *const Any as *const T))
|
||||
Some(&*(self as *const dyn Any as *const T))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
@ -240,7 +240,7 @@ impl Any {
|
|||
pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> {
|
||||
if self.is::<T>() {
|
||||
unsafe {
|
||||
Some(&mut *(self as *mut Any as *mut T))
|
||||
Some(&mut *(self as *mut dyn Any as *mut T))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
@ -248,7 +248,7 @@ impl Any {
|
|||
}
|
||||
}
|
||||
|
||||
impl Any+Send {
|
||||
impl dyn Any+Send {
|
||||
/// Forwards to the method defined on the type `Any`.
|
||||
///
|
||||
/// # Examples
|
||||
|
@ -332,7 +332,7 @@ impl Any+Send {
|
|||
}
|
||||
}
|
||||
|
||||
impl Any+Send+Sync {
|
||||
impl dyn Any+Send+Sync {
|
||||
/// Forwards to the method defined on the type `Any`.
|
||||
///
|
||||
/// # Examples
|
||||
|
|
|
@ -1532,7 +1532,7 @@ impl<T: CoerceUnsized<U>, U> CoerceUnsized<UnsafeCell<U>> for UnsafeCell<T> {}
|
|||
|
||||
#[allow(unused)]
|
||||
fn assert_coerce_unsized(a: UnsafeCell<&i32>, b: Cell<&i32>, c: RefCell<&i32>) {
|
||||
let _: UnsafeCell<&Send> = a;
|
||||
let _: Cell<&Send> = b;
|
||||
let _: RefCell<&Send> = c;
|
||||
let _: UnsafeCell<&dyn Send> = a;
|
||||
let _: Cell<&dyn Send> = b;
|
||||
let _: RefCell<&dyn Send> = c;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
use fmt;
|
||||
|
||||
struct PadAdapter<'a> {
|
||||
buf: &'a mut (fmt::Write + 'a),
|
||||
buf: &'a mut (dyn fmt::Write + 'a),
|
||||
on_newline: bool,
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>,
|
|||
impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
|
||||
/// Adds a new field to the generated struct output.
|
||||
#[stable(feature = "debug_builders", since = "1.2.0")]
|
||||
pub fn field(&mut self, name: &str, value: &fmt::Debug) -> &mut DebugStruct<'a, 'b> {
|
||||
pub fn field(&mut self, name: &str, value: &dyn fmt::Debug) -> &mut DebugStruct<'a, 'b> {
|
||||
self.result = self.result.and_then(|_| {
|
||||
let prefix = if self.has_fields {
|
||||
","
|
||||
|
@ -204,7 +204,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
|
|||
impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
|
||||
/// Adds a new field to the generated tuple struct output.
|
||||
#[stable(feature = "debug_builders", since = "1.2.0")]
|
||||
pub fn field(&mut self, value: &fmt::Debug) -> &mut DebugTuple<'a, 'b> {
|
||||
pub fn field(&mut self, value: &dyn fmt::Debug) -> &mut DebugTuple<'a, 'b> {
|
||||
self.result = self.result.and_then(|_| {
|
||||
let (prefix, space) = if self.fields > 0 {
|
||||
(",", " ")
|
||||
|
@ -258,7 +258,7 @@ struct DebugInner<'a, 'b: 'a> {
|
|||
}
|
||||
|
||||
impl<'a, 'b: 'a> DebugInner<'a, 'b> {
|
||||
fn entry(&mut self, entry: &fmt::Debug) {
|
||||
fn entry(&mut self, entry: &dyn fmt::Debug) {
|
||||
self.result = self.result.and_then(|_| {
|
||||
if self.is_pretty() {
|
||||
let mut slot = None;
|
||||
|
@ -340,7 +340,7 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b
|
|||
impl<'a, 'b: 'a> DebugSet<'a, 'b> {
|
||||
/// Adds a new entry to the set output.
|
||||
#[stable(feature = "debug_builders", since = "1.2.0")]
|
||||
pub fn entry(&mut self, entry: &fmt::Debug) -> &mut DebugSet<'a, 'b> {
|
||||
pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugSet<'a, 'b> {
|
||||
self.inner.entry(entry);
|
||||
self
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a,
|
|||
impl<'a, 'b: 'a> DebugList<'a, 'b> {
|
||||
/// Adds a new entry to the list output.
|
||||
#[stable(feature = "debug_builders", since = "1.2.0")]
|
||||
pub fn entry(&mut self, entry: &fmt::Debug) -> &mut DebugList<'a, 'b> {
|
||||
pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugList<'a, 'b> {
|
||||
self.inner.entry(entry);
|
||||
self
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b
|
|||
impl<'a, 'b: 'a> DebugMap<'a, 'b> {
|
||||
/// Adds a new entry to the map output.
|
||||
#[stable(feature = "debug_builders", since = "1.2.0")]
|
||||
pub fn entry(&mut self, key: &fmt::Debug, value: &fmt::Debug) -> &mut DebugMap<'a, 'b> {
|
||||
pub fn entry(&mut self, key: &dyn fmt::Debug, value: &dyn fmt::Debug) -> &mut DebugMap<'a, 'b> {
|
||||
self.result = self.result.and_then(|_| {
|
||||
if self.is_pretty() {
|
||||
let mut slot = None;
|
||||
|
|
|
@ -255,7 +255,7 @@ pub struct Formatter<'a> {
|
|||
width: Option<usize>,
|
||||
precision: Option<usize>,
|
||||
|
||||
buf: &'a mut (Write+'a),
|
||||
buf: &'a mut (dyn Write+'a),
|
||||
curarg: slice::Iter<'a, ArgumentV1<'a>>,
|
||||
args: &'a [ArgumentV1<'a>],
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ struct Void {
|
|||
///
|
||||
/// It was added after #45197 showed that one could share a `!Sync`
|
||||
/// object across threads by passing it into `format_args!`.
|
||||
_oibit_remover: PhantomData<*mut Fn()>,
|
||||
_oibit_remover: PhantomData<*mut dyn Fn()>,
|
||||
}
|
||||
|
||||
/// This struct represents the generic "argument" which is taken by the Xprintf
|
||||
|
@ -1020,7 +1020,7 @@ pub trait UpperExp {
|
|||
///
|
||||
/// [`write!`]: ../../std/macro.write.html
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn write(output: &mut Write, args: Arguments) -> Result {
|
||||
pub fn write(output: &mut dyn Write, args: Arguments) -> Result {
|
||||
let mut formatter = Formatter {
|
||||
flags: 0,
|
||||
width: None,
|
||||
|
@ -1062,7 +1062,7 @@ pub fn write(output: &mut Write, args: Arguments) -> Result {
|
|||
|
||||
impl<'a> Formatter<'a> {
|
||||
fn wrap_buf<'b, 'c, F>(&'b mut self, wrap: F) -> Formatter<'c>
|
||||
where 'b: 'c, F: FnOnce(&'b mut (Write+'b)) -> &'c mut (Write+'c)
|
||||
where 'b: 'c, F: FnOnce(&'b mut (dyn Write+'b)) -> &'c mut (dyn Write+'c)
|
||||
{
|
||||
Formatter {
|
||||
// We want to change this
|
||||
|
@ -1342,7 +1342,7 @@ impl<'a> Formatter<'a> {
|
|||
}
|
||||
|
||||
fn write_formatted_parts(&mut self, formatted: &flt2dec::Formatted) -> Result {
|
||||
fn write_bytes(buf: &mut Write, s: &[u8]) -> Result {
|
||||
fn write_bytes(buf: &mut dyn Write, s: &[u8]) -> Result {
|
||||
buf.write_str(unsafe { str::from_utf8_unchecked(s) })
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use super::{Inspect, Map, Peekable, Scan, Skip, SkipWhile, StepBy, Take, TakeWhi
|
|||
use super::{Zip, Sum, Product};
|
||||
use super::{ChainState, FromIterator, ZipImpl};
|
||||
|
||||
fn _assert_is_object_safe(_: &Iterator<Item=()>) {}
|
||||
fn _assert_is_object_safe(_: &dyn Iterator<Item=()>) {}
|
||||
|
||||
/// An interface for dealing with iterators.
|
||||
///
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
|
||||
|
||||
#![no_core]
|
||||
#![deny(bare_trait_objects)]
|
||||
#![deny(missing_docs)]
|
||||
#![deny(missing_debug_implementations)]
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ use fmt;
|
|||
#[stable(feature = "panic_hooks", since = "1.10.0")]
|
||||
#[derive(Debug)]
|
||||
pub struct PanicInfo<'a> {
|
||||
payload: &'a (Any + Send),
|
||||
payload: &'a (dyn Any + Send),
|
||||
message: Option<&'a fmt::Arguments<'a>>,
|
||||
location: Location<'a>,
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ impl<'a> PanicInfo<'a> {
|
|||
|
||||
#[doc(hidden)]
|
||||
#[inline]
|
||||
pub fn set_payload(&mut self, info: &'a (Any + Send)) {
|
||||
pub fn set_payload(&mut self, info: &'a (dyn Any + Send)) {
|
||||
self.payload = info;
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ impl<'a> PanicInfo<'a> {
|
|||
/// panic!("Normal panic");
|
||||
/// ```
|
||||
#[stable(feature = "panic_hooks", since = "1.10.0")]
|
||||
pub fn payload(&self) -> &(Any + Send) {
|
||||
pub fn payload(&self) -> &(dyn Any + Send) {
|
||||
self.payload
|
||||
}
|
||||
|
||||
|
@ -270,6 +270,6 @@ impl<'a> fmt::Display for Location<'a> {
|
|||
#[unstable(feature = "std_internals", issue = "0")]
|
||||
#[doc(hidden)]
|
||||
pub unsafe trait BoxMeUp {
|
||||
fn box_me_up(&mut self) -> *mut (Any + Send);
|
||||
fn get(&mut self) -> &(Any + Send);
|
||||
fn box_me_up(&mut self) -> *mut (dyn Any + Send);
|
||||
fn get(&mut self) -> &(dyn Any + Send);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ use super::{Executor, Waker, LocalWaker};
|
|||
/// when performing a single `poll` step on a task.
|
||||
pub struct Context<'a> {
|
||||
local_waker: &'a LocalWaker,
|
||||
executor: &'a mut Executor,
|
||||
executor: &'a mut dyn Executor,
|
||||
}
|
||||
|
||||
impl<'a> fmt::Debug for Context<'a> {
|
||||
|
@ -34,7 +34,7 @@ impl<'a> fmt::Debug for Context<'a> {
|
|||
impl<'a> Context<'a> {
|
||||
/// Create a new task `Context` with the provided `local_waker`, `waker`, and `executor`.
|
||||
#[inline]
|
||||
pub fn new(local_waker: &'a LocalWaker, executor: &'a mut Executor) -> Context<'a> {
|
||||
pub fn new(local_waker: &'a LocalWaker, executor: &'a mut dyn Executor) -> Context<'a> {
|
||||
Context {
|
||||
local_waker,
|
||||
executor,
|
||||
|
@ -58,7 +58,7 @@ impl<'a> Context<'a> {
|
|||
/// This method is useful primarily if you want to explicitly handle
|
||||
/// spawn failures.
|
||||
#[inline]
|
||||
pub fn executor(&mut self) -> &mut Executor {
|
||||
pub fn executor(&mut self) -> &mut dyn Executor {
|
||||
self.executor
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ use ptr::NonNull;
|
|||
/// trait, allowing notifications to get routed through it.
|
||||
#[repr(transparent)]
|
||||
pub struct Waker {
|
||||
inner: NonNull<UnsafeWake>,
|
||||
inner: NonNull<dyn UnsafeWake>,
|
||||
}
|
||||
|
||||
impl Unpin for Waker {}
|
||||
|
@ -41,7 +41,7 @@ impl Waker {
|
|||
/// use the `Waker::from` function instead which works with the safe
|
||||
/// `Arc` type and the safe `Wake` trait.
|
||||
#[inline]
|
||||
pub unsafe fn new(inner: NonNull<UnsafeWake>) -> Self {
|
||||
pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
|
||||
Waker { inner: inner }
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ impl Drop for Waker {
|
|||
/// behavior.
|
||||
#[repr(transparent)]
|
||||
pub struct LocalWaker {
|
||||
inner: NonNull<UnsafeWake>,
|
||||
inner: NonNull<dyn UnsafeWake>,
|
||||
}
|
||||
|
||||
impl Unpin for LocalWaker {}
|
||||
|
@ -119,7 +119,7 @@ impl LocalWaker {
|
|||
/// For this function to be used safely, it must be sound to call `inner.wake_local()`
|
||||
/// on the current thread.
|
||||
#[inline]
|
||||
pub unsafe fn new(inner: NonNull<UnsafeWake>) -> Self {
|
||||
pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
|
||||
LocalWaker { inner: inner }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue