Skip to content

Commit

Permalink
Regression tests for #13853
Browse files Browse the repository at this point in the history
Closes #13853, #14889.
  • Loading branch information
tamird committed Dec 28, 2014
1 parent 7a758d1 commit 9cd7864
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/compile-fail/issue-13853-2.rs
@@ -0,0 +1,16 @@
// 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 FromStructReader<'a> { }
trait ResponseHook {
fn get<'a, T: FromStructReader<'a>>(&'a self);
}
fn foo(res : Box<ResponseHook>) { res.get } //~ ERROR attempted to take value of method
fn main() {}
33 changes: 33 additions & 0 deletions src/test/compile-fail/issue-13853-3.rs
@@ -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.

#![crate_type = "lib"]

enum NodeContents<'a> {
Children(Vec<Node<'a>>),
}

impl<'a> Drop for NodeContents<'a> {
//~^ ERROR cannot implement a destructor on a structure with type parameters
fn drop( &mut self ) {
}
}

struct Node<'a> {
contents: NodeContents<'a>,
}

impl<'a> Node<'a> {
fn noName(contents: NodeContents<'a>) -> Node<'a> {
Node{ contents: contents,}
}
}

fn main() {}
21 changes: 21 additions & 0 deletions src/test/compile-fail/issue-13853-4.rs
@@ -0,0 +1,21 @@
// 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 AutoBuilder<'a> {
context: &'a int
}

impl<'a> Drop for AutoBuilder<'a> {
//~^ ERROR cannot implement a destructor on a structure with type parameters
fn drop(&mut self) {
}
}

fn main() {}
23 changes: 23 additions & 0 deletions src/test/compile-fail/issue-13853-5.rs
@@ -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.

trait Deserializer<'a> { }

trait Deserializable {
fn deserialize_token<'a, D: Deserializer<'a>>(D, &'a str) -> Self;
}

impl<'a, T: Deserializable> Deserializable for &'a str {
//~^ ERROR unable to infer enough type information
fn deserialize_token<D: Deserializer<'a>>(_x: D, _y: &'a str) -> &'a str {
}
}

fn main() {}
45 changes: 45 additions & 0 deletions src/test/compile-fail/issue-13853.rs
@@ -0,0 +1,45 @@
// 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 Node {
fn zomg();
}

trait Graph<N: Node> {
fn nodes<'a, I: Iterator<&'a N>>(&'a self) -> I;
}

impl<N: Node> Graph<N> for Vec<N> {
fn nodes<'a, I: Iterator<&'a N>>(&self) -> I {
self.iter() //~ ERROR mismatched types
}
}

struct Stuff;

impl Node for Stuff {
fn zomg() {
println!("zomg");
}
}

fn iterate<N: Node, G: Graph<N>>(graph: &G) {
for node in graph.iter() { //~ ERROR does not implement any method in scope named
node.zomg();
}
}

pub fn main() {
let graph = Vec::new();

graph.push(Stuff);

iterate(graph); //~ ERROR mismatched types
}

0 comments on commit 9cd7864

Please sign in to comment.