From 90ee51bcec910d10066447ea7b375f628592b034 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 22 Sep 2016 17:05:06 -0400 Subject: [PATCH] add notes from 2016-09-15 --- lang-team/2016-09-15.md | 147 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 lang-team/2016-09-15.md diff --git a/lang-team/2016-09-15.md b/lang-team/2016-09-15.md new file mode 100644 index 0000000..72a3840 --- /dev/null +++ b/lang-team/2016-09-15.md @@ -0,0 +1,147 @@ +# impl Trait + +impl Iterator for Foo { + type Item = impl Iterator; + fn next(&mut self) -> Option {...} +} + +type FooIter = impl Iterator; +type FooIter2 = impl Iterator; + +// Upstream crate: + +fn foo() -> impl Iterator { + ... +} + +// Downstream crate: + +pub type MyFooIter = impl Iterator; + +pub type MyFooIter: impl 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 = <... witness ...>; + pub type FooIter: impl Iterator = _; + pub type FooIter = impl Iterator; // witness inferred from function bodies + pub type FooIter: impl Iterator = <... witness ...>; +} + +HasFoo::FooIter + +trait Foo { + fn foo(&self) -> impl Iterator; <- pack + fn bar(&self) -> impl Iterator; <- 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 { + x: Option>> +} +``` + +``` +unsafe impl Send for Bar + where T::Item: Send +{ } +``` + +``` +Bar where Baz: Iterator> +``` + + +struct Foo { ... } + +impl<..> Foo<..> { +} + +impl<'a, ..> Trait<'a> for Foo<..> { ... } + +trait Example { + fn foo(&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: &T) { t.method(t) } // +foo::(...) // 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: &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::(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