///////////////////////////////////////////////////////////////////////////////
#[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")
}
// 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
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
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
}
}
-impl Any+Send {
+impl dyn Any+Send {
/// Forwards to the method defined on the type `Any`.
///
/// # Examples
}
}
-impl Any+Send+Sync {
+impl dyn Any+Send+Sync {
/// Forwards to the method defined on the type `Any`.
///
/// # Examples
#[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;
}
use fmt;
struct PadAdapter<'a> {
- buf: &'a mut (fmt::Write + 'a),
+ buf: &'a mut (dyn fmt::Write + 'a),
on_newline: bool,
}
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 {
","
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 {
(",", " ")
}
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;
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
}
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
}
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;
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>],
}
///
/// 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
///
/// [`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,
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
}
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) })
}
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.
///
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
#![no_core]
+#![deny(bare_trait_objects)]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
#[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>,
}
#[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;
}
/// 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
}
#[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);
}
/// 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> {
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,
/// 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
}
/// trait, allowing notifications to get routed through it.
#[repr(transparent)]
pub struct Waker {
- inner: NonNull<UnsafeWake>,
+ inner: NonNull<dyn UnsafeWake>,
}
impl Unpin for 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 }
}
/// behavior.
#[repr(transparent)]
pub struct LocalWaker {
- inner: NonNull<UnsafeWake>,
+ inner: NonNull<dyn UnsafeWake>,
}
impl Unpin for 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 }
}