Skip to content

Commit 895304c

Browse files
committed
---
yaml --- r: 234479 b: refs/heads/tmp c: a33532b h: refs/heads/master i: 234477: d7da691 234475: c24a9e3 234471: 0296a96 234463: 5ce9f36 v: v3
1 parent e7a6666 commit 895304c

File tree

6 files changed

+159
-3
lines changed

6 files changed

+159
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: 9577e426824d410e21147bec73b1c7d0a64f890d
28+
refs/heads/tmp: a33532b1b720eb87d358911e1f79cf635297dac6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/doc/reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,14 +1489,14 @@ impl Num for f64 {
14891489
let x: f64 = Num::from_i32(42);
14901490
```
14911491

1492-
Traits may inherit from other traits. Consider the following example:
1492+
Traits may inherit from other traits. For example, in
14931493

14941494
```
14951495
trait Shape { fn area(&self) -> f64; }
14961496
trait Circle : Shape { fn radius(&self) -> f64; }
14971497
```
14981498

1499-
The syntax `Circle : Shape` means that types that implement `Circle` must also
1499+
the syntax `Circle : Shape` means that types that implement `Circle` must also
15001500
have an implementation for `Shape`. Multiple supertraits are separated by `+`,
15011501
`trait Circle : Shape + PartialEq { }`. In an implementation of `Circle` for a
15021502
given type `T`, methods can refer to `Shape` methods, since the typechecker
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2015 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+
#![allow(unused)]
12+
13+
#[derive(Clone)]
14+
struct A (B);
15+
16+
impl A {
17+
pub fn matches<F: Fn()>(&self, f: &F) {
18+
//~^ ERROR reached the recursion limit during monomorphization
19+
let &A(ref term) = self;
20+
term.matches(f);
21+
}
22+
}
23+
24+
#[derive(Clone)]
25+
enum B {
26+
Variant1,
27+
Variant2(C),
28+
}
29+
30+
impl B {
31+
pub fn matches<F: Fn()>(&self, f: &F) {
32+
match self {
33+
&B::Variant2(ref factor) => {
34+
factor.matches(&|| ())
35+
}
36+
_ => unreachable!("")
37+
}
38+
}
39+
}
40+
41+
#[derive(Clone)]
42+
struct C (D);
43+
44+
impl C {
45+
pub fn matches<F: Fn()>(&self, f: &F) {
46+
let &C(ref base) = self;
47+
base.matches(&|| {
48+
C(base.clone()).matches(f)
49+
})
50+
}
51+
}
52+
53+
#[derive(Clone)]
54+
struct D (Box<A>);
55+
56+
impl D {
57+
pub fn matches<F: Fn()>(&self, f: &F) {
58+
let &D(ref a) = self;
59+
a.matches(f)
60+
}
61+
}
62+
63+
pub fn matches() {
64+
A(B::Variant1).matches(&(|| ()))
65+
}
66+
67+
fn main() {}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2015 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+
trait Wrap<'b> {
12+
fn foo(&'b mut self);
13+
}
14+
15+
struct Wrapper<P>(P);
16+
17+
impl<'b, P> Wrap<'b> for Wrapper<P>
18+
where P: Process<'b>,
19+
<P as Process<'b>>::Item: Iterator {
20+
fn foo(&mut self) {}
21+
}
22+
23+
24+
pub trait Process<'a> {
25+
type Item;
26+
fn bar(&'a self);
27+
}
28+
29+
fn push_process<P>(process: P) where P: Process<'static> {
30+
let _: Box<for<'b> Wrap<'b>> = Box::new(Wrapper(process));
31+
//~^ ERROR the trait `for<'b> Process<'b>` is not implemented for the type `P` [E0277]
32+
//~| ERROR the trait `for<'b> core::iter::Iterator` is not implemented for the type
33+
//~| ERROR cannot infer an appropriate lifetime for lifetime parameter `'b` due to conflicting
34+
}
35+
36+
fn main() {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2015 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+
#![feature(box_syntax)]
12+
use std::any::Any;
13+
14+
fn main()
15+
{
16+
fn h(x:i32) -> i32 {3*x}
17+
let mut vfnfer:Vec<Box<Any>> = vec![];
18+
vfnfer.push(box h);
19+
println!("{:?}",(vfnfer[0] as Fn)(3));
20+
//~^ ERROR the precise format of `Fn`-family traits'
21+
//~| ERROR wrong number of type arguments: expected 1, found 0
22+
//~| ERROR the value of the associated type `Output` (from the trait `core::ops::FnOnce`)
23+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2015 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+
pub enum Expr<'var, VAR> {
12+
Let(Box<Expr<'var, VAR>>,
13+
Box<for<'v: 'var> Fn(Expr<'v, VAR>) -> Expr<'v, VAR> + 'var>)
14+
}
15+
16+
pub fn add<'var, VAR>
17+
(a: Expr<'var, VAR>, b: Expr<'var, VAR>) -> Expr<'var, VAR> {
18+
loop {}
19+
}
20+
21+
pub fn let_<'var, VAR, F: for<'v: 'var> Fn(Expr<'v, VAR>) -> Expr<'v, VAR>>
22+
(a: Expr<'var, VAR>, b: F) -> Expr<'var, VAR> {
23+
loop {}
24+
}
25+
26+
fn main() {
27+
let ex = (|x| {
28+
let_(add(x,x), |y| { //~ ERROR unable to infer enough type information about `_`
29+
let_(add(x, x), |x|x)})});
30+
}

0 commit comments

Comments
 (0)