diff --git a/README.md b/README.md index 55e6e8d7f1889..f6f796911b8fa 100644 --- a/README.md +++ b/README.md @@ -261,3 +261,19 @@ BSD-like licenses. See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and [COPYRIGHT](COPYRIGHT) for details. + +## Trademark +[trademark]: #trademark + +The Rust programming language is an open source, community project governed +by a core team. It is also sponsored by the Mozilla Foundation (“Mozilla”), +which owns and protects the Rust and Cargo trademarks and logos +(the “Rust Trademarks”). + +If you want to use these names or brands, please read the [media guide][media-guide]. + +Third-party logos may be subject to third-party copyrights and trademarks. See +[Licenses][policies-licenses] for details. + +[media-guide]: https://www.rust-lang.org/policies/media-guide +[policies-licenses]: https://www.rust-lang.org/policies/licenses diff --git a/RELEASES.md b/RELEASES.md index fcaaa73bdc0f4..24461742ad898 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -113,15 +113,15 @@ Compatibility Notes [56470]: https://github.com/rust-lang/rust/pull/56470/ [cargo/6654]: https://github.com/rust-lang/cargo/pull/6654/ [`Any::type_id`]: https://doc.rust-lang.org/std/any/trait.Any.html#tymethod.type_id -[`Error::type_id`]: https://doc.rust-lang.org/std/error/trait.Error.html#tymethod.type_id -[`atomic::AtomicI16`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI16.html -[`atomic::AtomicI32`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI32.html -[`atomic::AtomicI64`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI64.html -[`atomic::AtomicI8`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI8.html -[`atomic::AtomicU16`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU16.html -[`atomic::AtomicU32`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU32.html -[`atomic::AtomicU64`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU64.html -[`atomic::AtomicU8`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU8.html +[`Error::type_id`]: https://doc.rust-lang.org/std/error/trait.Error.html#method.type_id +[`atomic::AtomicI16`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicI16.html +[`atomic::AtomicI32`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicI32.html +[`atomic::AtomicI64`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicI64.html +[`atomic::AtomicI8`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicI8.html +[`atomic::AtomicU16`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU16.html +[`atomic::AtomicU32`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU32.html +[`atomic::AtomicU64`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU64.html +[`atomic::AtomicU8`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU8.html [`convert::Infallible`]: https://doc.rust-lang.org/std/convert/enum.Infallible.html [`convert::TryFrom`]: https://doc.rust-lang.org/std/convert/trait.TryFrom.html [`convert::TryInto`]: https://doc.rust-lang.org/std/convert/trait.TryInto.html diff --git a/src/liballoc/borrow.rs b/src/liballoc/borrow.rs index ee1799fad8e15..d5e15b3719c2e 100644 --- a/src/liballoc/borrow.rs +++ b/src/liballoc/borrow.rs @@ -32,6 +32,7 @@ impl<'a, B: ?Sized> Borrow for Cow<'a, B> /// from any borrow of a given type. #[stable(feature = "rust1", since = "1.0.0")] pub trait ToOwned { + /// The resulting type after obtaining ownership. #[stable(feature = "rust1", since = "1.0.0")] type Owned: Borrow; diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 6a6a9146e2432..8a3950718d7d2 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -760,6 +760,7 @@ impl + ?Sized> Fn for Box { #[unstable(feature = "fnbox", reason = "will be deprecated if and when `Box` becomes usable", issue = "28796")] pub trait FnBox: FnOnce { + /// Performs the call operation. fn call_box(self: Box, args: A) -> Self::Output; } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 7f3acc933d413..63b3fbbdaefe1 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -58,12 +58,13 @@ #![no_std] #![needs_allocator] -#![deny(rust_2018_idioms)] -#![allow(explicit_outlives_requirements)] - #![warn(deprecated_in_future)] -#![warn(intra_doc_link_resolution_failure)] +#![warn(missing_docs)] #![warn(missing_debug_implementations)] +#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings + +#![deny(rust_2018_idioms)] +#![allow(explicit_outlives_requirements)] #![cfg_attr(not(test), feature(generator_trait))] #![cfg_attr(test, feature(test))] diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index f4b2d463778a9..6eac848740106 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -570,6 +570,16 @@ pub trait SliceConcatExt { #[stable(feature = "rename_connect_to_join", since = "1.3.0")] fn join(&self, sep: &T) -> Self::Output; + /// Flattens a slice of `T` into a single value `Self::Output`, placing a + /// given separator between each. + /// + /// # Examples + /// + /// ``` + /// # #![allow(deprecated)] + /// assert_eq!(["hello", "world"].connect(" "), "hello world"); + /// assert_eq!([[1, 2], [3, 4]].connect(&0), [1, 2, 0, 3, 4]); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(since = "1.3.0", reason = "renamed to join")] fn connect(&self, sep: &T) -> Self::Output; diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 63688e70c45cb..615549f47bbd6 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -60,8 +60,8 @@ #![warn(deprecated_in_future)] #![warn(missing_docs)] -#![warn(intra_doc_link_resolution_failure)] #![warn(missing_debug_implementations)] +#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings #![feature(allow_internal_unstable)] #![feature(arbitrary_self_types)] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 3da92c0a05ac4..68ef087d84b90 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -178,6 +178,7 @@ impl Option { /// ``` /// /// [`Some`]: #variant.Some + #[must_use] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_some(&self) -> bool { @@ -200,6 +201,7 @@ impl Option { /// ``` /// /// [`None`]: #variant.None + #[must_use] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_none(&self) -> bool { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 9b7b83689861b..e22a9ebbca4c3 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -277,6 +277,7 @@ impl Result { /// let x: Result = Err("Some error message"); /// assert_eq!(x.is_ok(), false); /// ``` + #[must_use] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_ok(&self) -> bool { @@ -301,6 +302,7 @@ impl Result { /// let x: Result = Err("Some error message"); /// assert_eq!(x.is_err(), true); /// ``` + #[must_use] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_err(&self) -> bool { diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 15ea6403e38ba..4b615345a26f3 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -755,8 +755,31 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> { } /// Check if a `DefId`'s path matches the given absolute type path usage. + /// + /// # Examples + /// ```rust,ignore (no `cx` or `def_id` available) + /// if cx.match_def_path(def_id, &["core", "option", "Option"]) { + /// // The given `def_id` is that of an `Option` type + /// } + /// ``` // Uplifted from rust-lang/rust-clippy - pub fn match_path(&self, def_id: DefId, path: &[&str]) -> bool { + pub fn match_def_path(&self, def_id: DefId, path: &[&str]) -> bool { + let names = self.get_def_path(def_id); + + names.len() == path.len() && names.into_iter().zip(path.iter()).all(|(a, &b)| *a == *b) + } + + /// Gets the absolute path of `def_id` as a vector of `&str`. + /// + /// # Examples + /// ```rust,ignore (no `cx` or `def_id` available) + /// let def_path = cx.get_def_path(def_id); + /// if let &["core", "option", "Option"] = &def_path[..] { + /// // The given `def_id` is that of an `Option` type + /// } + /// ``` + // Uplifted from rust-lang/rust-clippy + pub fn get_def_path(&self, def_id: DefId) -> Vec { pub struct AbsolutePathPrinter<'a, 'tcx> { pub tcx: TyCtxt<'a, 'tcx, 'tcx>, } @@ -856,10 +879,9 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> { } } - let names = AbsolutePathPrinter { tcx: self.tcx }.print_def_path(def_id, &[]).unwrap(); - - names.len() == path.len() - && names.into_iter().zip(path.iter()).all(|(a, &b)| *a == *b) + AbsolutePathPrinter { tcx: self.tcx } + .print_def_path(def_id, &[]) + .unwrap() } } diff --git a/src/librustc/lint/internal.rs b/src/librustc/lint/internal.rs index 0bafa93011ec4..91f1bee26de32 100644 --- a/src/librustc/lint/internal.rs +++ b/src/librustc/lint/internal.rs @@ -100,7 +100,7 @@ fn lint_ty_kind_usage(cx: &LateContext<'_, '_>, segment: &PathSegment) -> bool { if segment.ident.as_str() == "TyKind" { if let Some(def) = segment.def { if let Some(did) = def.opt_def_id() { - return cx.match_path(did, &["rustc", "ty", "sty", "TyKind"]); + return cx.match_def_path(did, &["rustc", "ty", "sty", "TyKind"]); } } } diff --git a/src/librustc_data_structures/owning_ref/mod.rs b/src/librustc_data_structures/owning_ref/mod.rs index 236559dcd7c10..0301891c9b292 100644 --- a/src/librustc_data_structures/owning_ref/mod.rs +++ b/src/librustc_data_structures/owning_ref/mod.rs @@ -1471,7 +1471,7 @@ mod tests { let x = Box::new(123_i32); let y: Box = x; - OwningRef::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_ok(); + assert!(OwningRef::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_ok()); } #[test] @@ -1481,7 +1481,7 @@ mod tests { let x = Box::new(123_i32); let y: Box = x; - OwningRef::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_err(); + assert!(!OwningRef::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_err()); } } @@ -1868,7 +1868,7 @@ mod tests { let x = Box::new(123_i32); let y: Box = x; - OwningRefMut::new(y).try_map_mut(|x| x.downcast_mut::().ok_or(())).is_ok(); + assert!(OwningRefMut::new(y).try_map_mut(|x| x.downcast_mut::().ok_or(())).is_ok()); } #[test] @@ -1878,7 +1878,7 @@ mod tests { let x = Box::new(123_i32); let y: Box = x; - OwningRefMut::new(y).try_map_mut(|x| x.downcast_mut::().ok_or(())).is_err(); + assert!(!OwningRefMut::new(y).try_map_mut(|x| x.downcast_mut::().ok_or(())).is_err()); } #[test] @@ -1888,7 +1888,7 @@ mod tests { let x = Box::new(123_i32); let y: Box = x; - OwningRefMut::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_ok(); + assert!(OwningRefMut::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_ok()); } #[test] @@ -1898,7 +1898,7 @@ mod tests { let x = Box::new(123_i32); let y: Box = x; - OwningRefMut::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_err(); + assert!(!OwningRefMut::new(y).try_map(|x| x.downcast_ref::().ok_or(())).is_err()); } #[test] diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index e994c661fdceb..80e796b0af732 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2325,6 +2325,10 @@ impl<'tcx> Clean for ty::AssociatedItem { } else { hir::Constness::NotConst }; + let defaultness = match self.container { + ty::ImplContainer(_) => Some(self.defaultness), + ty::TraitContainer(_) => None, + }; MethodItem(Method { generics, decl, @@ -2334,7 +2338,7 @@ impl<'tcx> Clean for ty::AssociatedItem { constness, asyncness: hir::IsAsync::NotAsync, }, - defaultness: Some(self.defaultness), + defaultness, all_types, ret_types, }) diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index ee6ba3f438f15..62bc1991cc93c 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -205,9 +205,10 @@ // Don't link to std. We are std. #![no_std] -#![deny(missing_docs)] -#![deny(intra_doc_link_resolution_failure)] -#![deny(missing_debug_implementations)] +//#![warn(deprecated_in_future)] // FIXME: std still has quite a few uses of `mem::uninitialized` +#![warn(missing_docs)] +#![warn(missing_debug_implementations)] +#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings #![deny(rust_2018_idioms)] #![allow(explicit_outlives_requirements)] diff --git a/src/libstd/sync/mpsc/mod.rs b/src/libstd/sync/mpsc/mod.rs index bc32b8e47b316..685c7909ff294 100644 --- a/src/libstd/sync/mpsc/mod.rs +++ b/src/libstd/sync/mpsc/mod.rs @@ -1005,7 +1005,7 @@ impl SyncSender { /// thread::spawn(move || { /// // This will return an error and send /// // no message if the buffer is full - /// sync_sender2.try_send(3).is_err(); + /// let _ = sync_sender2.try_send(3); /// }); /// /// let mut msg; diff --git a/src/stdsimd b/src/stdsimd index 2792b45c97588..2323a858f060a 160000 --- a/src/stdsimd +++ b/src/stdsimd @@ -1 +1 @@ -Subproject commit 2792b45c975880038240d477adb0d66f760ac048 +Subproject commit 2323a858f060a0d2a39786a619885608017d538f diff --git a/src/test/run-pass/issues/issue-18353.rs b/src/test/run-pass/issues/issue-18353.rs index aaa896b66c5d4..3d15c9980c352 100644 --- a/src/test/run-pass/issues/issue-18353.rs +++ b/src/test/run-pass/issues/issue-18353.rs @@ -11,5 +11,5 @@ struct Str { fn main() { let str: Option<&Str> = None; - str.is_some(); + let _ = str.is_some(); } diff --git a/src/test/rustdoc/default-trait-method.rs b/src/test/rustdoc/default-trait-method.rs new file mode 100644 index 0000000000000..3d6ebef5a1d5b --- /dev/null +++ b/src/test/rustdoc/default-trait-method.rs @@ -0,0 +1,26 @@ +#![feature(specialization)] + +// @has default_trait_method/trait.Item.html +// @has - '//*[@id="tymethod.foo"]' 'fn foo()' +// @!has - '//*[@id="tymethod.foo"]' 'default fn foo()' +// @has - '//*[@id="tymethod.bar"]' 'fn bar()' +// @!has - '//*[@id="tymethod.bar"]' 'default fn bar()' +// @has - '//*[@id="method.baz"]' 'fn baz()' +// @!has - '//*[@id="method.baz"]' 'default fn baz()' +pub trait Item { + fn foo(); + fn bar(); + fn baz() {} +} + +// @has default_trait_method/struct.Foo.html +// @has - '//*[@id="method.foo"]' 'default fn foo()' +// @has - '//*[@id="method.bar"]' 'fn bar()' +// @!has - '//*[@id="method.bar"]' 'default fn bar()' +// @has - '//*[@id="method.baz"]' 'fn baz()' +// @!has - '//*[@id="method.baz"]' 'default fn baz()' +pub struct Foo; +impl Item for Foo { + default fn foo() {} + fn bar() {} +} diff --git a/src/test/rustdoc/default_trait_method.rs b/src/test/rustdoc/default_trait_method.rs deleted file mode 100644 index dfbd8f2210fa4..0000000000000 --- a/src/test/rustdoc/default_trait_method.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(specialization)] - -pub trait Item { - fn foo(); - fn bar(); -} - -// @has default_trait_method/trait.Item.html -// @has - '//*[@id="method.foo"]' 'default fn foo()' -// @has - '//*[@id="method.bar"]' 'fn bar()' -// @!has - '//*[@id="method.bar"]' 'default fn bar()' -impl Item for T { - default fn foo() {} - fn bar() {} -} diff --git a/src/test/rustdoc/inline_cross/auxiliary/default-trait-method.rs b/src/test/rustdoc/inline_cross/auxiliary/default-trait-method.rs new file mode 100644 index 0000000000000..ce60bbfb4b0de --- /dev/null +++ b/src/test/rustdoc/inline_cross/auxiliary/default-trait-method.rs @@ -0,0 +1,16 @@ +#![feature(specialization)] + +#![crate_name = "foo"] + +pub trait Item { + fn foo(); + fn bar(); + fn baz() {} +} + +pub struct Foo; + +impl Item for Foo { + default fn foo() {} + fn bar() {} +} diff --git a/src/test/rustdoc/inline_cross/default-trait-method.rs b/src/test/rustdoc/inline_cross/default-trait-method.rs new file mode 100644 index 0000000000000..a4ec73a127d4e --- /dev/null +++ b/src/test/rustdoc/inline_cross/default-trait-method.rs @@ -0,0 +1,20 @@ +// aux-build:default-trait-method.rs + +extern crate foo; + +// @has default_trait_method/trait.Item.html +// @has - '//*[@id="tymethod.foo"]' 'fn foo()' +// @!has - '//*[@id="tymethod.foo"]' 'default fn foo()' +// @has - '//*[@id="tymethod.bar"]' 'fn bar()' +// @!has - '//*[@id="tymethod.bar"]' 'default fn bar()' +// @has - '//*[@id="method.baz"]' 'fn baz()' +// @!has - '//*[@id="method.baz"]' 'default fn baz()' +pub use foo::Item; + +// @has default_trait_method/struct.Foo.html +// @has - '//*[@id="method.foo"]' 'default fn foo()' +// @has - '//*[@id="method.bar"]' 'fn bar()' +// @!has - '//*[@id="method.bar"]' 'default fn bar()' +// @has - '//*[@id="method.baz"]' 'fn baz()' +// @!has - '//*[@id="method.baz"]' 'default fn baz()' +pub use foo::Foo;