From 4b4c6fd43402a22ce2978de4ec98f61540e09ea5 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Fri, 26 Feb 2016 14:01:16 -0800 Subject: [PATCH] Add regression test for duplicate items in overlapping impls. Note that a regression test already exists for *non*overlapping impls. --- src/test/compile-fail/inherent-overlap.rs | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/test/compile-fail/inherent-overlap.rs diff --git a/src/test/compile-fail/inherent-overlap.rs b/src/test/compile-fail/inherent-overlap.rs new file mode 100644 index 00000000000..5b014dbfd22 --- /dev/null +++ b/src/test/compile-fail/inherent-overlap.rs @@ -0,0 +1,44 @@ +// Copyright 2016 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. + +// Test that you cannot define items with the same name in overlapping inherent +// impl blocks. + +struct Foo; + +impl Foo { + fn id() {} //~ ERROR E0201 +} + +impl Foo { + fn id() {} +} + +struct Bar(T); + +impl Bar { + fn bar(&self) {} //~ ERROR E0201 +} + +impl Bar { + fn bar(&self) {} +} + +struct Baz(T); + +impl Baz { + fn baz(&self) {} //~ ERROR E0201 +} + +impl Baz> { + fn baz(&self) {} +} + +fn main() {} -- GitLab