From 29c0c956bf8ba9d6cdb1723d40685514bc9c17ef Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 9 Jul 2015 23:08:34 -0400 Subject: [PATCH 1/4] Rename SliceConcatExt::connect to join #26900 --- src/libcollections/slice.rs | 18 +++++++++++++++++- src/libcollections/str.rs | 6 +++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index d49463911e66e..c4d9ef844eb84 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1025,6 +1025,17 @@ pub trait SliceConcatExt { #[stable(feature = "rust1", since = "1.0.0")] fn concat(&self) -> Self::Output; + /// Flattens a slice of `T` into a single value `Self::Output`, placing a + /// given separator between each. + /// + /// # Examples + /// + /// ``` + /// assert_eq!(["hello", "world"].join(" "), "hello world"); + /// ``` + #[stable(feature = "rust1", since = "1.0.0")] + fn join(&self, sep: &T) -> Self::Output; + /// Flattens a slice of `T` into a single value `Self::Output`, placing a /// given separator between each. /// @@ -1034,6 +1045,7 @@ pub trait SliceConcatExt { /// assert_eq!(["hello", "world"].connect(" "), "hello world"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[deprecated(since = "1.3.0", reason = "renamed to join")] fn connect(&self, sep: &T) -> Self::Output; } @@ -1049,7 +1061,7 @@ impl> SliceConcatExt for [V] { result } - fn connect(&self, sep: &T) -> Vec { + fn join(&self, sep: &T) -> Vec { let size = self.iter().fold(0, |acc, v| acc + v.borrow().len()); let mut result = Vec::with_capacity(size + self.len()); let mut first = true; @@ -1059,6 +1071,10 @@ impl> SliceConcatExt for [V] { } result } + + fn connect(&self, sep: &T) -> Vec { + self.join(sep) + } } /// An iterator that yields the element swaps needed to produce diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 7e72ad1569a1f..7e4a219fc422f 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -105,7 +105,7 @@ impl> SliceConcatExt for [S] { result } - fn connect(&self, sep: &str) -> String { + fn join(&self, sep: &str) -> String { if self.is_empty() { return String::new(); } @@ -132,6 +132,10 @@ impl> SliceConcatExt for [S] { } result } + + fn connect(&self, sep: &str) -> String { + self.join(sep) + } } /* From 93ddee6cee6816843035575ddf0bf0309021ebc5 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Fri, 10 Jul 2015 08:19:21 -0400 Subject: [PATCH 2/4] Change some instances of .connect() to .join() --- src/compiletest/runtest.rs | 8 ++--- src/libcollectionstest/slice.rs | 20 ++++++------- src/libcollectionstest/str.rs | 30 +++++++++---------- src/libgetopts/lib.rs | 6 ++-- src/librustc/metadata/encoder.rs | 2 +- src/librustc/middle/infer/mod.rs | 2 +- src/librustc_driver/driver.rs | 2 +- src/librustc_driver/lib.rs | 2 +- src/librustc_driver/pretty.rs | 2 +- src/librustc_driver/test.rs | 2 +- src/librustc_lint/builtin.rs | 2 +- src/librustc_trans/trans/_match.rs | 4 +-- src/librustc_trans/trans/asm.rs | 2 +- src/librustc_trans/trans/build.rs | 2 +- src/librustc_trans/trans/builder.rs | 4 +-- .../trans/debuginfo/metadata.rs | 2 +- src/librustc_trans/trans/llrepr.rs | 2 +- src/librustc_trans/trans/type_.rs | 2 +- src/librustc_trans/trans/type_of.rs | 2 +- src/librustc_typeck/check/method/suggest.rs | 2 +- src/librustc_typeck/check/mod.rs | 6 ++-- src/librustc_typeck/coherence/mod.rs | 2 +- src/librustc_typeck/collect.rs | 2 +- src/librustdoc/clean/mod.rs | 6 ++-- src/librustdoc/html/format.rs | 2 +- src/librustdoc/html/markdown.rs | 10 +++---- src/librustdoc/html/render.rs | 22 +++++++------- src/librustdoc/passes.rs | 2 +- src/librustdoc/test.rs | 2 +- src/libstd/net/ip.rs | 2 +- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/ext/source_util.rs | 2 +- src/libsyntax/ext/tt/macro_parser.rs | 2 +- src/libsyntax/parse/lexer/comments.rs | 2 +- src/libsyntax/parse/parser.rs | 2 +- src/libtest/lib.rs | 2 +- src/test/auxiliary/plugin_args.rs | 2 +- src/test/run-pass/issue-3563-3.rs | 2 +- src/test/run-pass/trait-to-str.rs | 2 +- 39 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 93054f3979085..5b62f29b82423 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -344,7 +344,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) { check_lines, breakpoint_lines } = parse_debugger_commands(testfile, "gdb"); - let mut cmds = commands.connect("\n"); + let mut cmds = commands.join("\n"); // compile test file (it should have 'compile-flags:-g' in the header) let compiler_run_result = compile_test(config, props, testfile); @@ -799,7 +799,7 @@ fn cleanup_debug_info_options(options: &Option) -> Option { split_maybe_args(options).into_iter() .filter(|x| !options_to_remove.contains(x)) .collect::>() - .connect(" "); + .join(" "); Some(new_options) } @@ -1412,7 +1412,7 @@ fn make_cmdline(libpath: &str, prog: &str, args: &[String]) -> String { // Linux and mac don't require adjusting the library search path if cfg!(unix) { - format!("{} {}", prog, args.connect(" ")) + format!("{} {}", prog, args.join(" ")) } else { // Build the LD_LIBRARY_PATH variable as it would be seen on the command line // for diagnostic purposes @@ -1420,7 +1420,7 @@ fn make_cmdline(libpath: &str, prog: &str, args: &[String]) -> String { format!("{}=\"{}\"", util::lib_path_env_var(), util::make_new_path(path)) } - format!("{} {} {}", lib_path_cmd_prefix(libpath), prog, args.connect(" ")) + format!("{} {} {}", lib_path_cmd_prefix(libpath), prog, args.join(" ")) } } diff --git a/src/libcollectionstest/slice.rs b/src/libcollectionstest/slice.rs index d88d8b8e4a068..436e71fd4a0ed 100644 --- a/src/libcollectionstest/slice.rs +++ b/src/libcollectionstest/slice.rs @@ -606,22 +606,22 @@ fn test_concat() { assert_eq!(d, [1, 2, 3]); let v: &[&[_]] = &[&[1], &[2, 3]]; - assert_eq!(v.connect(&0), [1, 0, 2, 3]); + assert_eq!(v.join(&0), [1, 0, 2, 3]); let v: &[&[_]] = &[&[1], &[2], &[3]]; - assert_eq!(v.connect(&0), [1, 0, 2, 0, 3]); + assert_eq!(v.join(&0), [1, 0, 2, 0, 3]); } #[test] -fn test_connect() { +fn test_join() { let v: [Vec; 0] = []; - assert_eq!(v.connect(&0), []); - assert_eq!([vec![1], vec![2, 3]].connect(&0), [1, 0, 2, 3]); - assert_eq!([vec![1], vec![2], vec![3]].connect(&0), [1, 0, 2, 0, 3]); + assert_eq!(v.join(&0), []); + assert_eq!([vec![1], vec![2, 3]].join(&0), [1, 0, 2, 3]); + assert_eq!([vec![1], vec![2], vec![3]].join(&0), [1, 0, 2, 0, 3]); let v: [&[_]; 2] = [&[1], &[2, 3]]; - assert_eq!(v.connect(&0), [1, 0, 2, 3]); + assert_eq!(v.join(&0), [1, 0, 2, 3]); let v: [&[_]; 3] = [&[1], &[2], &[3]]; - assert_eq!(v.connect(&0), [1, 0, 2, 0, 3]); + assert_eq!(v.join(&0), [1, 0, 2, 0, 3]); } #[test] @@ -1339,11 +1339,11 @@ mod bench { } #[bench] - fn connect(b: &mut Bencher) { + fn join(b: &mut Bencher) { let xss: Vec> = (0..100).map(|i| (0..i).collect()).collect(); b.iter(|| { - xss.connect(&0) + xss.join(&0) }); } diff --git a/src/libcollectionstest/str.rs b/src/libcollectionstest/str.rs index 87a018ced195a..e92af585c1572 100644 --- a/src/libcollectionstest/str.rs +++ b/src/libcollectionstest/str.rs @@ -158,32 +158,32 @@ fn test_concat_for_different_lengths() { test_concat!("abc", ["", "a", "bc"]); } -macro_rules! test_connect { +macro_rules! test_join { ($expected: expr, $string: expr, $delim: expr) => { { - let s = $string.connect($delim); + let s = $string.join($delim); assert_eq!($expected, s); } } } #[test] -fn test_connect_for_different_types() { - test_connect!("a-b", ["a", "b"], "-"); +fn test_join_for_different_types() { + test_join!("a-b", ["a", "b"], "-"); let hyphen = "-".to_string(); - test_connect!("a-b", [s("a"), s("b")], &*hyphen); - test_connect!("a-b", vec!["a", "b"], &*hyphen); - test_connect!("a-b", &*vec!["a", "b"], "-"); - test_connect!("a-b", vec![s("a"), s("b")], "-"); + test_join!("a-b", [s("a"), s("b")], &*hyphen); + test_join!("a-b", vec!["a", "b"], &*hyphen); + test_join!("a-b", &*vec!["a", "b"], "-"); + test_join!("a-b", vec![s("a"), s("b")], "-"); } #[test] -fn test_connect_for_different_lengths() { +fn test_join_for_different_lengths() { let empty: &[&str] = &[]; - test_connect!("", empty, "-"); - test_connect!("a", ["a"], "-"); - test_connect!("a-b", ["a", "b"], "-"); - test_connect!("-a-bc", ["", "a", "bc"], "-"); + test_join!("", empty, "-"); + test_join!("a", ["a"], "-"); + test_join!("a-b", ["a", "b"], "-"); + test_join!("-a-bc", ["", "a", "bc"], "-"); } #[test] @@ -2081,12 +2081,12 @@ mod bench { } #[bench] - fn bench_connect(b: &mut Bencher) { + fn bench_join(b: &mut Bencher) { let s = "ศไทย中华Việt Nam; Mary had a little lamb, Little lamb"; let sep = "→"; let v = vec![s, s, s, s, s, s, s, s, s, s]; b.iter(|| { - assert_eq!(v.connect(sep).len(), s.len() * 10 + sep.len() * 9); + assert_eq!(v.join(sep).len(), s.len() * 10 + sep.len() * 9); }) } diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 0d15f584d648a..65e85b92e0b2c 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -784,13 +784,13 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String { // FIXME: #5516 should be graphemes not codepoints // wrapped description - row.push_str(&desc_rows.connect(&desc_sep[..])); + row.push_str(&desc_rows.join(&desc_sep[..])); row }); format!("{}\n\nOptions:\n{}\n", brief, - rows.collect::>().connect("\n")) + rows.collect::>().join("\n")) } fn format_option(opt: &OptGroup) -> String { @@ -836,7 +836,7 @@ pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> String { line.push_str(&opts.iter() .map(format_option) .collect::>() - .connect(" ")[..]); + .join(" ")[..]); line } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index a9e9f17bdce75..f38369e3f4c05 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -2028,7 +2028,7 @@ fn encode_dylib_dependency_formats(rbml_w: &mut Encoder, ecx: &EncodeContext) { cstore::RequireStatic => "s", })).to_string()) }).collect::>(); - rbml_w.wr_tagged_str(tag, &s.connect(",")); + rbml_w.wr_tagged_str(tag, &s.join(",")); } None => { rbml_w.wr_tagged_str(tag, ""); diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 63f31921ec2ec..e24fadba6a55e 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -1098,7 +1098,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn tys_to_string(&self, ts: &[Ty<'tcx>]) -> String { let tstrs: Vec = ts.iter().map(|t| self.ty_to_string(*t)).collect(); - format!("({})", tstrs.connect(", ")) + format!("({})", tstrs.join(", ")) } pub fn trait_ref_to_string(&self, t: &ty::TraitRef<'tcx>) -> String { diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 9541076df82be..67301a09e52bf 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -843,7 +843,7 @@ fn write_out_deps(sess: &Session, let mut file = try!(fs::File::create(&deps_filename)); for path in &out_filenames { try!(write!(&mut file, - "{}: {}\n\n", path.display(), files.connect(" "))); + "{}: {}\n\n", path.display(), files.join(" "))); } Ok(()) })(); diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 7ccada1079ff9..2906fd35a0a18 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -606,7 +606,7 @@ Available lint options: for (name, to) in lints { let name = name.to_lowercase().replace("_", "-"); let desc = to.into_iter().map(|x| x.as_str().replace("_", "-")) - .collect::>().connect(", "); + .collect::>().join(", "); println!(" {} {}", padded(&name[..]), desc); } diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 610f3f3a75ee6..0e735cbb7ff8e 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -378,7 +378,7 @@ impl UserIdentifiedItem { fn reconstructed_input(&self) -> String { match *self { ItemViaNode(node_id) => node_id.to_string(), - ItemViaPath(ref parts) => parts.connect("::"), + ItemViaPath(ref parts) => parts.join("::"), } } diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 128b0b7baabc0..a9efd13a99898 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -178,7 +178,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { return match search_mod(self, &self.infcx.tcx.map.krate().module, 0, names) { Some(id) => id, None => { - panic!("no item found: `{}`", names.connect("::")); + panic!("no item found: `{}`", names.join("::")); } }; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 186361626fff3..1574080b313b5 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -923,7 +923,7 @@ impl NonSnakeCase { } words.push(buf); } - words.connect("_") + words.join("_") } fn check_snake_case(&self, cx: &Context, sort: &str, name: &str, span: Option) { diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index 936b0070dfccf..3aa98ab031d1d 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -936,7 +936,7 @@ fn compile_guard<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, bcx.to_str(), guard_expr, m, - vals.iter().map(|v| bcx.val_to_string(*v)).collect::>().connect(", ")); + vals.iter().map(|v| bcx.val_to_string(*v)).collect::>().join(", ")); let _indenter = indenter(); let mut bcx = insert_lllocals(bcx, &data.bindings_map, None); @@ -981,7 +981,7 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, debug!("compile_submatch(bcx={}, m={:?}, vals=[{}])", bcx.to_str(), m, - vals.iter().map(|v| bcx.val_to_string(*v)).collect::>().connect(", ")); + vals.iter().map(|v| bcx.val_to_string(*v)).collect::>().join(", ")); let _indenter = indenter(); let _icx = push_ctxt("match::compile_submatch"); let mut bcx = bcx; diff --git a/src/librustc_trans/trans/asm.rs b/src/librustc_trans/trans/asm.rs index b25d6f2daaca9..67e7aa5baf62b 100644 --- a/src/librustc_trans/trans/asm.rs +++ b/src/librustc_trans/trans/asm.rs @@ -92,7 +92,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) .chain(arch_clobbers.iter() .map(|s| s.to_string())) .collect::>() - .connect(","); + .join(","); debug!("Asm Constraints: {}", &all_constraints[..]); diff --git a/src/librustc_trans/trans/build.rs b/src/librustc_trans/trans/build.rs index 05d0a967e64b6..7d68250404423 100644 --- a/src/librustc_trans/trans/build.rs +++ b/src/librustc_trans/trans/build.rs @@ -148,7 +148,7 @@ pub fn Invoke(cx: Block, terminate(cx, "Invoke"); debug!("Invoke({} with arguments ({}))", cx.val_to_string(fn_), - args.iter().map(|a| cx.val_to_string(*a)).collect::>().connect(", ")); + args.iter().map(|a| cx.val_to_string(*a)).collect::>().join(", ")); debug_loc.apply(cx.fcx); B(cx).invoke(fn_, args, then, catch, attributes) } diff --git a/src/librustc_trans/trans/builder.rs b/src/librustc_trans/trans/builder.rs index e100defc24875..32d9ee7a508b1 100644 --- a/src/librustc_trans/trans/builder.rs +++ b/src/librustc_trans/trans/builder.rs @@ -167,7 +167,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { args.iter() .map(|&v| self.ccx.tn().val_to_string(v)) .collect::>() - .connect(", ")); + .join(", ")); unsafe { let v = llvm::LLVMBuildInvoke(self.llbuilder, @@ -809,7 +809,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { args.iter() .map(|&v| self.ccx.tn().val_to_string(v)) .collect::>() - .connect(", ")); + .join(", ")); unsafe { let v = llvm::LLVMBuildCall(self.llbuilder, llfn, args.as_ptr(), diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index 45349969a0b3e..45d8fa67db683 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -1443,7 +1443,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> { let discrfield = discrfield.iter() .skip(1) .map(|x| x.to_string()) - .collect::>().connect("$"); + .collect::>().join("$"); let union_member_name = format!("RUST$ENCODED$ENUM${}${}", discrfield, null_variant_name); diff --git a/src/librustc_trans/trans/llrepr.rs b/src/librustc_trans/trans/llrepr.rs index 6dd566797970e..6b785e7edfd6a 100644 --- a/src/librustc_trans/trans/llrepr.rs +++ b/src/librustc_trans/trans/llrepr.rs @@ -19,7 +19,7 @@ pub trait LlvmRepr { impl LlvmRepr for [T] { fn llrepr(&self, ccx: &CrateContext) -> String { let reprs: Vec = self.iter().map(|t| t.llrepr(ccx)).collect(); - format!("[{}]", reprs.connect(",")) + format!("[{}]", reprs.join(",")) } } diff --git a/src/librustc_trans/trans/type_.rs b/src/librustc_trans/trans/type_.rs index ac39d10a23d6e..c88509dac4caa 100644 --- a/src/librustc_trans/trans/type_.rs +++ b/src/librustc_trans/trans/type_.rs @@ -322,7 +322,7 @@ impl TypeNames { pub fn types_to_str(&self, tys: &[Type]) -> String { let strs: Vec = tys.iter().map(|t| self.type_to_string(*t)).collect(); - format!("[{}]", strs.connect(",")) + format!("[{}]", strs.join(",")) } pub fn val_to_string(&self, val: ValueRef) -> String { diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index 4359a8d270da2..36905ffe93b94 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -457,7 +457,7 @@ fn llvm_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let tstr = if strings.is_empty() { base } else { - format!("{}<{}>", base, strings.connect(", ")) + format!("{}<{}>", base, strings.join(", ")) }; if did.krate == 0 { diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 4d86a4f7c70ff..f14886606c218 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -134,7 +134,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, p.self_ty(), p)) .collect::>() - .connect(", "); + .join(", "); cx.sess.fileline_note( span, &format!("the method `{}` exists but the \ diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 638cc86852742..0f9ebf3713c58 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1002,7 +1002,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, "not all trait items implemented, missing: `{}`", missing_items.iter() .map(::as_str) - .collect::>().connect("`, `")) + .collect::>().join("`, `")) } if !invalidated_items.is_empty() { @@ -1013,7 +1013,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, invalidator.ident.as_str(), invalidated_items.iter() .map(::as_str) - .collect::>().connect("`, `")) + .collect::>().join("`, `")) } } @@ -2868,7 +2868,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, span_err!(tcx.sess, span, E0063, "missing field{}: {}", if missing_fields.len() == 1 {""} else {"s"}, - missing_fields.connect(", ")); + missing_fields.join(", ")); } } diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 20407e927f7ff..cd904425d6346 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -514,7 +514,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { } else { name.to_string() }, a, b) - }).collect::>().connect(", ")); + }).collect::>().join(", ")); return; } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index e170808ad07d6..5d2e3533efccf 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1536,7 +1536,7 @@ fn convert_typed_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, d => format!("{:?}", d), }) .collect::>() - .connect(","); + .join(","); tcx.sess.span_err(it.span, &object_lifetime_default_reprs); } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c25267520ccd8..daa4e1af3382d 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2536,12 +2536,12 @@ fn name_from_pat(p: &ast::Pat) -> String { format!("{} {{ {}{} }}", path_to_string(name), fields.iter().map(|&Spanned { node: ref fp, .. }| format!("{}: {}", fp.ident.as_str(), name_from_pat(&*fp.pat))) - .collect::>().connect(", "), + .collect::>().join(", "), if etc { ", ..." } else { "" } ) }, PatTup(ref elts) => format!("({})", elts.iter().map(|p| name_from_pat(&**p)) - .collect::>().connect(", ")), + .collect::>().join(", ")), PatBox(ref p) => name_from_pat(&**p), PatRegion(ref p, _) => name_from_pat(&**p), PatLit(..) => { @@ -2555,7 +2555,7 @@ fn name_from_pat(p: &ast::Pat) -> String { let begin = begin.iter().map(|p| name_from_pat(&**p)); let mid = mid.as_ref().map(|p| format!("..{}", name_from_pat(&**p))).into_iter(); let end = end.iter().map(|p| name_from_pat(&**p)); - format!("[{}]", begin.chain(mid).chain(end).collect::>().connect(", ")) + format!("[{}]", begin.chain(mid).chain(end).collect::>().join(", ")) }, PatMac(..) => { warn!("can't document the name of a function argument \ diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 9439fc3c5f405..fc06dc347b5ed 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -360,7 +360,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: ast::DefId, path: &clean::Path, match href(did) { Some((url, shortty, fqp)) => { try!(write!(w, "{}", - shortty, url, fqp.connect("::"), last.name)); + shortty, url, fqp.join("::"), last.name)); } _ => try!(write!(w, "{}", last.name)), } diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 4982215d02f49..4ec4ffb0c31af 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -199,7 +199,7 @@ fn stripped_filtered_line<'a>(s: &'a str) -> Option<&'a str> { fn collapse_whitespace(s: &str) -> String { s.split(|c: char| c.is_whitespace()).filter(|s| { !s.is_empty() - }).collect::>().connect(" ") + }).collect::>().join(" ") } thread_local!(static USED_HEADER_MAP: RefCell> = { @@ -238,14 +238,14 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result { let lines = origtext.lines().filter(|l| { stripped_filtered_line(*l).is_none() }); - let text = lines.collect::>().connect("\n"); + let text = lines.collect::>().join("\n"); if rendered { return } PLAYGROUND_KRATE.with(|krate| { let mut s = String::new(); krate.borrow().as_ref().map(|krate| { let test = origtext.lines().map(|l| { stripped_filtered_line(l).unwrap_or(l) - }).collect::>().connect("\n"); + }).collect::>().join("\n"); let krate = krate.as_ref().map(|s| &**s); let test = test::maketest(&test, krate, false, &Default::default()); @@ -275,7 +275,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result { // Transform the contents of the header into a hyphenated string let id = s.split_whitespace().map(|s| s.to_ascii_lowercase()) - .collect::>().connect("-"); + .collect::>().join("-"); // This is a terrible hack working around how hoedown gives us rendered // html for text rather than the raw text. @@ -387,7 +387,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) { let lines = text.lines().map(|l| { stripped_filtered_line(l).unwrap_or(l) }); - let text = lines.collect::>().connect("\n"); + let text = lines.collect::>().join("\n"); tests.add_test(text.to_string(), block_info.should_panic, block_info.no_run, block_info.ignore, block_info.test_harness); diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 5ecf0fe8ecfb9..07e3ae975d66d 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -285,7 +285,7 @@ impl fmt::Display for IndexItemFunctionType { let inputs: Vec = self.inputs.iter().map(|ref t| { format!("{}", t) }).collect(); - try!(write!(f, "{{\"inputs\":[{}],\"output\":", inputs.connect(","))); + try!(write!(f, "{{\"inputs\":[{}],\"output\":", inputs.join(","))); match self.output { Some(ref t) => try!(write!(f, "{}", t)), @@ -461,7 +461,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::Result { search_index.push(IndexItem { ty: shortty(item), name: item.name.clone().unwrap(), - path: fqp[..fqp.len() - 1].connect("::"), + path: fqp[..fqp.len() - 1].join("::"), desc: shorter(item.doc_value()), parent: Some(did), search_type: get_index_search_type(&item, parent_basename), @@ -957,7 +957,7 @@ impl DocFolder for Cache { self.search_index.push(IndexItem { ty: shortty(&item), name: s.to_string(), - path: path.connect("::").to_string(), + path: path.join("::").to_string(), desc: shorter(item.doc_value()), parent: parent, search_type: get_index_search_type(&item, parent_basename), @@ -1187,7 +1187,7 @@ impl Context { *slot.borrow_mut() = cx.current.clone(); }); - let mut title = cx.current.connect("::"); + let mut title = cx.current.join("::"); if pushname { if !title.is_empty() { title.push_str("::"); @@ -1393,7 +1393,7 @@ impl<'a> Item<'a> { Some(format!("{root}src/{krate}/{path}.html#{href}", root = self.cx.root_path, krate = self.cx.layout.krate, - path = path.connect("/"), + path = path.join("/"), href = href)) // If this item is not part of the local crate, then things get a little @@ -1417,7 +1417,7 @@ impl<'a> Item<'a> { }; Some(format!("{root}{path}/{file}?gotosrc={goto}", root = root, - path = path[..path.len() - 1].connect("/"), + path = path[..path.len() - 1].join("/"), file = item_path(self.item), goto = self.item.def_id.node)) } @@ -1523,7 +1523,7 @@ fn item_path(item: &clean::Item) -> String { } fn full_path(cx: &Context, item: &clean::Item) -> String { - let mut s = cx.current.connect("::"); + let mut s = cx.current.join("::"); s.push_str("::"); s.push_str(item.name.as_ref().unwrap()); return s @@ -1535,7 +1535,7 @@ fn shorter<'a>(s: Option<&'a str>) -> String { (*line).chars().any(|chr|{ !chr.is_whitespace() }) - }).collect::>().connect("\n"), + }).collect::>().join("\n"), None => "".to_string() } } @@ -1920,12 +1920,12 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, try!(write!(w, r#""#, - root_path = vec![".."; cx.current.len()].connect("/"), + root_path = vec![".."; cx.current.len()].join("/"), path = if ast_util::is_local(it.def_id) { - cx.current.connect("/") + cx.current.join("/") } else { let path = &cache.external_paths[&it.def_id]; - path[..path.len() - 1].connect("/") + path[..path.len() - 1].join("/") }, ty = shortty(it).to_static_str(), name = *it.name.as_ref().unwrap())); diff --git a/src/librustdoc/passes.rs b/src/librustdoc/passes.rs index 74c16127f41cc..6e1c8beb3ada1 100644 --- a/src/librustdoc/passes.rs +++ b/src/librustdoc/passes.rs @@ -361,7 +361,7 @@ pub fn unindent(s: &str) -> String { line[min_indent..].to_string() } }).collect::>()); - unindented.connect("\n") + unindented.join("\n") } else { s.to_string() } diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 1ac9517786068..3ce2922c4c97d 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -360,7 +360,7 @@ impl Collector { let s = self.current_header.as_ref().map(|s| &**s).unwrap_or(""); format!("{}_{}", s, self.cnt) } else { - format!("{}_{}", self.names.connect("::"), self.cnt) + format!("{}_{}", self.names.join("::"), self.cnt) }; self.cnt += 1; let libs = self.libs.clone(); diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index bc13d966a10b7..3fe44d4809e5e 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -442,7 +442,7 @@ impl fmt::Display for Ipv6Addr { .iter() .map(|&seg| format!("{:x}", seg)) .collect::>() - .connect(":") + .join(":") } write!(fmt, "{}::{}", diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 7d7ea371ba533..6b38762316cdc 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -27,7 +27,7 @@ pub fn path_name_i(idents: &[Ident]) -> String { // FIXME: Bad copies (#2543 -- same for everything else that says "bad") idents.iter().map(|i| { token::get_ident(*i).to_string() - }).collect::>().connect("::") + }).collect::>().join("::") } pub fn local_def(id: NodeId) -> DefId { diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 3866f5534c2eb..5418b1f43e4af 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -78,7 +78,7 @@ pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) .iter() .map(|x| token::get_ident(*x).to_string()) .collect::>() - .connect("::"); + .join("::"); base::MacEager::expr(cx.expr_str( sp, token::intern_and_get_ident(&string[..]))) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 5521c68e75c69..5b3887e76b494 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -465,7 +465,7 @@ pub fn parse(sess: &ParseSess, token::get_ident(bind))).to_string() } _ => panic!() - } }).collect::>().connect(" or "); + } }).collect::>().join(" or "); return Error(sp, format!( "local ambiguity: multiple parsing options: \ built-in NTs {} or {} other options.", diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index 1577b50ad760c..467345624c275 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -139,7 +139,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String { let lines = vertical_trim(lines); let lines = horizontal_trim(lines); - return lines.connect("\n"); + return lines.join("\n"); } panic!("not a doc-comment: {}", comment); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 81ae607fea250..d77b529a3bf0b 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -5215,7 +5215,7 @@ impl<'a> Parser<'a> { last_span, &format!("illegal ABI: expected one of [{}], \ found `{}`", - abi::all_names().connect(", "), + abi::all_names().join(", "), the_string)); Ok(None) } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 724c0b2a8927f..629e3920e1041 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -1080,7 +1080,7 @@ impl MetricMap { .map(|(k,v)| format!("{}: {} (+/- {})", *k, v.value, v.noise)) .collect(); - v.connect(", ") + v.join(", ") } } diff --git a/src/test/auxiliary/plugin_args.rs b/src/test/auxiliary/plugin_args.rs index 5a615502a95e3..1920185d4e5a0 100644 --- a/src/test/auxiliary/plugin_args.rs +++ b/src/test/auxiliary/plugin_args.rs @@ -36,7 +36,7 @@ impl TTMacroExpander for Expander { sp: Span, _: &[ast::TokenTree]) -> Box { let args = self.args.iter().map(|i| pprust::meta_item_to_string(&*i)) - .collect::>().connect(", "); + .collect::>().join(", "); let interned = token::intern_and_get_ident(&args[..]); MacEager::expr(ecx.expr_str(sp, interned)) } diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 5cd58c0ecfb26..ecee2fd0faaca 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -108,7 +108,7 @@ impl fmt::Display for AsciiArt { .collect::>(); // Concatenate the lines together using a new-line. - write!(f, "{}", lines.connect("\n")) + write!(f, "{}", lines.join("\n")) } } diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index 8fa628def7969..f5af05d872bd4 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -24,7 +24,7 @@ impl to_str for Vec { self.iter() .map(|e| e.to_string_()) .collect::>() - .connect(", ")) + .join(", ")) } } From 5ee801adbf479d0503cb4e4b26a96fea0c9cb861 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Sat, 11 Jul 2015 11:00:18 -0400 Subject: [PATCH 3/4] Fix version number on SliceConcatExt:join --- src/libcollections/slice.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index c4d9ef844eb84..1f797d7febf12 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1033,7 +1033,7 @@ pub trait SliceConcatExt { /// ``` /// assert_eq!(["hello", "world"].join(" "), "hello world"); /// ``` - #[stable(feature = "rust1", since = "1.0.0")] + #[stable(feature = "rust1", since = "1.3.0")] fn join(&self, sep: &T) -> Self::Output; /// Flattens a slice of `T` into a single value `Self::Output`, placing a From ed472c8e0dc0e26e48fd875e2cf08042546c2706 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Sat, 11 Jul 2015 11:14:23 -0400 Subject: [PATCH 4/4] Fix feature name --- src/libcollections/slice.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 1f797d7febf12..85a4d6f192ee7 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -1033,7 +1033,7 @@ pub trait SliceConcatExt { /// ``` /// assert_eq!(["hello", "world"].join(" "), "hello world"); /// ``` - #[stable(feature = "rust1", since = "1.3.0")] + #[stable(feature = "rename_connect_to_join", since = "1.3.0")] fn join(&self, sep: &T) -> Self::Output; /// Flattens a slice of `T` into a single value `Self::Output`, placing a