]> git.proxmox.com Git - rustc.git/blame - src/test/compile-fail/where-clauses-method-unsatisfied.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / test / compile-fail / where-clauses-method-unsatisfied.rs
CommitLineData
1a4d82fc
JJ
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// Test that a where clause attached to a method allows us to add
12// additional constraints to a parameter out of scope.
13
14struct Foo<T> {
15 value: T
16}
17
18struct Bar; // does not implement Eq
19
20impl<T> Foo<T> {
21 fn equals(&self, u: &Foo<T>) -> bool where T : Eq {
22 self.value == u.value
23 }
24}
25
26fn main() {
27 let x = Foo { value: Bar };
28 x.equals(&x);
54a0048b 29 //~^ ERROR `Bar: std::cmp::Eq` is not satisfied
1a4d82fc 30}