From 65582933cff313f131c71515a4dd98237c9a73b8 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 9 Sep 2019 15:24:24 -0400 Subject: [PATCH 1/3] make all traits non-enumerable As discussed on Zulip, this actually matches the present behavior of rustc. --- crates/ra_hir/src/ty/traits/chalk.rs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index 8a127efa19..e3fc362e1f 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs @@ -356,14 +356,6 @@ fn make_binders(value: T, num_vars: usize) -> chalk_ir::Binders { } } -fn is_non_enumerable_trait(db: &impl HirDatabase, trait_: Trait) -> bool { - let name = trait_.name(db).unwrap_or_else(crate::Name::missing).to_string(); - match &*name { - "Sized" => true, - _ => false, - } -} - fn convert_where_clauses( db: &impl HirDatabase, def: GenericDef, @@ -503,7 +495,7 @@ pub(crate) fn trait_datum_query( let flags = chalk_rust_ir::TraitFlags { auto: trait_.is_auto(db), upstream: trait_.module(db).krate(db) != Some(krate), - non_enumerable: is_non_enumerable_trait(db, trait_), + non_enumerable: true, // FIXME set these flags correctly marker: false, fundamental: false, From 3f9996d18a22a4b92340b59c56e87f9e952fe178 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 9 Sep 2019 15:30:26 -0400 Subject: [PATCH 2/3] also make "unknown" case non-enumerable --- crates/ra_hir/src/ty/traits/chalk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index e3fc362e1f..0367c65609 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs @@ -478,7 +478,7 @@ pub(crate) fn trait_datum_query( associated_ty_ids: Vec::new(), where_clauses: Vec::new(), flags: chalk_rust_ir::TraitFlags { - non_enumerable: false, + non_enumerable: true, auto: false, marker: false, upstream: true, From 85fdf57dbd2cacba6320b55ef1cd57f7795c8ea5 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 9 Sep 2019 16:05:31 -0400 Subject: [PATCH 3/3] modify tests Some method resolution tests now yield `{unknown}` where they did not before. Other tests now succeed, likely because this is helping the solver steer its efforts. --- crates/ra_hir/src/ty/tests.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 25716fe8c1..2c7d94bce2 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -3007,7 +3007,7 @@ impl Into for T where U: From {} fn test() { S2.into()<|>; } "#, ); - assert_eq!(t, "S1"); + assert_eq!(t, "{unknown}"); } #[test] @@ -3024,7 +3024,7 @@ impl> Into for T {} fn test() { S2.into()<|>; } "#, ); - assert_eq!(t, "S1"); + assert_eq!(t, "{unknown}"); } #[test] @@ -3066,7 +3066,7 @@ impl Trait for S where C: FnX, B: SendX {} fn test() { (S {}).method()<|>; } "#, ); - assert_eq!(t, "{unknown}"); + assert_eq!(t, "()"); } #[test] @@ -3546,11 +3546,11 @@ fn test(x: Trait, y: &Trait) -> u64 { [129; 132) 'bar': fn bar() -> {unknown} [129; 134) 'bar()': {unknown} [140; 141) 'x': {unknown} - [140; 147) 'x.foo()': {unknown} + [140; 147) 'x.foo()': u64 [153; 154) 'y': &{unknown} - [153; 160) 'y.foo()': {unknown} + [153; 160) 'y.foo()': u64 [166; 167) 'z': {unknown} - [166; 173) 'z.foo()': {unknown} + [166; 173) 'z.foo()': u64 "### ); }