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

s/"\.to_string\(/"\.to_owned\( #26176

Closed
wants to merge 2 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 4 additions & 4 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ pub fn opt_str<'a>(maybestr: &'a Option<String>) -> &'a str {

pub fn opt_str2(maybestr: Option<String>) -> String {
match maybestr {
None => "(none)".to_string(),
None => "(none)".to_owned(),
Some(s) => s,
}
}
Expand Down Expand Up @@ -292,10 +292,10 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
// Pretty-printer does not work with .rc files yet
let valid_extensions =
match config.mode {
Pretty => vec!(".rs".to_string()),
_ => vec!(".rc".to_string(), ".rs".to_string())
Pretty => vec!(".rs".to_owned()),
_ => vec!(".rc".to_owned(), ".rs".to_owned())
};
let invalid_prefixes = vec!(".".to_string(), "#".to_string(), "~".to_string());
let invalid_prefixes = vec!(".".to_owned(), "#".to_owned(), "~".to_owned());
let name = testfile.file_name().unwrap().to_str().unwrap();

let mut valid = false;
Expand Down
6 changes: 3 additions & 3 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
check_stdout: check_stdout,
no_prefer_dynamic: no_prefer_dynamic,
pretty_expanded: pretty_expanded,
pretty_mode: pretty_mode.unwrap_or("normal".to_string()),
pretty_mode: pretty_mode.unwrap_or("normal".to_owned()),
pretty_compare_only: pretty_compare_only,
forbid_output: forbid_output,
}
Expand Down Expand Up @@ -320,7 +320,7 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
.collect();

