Let String pass #[track_caller] to its Vec calls
This commit is contained in:
parent
2fcf1776b9
commit
b26dfa175c
1 changed files with 17 additions and 0 deletions
|
|
@ -1105,6 +1105,7 @@ impl String {
|
|||
/// ```
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_confusables("append", "push")]
|
||||
#[rustc_diagnostic_item = "string_push_str"]
|
||||
|
|
@ -1135,6 +1136,7 @@ impl String {
|
|||
/// ```
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
#[stable(feature = "string_extend_from_within", since = "1.87.0")]
|
||||
#[track_caller]
|
||||
pub fn extend_from_within<R>(&mut self, src: R)
|
||||
where
|
||||
R: RangeBounds<usize>,
|
||||
|
|
@ -1206,6 +1208,7 @@ impl String {
|
|||
/// ```
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn reserve(&mut self, additional: usize) {
|
||||
self.vec.reserve(additional)
|
||||
|
|
@ -1257,6 +1260,7 @@ impl String {
|
|||
#[cfg(not(no_global_oom_handling))]
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[track_caller]
|
||||
pub fn reserve_exact(&mut self, additional: usize) {
|
||||
self.vec.reserve_exact(additional)
|
||||
}
|
||||
|
|
@ -1352,6 +1356,7 @@ impl String {
|
|||
/// ```
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn shrink_to_fit(&mut self) {
|
||||
self.vec.shrink_to_fit()
|
||||
|
|
@ -1379,6 +1384,7 @@ impl String {
|
|||
/// ```
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[stable(feature = "shrink_to", since = "1.56.0")]
|
||||
pub fn shrink_to(&mut self, min_capacity: usize) {
|
||||
self.vec.shrink_to(min_capacity)
|
||||
|
|
@ -1400,6 +1406,7 @@ impl String {
|
|||
#[cfg(not(no_global_oom_handling))]
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[track_caller]
|
||||
pub fn push(&mut self, ch: char) {
|
||||
let len = self.len();
|
||||
let ch_len = ch.len_utf8();
|
||||
|
|
@ -1889,6 +1896,7 @@ impl String {
|
|||
/// ```
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[stable(feature = "string_split_off", since = "1.16.0")]
|
||||
#[must_use = "use `.truncate()` if you don't need the other half"]
|
||||
pub fn split_off(&mut self, at: usize) -> String {
|
||||
|
|
@ -2101,6 +2109,7 @@ impl String {
|
|||
#[stable(feature = "box_str", since = "1.4.0")]
|
||||
#[must_use = "`self` will be dropped if the result is not used"]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
pub fn into_boxed_str(self) -> Box<str> {
|
||||
let slice = self.vec.into_boxed_slice();
|
||||
unsafe { from_boxed_utf8_unchecked(slice) }
|
||||
|
|
@ -2288,6 +2297,7 @@ impl Error for FromUtf16Error {
|
|||
#[cfg(not(no_global_oom_handling))]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl Clone for String {
|
||||
#[track_caller]
|
||||
fn clone(&self) -> Self {
|
||||
String { vec: self.vec.clone() }
|
||||
}
|
||||
|
|
@ -2296,6 +2306,7 @@ impl Clone for String {
|
|||
///
|
||||
/// This method is preferred over simply assigning `source.clone()` to `self`,
|
||||
/// as it avoids reallocation if possible.
|
||||
#[track_caller]
|
||||
fn clone_from(&mut self, source: &Self) {
|
||||
self.vec.clone_from(&source.vec);
|
||||
}
|
||||
|
|
@ -2469,11 +2480,14 @@ impl<'a> Extend<Cow<'a, str>> for String {
|
|||
#[cfg(not(no_global_oom_handling))]
|
||||
#[unstable(feature = "ascii_char", issue = "110998")]
|
||||
impl Extend<core::ascii::Char> for String {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn extend<I: IntoIterator<Item = core::ascii::Char>>(&mut self, iter: I) {
|
||||
self.vec.extend(iter.into_iter().map(|c| c.to_u8()));
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn extend_one(&mut self, c: core::ascii::Char) {
|
||||
self.vec.push(c.to_u8());
|
||||
}
|
||||
|
|
@ -2482,11 +2496,14 @@ impl Extend<core::ascii::Char> for String {
|
|||
#[cfg(not(no_global_oom_handling))]
|
||||
#[unstable(feature = "ascii_char", issue = "110998")]
|
||||
impl<'a> Extend<&'a core::ascii::Char> for String {
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn extend<I: IntoIterator<Item = &'a core::ascii::Char>>(&mut self, iter: I) {
|
||||
self.extend(iter.into_iter().cloned());
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
fn extend_one(&mut self, c: &'a core::ascii::Char) {
|
||||
self.vec.push(c.to_u8());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue