Skip to content
This repository has been archived by the owner on Oct 9, 2018. It is now read-only.

Commit

Permalink
add notes from 2016-09-15
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Sep 22, 2016
1 parent a467327 commit 90ee51b
Showing 1 changed file with 147 additions and 0 deletions.
147 changes: 147 additions & 0 deletions lang-team/2016-09-15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# impl Trait

impl Iterator for Foo {
type Item = impl Iterator<Item=String>;
fn next(&mut self) -> Option<Self::Item> {...}
}

type FooIter = impl Iterator<Item = u32>;
type FooIter2 = impl Iterator<Item = u32>;

// Upstream crate:

fn foo() -> impl Iterator<Item = u32> {
...
}

// Downstream crate:

pub type MyFooIter = impl Iterator<Item = u32>;

pub type MyFooIter: impl Iterator<Item = u32> = <BlahIter as Iterator>::next::Output;


pub fn my_foo() -> MyFooIter {
foo()
}

pub struct HasFoo {
pub iter: MyFooIter
}

HasFoo { iter: foo() } // <- the pack!!!!


trait SomeTrait {
type Assoc;
fn foo(&self) -> Assoc;
fn bar(&self) -> Assoc;
}

impl SomeTrait for Blah {
type Assoc = impl AnotherTrait;
fn foo(&self) ->



impl HasFoo {
pub type FooIter: Iterator<Item = u32> = <... witness ...>;
pub type FooIter: impl Iterator<Item = u32> = _;
pub type FooIter = impl Iterator<Item = u32>; // witness inferred from function bodies
pub type FooIter: impl Iterator<Item = u32> = <... witness ...>;
}

HasFoo::FooIter

trait Foo {
fn foo(&self) -> impl Iterator<Item = u32>; <- pack
fn bar(&self) -> impl Iterator<Item = u32>; <- pack, again
}

impl Foo {
fn foo(&self) -> Concrete { ... }
fn bar(&self) -> Concrete { ... }
}

# Action items

- [x] advertise FCP for stabilisation issues
- [ ] merge/close FCP'd RFCs
- [ ] thread about private-in-public

Default arguments etc

fn foo(x: u32, y: u32 = x)




- [x] B-RFC-accepted and B-unstable - talk to brson, triage - nrc
- [ ] stabilise https://github.com/rust-lang/rust/issues/27245
- [ ] FCP remaining nominated things in the way you expect

```
struct Bar<T: Iterator> {
x: Option<Box<Bar<T::Item>>>
}
```

```
unsafe impl<T: Iterator> Send for Bar<T>
where T::Item: Send
{ }
```

```
Bar<Baz> where Baz: Iterator<Item=Bar<Baz>>
```


struct Foo<X: Bar> { ... }

impl<..> Foo<..> {
}

impl<'a, ..> Trait<'a> for Foo<..> { ... }

trait Example {
fn foo<T>(&self, t: T)
}

impl Example for [u8] { ... }
impl Example for SomeOtherTrait { ... }

```
trait Trait { fn method(&self, self: &Self) // <-- should not be invokable when Self == Trait }
fn foo<T:?Sized + Trait>(t: &T) { t.method(t) } //
foo::<Trait>(...) // what prevents this?
```

- Key idea:
- Could we add `where Self: Sized` implicitly so as to make all traits (or most traits) object-safe, but disallow methods from being called?
- Answer:
- No, because backwards compat. There are traits like this one that are not object-safe but still usable with unsized self:

```
trait Trait { fn method(&self, self: &Self) // <-- should not be invokable when Self == Trait }
fn foo<T:?Sized + Trait>(t: &T) { t.method(t) } //
```

- So if we added `Self: Sized` that would be bad
- If we tried to make some other criteria that is not `Self: Sized`, it would accept the fn `foo` above, but then what stops us from calling `foo::<Trait>(t: &Trait)` // since `Trait` is now object-safe?

- [x] Close https://github.com/rust-lang/rfcs/pull/1180
- [x] Merge https://github.com/rust-lang/rfcs/pull/1561
- [x] Close https://github.com/rust-lang/rfcs/pull/1573
- [x] Close https://github.com/rust-lang/rfcs/pull/1583
- [x] Merge https://github.com/rust-lang/rfcs/pull/1623
- [x] Merge https://github.com/rust-lang/rfcs/pull/1681 but checkin with acrichto about unresolved questions
- [x] Close https://github.com/rust-lang/rfcs/pull/1694
- [x] FCP to stabilize https://github.com/rust-lang/rust/issues/31436
- [x] FCP to remove https://github.com/rust-lang/rust/issues/29721
- [x] Calling for an RFC to do better -- https://github.com/rust-lang/rust/issues/28237
- [x] FCP to stabilize statements https://github.com/rust-lang/rust/issues/15701
- seek feedback on expressions
- [x] FCP https://github.com/rust-lang/rfcs/pull/1696
- [x] FCP to deprecate the Reflect trait
- [x] FCP to deprecate https://github.com/rust-lang/rust/issues/27749

0 comments on commit 90ee51b

Please sign in to comment.