3966: Add support for bounds on associated types in trait definitions r=matklad a=flodiebold

E.g.
```rust
trait Trait {
    type Item: SomeOtherTrait;
}
```
Note that these don't simply desugar to where clauses; as I understand it, where clauses have to be proved by the *user* of the trait, but these bounds are proved by the *implementor*. (Also, where clauses on associated types are unstable.)

(Another one from my recursive solver branch...)

3968: Remove format from syntax_bridge hot path r=matklad a=edwin0cheng

Although only around 1% speed up by running:

```
Measure-Command {start-process .\target\release\rust-analyzer "analysis-stats -q ." -NoNewWindow -wait}
```

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
bors[bot] 2020-04-15 09:29:36 +00:00 committed by GitHub
commit 1e0ba04033
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 119 additions and 16 deletions

View file

@ -2093,6 +2093,33 @@ fn main() {
);
}
#[test]
fn associated_type_bound() {
let t = type_at(
r#"
//- /main.rs
pub trait Trait {
type Item: OtherTrait<u32>;
}
pub trait OtherTrait<T> {
fn foo(&self) -> T;
}
// this is just a workaround for chalk#234
pub struct S<T>;
impl<T: Trait> Trait for S<T> {
type Item = <T as Trait>::Item;
}
fn test<T: Trait>() {
let y: <S<T> as Trait>::Item = no_matter;
y.foo()<|>;
}
"#,
);
assert_eq!(t, "u32");
}
#[test]
fn dyn_trait_through_chalk() {
let t = type_at(