]> git.lizzy.rs Git - rust.git/commitdiff
Incorporate `dyn` into more comments and docs.
authorCorey Farwell <coreyf@rwell.org>
Tue, 20 Nov 2018 14:34:15 +0000 (09:34 -0500)
committerCorey Farwell <coreyf@rwell.org>
Tue, 20 Nov 2018 14:35:03 +0000 (09:35 -0500)
src/liballoc/boxed.rs
src/liballoc/rc.rs
src/libcore/raw.rs
src/librustc/mir/mod.rs
src/librustc/ty/adjustment.rs
src/librustc/ty/util.rs
src/librustc_codegen_ssa/meth.rs
src/libstd/fs.rs
src/test/run-pass/string-box-error.rs

index 63b262d1f3d986ac22aa793a2270c1b735e11a3e..c3a84bf778d03de1d67ed15c09a352006845c47a 100644 (file)
@@ -489,7 +489,7 @@ impl Box<dyn Any> {
     /// ```
     /// use std::any::Any;
     ///
-    /// fn print_if_string(value: Box<Any>) {
+    /// fn print_if_string(value: Box<dyn Any>) {
     ///     if let Ok(string) = value.downcast::<String>() {
     ///         println!("String ({}): {}", string.len(), string);
     ///     }
@@ -523,7 +523,7 @@ impl Box<dyn Any + Send> {
     /// ```
     /// use std::any::Any;
     ///
-    /// fn print_if_string(value: Box<Any + Send>) {
+    /// fn print_if_string(value: Box<dyn Any + Send>) {
     ///     if let Ok(string) = value.downcast::<String>() {
     ///         println!("String ({}): {}", string.len(), string);
     ///     }
@@ -618,10 +618,10 @@ impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {}
 
 /// `FnBox` is a version of the `FnOnce` intended for use with boxed
 /// closure objects. The idea is that where one would normally store a
-/// `Box<FnOnce()>` in a data structure, you should use
-/// `Box<FnBox()>`. The two traits behave essentially the same, except
+/// `Box<dyn FnOnce()>` in a data structure, you should use
+/// `Box<dyn FnBox()>`. The two traits behave essentially the same, except
 /// that a `FnBox` closure can only be called if it is boxed. (Note
-/// that `FnBox` may be deprecated in the future if `Box<FnOnce()>`
+/// that `FnBox` may be deprecated in the future if `Box<dyn FnOnce()>`
 /// closures become directly usable.)
 ///
 /// # Examples
@@ -629,7 +629,7 @@ impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {}
 /// Here is a snippet of code which creates a hashmap full of boxed
 /// once closures and then removes them one by one, calling each
 /// closure as it is removed. Note that the type of the closures
-/// stored in the map is `Box<FnBox() -> i32>` and not `Box<FnOnce()
+/// stored in the map is `Box<dyn FnBox() -> i32>` and not `Box<dyn FnOnce()
 /// -> i32>`.
 ///
 /// ```
@@ -638,8 +638,8 @@ impl<I: FusedIterator + ?Sized> FusedIterator for Box<I> {}
 /// use std::boxed::FnBox;
 /// use std::collections::HashMap;
 ///
-/// fn make_map() -> HashMap<i32, Box<FnBox() -> i32>> {
-///     let mut map: HashMap<i32, Box<FnBox() -> i32>> = HashMap::new();
+/// fn make_map() -> HashMap<i32, Box<dyn FnBox() -> i32>> {
+///     let mut map: HashMap<i32, Box<dyn FnBox() -> i32>> = HashMap::new();
 ///     map.insert(1, Box::new(|| 22));
 ///     map.insert(2, Box::new(|| 44));
 ///     map
index bb52d7990ff5772fdc27c821ee3c730896af9630..12c19912662fc3120c2277b1aabedc0f2503473d 100644 (file)
@@ -634,7 +634,7 @@ pub fn make_mut(this: &mut Self) -> &mut T {
 impl Rc<dyn Any> {
     #[inline]
     #[stable(feature = "rc_downcast", since = "1.29.0")]
-    /// Attempt to downcast the `Rc<Any>` to a concrete type.
+    /// Attempt to downcast the `Rc<dyn Any>` to a concrete type.
     ///
     /// # Examples
     ///
@@ -642,7 +642,7 @@ impl Rc<dyn Any> {
     /// use std::any::Any;
     /// use std::rc::Rc;
     ///
-    /// fn print_if_string(value: Rc<Any>) {
+    /// fn print_if_string(value: Rc<dyn Any>) {
     ///     if let Ok(string) = value.downcast::<String>() {
     ///         println!("String ({}): {}", string.len(), string);
     ///     }
index a95f05227fb8b1b38ef596cdacaae5744569c1f7..b7597795b5e62aea077154f2830dabee712b253e 100644 (file)
@@ -21,7 +21,7 @@
 /// The representation of a trait object like `&SomeTrait`.
 ///
 /// This struct has the same layout as types like `&SomeTrait` and
-/// `Box<AnotherTrait>`. The [Trait Objects chapter of the
+/// `Box<dyn AnotherTrait>`. The [Trait Objects chapter of the
 /// Book][moreinfo] contains more details about the precise nature of
 /// these internals.
 ///
index d8e45c881f5551541e35418a9b4591fc05adeb42..acc03bd4a48b1942edc73188e9e8e77aed2a8d90 100644 (file)
@@ -2207,7 +2207,7 @@ pub enum CastKind {
     /// "Unsize" -- convert a thin-or-fat pointer to a fat pointer.
     /// codegen must figure out the details once full monomorphization
     /// is known. For example, this could be used to cast from a
-    /// `&[i32;N]` to a `&[i32]`, or a `Box<T>` to a `Box<Trait>`
+    /// `&[i32;N]` to a `&[i32]`, or a `Box<T>` to a `Box<dyn Trait>`
     /// (presuming `T: Trait`).
     Unsize,
 }
index 3263da8fda365756298c026f23db0a546b383825..83521c5f7240682064d1c73e9dd6c45da8a8fe35 100644 (file)
@@ -48,7 +48,7 @@
 ///    stored in `unsize` is `Foo<[i32]>`, we don't store any further detail about
 ///    the underlying conversions from `[i32; 4]` to `[i32]`.
 ///
-/// 3. Coercing a `Box<T>` to `Box<Trait>` is an interesting special case.  In
+/// 3. Coercing a `Box<T>` to `Box<dyn Trait>` is an interesting special case.  In
 ///    that case, we have the pointer we need coming in, so there are no
 ///    autoderefs, and no autoref. Instead we just do the `Unsize` transformation.
 ///    At some point, of course, `Box` should move out of the compiler, in which
index 3d0c54d6b0a5b44f5165c4ce7ff9c8e9d9b35097..0d756aa078195dc31efb392959a79c9c95f33fd1 100644 (file)
@@ -303,7 +303,7 @@ pub fn struct_tail(self, mut ty: Ty<'tcx>) -> Ty<'tcx> {
     /// Same as applying struct_tail on `source` and `target`, but only
     /// keeps going as long as the two types are instances of the same
     /// structure definitions.
-    /// For `(Foo<Foo<T>>, Foo<Trait>)`, the result will be `(Foo<T>, Trait)`,
+    /// For `(Foo<Foo<T>>, Foo<dyn Trait>)`, the result will be `(Foo<T>, Trait)`,
     /// whereas struct_tail produces `T`, and `Trait`, respectively.
     pub fn struct_lockstep_tails(self,
                                  source: Ty<'tcx>,
index 06c4f7a87d88017de8337a6c123700da70ea0950..24be932141c7e4a936ed76857240740128f46696 100644 (file)
@@ -74,7 +74,7 @@ pub fn get_usize<Bx: BuilderMethods<'a, 'tcx>>(
 /// The vtables are cached instead of created on every call.
 ///
 /// The `trait_ref` encodes the erased self type. Hence if we are
-/// making an object `Foo<Trait>` from a value of type `Foo<T>`, then
+/// making an object `Foo<dyn Trait>` from a value of type `Foo<T>`, then
 /// `trait_ref` would map `T:Trait`.
 pub fn get_vtable<'tcx, Cx: CodegenMethods<'tcx>>(
     cx: &Cx,
index f4703dec187b8cf0843f973e2c80bbf0c4b973f1..92678dd5cede0db6910594d8fc817e043003686a 100644 (file)
@@ -256,7 +256,7 @@ fn initial_buffer_size(file: &File) -> usize {
 /// use std::fs;
 /// use std::net::SocketAddr;
 ///
-/// fn main() -> Result<(), Box<std::error::Error + 'static>> {
+/// fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
 ///     let foo: SocketAddr = String::from_utf8_lossy(&fs::read("address.txt")?).parse()?;
 ///     Ok(())
 /// }
@@ -298,7 +298,7 @@ pub fn read<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
 /// use std::fs;
 /// use std::net::SocketAddr;
 ///
-/// fn main() -> Result<(), Box<std::error::Error + 'static>> {
+/// fn main() -> Result<(), Box<dyn std::error::Error + 'static>> {
 ///     let foo: SocketAddr = fs::read_to_string("address.txt")?.parse()?;
 ///     Ok(())
 /// }
index a80d9a059356619e4cde086a241c8f7f743eff81..5d8a664b93daddb5dcb678bca114a65bb3bd6388 100644 (file)
@@ -8,7 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Ensure that both `Box<Error + Send + Sync>` and `Box<Error>` can be obtained from `String`.
+// Ensure that both `Box<dyn Error + Send + Sync>` and `Box<dyn Error>` can be
+// obtained from `String`.
 
 use std::error::Error;