mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Use Chalk's dyn/impl trait support
This commit is contained in:
parent
e21b82e035
commit
9c2a9a9a06
3 changed files with 16 additions and 13 deletions
|
@ -228,14 +228,10 @@ fn iterate_trait_method_candidates<T>(
|
|||
'traits: for t in traits {
|
||||
let data = t.trait_data(db);
|
||||
|
||||
// FIXME this is a bit of a hack, since Chalk should say the same thing
|
||||
// anyway, but currently Chalk doesn't implement `dyn/impl Trait` yet
|
||||
let inherently_implemented = ty.value.inherent_trait() == Some(t);
|
||||
|
||||
// we'll be lazy about checking whether the type implements the
|
||||
// trait, but if we find out it doesn't, we'll skip the rest of the
|
||||
// iteration
|
||||
let mut known_implemented = inherently_implemented;
|
||||
let mut known_implemented = false;
|
||||
for &item in data.items() {
|
||||
if !is_valid_candidate(db, name, mode, item) {
|
||||
continue;
|
||||
|
|
|
@ -3983,11 +3983,11 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u64>) {
|
|||
[180; 183) 'bar': fn bar() -> impl Trait<u64>
|
||||
[180; 185) 'bar()': impl Trait<u64>
|
||||
[191; 192) 'x': impl Trait<u64>
|
||||
[191; 198) 'x.foo()': {unknown}
|
||||
[191; 198) 'x.foo()': u64
|
||||
[204; 205) 'y': &impl Trait<u64>
|
||||
[204; 211) 'y.foo()': {unknown}
|
||||
[204; 211) 'y.foo()': u64
|
||||
[217; 218) 'z': impl Trait<u64>
|
||||
[217; 224) 'z.foo()': {unknown}
|
||||
[217; 224) 'z.foo()': u64
|
||||
[230; 231) 'x': impl Trait<u64>
|
||||
[230; 238) 'x.foo2()': i64
|
||||
[244; 245) 'y': &impl Trait<u64>
|
||||
|
@ -4033,11 +4033,11 @@ fn test(x: dyn Trait<u64>, y: &dyn Trait<u64>) {
|
|||
[177; 180) 'bar': fn bar() -> dyn Trait<u64>
|
||||
[177; 182) 'bar()': dyn Trait<u64>
|
||||
[188; 189) 'x': dyn Trait<u64>
|
||||
[188; 195) 'x.foo()': {unknown}
|
||||
[188; 195) 'x.foo()': u64
|
||||
[201; 202) 'y': &dyn Trait<u64>
|
||||
[201; 208) 'y.foo()': {unknown}
|
||||
[201; 208) 'y.foo()': u64
|
||||
[214; 215) 'z': dyn Trait<u64>
|
||||
[214; 221) 'z.foo()': {unknown}
|
||||
[214; 221) 'z.foo()': u64
|
||||
[227; 228) 'x': dyn Trait<u64>
|
||||
[227; 235) 'x.foo2()': i64
|
||||
[241; 242) 'y': &dyn Trait<u64>
|
||||
|
|
|
@ -68,8 +68,15 @@ impl ToChalk for Ty {
|
|||
}
|
||||
Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(),
|
||||
Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"),
|
||||
// FIXME use Chalk's Dyn/Opaque once the bugs with that are fixed
|
||||
Ty::Unknown | Ty::Dyn(_) | Ty::Opaque(_) => {
|
||||
Ty::Dyn(predicates) => {
|
||||
let where_clauses = predicates.iter().cloned().map(|p| p.to_chalk(db)).collect();
|
||||
chalk_ir::TyData::Dyn(make_binders(where_clauses, 1)).intern()
|
||||
}
|
||||
Ty::Opaque(predicates) => {
|
||||
let where_clauses = predicates.iter().cloned().map(|p| p.to_chalk(db)).collect();
|
||||
chalk_ir::TyData::Opaque(make_binders(where_clauses, 1)).intern()
|
||||
}
|
||||
Ty::Unknown => {
|
||||
let parameters = Vec::new();
|
||||
let name = TypeName::Error;
|
||||
chalk_ir::ApplicationTy { name, parameters }.cast().intern()
|
||||
|
|
Loading…
Reference in a new issue