Skip to content

Commit fba72d3

Browse files
committed
rollup merge of #17721 : jakub-/resolved-issues
2 parents 2bb4455 + 52d2f2a commit fba72d3

13 files changed

+339
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn read_lines_borrowed<'a>() -> Vec<&'a str> {
12+
let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()];
13+
rawLines //~ ERROR `rawLines` does not live long enough
14+
.iter().map(|l| l.as_slice().trim()).collect()
15+
}
16+
17+
fn main() {}

src/test/compile-fail/issue-13497.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn read_lines_borrowed1() -> Vec<
12+
&str //~ ERROR missing lifetime specifier
13+
> {
14+
let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()];
15+
rawLines.iter().map(|l| l.as_slice().trim()).collect()
16+
}
17+
18+
fn main() {}

src/test/compile-fail/issue-14366.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let _x = "test" as &::std::any::Any;
13+
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str`
14+
//~^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type
15+
//~^^^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str`
16+
//~^^^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type
17+
}

src/test/compile-fail/issue-14853.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::fmt::Show;
12+
13+
trait Something {
14+
fn yay<T: Show>(_: Option<Self>, thing: &[T]) -> String {
15+
}
16+
}
17+
18+
struct X { data: u32 }
19+
20+
impl Something for X {
21+
fn yay<T: Str>(_:Option<X>, thing: &[T]) -> String {
22+
//~^ ERROR in method `yay`, type parameter 0 requires bound `core::str::Str`, which is not required
23+
format!("{:s}", thing[0])
24+
}
25+
}
26+
27+
fn main() {
28+
let arr = &["one", "two", "three"];
29+
println!("{}", Something::yay(None::<X>, arr));
30+
}

src/test/run-pass/issue-11869.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct A {
12+
a: String
13+
}
14+
15+
fn borrow<'a>(binding: &'a A) -> &'a str {
16+
match binding.a.as_slice() {
17+
"in" => "in_",
18+
"ref" => "ref_",
19+
ident => ident
20+
}
21+
}
22+
23+
fn main() {}

src/test/run-pass/issue-13167.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::slice;
12+
13+
pub struct PhfMapEntries<'a, T> {
14+
iter: slice::Items<'a, (&'static str, T)>,
15+
}
16+
17+
impl<'a, T> Iterator<(&'static str, &'a T)> for PhfMapEntries<'a, T> {
18+
fn next(&mut self) -> Option<(&'static str, &'a T)> {
19+
self.iter.by_ref().map(|&(key, ref value)| (key, value)).next()
20+
}
21+
22+
fn size_hint(&self) -> (uint, Option<uint>) {
23+
self.iter.size_hint()
24+
}
25+
}
26+
27+
fn main() {}

src/test/run-pass/issue-13405.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Foo<'a> {
12+
i: &'a bool,
13+
j: Option<&'a int>,
14+
}
15+
16+
impl<'a> Foo<'a> {
17+
fn bar(&mut self, j: &int) {
18+
let child = Foo {
19+
i: self.i,
20+
j: Some(j)
21+
};
22+
}
23+
}
24+
25+
fn main() {}

src/test/run-pass/issue-13434.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern crate debug;
12+
13+
struct MyStruct;
14+
15+
trait Repro {
16+
fn repro(self, s: MyStruct) -> String;
17+
}
18+
19+
impl Repro for |MyStruct|:'static -> String {
20+
fn repro(self, s: MyStruct) -> String {
21+
self(s)
22+
}
23+
}
24+
25+
fn do_stuff<R: Repro>(r: R) -> String {
26+
r.repro(MyStruct)
27+
}
28+
29+
pub fn main() {
30+
assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s)));
31+
}

src/test/run-pass/issue-13703.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub struct Foo<'a, 'b: 'a> { foo: &'a &'b int }
12+
pub fn foo<'a, 'b>(x: Foo<'a, 'b>, _o: Option<& & ()>) { let _y = x.foo; }
13+
fn main() {}

src/test/run-pass/issue-14919.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Matcher {
12+
fn next_match(&mut self) -> Option<(uint, uint)>;
13+
}
14+
15+
struct CharPredMatcher<'a, 'b> {
16+
str: &'a str,
17+
pred: |char|:'b -> bool
18+
}
19+
20+
impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> {
21+
fn next_match(&mut self) -> Option<(uint, uint)> {
22+
None
23+
}
24+
}
25+
26+
trait IntoMatcher<'a, T> {
27+
fn into_matcher(self, &'a str) -> T;
28+
}
29+
30+
impl<'a, 'b> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for |char|:'b -> bool {
31+
fn into_matcher(self, s: &'a str) -> CharPredMatcher<'a, 'b> {
32+
CharPredMatcher {
33+
str: s,
34+
pred: self
35+
}
36+
}
37+
}
38+
39+
struct MatchIndices<M> {
40+
matcher: M
41+
}
42+
43+
impl<M: Matcher> Iterator<(uint, uint)> for MatchIndices<M> {
44+
fn next(&mut self) -> Option<(uint, uint)> {
45+
self.matcher.next_match()
46+
}
47+
}
48+
49+
fn match_indices<'a, M, T: IntoMatcher<'a, M>>(s: &'a str, from: T) -> MatchIndices<M> {
50+
let string_matcher = from.into_matcher(s);
51+
MatchIndices { matcher: string_matcher }
52+
}
53+
54+
fn main() {
55+
let s = "abcbdef";
56+
match_indices(s, |c: char| c == 'b')
57+
.collect::<Vec<(uint, uint)>>();
58+
}

0 commit comments

Comments
 (0)