rollup merge of #17721 : jakub-/resolved-issues
This commit is contained in:
commit
fba72d3825
17
src/test/compile-fail/issue-13497-2.rs
Normal file
17
src/test/compile-fail/issue-13497-2.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn read_lines_borrowed<'a>() -> Vec<&'a str> {
|
||||
let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()];
|
||||
rawLines //~ ERROR `rawLines` does not live long enough
|
||||
.iter().map(|l| l.as_slice().trim()).collect()
|
||||
}
|
||||
|
||||
fn main() {}
|
18
src/test/compile-fail/issue-13497.rs
Normal file
18
src/test/compile-fail/issue-13497.rs
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn read_lines_borrowed1() -> Vec<
|
||||
&str //~ ERROR missing lifetime specifier
|
||||
> {
|
||||
let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()];
|
||||
rawLines.iter().map(|l| l.as_slice().trim()).collect()
|
||||
}
|
||||
|
||||
fn main() {}
|
17
src/test/compile-fail/issue-14366.rs
Normal file
17
src/test/compile-fail/issue-14366.rs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let _x = "test" as &::std::any::Any;
|
||||
//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str`
|
||||
//~^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type
|
||||
//~^^^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str`
|
||||
//~^^^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type
|
||||
}
|
30
src/test/compile-fail/issue-14853.rs
Normal file
30
src/test/compile-fail/issue-14853.rs
Normal file
@ -0,0 +1,30 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::fmt::Show;
|
||||
|
||||
trait Something {
|
||||
fn yay<T: Show>(_: Option<Self>, thing: &[T]) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
struct X { data: u32 }
|
||||
|
||||
impl Something for X {
|
||||
fn yay<T: Str>(_:Option<X>, thing: &[T]) -> String {
|
||||
//~^ ERROR in method `yay`, type parameter 0 requires bound `core::str::Str`, which is not required
|
||||
format!("{:s}", thing[0])
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let arr = &["one", "two", "three"];
|
||||
println!("{}", Something::yay(None::<X>, arr));
|
||||
}
|
23
src/test/run-pass/issue-11869.rs
Normal file
23
src/test/run-pass/issue-11869.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct A {
|
||||
a: String
|
||||
}
|
||||
|
||||
fn borrow<'a>(binding: &'a A) -> &'a str {
|
||||
match binding.a.as_slice() {
|
||||
"in" => "in_",
|
||||
"ref" => "ref_",
|
||||
ident => ident
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
27
src/test/run-pass/issue-13167.rs
Normal file
27
src/test/run-pass/issue-13167.rs
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::slice;
|
||||
|
||||
pub struct PhfMapEntries<'a, T> {
|
||||
iter: slice::Items<'a, (&'static str, T)>,
|
||||
}
|
||||
|
||||
impl<'a, T> Iterator<(&'static str, &'a T)> for PhfMapEntries<'a, T> {
|
||||
fn next(&mut self) -> Option<(&'static str, &'a T)> {
|
||||
self.iter.by_ref().map(|&(key, ref value)| (key, value)).next()
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (uint, Option<uint>) {
|
||||
self.iter.size_hint()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
25
src/test/run-pass/issue-13405.rs
Normal file
25
src/test/run-pass/issue-13405.rs
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct Foo<'a> {
|
||||
i: &'a bool,
|
||||
j: Option<&'a int>,
|
||||
}
|
||||
|
||||
impl<'a> Foo<'a> {
|
||||
fn bar(&mut self, j: &int) {
|
||||
let child = Foo {
|
||||
i: self.i,
|
||||
j: Some(j)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
31
src/test/run-pass/issue-13434.rs
Normal file
31
src/test/run-pass/issue-13434.rs
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
extern crate debug;
|
||||
|
||||
struct MyStruct;
|
||||
|
||||
trait Repro {
|
||||
fn repro(self, s: MyStruct) -> String;
|
||||
}
|
||||
|
||||
impl Repro for |MyStruct|:'static -> String {
|
||||
fn repro(self, s: MyStruct) -> String {
|
||||
self(s)
|
||||
}
|
||||
}
|
||||
|
||||
fn do_stuff<R: Repro>(r: R) -> String {
|
||||
r.repro(MyStruct)
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s)));
|
||||
}
|
13
src/test/run-pass/issue-13703.rs
Normal file
13
src/test/run-pass/issue-13703.rs
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub struct Foo<'a, 'b: 'a> { foo: &'a &'b int }
|
||||
pub fn foo<'a, 'b>(x: Foo<'a, 'b>, _o: Option<& & ()>) { let _y = x.foo; }
|
||||
fn main() {}
|
58
src/test/run-pass/issue-14919.rs
Normal file
58
src/test/run-pass/issue-14919.rs
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
trait Matcher {
|
||||
fn next_match(&mut self) -> Option<(uint, uint)>;
|
||||
}
|
||||
|
||||
struct CharPredMatcher<'a, 'b> {
|
||||
str: &'a str,
|
||||
pred: |char|:'b -> bool
|
||||
}
|
||||
|
||||
impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> {
|
||||
fn next_match(&mut self) -> Option<(uint, uint)> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
trait IntoMatcher<'a, T> {
|
||||
fn into_matcher(self, &'a str) -> T;
|
||||
}
|
||||
|
||||
impl<'a, 'b> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for |char|:'b -> bool {
|
||||
fn into_matcher(self, s: &'a str) -> CharPredMatcher<'a, 'b> {
|
||||
CharPredMatcher {
|
||||
str: s,
|
||||
pred: self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct MatchIndices<M> {
|
||||
matcher: M
|
||||
}
|
||||
|
||||
impl<M: Matcher> Iterator<(uint, uint)> for MatchIndices<M> {
|
||||
fn next(&mut self) -> Option<(uint, uint)> {
|
||||
self.matcher.next_match()
|
||||
}
|
||||
}
|
||||
|
||||
fn match_indices<'a, M, T: IntoMatcher<'a, M>>(s: &'a str, from: T) -> MatchIndices<M> {
|
||||
let string_matcher = from.into_matcher(s);
|
||||
MatchIndices { matcher: string_matcher }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let s = "abcbdef";
|
||||
match_indices(s, |c: char| c == 'b')
|
||||
.collect::<Vec<(uint, uint)>>();
|
||||
}
|
15
src/test/run-pass/issue-15673.rs
Normal file
15
src/test/run-pass/issue-15673.rs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::iter::AdditiveIterator;
|
||||
fn main() {
|
||||
let x: [u64, ..3] = [1, 2, 3];
|
||||
assert_eq!(6, range(0, 3).map(|i| x[i]).sum());
|
||||
}
|
32
src/test/run-pass/issue-15924.rs
Normal file
32
src/test/run-pass/issue-15924.rs
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(unsafe_destructor)]
|
||||
|
||||
extern crate serialize;
|
||||
|
||||
use std::io::IoError;
|
||||
use serialize::{Encoder, Encodable};
|
||||
use serialize::json;
|
||||
|
||||
struct Foo<T> {
|
||||
v: T,
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl<'a, T: Encodable<json::Encoder<'a>, IoError>> Drop for Foo<T> {
|
||||
fn drop(&mut self) {
|
||||
json::encode(&self.v);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = Foo { v: 10i };
|
||||
}
|
33
src/test/run-pass/issue-5718.rs
Normal file
33
src/test/run-pass/issue-5718.rs
Normal file
@ -0,0 +1,33 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(macro_rules)]
|
||||
|
||||
struct Element;
|
||||
|
||||
macro_rules! foo {
|
||||
($tag: expr, $string: expr) => {
|
||||
if $tag == $string {
|
||||
let element = box Element;
|
||||
unsafe {
|
||||
return std::mem::transmute::<_, uint>(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn bar() -> uint {
|
||||
foo!("a", "b");
|
||||
0
|
||||
}
|
||||
|
||||
fn main() {
|
||||
bar();
|
||||
}
|
Loading…
Reference in New Issue
Block a user