From 9cd7864147a5f18731908245c8aa5575e2542fb6 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Mon, 22 Dec 2014 21:20:31 -0800 Subject: [PATCH] Regression tests for #13853 Closes #13853, #14889. --- src/test/compile-fail/issue-13853-2.rs | 16 +++++++++ src/test/compile-fail/issue-13853-3.rs | 33 +++++++++++++++++++ src/test/compile-fail/issue-13853-4.rs | 21 ++++++++++++ src/test/compile-fail/issue-13853-5.rs | 23 +++++++++++++ src/test/compile-fail/issue-13853.rs | 45 ++++++++++++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 src/test/compile-fail/issue-13853-2.rs create mode 100644 src/test/compile-fail/issue-13853-3.rs create mode 100644 src/test/compile-fail/issue-13853-4.rs create mode 100644 src/test/compile-fail/issue-13853-5.rs create mode 100644 src/test/compile-fail/issue-13853.rs diff --git a/src/test/compile-fail/issue-13853-2.rs b/src/test/compile-fail/issue-13853-2.rs new file mode 100644 index 0000000000000..ea0d880f4a1cc --- /dev/null +++ b/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 or the MIT license +// , 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) { res.get } //~ ERROR attempted to take value of method +fn main() {} diff --git a/src/test/compile-fail/issue-13853-3.rs b/src/test/compile-fail/issue-13853-3.rs new file mode 100644 index 0000000000000..f10c47b594ea2 --- /dev/null +++ b/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 or the MIT license +// , 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>), +} + +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() {} diff --git a/src/test/compile-fail/issue-13853-4.rs b/src/test/compile-fail/issue-13853-4.rs new file mode 100644 index 0000000000000..7d653f5ab9e29 --- /dev/null +++ b/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 or the MIT license +// , 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() {} diff --git a/src/test/compile-fail/issue-13853-5.rs b/src/test/compile-fail/issue-13853-5.rs new file mode 100644 index 0000000000000..b3a4f341f8448 --- /dev/null +++ b/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 or the MIT license +// , 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>(_x: D, _y: &'a str) -> &'a str { + } +} + +fn main() {} diff --git a/src/test/compile-fail/issue-13853.rs b/src/test/compile-fail/issue-13853.rs new file mode 100644 index 0000000000000..868836a4bbd0a --- /dev/null +++ b/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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Node { + fn zomg(); +} + +trait Graph { + fn nodes<'a, I: Iterator<&'a N>>(&'a self) -> I; +} + +impl Graph for Vec { + 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>(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 +}