Skip to content

Commit 07133ac

Browse files
committed
Auto merge of #59991 - Centril:rollup-bqxt4w3, r=Centril
Rollup of 6 pull requests Successful merges: - #59648 (Add must_use annotations to Result::is_ok and is_err) - #59748 (Add summary and reference to Rust trademark guide) - #59779 (Uplift `get_def_path` from Clippy) - #59955 (bump stdsimd; make intra_doc_link_resolution_failure an error again; make lints more consistent) - #59978 (rustdoc: Remove default keyword from re-exported trait methods) - #59989 (Fix links to Atomic* in RELEASES.md) Failed merges: r? @ghost
2 parents 9217fe0 + 6434fe9 commit 07133ac

File tree

21 files changed

+155
-48
lines changed

21 files changed

+155
-48
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,19 @@ BSD-like licenses.
261261

262262
See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and
263263
[COPYRIGHT](COPYRIGHT) for details.
264+
265+
## Trademark
266+
[trademark]: #trademark
267+
268+
The Rust programming language is an open source, community project governed
269+
by a core team. It is also sponsored by the Mozilla Foundation (“Mozilla”),
270+
which owns and protects the Rust and Cargo trademarks and logos
271+
(the “Rust Trademarks”).
272+
273+
If you want to use these names or brands, please read the [media guide][media-guide].
274+
275+
Third-party logos may be subject to third-party copyrights and trademarks. See
276+
[Licenses][policies-licenses] for details.
277+
278+
[media-guide]: https://www.rust-lang.org/policies/media-guide
279+
[policies-licenses]: https://www.rust-lang.org/policies/licenses

