Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a57c18b
add `Poll::ready`
ibraheemdev Oct 7, 2021
a3f98a7
Fix inherent impl overlap check.
cjgillot Oct 7, 2021
5f7e7d2
revert stabilization of `core::task::ready!`
ibraheemdev Oct 7, 2021
597090e
Re-use TypeChecker instead of passing around some of its fields
oli-obk Sep 30, 2021
49b06a2
Directly call relate_types function instead of having a method wrapper
oli-obk Oct 8, 2021
7f974d0
Greatly reduce amount of debuginfo compiled for bootstrap itself
jyn514 Oct 11, 2021
1b283d4
Remove hack ignoring unused attributes for stage 0 std
jyn514 Oct 11, 2021
3ac0ae2
Add #[must_use] to MaybeUninit::new
jkugelman Oct 11, 2021
6531cd8
Fix function-names test for GDB 10.1
michaelwoerister Oct 11, 2021
3d1996a
Add #[must_use] to From::from and Into::into
jkugelman Oct 11, 2021
de940fc
Use Ancestory to check default fn in const impl instead of comparing …
nbdd0121 Oct 2, 2021
0a03f8c
Split impl-with-default-fn test into a pass test and a fail test
nbdd0121 Oct 11, 2021
06e625f
Add #[must_use] to as_type conversions
jkugelman Oct 11, 2021
b0b09f0
Update library/core/src/mem/maybe_uninit.rs
jkugelman Oct 11, 2021
7a7dfa8
Remove task::ready! from 1.56.0 release notes
dtolnay Oct 11, 2021
a1e03fc
Add library tracking issue for poll_ready feature
dtolnay Oct 11, 2021
4be2dea
Rollup merge of #89471 - nbdd0121:const3, r=fee1-dead
matthiaskrgr Oct 11, 2021
8ec0e28
Rollup merge of #89643 - cjgillot:overlap, r=matthewjasper
matthiaskrgr Oct 11, 2021
ab3df12
Rollup merge of #89651 - ibraheemdev:poll-ready, r=dtolnay
matthiaskrgr Oct 11, 2021
43a94bf
Rollup merge of #89675 - oli-obk:type_checker, r=davidtwco
matthiaskrgr Oct 11, 2021
85412d4
Rollup merge of #89756 - jyn514:bootstrap-times, r=Mark-Simulacrum
matthiaskrgr Oct 11, 2021
7ebfc6c
Rollup merge of #89760 - jyn514:remove-incremental-hack, r=Mark-Simul…
matthiaskrgr Oct 11, 2021
817ccb7
Rollup merge of #89769 - jkugelman:must-use-maybe-uninit-new, r=josht…
matthiaskrgr Oct 11, 2021
18730a2
Rollup merge of #89770 - jkugelman:must-use-from-and-into, r=joshtrip…
matthiaskrgr Oct 11, 2021
4fddd9e
Rollup merge of #89772 - michaelwoerister:fix-function-names-test-gdb…
matthiaskrgr Oct 11, 2021
96fe5ad
Rollup merge of #89778 - jkugelman:must-use-as_type-conversions, r=jo…
matthiaskrgr Oct 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/alloc/src/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ impl<T> BinaryHeap<T> {
///
/// io::sink().write(heap.as_slice()).unwrap();
/// ```
#[must_use]
#[unstable(feature = "binary_heap_as_slice", issue = "83659")]
pub fn as_slice(&self) -> &[T] {
self.data.as_slice()
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,7 @@ impl<'a, T> CursorMut<'a, T> {
/// The lifetime of the returned `Cursor` is bound to that of the
/// `CursorMut`, which means it cannot outlive the `CursorMut` and that the
/// `CursorMut` is frozen for the lifetime of the `Cursor`.
#[must_use]
#[unstable(feature = "linked_list_cursors", issue = "58533")]
pub fn as_cursor(&self) -> Cursor<'_, T> {
Cursor { list: self.list, current: self.current, index: self.index }
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,7 @@ impl<T: ?Sized> Weak<T> {
/// ```
///
/// [`null`]: ptr::null
#[must_use]
#[stable(feature = "rc_as_ptr", since = "1.45.0")]
pub fn as_ptr(&self) -> *const T {
let ptr: *mut RcBox<T> = NonNull::as_ptr(self.ptr);
Expand Down
5 changes: 5 additions & 0 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ impl String {
/// assert_eq!("foo", s.as_str());
/// ```
#[inline]
#[must_use]
#[stable(feature = "string_as_str", since = "1.7.0")]
pub fn as_str(&self) -> &str {
self
Expand All @@ -823,6 +824,7 @@ impl String {
/// assert_eq!("FOOBAR", s_mut_str);
/// ```
#[inline]
#[must_use]
#[stable(feature = "string_as_str", since = "1.7.0")]
pub fn as_mut_str(&mut self) -> &mut str {
self
Expand Down Expand Up @@ -1163,6 +1165,7 @@ impl String {
/// assert_eq!(&[104, 101, 108, 108, 111], s.as_bytes());
/// ```
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn as_bytes(&self) -> &[u8] {
&self.vec
Expand Down Expand Up @@ -1766,6 +1769,7 @@ impl FromUtf8Error {
///
/// assert_eq!(&[0, 159], value.unwrap_err().as_bytes());
/// ```
#[must_use]
#[stable(feature = "from_utf8_error_as_bytes", since = "1.26.0")]
pub fn as_bytes(&self) -> &[u8] {
&self.bytes[..]
Expand Down Expand Up @@ -2782,6 +2786,7 @@ impl<'a> Drain<'a> {
/// let _ = drain.next().unwrap();
/// assert_eq!(drain.as_str(), "bc");
/// ```
#[must_use]
#[stable(feature = "string_drain_as_str", since = "1.55.0")]
pub fn as_str(&self) -> &str {
self.iter.as_str()
Expand Down
2 changes: 2 additions & 0 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ impl<T: ?Sized> Arc<T> {
/// assert_eq!(x_ptr, Arc::as_ptr(&y));
/// assert_eq!(unsafe { &*x_ptr }, "hello");
/// ```
#[must_use]
#[stable(feature = "rc_as_ptr", since = "1.45.0")]
pub fn as_ptr(this: &Self) -> *const T {
let ptr: *mut ArcInner<T> = NonNull::as_ptr(this.ptr);
Expand Down Expand Up @@ -1724,6 +1725,7 @@ impl<T: ?Sized> Weak<T> {
/// ```
///
/// [`null`]: core::ptr::null "ptr::null"
#[must_use]
#[stable(feature = "weak_into_raw", since = "1.45.0")]
pub fn as_ptr(&self) -> *const T {
let ptr: *mut ArcInner<T> = NonNull::as_ptr(self.ptr);
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/vec/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ impl<'a, T, A: Allocator> Drain<'a, T, A> {
/// let _ = drain.next().unwrap();
/// assert_eq!(drain.as_slice(), &['b', 'c']);
/// ```
#[must_use]
#[stable(feature = "vec_drain_as_slice", since = "1.46.0")]
pub fn as_slice(&self) -> &[T] {
self.iter.as_slice()
Expand Down
1 change: 1 addition & 0 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ impl<'a> Arguments<'a> {
/// ```
#[stable(feature = "fmt_as_str", since = "1.52.0")]
#[rustc_const_unstable(feature = "const_arguments_as_str", issue = "none")]
#[must_use]
#[inline]
pub const fn as_str(&self) -> Option<&'static str> {
match (self.pieces, self.args) {
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ impl<T> Option<T> {
///
/// [&]: reference "shared reference"
#[inline]
#[must_use]
#[stable(feature = "pin", since = "1.33.0")]
pub fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&T>> {
// SAFETY: `x` is guaranteed to be pinned because it comes from `self`
Expand All @@ -668,6 +669,7 @@ impl<T> Option<T> {
///
/// [&mut]: reference "mutable reference"
#[inline]
#[must_use]
#[stable(feature = "pin", since = "1.33.0")]
pub fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut T>> {
// SAFETY: `get_unchecked_mut` is never used to move the `Option` inside `self`.
Expand Down
9 changes: 9 additions & 0 deletions library/core/src/ptr/non_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl<T: Sized> NonNull<T> {
///
/// [the module documentation]: crate::ptr#safety
#[inline]
#[must_use]
#[unstable(feature = "ptr_as_uninit", issue = "75402")]
pub unsafe fn as_uninit_ref<'a>(&self) -> &'a MaybeUninit<T> {
// SAFETY: the caller must guarantee that `self` meets all the
Expand Down Expand Up @@ -151,6 +152,7 @@ impl<T: Sized> NonNull<T> {
///
/// [the module documentation]: crate::ptr#safety
#[inline]
#[must_use]
#[unstable(feature = "ptr_as_uninit", issue = "75402")]
pub unsafe fn as_uninit_mut<'a>(&mut self) -> &'a mut MaybeUninit<T> {
// SAFETY: the caller must guarantee that `self` meets all the
Expand Down Expand Up @@ -264,6 +266,7 @@ impl<T: ?Sized> NonNull<T> {
/// ```
#[stable(feature = "nonnull", since = "1.25.0")]
#[rustc_const_stable(feature = "const_nonnull_as_ptr", since = "1.32.0")]
#[must_use]
#[inline]
pub const fn as_ptr(self) -> *mut T {
self.pointer as *mut T
Expand Down Expand Up @@ -310,6 +313,7 @@ impl<T: ?Sized> NonNull<T> {
///
/// [the module documentation]: crate::ptr#safety
#[stable(feature = "nonnull", since = "1.25.0")]
#[must_use]
#[inline]
pub unsafe fn as_ref<'a>(&self) -> &'a T {
// SAFETY: the caller must guarantee that `self` meets all the
Expand Down Expand Up @@ -359,6 +363,7 @@ impl<T: ?Sized> NonNull<T> {
///
/// [the module documentation]: crate::ptr#safety
#[stable(feature = "nonnull", since = "1.25.0")]
#[must_use]
#[inline]
pub unsafe fn as_mut<'a>(&mut self) -> &'a mut T {
// SAFETY: the caller must guarantee that `self` meets all the
Expand Down Expand Up @@ -455,6 +460,7 @@ impl<T> NonNull<[T]> {
/// assert_eq!(slice.as_non_null_ptr(), NonNull::new(1 as *mut i8).unwrap());
/// ```
#[inline]
#[must_use]
#[unstable(feature = "slice_ptr_get", issue = "74265")]
#[rustc_const_unstable(feature = "slice_ptr_get", issue = "74265")]
pub const fn as_non_null_ptr(self) -> NonNull<T> {
Expand All @@ -474,6 +480,7 @@ impl<T> NonNull<[T]> {
/// assert_eq!(slice.as_mut_ptr(), 1 as *mut i8);
/// ```
#[inline]
#[must_use]
#[unstable(feature = "slice_ptr_get", issue = "74265")]
#[rustc_const_unstable(feature = "slice_ptr_get", issue = "74265")]
pub const fn as_mut_ptr(self) -> *mut T {
Expand Down Expand Up @@ -518,6 +525,7 @@ impl<T> NonNull<[T]> {
///
/// [valid]: crate::ptr#safety
#[inline]
#[must_use]
#[unstable(feature = "ptr_as_uninit", issue = "75402")]
pub unsafe fn as_uninit_slice<'a>(&self) -> &'a [MaybeUninit<T>] {
// SAFETY: the caller must uphold the safety contract for `as_uninit_slice`.
Expand Down Expand Up @@ -579,6 +587,7 @@ impl<T> NonNull<[T]> {
/// # Ok::<_, std::alloc::AllocError>(())
/// ```
#[inline]
#[must_use]
#[unstable(feature = "ptr_as_uninit", issue = "75402")]
pub unsafe fn as_uninit_slice_mut<'a>(&self) -> &'a mut [MaybeUninit<T>] {
// SAFETY: the caller must uphold the safety contract for `as_uninit_slice_mut`.
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/ptr/unique.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl<T: ?Sized> Unique<T> {
/// The resulting lifetime is bound to self so this behaves "as if"
/// it were actually an instance of T that is getting borrowed. If a longer
/// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`.
#[must_use]
#[inline]
pub unsafe fn as_ref(&self) -> &T {
// SAFETY: the caller must guarantee that `self` meets all the
Expand All @@ -124,6 +125,7 @@ impl<T: ?Sized> Unique<T> {
/// The resulting lifetime is bound to self so this behaves "as if"
/// it were actually an instance of T that is getting borrowed. If a longer
/// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`.
#[must_use]
#[inline]
pub unsafe fn as_mut(&mut self) -> &mut T {
// SAFETY: the caller must guarantee that `self` meets all the
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/slice/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ impl<'a, T> Iter<'a, T> {
/// // Now `as_slice` returns "[2, 3]":
/// println!("{:?}", iter.as_slice());
/// ```
#[must_use]
#[stable(feature = "iter_to_slice", since = "1.4.0")]
pub fn as_slice(&self) -> &'a [T] {
self.make_slice()
Expand Down Expand Up @@ -298,6 +299,7 @@ impl<'a, T> IterMut<'a, T> {
/// // Now `as_slice` returns "[2, 3]":
/// assert_eq!(iter.as_slice(), &[2, 3]);
/// ```
#[must_use]
#[stable(feature = "slice_iter_mut_as_slice", since = "1.53.0")]
pub fn as_slice(&self) -> &[T] {
self.make_slice()
Expand Down
4 changes: 4 additions & 0 deletions library/core/src/str/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ impl<'a> Chars<'a> {
/// assert_eq!(chars.as_str(), "");
/// ```
#[stable(feature = "iter_to_slice", since = "1.4.0")]
#[must_use]
#[inline]
pub fn as_str(&self) -> &'a str {
// SAFETY: `Chars` is only made from a str, which guarantees the iter is valid UTF-8.
Expand Down Expand Up @@ -185,6 +186,7 @@ impl<'a> CharIndices<'a> {
/// This has the same lifetime as the original slice, and so the
/// iterator can continue to be used while this exists.
#[stable(feature = "iter_to_slice", since = "1.4.0")]
#[must_use]
#[inline]
pub fn as_str(&self) -> &'a str {
self.iter.as_str()
Expand Down Expand Up @@ -1247,6 +1249,7 @@ impl<'a> SplitWhitespace<'a> {
/// assert_eq!(split.as_str(), "");
/// ```
#[inline]
#[must_use]
#[unstable(feature = "str_split_whitespace_as_str", issue = "77998")]
pub fn as_str(&self) -> &'a str {
self.inner.iter.as_str()
Expand Down Expand Up @@ -1302,6 +1305,7 @@ impl<'a> SplitAsciiWhitespace<'a> {
/// assert_eq!(split.as_str(), "");
/// ```
#[inline]
#[must_use]
#[unstable(feature = "str_split_whitespace_as_str", issue = "77998")]
pub fn as_str(&self) -> &'a str {
if self.inner.iter.iter.finished {
Expand Down
4 changes: 4 additions & 0 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ impl str {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "str_as_bytes", since = "1.39.0")]
#[must_use]
#[inline(always)]
#[allow(unused_attributes)]
pub const fn as_bytes(&self) -> &[u8] {
Expand Down Expand Up @@ -274,6 +275,7 @@ impl str {
/// assert_eq!("🍔∈🌏", s);
/// ```
#[stable(feature = "str_mut_extras", since = "1.20.0")]
#[must_use]
#[inline(always)]
pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] {
// SAFETY: the cast from `&str` to `&[u8]` is safe since `str`
Expand Down Expand Up @@ -304,6 +306,7 @@ impl str {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "rustc_str_as_ptr", since = "1.32.0")]
#[must_use]
#[inline]
pub const fn as_ptr(&self) -> *const u8 {
self as *const str as *const u8
Expand All @@ -318,6 +321,7 @@ impl str {
/// It is your responsibility to make sure that the string slice only gets
/// modified in a way that it remains valid UTF-8.
#[stable(feature = "str_as_mut_ptr", since = "1.36.0")]
#[must_use]
#[inline]
pub fn as_mut_ptr(&mut self) -> *mut u8 {
self as *mut str as *mut u8
Expand Down
6 changes: 6 additions & 0 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ impl Duration {
/// [`subsec_nanos`]: Duration::subsec_nanos
#[stable(feature = "duration", since = "1.3.0")]
#[rustc_const_stable(feature = "duration", since = "1.32.0")]
#[must_use]
#[inline]
pub const fn as_secs(&self) -> u64 {
self.secs
Expand Down Expand Up @@ -417,6 +418,7 @@ impl Duration {
/// ```
#[stable(feature = "duration_as_u128", since = "1.33.0")]
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
#[must_use]
#[inline]
pub const fn as_millis(&self) -> u128 {
self.secs as u128 * MILLIS_PER_SEC as u128 + (self.nanos / NANOS_PER_MILLI) as u128
Expand All @@ -434,6 +436,7 @@ impl Duration {
/// ```
#[stable(feature = "duration_as_u128", since = "1.33.0")]
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
#[must_use]
#[inline]
pub const fn as_micros(&self) -> u128 {
self.secs as u128 * MICROS_PER_SEC as u128 + (self.nanos / NANOS_PER_MICRO) as u128
Expand All @@ -451,6 +454,7 @@ impl Duration {
/// ```
#[stable(feature = "duration_as_u128", since = "1.33.0")]
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
#[must_use]
#[inline]
pub const fn as_nanos(&self) -> u128 {
self.secs as u128 * NANOS_PER_SEC as u128 + self.nanos as u128
Expand Down Expand Up @@ -674,6 +678,7 @@ impl Duration {
/// assert_eq!(dur.as_secs_f64(), 2.7);
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[must_use]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn as_secs_f64(&self) -> f64 {
Expand All @@ -692,6 +697,7 @@ impl Duration {
/// assert_eq!(dur.as_secs_f32(), 2.7);
/// ```
#[stable(feature = "duration_float", since = "1.38.0")]
#[must_use]
#[inline]
#[rustc_const_unstable(feature = "duration_consts_2", issue = "72440")]
pub const fn as_secs_f32(&self) -> f32 {
Expand Down
5 changes: 5 additions & 0 deletions library/std/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ impl FromVecWithNulError {
///
/// assert_eq!(&bytes[..], value.unwrap_err().as_bytes());
/// ```
#[must_use]
pub fn as_bytes(&self) -> &[u8] {
&self.bytes[..]
}
Expand Down Expand Up @@ -618,6 +619,7 @@ impl CString {
/// assert_eq!(bytes, &[b'f', b'o', b'o']);
/// ```
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn as_bytes(&self) -> &[u8] {
// SAFETY: CString has a length at least 1
Expand All @@ -637,6 +639,7 @@ impl CString {
/// assert_eq!(bytes, &[b'f', b'o', b'o', b'\0']);
/// ```
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn as_bytes_with_nul(&self) -> &[u8] {
&self.inner
Expand All @@ -655,6 +658,7 @@ impl CString {
/// CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed"));
/// ```
#[inline]
#[must_use]
#[stable(feature = "as_c_str", since = "1.20.0")]
pub fn as_c_str(&self) -> &CStr {
&*self
Expand Down Expand Up @@ -1313,6 +1317,7 @@ impl CStr {
/// This way, the lifetime of the [`CString`] in `hello` encompasses
/// the lifetime of `ptr` and the `unsafe` block.
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_str_as_ptr", since = "1.32.0")]
pub const fn as_ptr(&self) -> *const c_char {
Expand Down
1 change: 1 addition & 0 deletions library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ impl OsString {
/// assert_eq!(os_string.as_os_str(), os_str);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use]
#[inline]
pub fn as_os_str(&self) -> &OsStr {
self
Expand Down
1 change: 1 addition & 0 deletions library/std/src/os/unix/net/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ impl SocketAddr {
/// }
/// ```
#[stable(feature = "unix_socket", since = "1.10.0")]
#[must_use]
pub fn as_pathname(&self) -> Option<&Path> {
if let AddressKind::Pathname(path) = self.address() { Some(path) } else { None }
}
Expand Down
Loading