Rewrite associated types to use projection rather than dummy type parameters#20307
Conversation
|
Oh, and this incorporates PR #20159 so I will close that. |
|
Awesome, I'm excited to see this land! |
There was a problem hiding this comment.
This makes me happy, it seems like a really clean way to handle this extra constraints.
There was a problem hiding this comment.
item_name should have a more precise name or a comment (which item is it - the associated item, the trait, the concrete item?) It would be good to have a comment on the fn too stating what normalisation actually is
6bdf21e to
3e0b041
Compare
|
The following example still fails to compile with this branch merged. I get the following error: |
|
r=me with the changes (all minor) |
|
@kinghajj the reason is that the method dispatch is not yet integrated with assoc types; should open an issue on that. If you convert to UFCS form, your test passes: #![feature(associated_types)]
trait Foo {
fn foo(&self) -> ();
}
trait Bar {
type F: Foo;
}
struct Wat<B: Bar> {
fs: Vec<B::F>,
}
impl<B: Bar> Wat<B> {
fn wat(&mut self) -> () {
Foo::foo(&self.fs.pop().unwrap()); // <-- changed to UFCS here
}
}
fn main() {
} |
81f8feb to
3fed71b
Compare
types are always known and hence the ParameterEnvironment is not necessary. For other `Sized` queries, use the trait infrastructure just like `Copy`.
…e instantiate them. Also fix some assertions and handling of builtin bounds.
…ow. Seems better to err on the side of being more correct rather than less. Fix a bug in typing index expressions that was exposed as a result, and add one type annotation that is not required. Delete some random tests that were relying on old behavior and don't seem to add anything anymore.
…k to their respective commits but oh dear what a pain.
for lack of impl-trait-for-trait just a bit more targeted (don't substitute err, just drop the troublesome bound for now) -- otherwise substituting false types leads us into trouble when we normalize etc.
5938adc to
6f6944e
Compare
6f6944e to
e186acc
Compare
…tend-bound, r=nrc Rewrite associated types to use projection rather than dummy type parameters. This closes almost every (major) open issue, but I'm holding off on that until the code has landed and baked a bit. Probably it should have more tests, as well, but I wanted to get this landed as fast as possible so that we can collaborate on improving it. The commit history is a little messy, particularly the merge commit at the end. If I get some time, I might just "reset" to the beginning and try to carve up the final state into logical pieces. Let me know if it seems hard to follow. By far the most crucial commit is "Implement associated type projection and normalization." r? @nick29581
…ression_from_format_string Migrate `extract_expressions_from_format_string` assist to use `SyntaxEditor`
Rewrite associated types to use projection rather than dummy type parameters. This closes almost every (major) open issue, but I'm holding off on that until the code has landed and baked a bit. Probably it should have more tests, as well, but I wanted to get this landed as fast as possible so that we can collaborate on improving it.
The commit history is a little messy, particularly the merge commit at the end. If I get some time, I might just "reset" to the beginning and try to carve up the final state into logical pieces. Let me know if it seems hard to follow. By far the most crucial commit is "Implement associated type projection and normalization."
r? @nick29581