RELEASES.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ Compatibility Notes
113113
[56470]: https://github.com/rust-lang/rust/pull/56470/
114114
[cargo/6654]: https://github.com/rust-lang/cargo/pull/6654/
115115
[`Any::type_id`]: https://doc.rust-lang.org/std/any/trait.Any.html#tymethod.type_id
116-
[`Error::type_id`]: https://doc.rust-lang.org/std/error/trait.Error.html#tymethod.type_id
117-
[`atomic::AtomicI16`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI16.html
118-
[`atomic::AtomicI32`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI32.html
119-
[`atomic::AtomicI64`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI64.html
120-
[`atomic::AtomicI8`]: https://doc.rust-lang.org/std/atomic/struct.AtomicI8.html
121-
[`atomic::AtomicU16`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU16.html
122-
[`atomic::AtomicU32`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU32.html
123-
[`atomic::AtomicU64`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU64.html
124-
[`atomic::AtomicU8`]: https://doc.rust-lang.org/std/atomic/struct.AtomicU8.html
116+
[`Error::type_id`]: https://doc.rust-lang.org/std/error/trait.Error.html#method.type_id
117+
[`atomic::AtomicI16`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicI16.html
118+
[`atomic::AtomicI32`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicI32.html
119+
[`atomic::AtomicI64`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicI64.html
120+
[`atomic::AtomicI8`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicI8.html
121+
[`atomic::AtomicU16`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU16.html
122+
[`atomic::AtomicU32`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU32.html
123+
[`atomic::AtomicU64`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU64.html
124+
[`atomic::AtomicU8`]: https://doc.rust-lang.org/std/sync/atomic/struct.AtomicU8.html
125125
[`convert::Infallible`]: https://doc.rust-lang.org/std/convert/enum.Infallible.html
126126
[`convert::TryFrom`]: https://doc.rust-lang.org/std/convert/trait.TryFrom.html
127127
[`convert::TryInto`]: https://doc.rust-lang.org/std/convert/trait.TryInto.html

src/liballoc/borrow.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ impl<'a, B: ?Sized> Borrow<B> for Cow<'a, B>
3232
/// from any borrow of a given type.
3333
#[stable(feature = "rust1", since = "1.0.0")]
3434
pub trait ToOwned {
35+
/// The resulting type after obtaining ownership.
3536
#[stable(feature = "rust1", since = "1.0.0")]
3637
type Owned: Borrow<Self>;
3738

src/liballoc/boxed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ impl<A, F: Fn<A> + ?Sized> Fn<A> for Box<F> {
760760
#[unstable(feature = "fnbox",
761761
reason = "will be deprecated if and when `Box<FnOnce>` becomes usable", issue = "28796")]
762762
pub trait FnBox<A>: FnOnce<A> {
763+
/// Performs the call operation.
763764
fn call_box(self: Box<Self>, args: A) -> Self::Output;
764765
}
765766

src/liballoc/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@
5858
#![no_std]
5959
#![needs_allocator]
6060

61-
#![deny(rust_2018_idioms)]
62-
#![allow(explicit_outlives_requirements)]
63-
6461
#![warn(deprecated_in_future)]
65-
#![warn(intra_doc_link_resolution_failure)]
62+
#![warn(missing_docs)]
6663
#![warn(missing_debug_implementations)]
64+
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
65+
66+
#![deny(rust_2018_idioms)]
67+
#![allow(explicit_outlives_requirements)]
6768

6869
#![cfg_attr(not(test), feature(generator_trait))]
6970
#![cfg_attr(test, feature(test))]

src/liballoc/slice.rs

+10
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,16 @@ pub trait SliceConcatExt<T: ?Sized> {
570570
#[stable(feature = "rename_connect_to_join", since = "1.3.0")]
571571
fn join(&self, sep: &T) -> Self::Output;
572572

573+
/// Flattens a slice of `T` into a single value `Self::Output`, placing a
574+
/// given separator between each.
575+
///
576+
/// # Examples
577+
///
578+
/// ```
579+
/// # #![allow(deprecated)]
580+
/// assert_eq!(["hello", "world"].connect(" "), "hello world");
581+
/// assert_eq!([[1, 2], [3, 4]].connect(&0), [1, 2, 0, 3, 4]);
582+
/// ```
573583
#[stable(feature = "rust1", since = "1.0.0")]
574584
#[rustc_deprecated(since = "1.3.0", reason = "renamed to join")]
575585
fn connect(&self, sep: &T) -> Self::Output;

src/libcore/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060

6161
#![warn(deprecated_in_future)]
6262
#![warn(missing_docs)]
63-
#![warn(intra_doc_link_resolution_failure)]
6463
#![warn(missing_debug_implementations)]
64+
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
6565

6666
#![feature(allow_internal_unstable)]
6767
#![feature(arbitrary_self_types)]

src/libcore/option.rs

+2
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ impl<T> Option<T> {
178178
/// ```
179179
///
180180
/// [`Some`]: #variant.Some
181+
#[must_use]
181182
#[inline]
182183
#[stable(feature = "rust1", since = "1.0.0")]
183184
pub fn is_some(&self) -> bool {
@@ -200,6 +201,7 @@ impl<T> Option<T> {
200201
/// ```
201202
///
202203
/// [`None`]: #variant.None
204+
#[must_use]
203205
#[inline]
204206
#[stable(feature = "rust1", since = "1.0.0")]
205207
pub fn is_none(&self) -> bool {

src/libcore/result.rs

+2
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ impl<T, E> Result<T, E> {
277277
/// let x: Result<i32, &str> = Err("Some error message");
278278
/// assert_eq!(x.is_ok(), false);
279279
/// ```
280+
#[must_use]
280281
#[inline]
281282
#[stable(feature = "rust1", since = "1.0.0")]
282283
pub fn is_ok(&self) -> bool {
@@ -301,6 +302,7 @@ impl<T, E> Result<T, E> {
301302
/// let x: Result<i32, &str> = Err("Some error message");
302303
/// assert_eq!(x.is_err(), true);
303304
/// ```
305+
#[must_use]
304306
#[inline]
305307
#[stable(feature = "rust1", since = "1.0.0")]
306308
pub fn is_err(&self) -> bool {

src/librustc/lint/context.rs

+27-5
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,31 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
755755
}
756756

757757
/// Check if a `DefId`'s path matches the given absolute type path usage.
758+
///
759+
/// # Examples
760+
/// ```rust,ignore (no `cx` or `def_id` available)
761+
/// if cx.match_def_path(def_id, &["core", "option", "Option"]) {
762+
/// // The given `def_id` is that of an `Option` type
763+
/// }
764+
/// ```
758765
// Uplifted from rust-lang/rust-clippy
759-
pub fn match_path(&self, def_id: DefId, path: &[&str]) -> bool {
766+
pub fn match_def_path(&self, def_id: DefId, path: &[&str]) -> bool {
767+
let names = self.get_def_path(def_id);
768+
769+
names.len() == path.len() && names.into_iter().zip(path.iter()).all(|(a, &b)| *a == *b)
770+
}
771+
772+
/// Gets the absolute path of `def_id` as a vector of `&str`.
773+
///
774+
/// # Examples
775+
/// ```rust,ignore (no `cx` or `def_id` available)
776+
/// let def_path = cx.get_def_path(def_id);
777+
/// if let &["core", "option", "Option"] = &def_path[..] {
778+
/// // The given `def_id` is that of an `Option` type
779+
/// }
780+
/// ```
781+
// Uplifted from rust-lang/rust-clippy
782+
pub fn get_def_path(&self, def_id: DefId) -> Vec<LocalInternedString> {
760783
pub struct AbsolutePathPrinter<'a, 'tcx> {
761784
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
762785
}
@@ -856,10 +879,9 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
856879
}
857880
}
858881

859-
let names = AbsolutePathPrinter { tcx: self.tcx }.print_def_path(def_id, &[]).unwrap();
860-
861-
names.len() == path.len()
862-
&& names.into_iter().zip(path.iter()).all(|(a, &b)| *a == *b)
882+
AbsolutePathPrinter { tcx: self.tcx }
883+
.print_def_path(def_id, &[])
884+
.unwrap()
863885
}
864886
}
865887

src/librustc/lint/internal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ fn lint_ty_kind_usage(cx: &LateContext<'_, '_>, segment: &PathSegment) -> bool {
100100
if segment.ident.as_str() == "TyKind" {
101101
if let Some(def) = segment.def {
102102
if let Some(did) = def.opt_def_id() {
103-
return cx.match_path(did, &["rustc", "ty", "sty", "TyKind"]);
103+
return cx.match_def_path(did, &["rustc", "ty", "sty", "TyKind"]);
104104
}
105105
}
106106
}

src/librustc_data_structures/owning_ref/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ mod tests {
14711471
let x = Box::new(123_i32);
14721472
let y: Box<dyn Any> = x;
14731473

1474-
OwningRef::new(y).try_map(|x| x.downcast_ref::<i32>().ok_or(())).is_ok();
1474+
assert!(OwningRef::new(y).try_map(|x| x.downcast_ref::<i32>().ok_or(())).is_ok());
14751475
}
14761476

14771477
#[test]
@@ -1481,7 +1481,7 @@ mod tests {
14811481
let x = Box::new(123_i32);
14821482
let y: Box<dyn Any> = x;
14831483

1484-
OwningRef::new(y).try_map(|x| x.downcast_ref::<i32>().ok_or(())).is_err();
1484+
assert!(!OwningRef::new(y).try_map(|x| x.downcast_ref::<i32>().ok_or(())).is_err());
14851485
}
14861486
}
14871487

@@ -1868,7 +1868,7 @@ mod tests {
18681868
let x = Box::new(123_i32);
18691869
let y: Box<dyn Any> = x;
18701870

1871-
OwningRefMut::new(y).try_map_mut(|x| x.downcast_mut::<i32>().ok_or(())).is_ok();
1871+
assert!(OwningRefMut::new(y).try_map_mut(|x| x.downcast_mut::<i32>().ok_or(())).is_ok());
18721872
}
18731873

18741874
#[test]
@@ -1878,7 +1878,7 @@ mod tests {
18781878
let x = Box::new(123_i32);
18791879
let y: Box<dyn Any> = x;
18801880

1881-
OwningRefMut::new(y).try_map_mut(|x| x.downcast_mut::<i32>().ok_or(())).is_err();
1881+
assert!(!OwningRefMut::new(y).try_map_mut(|x| x.downcast_mut::<i32>().ok_or(())).is_err());
18821882
}
18831883

18841884
#[test]
@@ -1888,7 +1888,7 @@ mod tests {
18881888
let x = Box::new(123_i32);
18891889
let y: Box<dyn Any> = x;
18901890

1891-
OwningRefMut::new(y).try_map(|x| x.downcast_ref::<i32>().ok_or(())).is_ok();
1891+
assert!(OwningRefMut::new(y).try_map(|x| x.downcast_ref::<i32>().ok_or(())).is_ok());
18921892
}
18931893

18941894
#[test]
@@ -1898,7 +1898,7 @@ mod tests {
18981898
let x = Box::new(123_i32);
18991899
let y: Box<dyn Any> = x;
19001900

1901-
OwningRefMut::new(y).try_map(|x| x.downcast_ref::<i32>().ok_or(())).is_err();
1901+
assert!(!OwningRefMut::new(y).try_map(|x| x.downcast_ref::<i32>().ok_or(())).is_err());
19021902
}
19031903

19041904
#[test]

src/librustdoc/clean/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,10 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
23252325
} else {
23262326
hir::Constness::NotConst
23272327
};
2328+
let defaultness = match self.container {
2329+
ty::ImplContainer(_) => Some(self.defaultness),
2330+
ty::TraitContainer(_) => None,
2331+
};
23282332
MethodItem(Method {
23292333
generics,
23302334
decl,
@@ -2334,7 +2338,7 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
23342338
constness,
23352339
asyncness: hir::IsAsync::NotAsync,
23362340
},
2337-
defaultness: Some(self.defaultness),
2341+
defaultness,
23382342
all_types,
23392343
ret_types,
23402344
})

src/libstd/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,10 @@
205205
// Don't link to std. We are std.
206206
#![no_std]
207207

208-
#![deny(missing_docs)]
209-
#![deny(intra_doc_link_resolution_failure)]
210-
#![deny(missing_debug_implementations)]
208+
//#![warn(deprecated_in_future)] // FIXME: std still has quite a few uses of `mem::uninitialized`
209+
#![warn(missing_docs)]
210+
#![warn(missing_debug_implementations)]
211+
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
211212

212213
#![deny(rust_2018_idioms)]
213214
#![allow(explicit_outlives_requirements)]

src/libstd/sync/mpsc/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ impl<T> SyncSender<T> {
10051005
/// thread::spawn(move || {
10061006
/// // This will return an error and send
10071007
/// // no message if the buffer is full
1008-
/// sync_sender2.try_send(3).is_err();
1008+
/// let _ = sync_sender2.try_send(3);
10091009
/// });
10101010
///
10111011
/// let mut msg;

src/stdsimd

src/test/run-pass/issues/issue-18353.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ struct Str {
1111

1212
fn main() {
1313
let str: Option<&Str> = None;
14-
str.is_some();
14+
let _ = str.is_some();
1515
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#![feature(specialization)]
2+
3+
// @has default_trait_method/trait.Item.html
4+
// @has - '//*[@id="tymethod.foo"]' 'fn foo()'
5+
// @!has - '//*[@id="tymethod.foo"]' 'default fn foo()'
6+
// @has - '//*[@id="tymethod.bar"]' 'fn bar()'
7+
// @!has - '//*[@id="tymethod.bar"]' 'default fn bar()'
8+
// @has - '//*[@id="method.baz"]' 'fn baz()'
9+
// @!has - '//*[@id="method.baz"]' 'default fn baz()'
10+
pub trait Item {
11+
fn foo();
12+
fn bar();
13+
fn baz() {}
14+
}
15+
16+
// @has default_trait_method/struct.Foo.html
17+
// @has - '//*[@id="method.foo"]' 'default fn foo()'
18+
// @has - '//*[@id="method.bar"]' 'fn bar()'
19+
// @!has - '//*[@id="method.bar"]' 'default fn bar()'
20+
// @has - '//*[@id="method.baz"]' 'fn baz()'
21+
// @!has - '//*[@id="method.baz"]' 'default fn baz()'
22+
pub struct Foo;
23+
impl Item for Foo {
24+
default fn foo() {}
25+
fn bar() {}
26+
}

src/test/rustdoc/default_trait_method.rs

-15
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![feature(specialization)]
2+
3+
#![crate_name = "foo"]
4+
5+
pub trait Item {
6+
fn foo();
7+
fn bar();
8+
fn baz() {}
9+
}
10+
11+
pub struct Foo;
12+
13+
impl Item for Foo {
14+
default fn foo() {}
15+
fn bar() {}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// aux-build:default-trait-method.rs
2+
3+
extern crate foo;
4+
5+
// @has default_trait_method/trait.Item.html
6+
// @has - '//*[@id="tymethod.foo"]' 'fn foo()'
7+
// @!has - '//*[@id="tymethod.foo"]' 'default fn foo()'
8+
// @has - '//*[@id="tymethod.bar"]' 'fn bar()'
9+
// @!has - '//*[@id="tymethod.bar"]' 'default fn bar()'
10+
// @has - '//*[@id="method.baz"]' 'fn baz()'
11+
// @!has - '//*[@id="method.baz"]' 'default fn baz()'
12+
pub use foo::Item;
13+
14+
// @has default_trait_method/struct.Foo.html
15+
// @has - '//*[@id="method.foo"]' 'default fn foo()'
16+
// @has - '//*[@id="method.bar"]' 'fn bar()'
17+
// @!has - '//*[@id="method.bar"]' 'default fn bar()'
18+
// @has - '//*[@id="method.baz"]' 'fn baz()'
19+
// @!has - '//*[@id="method.baz"]' 'default fn baz()'
20+
pub use foo::Foo;

0 commit comments

Comments
 (0)