Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove a couple of #[doc(hidden)] pub fn and their #[feature] gates #106677

Merged
merged 1 commit into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 1 addition & 7 deletions library/alloc/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,12 +991,6 @@ impl IntoStringError {
pub fn utf8_error(&self) -> Utf8Error {
self.error
}

#[doc(hidden)]
#[unstable(feature = "cstr_internals", issue = "none")]
pub fn __source(&self) -> &Utf8Error {
&self.error
}
}

impl IntoStringError {
Expand Down Expand Up @@ -1141,6 +1135,6 @@ impl core::error::Error for IntoStringError {
}

fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
Some(self.__source())
Some(&self.error)
}
}
17 changes: 2 additions & 15 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,28 +131,15 @@ pub struct TryFromSliceError(());
impl fmt::Display for TryFromSliceError {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self.__description(), f)
#[allow(deprecated)]
self.description().fmt(f)
}
}

#[stable(feature = "try_from", since = "1.34.0")]
impl Error for TryFromSliceError {
#[allow(deprecated)]
fn description(&self) -> &str {
self.__description()
}
}

impl TryFromSliceError {
#[unstable(
feature = "array_error_internals",
reason = "available through Error trait and this method should not \
be exposed publicly",
issue = "none"
)]
#[inline]
#[doc(hidden)]
pub fn __description(&self) -> &str {
"could not convert slice to array"
}
}
Expand Down
28 changes: 13 additions & 15 deletions library/core/src/char/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use crate::char::TryFromCharError;
use crate::convert::TryFrom;
use crate::error::Error;
use crate::fmt;
use crate::mem::transmute;
use crate::str::FromStr;
Expand Down Expand Up @@ -150,31 +151,28 @@ pub struct ParseCharError {
kind: CharErrorKind,
}

impl ParseCharError {
#[unstable(
feature = "char_error_internals",
reason = "this method should not be available publicly",
issue = "none"
)]
#[doc(hidden)]
pub fn __description(&self) -> &str {
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
enum CharErrorKind {
EmptyString,
TooManyChars,
}

#[stable(feature = "char_from_str", since = "1.20.0")]
impl Error for ParseCharError {
#[allow(deprecated)]
fn description(&self) -> &str {
match self.kind {
CharErrorKind::EmptyString => "cannot parse char from empty string",
CharErrorKind::TooManyChars => "too many characters in string",
}
}
}

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
enum CharErrorKind {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: in future, please try to keep things in a relative order such that things like this type don't show as delete-then-add in the diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. Not sure why I did this.

EmptyString,
TooManyChars,
}

#[stable(feature = "char_from_str", since = "1.20.0")]
impl fmt::Display for ParseCharError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.__description().fmt(f)
#[allow(deprecated)]
self.description().fmt(f)
}
}

Expand Down
16 changes: 0 additions & 16 deletions library/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,25 +486,9 @@ impl Error for crate::char::CharTryFromError {
}
}

#[stable(feature = "char_from_str", since = "1.20.0")]
impl Error for crate::char::ParseCharError {
#[allow(deprecated)]
fn description(&self) -> &str {
self.__description()
}
}

#[stable(feature = "duration_checked_float", since = "1.66.0")]
impl Error for crate::time::TryFromFloatSecsError {}

#[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")]
impl Error for crate::ffi::FromBytesWithNulError {
#[allow(deprecated)]
fn description(&self) -> &str {
self.__description()
}
}

#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")]
impl Error for crate::ffi::FromBytesUntilNulError {}

Expand Down
11 changes: 7 additions & 4 deletions library/core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::cmp::Ordering;
use crate::error::Error;
use crate::ffi::c_char;
use crate::fmt;
use crate::intrinsics;
Expand Down Expand Up @@ -129,10 +130,12 @@ impl FromBytesWithNulError {
const fn not_nul_terminated() -> FromBytesWithNulError {
FromBytesWithNulError { kind: FromBytesWithNulErrorKind::NotNulTerminated }
}
}

#[doc(hidden)]
#[unstable(feature = "cstr_internals", issue = "none")]
pub fn __description(&self) -> &str {
#[stable(feature = "frombyteswithnulerror_impls", since = "1.17.0")]
impl Error for FromBytesWithNulError {
#[allow(deprecated)]
fn description(&self) -> &str {
match self.kind {
FromBytesWithNulErrorKind::InteriorNul(..) => {
"data provided contains an interior nul byte"
Expand Down Expand Up @@ -180,7 +183,7 @@ impl Default for &CStr {
impl fmt::Display for FromBytesWithNulError {
#[allow(deprecated, deprecated_in_future)]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.__description())?;
f.write_str(self.description())?;
if let FromBytesWithNulErrorKind::InteriorNul(pos) = self.kind {
write!(f, " at byte pos {pos}")?;
}
Expand Down
17 changes: 7 additions & 10 deletions library/core/src/num/dec2flt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
issue = "none"
)]

use crate::error::Error;
use crate::fmt;
use crate::str::FromStr;

Expand Down Expand Up @@ -182,15 +183,10 @@ enum FloatErrorKind {
Invalid,
}

impl ParseFloatError {
#[unstable(
feature = "int_error_internals",
reason = "available through Error trait and this method should \
not be exposed publicly",
issue = "none"
)]
#[doc(hidden)]
pub fn __description(&self) -> &str {
#[stable(feature = "rust1", since = "1.0.0")]
impl Error for ParseFloatError {
#[allow(deprecated)]
fn description(&self) -> &str {
match self.kind {
FloatErrorKind::Empty => "cannot parse float from empty string",
FloatErrorKind::Invalid => "invalid float literal",
Expand All @@ -201,7 +197,8 @@ impl ParseFloatError {
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Display for ParseFloatError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.__description().fmt(f)
#[allow(deprecated)]
self.description().fmt(f)
}
}

Expand Down
57 changes: 18 additions & 39 deletions library/core/src/num/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,19 @@ use crate::fmt;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct TryFromIntError(pub(crate) ());

impl TryFromIntError {
#[unstable(
feature = "int_error_internals",
reason = "available through Error trait and this method should \
not be exposed publicly",
issue = "none"
)]
#[doc(hidden)]
pub fn __description(&self) -> &str {
"out of range integral type conversion attempted"
#[stable(feature = "try_from", since = "1.34.0")]
impl fmt::Display for TryFromIntError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
#[allow(deprecated)]
self.description().fmt(fmt)
}
}

#[stable(feature = "try_from", since = "1.34.0")]
impl fmt::Display for TryFromIntError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
self.__description().fmt(fmt)
impl Error for TryFromIntError {
#[allow(deprecated)]
fn description(&self) -> &str {
"out of range integral type conversion attempted"
}
}

Expand Down Expand Up @@ -121,43 +117,26 @@ impl ParseIntError {
pub fn kind(&self) -> &IntErrorKind {
&self.kind
}
#[unstable(
feature = "int_error_internals",
reason = "available through Error trait and this method should \
not be exposed publicly",
issue = "none"
)]
#[doc(hidden)]
pub fn __description(&self) -> &str {
match self.kind {
IntErrorKind::Empty => "cannot parse integer from empty string",
IntErrorKind::InvalidDigit => "invalid digit found in string",
IntErrorKind::PosOverflow => "number too large to fit in target type",
IntErrorKind::NegOverflow => "number too small to fit in target type",
IntErrorKind::Zero => "number would be zero for non-zero type",
}
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Display for ParseIntError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.__description().fmt(f)
#[allow(deprecated)]
self.description().fmt(f)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl Error for ParseIntError {
#[allow(deprecated)]
fn description(&self) -> &str {
self.__description()
}
}

#[stable(feature = "try_from", since = "1.34.0")]
impl Error for TryFromIntError {
#[allow(deprecated)]
fn description(&self) -> &str {
self.__description()
match self.kind {
IntErrorKind::Empty => "cannot parse integer from empty string",
IntErrorKind::InvalidDigit => "invalid digit found in string",
IntErrorKind::PosOverflow => "number too large to fit in target type",
IntErrorKind::NegOverflow => "number too small to fit in target type",
IntErrorKind::Zero => "number would be zero for non-zero type",
}
}
}
12 changes: 0 additions & 12 deletions library/core/src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ use crate::mem;
use crate::ops::{Add, Mul, Sub};
use crate::str::FromStr;

#[cfg(not(no_fp_fmt_parse))]
use crate::error::Error;

// Used because the `?` operator is not allowed in a const context.
macro_rules! try_opt {
($e:expr) => {
Expand Down Expand Up @@ -61,15 +58,6 @@ pub use wrapping::Wrapping;
#[cfg(not(no_fp_fmt_parse))]
pub use dec2flt::ParseFloatError;

#[cfg(not(no_fp_fmt_parse))]
#[stable(feature = "rust1", since = "1.0.0")]
impl Error for ParseFloatError {
#[allow(deprecated)]
fn description(&self) -> &str {
self.__description()
}
}

#[stable(feature = "rust1", since = "1.0.0")]
pub use error::ParseIntError;

Expand Down
4 changes: 0 additions & 4 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,9 @@
#![feature(utf8_chunks)]
//
// Library features (core):
#![feature(array_error_internals)]
#![feature(atomic_mut_ptr)]
#![feature(char_error_internals)]
#![feature(char_internals)]
#![feature(core_intrinsics)]
#![feature(cstr_internals)]
#![feature(duration_constants)]
#![feature(error_generic_member_access)]
#![feature(error_in_core)]
Expand All @@ -290,7 +287,6 @@
#![feature(float_next_up_down)]
#![feature(hasher_prefixfree_extras)]
#![feature(hashmap_internals)]
#![feature(int_error_internals)]
#![feature(is_some_and)]
#![feature(maybe_uninit_slice)]
#![feature(maybe_uninit_write_slice)]
Expand Down

This file was deleted.

This file was deleted.