Skip to content

Commit aa7e78c

Browse files
committed
Merge pull request #71 from kiljacken/master
Explicitly borrow slices.
2 parents a680e6e + 22a7084 commit aa7e78c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/racer/nameres.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ pub fn do_file_search(searchstr: &str, currentdir: &Path) -> vec::MoveItems<Matc
238238
let fname = fpath.str_components().rev().next().unwrap().unwrap();
239239
if fname.starts_with(format!("lib{}", searchstr).as_slice()) {
240240
//debug!("Yeah found {}",fpath.as_str());
241-
let filepath = Path::new(fpath).join_many([Path::new("lib.rs")]);
241+
let filepath = Path::new(fpath).join_many(&[Path::new("lib.rs")]);
242242
if File::open(&filepath).is_ok() {
243243
let m = Match {matchstr: fname.slice_from(3).to_string(),
244244
filepath: filepath.clone(),
@@ -256,7 +256,7 @@ pub fn do_file_search(searchstr: &str, currentdir: &Path) -> vec::MoveItems<Matc
256256
if fname.starts_with(searchstr) {
257257
{
258258
// try <name>/<name>.rs, like in the servo codebase
259-
let filepath = Path::new(fpath).join_many([Path::new(format!("{}.rs", fname))]);
259+
let filepath = Path::new(fpath).join_many(&[Path::new(format!("{}.rs", fname))]);
260260

261261
if File::open(&filepath).is_ok() {
262262
let m = Match {matchstr: fname.to_string(),
@@ -273,7 +273,7 @@ pub fn do_file_search(searchstr: &str, currentdir: &Path) -> vec::MoveItems<Matc
273273
}
274274
{
275275
// try <name>/mod.rs
276-
let filepath = Path::new(fpath).join_many([Path::new("mod.rs")]);
276+
let filepath = Path::new(fpath).join_many(&[Path::new("mod.rs")]);
277277
if File::open(&filepath).is_ok() {
278278
let m = Match {matchstr: fname.to_string(),
279279
filepath: filepath.clone(),
@@ -289,7 +289,7 @@ pub fn do_file_search(searchstr: &str, currentdir: &Path) -> vec::MoveItems<Matc
289289
}
290290
{
291291
// try <name>/lib.rs
292-
let filepath = Path::new(srcpath).join_many([Path::new("lib.rs")]);
292+
let filepath = Path::new(srcpath).join_many(&[Path::new("lib.rs")]);
293293
if File::open(&filepath).is_ok() {
294294
let m = Match {matchstr: fname.to_string(),
295295
filepath: filepath.clone(),
@@ -356,14 +356,14 @@ pub fn find_possible_crate_root_modules(currentdir: &Path) -> Vec<Path> {
356356
let mut res = Vec::new();
357357

358358
{
359-
let filepath = currentdir.join_many([Path::new("lib.rs")]);
359+
let filepath = currentdir.join_many(&[Path::new("lib.rs")]);
360360
if File::open(&filepath).is_ok() {
361361
res.push(filepath);
362362
return res; // for now stop at the first match
363363
}
364364
}
365365
{
366-
let filepath = currentdir.join_many([Path::new("main.rs")]);
366+
let filepath = currentdir.join_many(&[Path::new("main.rs")]);
367367
if File::open(&filepath).is_ok() {
368368
res.push(filepath);
369369
return res; // for now stop at the first match
@@ -407,7 +407,7 @@ pub fn get_crate_file(name: &str) -> Option<Path> {
407407
{
408408
// try lib<name>/lib.rs, like in the rust source dir
409409
let cratelibname = format!("lib{}", name);
410-
let filepath = Path::new(srcpath).join_many([Path::new(cratelibname),
410+
let filepath = Path::new(srcpath).join_many(&[Path::new(cratelibname),
411411
Path::new("lib.rs")]);
412412
if File::open(&filepath).is_ok() {
413413
return Some(filepath);
@@ -416,7 +416,7 @@ pub fn get_crate_file(name: &str) -> Option<Path> {
416416

417417
{
418418
// try <name>/lib.rs
419-
let filepath = Path::new(srcpath).join_many([Path::new(name),
419+
let filepath = Path::new(srcpath).join_many(&[Path::new(name),
420420
Path::new("lib.rs")]);
421421
if File::open(&filepath).is_ok() {
422422
return Some(filepath);
@@ -429,14 +429,14 @@ pub fn get_crate_file(name: &str) -> Option<Path> {
429429
pub fn get_module_file(name: &str, parentdir: &Path) -> Option<Path> {
430430
{
431431
// try just <name>.rs
432-
let filepath = parentdir.join_many([Path::new(format!("{}.rs", name))]);
432+
let filepath = parentdir.join_many(&[Path::new(format!("{}.rs", name))]);
433433
if File::open(&filepath).is_ok() {
434434
return Some(filepath);
435435
}
436436
}
437437
{
438438
// try <name>/mod.rs
439-
let filepath = parentdir.join_many([Path::new(name),
439+
let filepath = parentdir.join_many(&[Path::new(name),
440440
Path::new("mod.rs")]);
441441
if File::open(&filepath).is_ok() {
442442
return Some(filepath);
@@ -575,7 +575,7 @@ pub fn search_prelude_file(pathseg: &racer::PathSegment, search_type: SearchType
575575
let v: Vec<&str> = srcpaths.as_slice().split_str(":").collect();
576576

577577
for srcpath in v.into_iter() {
578-
let filepath = Path::new(srcpath).join_many([Path::new("libstd"),
578+
let filepath = Path::new(srcpath).join_many(&[Path::new("libstd"),
579579
Path::new("prelude.rs")]);
580580
if File::open(&filepath).is_ok() {
581581
let msrc = racer::load_file_and_mask_comments(&filepath);

0 commit comments

Comments
 (0)