diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index f28c4673cc033..b89d86d7885b9 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -1588,7 +1588,7 @@ pub trait Iterator { /// This will print: /// /// ```text - /// Parsing error: invalid digit found in string + /// Parsing error: invalid digit found at index 0 /// Sum: 3 /// ``` #[inline] diff --git a/library/core/src/num/error.rs b/library/core/src/num/error.rs index 85fdbaf6bce96..441375fe62a50 100644 --- a/library/core/src/num/error.rs +++ b/library/core/src/num/error.rs @@ -146,6 +146,11 @@ impl ParseIntError { #[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) + match self.kind { + IntErrorKind::InvalidDigit(i) => { + write!(f, "invalid digit found at index {}", i) + } + _ => self.__description().fmt(f), + } } } diff --git a/src/test/ui/feature-gates/unstable-attribute-allow-issue-0.stderr b/src/test/ui/feature-gates/unstable-attribute-allow-issue-0.stderr index 4ed42101af8e6..eca616ad86277 100644 --- a/src/test/ui/feature-gates/unstable-attribute-allow-issue-0.stderr +++ b/src/test/ui/feature-gates/unstable-attribute-allow-issue-0.stderr @@ -12,7 +12,7 @@ error[E0545]: `issue` must be a non-zero numeric string or "none" LL | #[unstable(feature = "unstable_test_feature", issue = "something")] | ^^^^^^^^----------- | | - | invalid digit found in string + | invalid digit found at index 0 error: aborting due to 2 previous errors diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity-2.stderr b/src/test/ui/stability-attribute/stability-attribute-sanity-2.stderr index bd7b88da1584d..57ac2f88d9feb 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity-2.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-sanity-2.stderr @@ -16,7 +16,7 @@ error[E0545]: `issue` must be a non-zero numeric string or "none" LL | #[unstable(feature = "a", issue = "no")] | ^^^^^^^^---- | | - | invalid digit found in string + | invalid digit found at index 0 error: aborting due to 3 previous errors