match strs.len() {
1 => (strs.pop().unwrap(), "".to_string()),
1 => (strs.pop().unwrap(), "".to_owned()),
2 => {
let end = strs.pop().unwrap();
(strs.pop().unwrap(), end)
Expand All @@ -345,7 +345,7 @@ fn parse_pp_exact(line: &str, testfile: &Path) -> Option<PathBuf> {

fn parse_name_directive(line: &str, directive: &str) -> bool {
// This 'no-' rule is a quick hack to allow pretty-expanded and no-pretty-expanded to coexist
line.contains(directive) && !line.contains(&("no-".to_string() + directive))
line.contains(directive) && !line.contains(&("no-".to_owned() + directive))
}

pub fn parse_name_value_directive(line: &str, directive: &str)
Expand Down
142 changes: 71 additions & 71 deletions src/compiletest/runtest.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/grammar/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn parse_token_list(file: &str) -> HashMap<String, token::Token> {

let mut res = HashMap::new();

res.insert("-1".to_string(), token::Eof);
res.insert("-1".to_owned(), token::Eof);

for line in file.split('\n') {
let eq = match line.trim().rfind('=') {
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
//! // through a shared reference.
//! let gadget_owner : Rc<Owner> = Rc::new(
//! Owner {
//! name: "Gadget Man".to_string(),
//! name: "Gadget Man".to_owned(),
//! gadgets: RefCell::new(Vec::new())
//! }
//! );
Expand Down
8 changes: 4 additions & 4 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ mod tests {
let arena = TypedArena::new();
for _ in 0..100000 {
arena.alloc(Noncopy {
string: "hello world".to_string(),
string: "hello world".to_owned(),
array: vec!( 1, 2, 3, 4, 5 ),
});
}
Expand All @@ -641,7 +641,7 @@ mod tests {
let arena = TypedArena::new();
b.iter(|| {
arena.alloc(Noncopy {
string: "hello world".to_string(),
string: "hello world".to_owned(),
array: vec!( 1, 2, 3, 4, 5 ),
})
})
Expand All @@ -651,7 +651,7 @@ mod tests {
pub fn bench_noncopy_nonarena(b: &mut Bencher) {
b.iter(|| {
let _: Box<_> = box Noncopy {
string: "hello world".to_string(),
string: "hello world".to_owned(),
array: vec!( 1, 2, 3, 4, 5 ),
};
})
Expand All @@ -662,7 +662,7 @@ mod tests {
let arena = Arena::new();
b.iter(|| {
arena.alloc(|| Noncopy {
string: "hello world".to_string(),
string: "hello world".to_owned(),
array: vec!( 1, 2, 3, 4, 5 ),
})
})
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub trait Borrow<Borrowed: ?Sized> {
/// assert_eq!("Hello", s.borrow());
/// }
///
/// let s = "Hello".to_string();
/// let s = "Hello".to_owned();
///
/// check(s);
///
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ use string;
/// use std::fmt;
///
/// let s = fmt::format(format_args!("Hello, {}!", "world"));
/// assert_eq!(s, "Hello, world!".to_string());
/// assert_eq!(s, "Hello, world!".to_owned());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn format(args: Arguments) -> string::String {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ mod hack {
assert_eq!(it.next(), None);
}
{
let v = ["Hello".to_string()];
let v = ["Hello".to_owned()];
let mut it = permutations(&v);
let (min_size, max_opt) = it.size_hint();
assert_eq!(min_size, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//! You can get a non-`'static` `&str` by taking a slice of a `String`:
//!
//! ```
//! let some_string = "Hello, world.".to_string();
//! let some_string = "Hello, world.".to_owned();
//! let s = &some_string;
//! ```
//!
Expand Down
8 changes: 4 additions & 4 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ impl String {
/// let mut v = &mut [0xD834, 0xDD1E, 0x006d, 0x0075,
/// 0x0073, 0x0069, 0x0063];
/// assert_eq!(String::from_utf16(v).unwrap(),
/// "𝄞music".to_string());
/// "𝄞music".to_owned());
///
/// // 𝄞mu<invalid>ic
/// v[4] = 0xD800;
Expand Down Expand Up @@ -307,7 +307,7 @@ impl String {
/// 0xD834];
///
/// assert_eq!(String::from_utf16_lossy(v),
/// "𝄞mus\u{FFFD}ic\u{FFFD}".to_string());
/// "𝄞mus\u{FFFD}ic\u{FFFD}".to_owned());
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -648,7 +648,7 @@ impl String {
/// # Examples
///
/// ```
/// let a = "foo".to_string();
/// let a = "foo".to_owned();
/// assert_eq!(a.len(), 3);
/// ```
#[inline]
Expand All @@ -674,7 +674,7 @@ impl String {
/// # Examples
///
/// ```
/// let mut s = "foo".to_string();
/// let mut s = "foo".to_owned();
/// s.clear();
/// assert!(s.is_empty());
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ impl<T> IntoIterator for Vec<T> {
/// # Examples
///
/// ```
/// let v = vec!["a".to_string(), "b".to_string()];
/// let v = vec!["a".to_owned(), "b".to_owned()];
/// for s in v.into_iter() {
/// // s has type String, not &String
/// println!("{}", s);
Expand Down
4 changes: 2 additions & 2 deletions src/libcollectionstest/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ macro_rules! test_connect {
#[test]
fn test_connect_for_different_types() {
test_connect!("a-b", ["a", "b"], "-");
let hyphen = "-".to_string();
let hyphen = "-".to_owned();
test_connect!("a-b", [s("a"), s("b")], &*hyphen);
test_connect!("a-b", vec!["a", "b"], &*hyphen);
test_connect!("a-b", &*vec!["a", "b"], "-");
Expand Down Expand Up @@ -1516,7 +1516,7 @@ fn test_pattern_deref_forward() {
let data = "aabcdaa";
assert!(data.contains("bcd"));
assert!(data.contains(&"bcd"));
assert!(data.contains(&"bcd".to_string()));
assert!(data.contains(&"bcd".to_owned()));
}

#[test]
Expand Down
18 changes: 9 additions & 9 deletions src/libcollectionstest/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ fn test_str_add() {

#[test]
fn remove() {
let mut s = "ศไทย中华Việt Nam; foobar".to_string();;
let mut s = "ศไทย中华Việt Nam; foobar".to_owned();;
assert_eq!(s.remove(0), 'ศ');
assert_eq!(s.len(), 33);
assert_eq!(s, "ไทย中华Việt Nam; foobar");
Expand All @@ -282,24 +282,24 @@ fn remove() {

#[test] #[should_panic]
fn remove_bad() {
"ศ".to_string().remove(1);
"ศ".to_owned().remove(1);
}

#[test]
fn insert() {
let mut s = "foobar".to_string();
let mut s = "foobar".to_owned();
s.insert(0, 'ệ');
assert_eq!(s, "ệfoobar");
s.insert(6, 'ย');
assert_eq!(s, "ệfooยbar");
}

#[test] #[should_panic] fn insert_bad1() { "".to_string().insert(1, 't'); }
#[test] #[should_panic] fn insert_bad2() { "ệ".to_string().insert(1, 't'); }
#[test] #[should_panic] fn insert_bad1() { "".to_owned().insert(1, 't'); }
#[test] #[should_panic] fn insert_bad2() { "ệ".to_owned().insert(1, 't'); }

#[test]
fn test_slicing() {
let s = "foobar".to_string();
let s = "foobar".to_owned();
assert_eq!("foobar", &s[..]);
assert_eq!("foo", &s[..3]);
assert_eq!("bar", &s[3..]);
Expand All @@ -314,7 +314,7 @@ fn test_simple_types() {
assert_eq!(2.to_string(), "2");
assert_eq!(true.to_string(), "true");
assert_eq!(false.to_string(), "false");
assert_eq!(("hi".to_string()).to_string(), "hi");
assert_eq!(("hi".to_owned()).to_string(), "hi");
}

#[test]
Expand All @@ -329,7 +329,7 @@ fn test_vectors() {

#[test]
fn test_from_iterator() {
let s = "ศไทย中华Việt Nam".to_string();
let s = "ศไทย中华Việt Nam".to_owned();
let t = "ศไทย中华";
let u = "Việt Nam";

Expand Down Expand Up @@ -367,7 +367,7 @@ fn test_drain() {

#[test]
fn test_extend_ref() {
let mut a = "foo".to_string();
let mut a = "foo".to_owned();
a.extend(&['b', 'a', 'r']);

assert_eq!(&a, "foobar");
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
//! }
//!
//! fn main() {
//! let my_string = "Hello World".to_string();
//! let my_string = "Hello World".to_owned();
//! do_work(&my_string);
//!
//! let my_i8: i8 = 100;
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use marker::Sized;
/// let s = "hello";
/// is_hello(s);
///
/// let s = "hello".to_string();
/// let s = "hello".to_owned();
/// is_hello(s);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -71,7 +71,7 @@ pub trait AsMut<T: ?Sized> {
/// assert_eq!(bytes, s.into());
/// }
///
/// let s = "hello".to_string();
/// let s = "hello".to_owned();
/// is_hello(s);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
Expand All @@ -88,7 +88,7 @@ pub trait Into<T>: Sized {
/// `String` implements `From<&str>`:
///
/// ```
/// let string = "hello".to_string();
/// let string = "hello".to_owned();
/// let other_string = String::from("hello");
///
/// assert_eq!(string, other_string);
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ impl<'a> Formatter<'a> {
/// }
///
/// // prints "Foo { bar: 10, baz: "Hello World" }"
/// println!("{:?}", Foo { bar: 10, baz: "Hello World".to_string() });
/// println!("{:?}", Foo { bar: 10, baz: "Hello World".to_owned() });
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")]
#[inline]
Expand Down Expand Up @@ -808,7 +808,7 @@ impl<'a> Formatter<'a> {
/// }
///
/// // prints "Foo(10, "Hello World")"
/// println!("{:?}", Foo(10, "Hello World".to_string()));
/// println!("{:?}", Foo(10, "Hello World".to_owned()));
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")]
#[inline]
Expand Down Expand Up @@ -883,7 +883,7 @@ impl<'a> Formatter<'a> {
/// }
///
/// // prints "{"A": 10, "B": 11}"
/// println!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)]));
/// println!("{:?}", Foo(vec![("A".to_owned(), 10), ("B".to_owned(), 11)]));
/// ```
#[stable(feature = "debug_builders", since = "1.2.0")]
#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub struct RadixFmt<T, R>(T, R);
/// ```
/// # #![feature(core)]
/// use std::fmt::radix;
/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string());
/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_owned());
/// ```
#[unstable(feature = "core",
reason = "may be renamed or move to a different module")]
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/hash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
//! phone: u64,
//! }
//!
//! let person1 = Person { id: 5, name: "Janet".to_string(), phone: 555_666_7777 };
//! let person2 = Person { id: 5, name: "Bob".to_string(), phone: 555_666_7777 };
//! let person1 = Person { id: 5, name: "Janet".to_owned(), phone: 555_666_7777 };
//! let person2 = Person { id: 5, name: "Bob".to_owned(), phone: 555_666_7777 };
//!
//! assert!(hash::<_, SipHasher>(&person1) != hash::<_, SipHasher>(&person2));
//! ```
Expand All @@ -52,8 +52,8 @@
//! }
//! }
//!
//! let person1 = Person { id: 5, name: "Janet".to_string(), phone: 555_666_7777 };
//! let person2 = Person { id: 5, name: "Bob".to_string(), phone: 555_666_7777 };
//! let person1 = Person { id: 5, name: "Janet".to_owned(), phone: 555_666_7777 };
//! let person2 = Person { id: 5, name: "Bob".to_owned(), phone: 555_666_7777 };
//!
//! assert_eq!(hash::<_, SipHasher>(&person1), hash::<_, SipHasher>(&person2));
//! ```
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl<T> Option<T> {
/// to the value inside the original.
///
/// ```
/// let num_as_str: Option<String> = Some("10".to_string());
/// let num_as_str: Option<String> = Some("10".to_owned());
/// // First, cast `Option<String>` to `Option<&String>` with `as_ref`,
/// // then consume *that* with `map`, leaving `num_as_str` on the stack.
/// let num_as_int: Option<usize> = num_as_str.as_ref().map(|n| n.len());
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ impl<T, E> Result<T, E> {
/// assert_eq!(x.map_err(stringify), Ok(2));
///
/// let x: Result<u32, u32> = Err(13);
/// assert_eq!(x.map_err(stringify), Err("error code: 13".to_string()));
/// assert_eq!(x.map_err(stringify), Err("error code: 13".to_owned()));
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
4 changes: 2 additions & 2 deletions src/libcoretest/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn test_swap() {

#[test]
fn test_replace() {
let mut x = Some("test".to_string());
let mut x = Some("test".to_owned());
let y = replace(&mut x, None);
assert!(x.is_none());
assert!(y.is_some());
Expand All @@ -103,7 +103,7 @@ fn test_transmute() {
}

unsafe {
assert_eq!(transmute::<_, Vec<u8>>("L".to_string()), [76]);
assert_eq!(transmute::<_, Vec<u8>>("L".to_owned()), [76]);
}
}

Expand Down
Loading