aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir/src/code_model.rs2
-rw-r--r--crates/hir_ty/src/method_resolution.rs13
-rw-r--r--crates/ide/src/syntax_highlighting/test_data/highlighting.html6
-rw-r--r--crates/ide/src/syntax_highlighting/tests.rs6
4 files changed, 26 insertions, 1 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs
index 63c1a8ebf..563145f92 100644
--- a/crates/hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
@@ -1398,7 +1398,7 @@ impl Type {
1398 }; 1398 };
1399 1399
1400 let canonical_ty = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) }; 1400 let canonical_ty = Canonical { value: self.ty.value.clone(), kinds: Arc::new([]) };
1401 method_resolution::implements_trait( 1401 method_resolution::implements_trait_unique(
1402 &canonical_ty, 1402 &canonical_ty,
1403 db, 1403 db,
1404 self.ty.environment.clone(), 1404 self.ty.environment.clone(),
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs
index 8961df404..5a6f0c67f 100644
--- a/crates/hir_ty/src/method_resolution.rs
+++ b/crates/hir_ty/src/method_resolution.rs
@@ -740,6 +740,19 @@ pub fn implements_trait(
740 solution.is_some() 740 solution.is_some()
741} 741}
742 742
743pub fn implements_trait_unique(
744 ty: &Canonical<Ty>,
745 db: &dyn HirDatabase,
746 env: Arc<TraitEnvironment>,
747 krate: CrateId,
748 trait_: TraitId,
749) -> bool {
750 let goal = generic_implements_goal(db, env, trait_, ty.clone());
751 let solution = db.trait_solve(krate, goal);
752
753 matches!(solution, Some(crate::traits::Solution::Unique(_)))
754}
755
743/// This creates Substs for a trait with the given Self type and type variables 756/// This creates Substs for a trait with the given Self type and type variables
744/// for all other parameters, to query Chalk with it. 757/// for all other parameters, to query Chalk with it.
745fn generic_implements_goal( 758fn generic_implements_goal(
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
index c6b4f5a00..ee115972b 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
@@ -115,6 +115,12 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
115 <span class="value_param callable">f</span><span class="punctuation">(</span><span class="punctuation">)</span> 115 <span class="value_param callable">f</span><span class="punctuation">(</span><span class="punctuation">)</span>
116<span class="punctuation">}</span> 116<span class="punctuation">}</span>
117 117
118<span class="keyword">fn</span> <span class="function declaration">foobar</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="operator">-&gt;</span> <span class="keyword">impl</span> <span class="unresolved_reference">Copy</span> <span class="punctuation">{</span><span class="punctuation">}</span>
119
120<span class="keyword">fn</span> <span class="function declaration">foo</span><span class="punctuation">(</span><span class="punctuation">)</span> <span class="punctuation">{</span>
121 <span class="keyword">let</span> <span class="variable declaration">bar</span> <span class="operator">=</span> <span class="function">foobar</span><span class="punctuation">(</span><span class="punctuation">)</span><span class="punctuation">;</span>
122<span class="punctuation">}</span>
123
118<span class="macro">macro_rules!</span> <span class="macro declaration">def_fn</span> <span class="punctuation">{</span> 124<span class="macro">macro_rules!</span> <span class="macro declaration">def_fn</span> <span class="punctuation">{</span>
119 <span class="punctuation">(</span><span class="punctuation">$</span><span class="punctuation">(</span><span class="punctuation">$</span>tt<span class="punctuation">:</span>tt<span class="punctuation">)</span><span class="punctuation">*</span><span class="punctuation">)</span> <span class="operator">=</span><span class="punctuation">&gt;</span> <span class="punctuation">{</span><span class="punctuation">$</span><span class="punctuation">(</span><span class="punctuation">$</span>tt<span class="punctuation">)</span><span class="punctuation">*</span><span class="punctuation">}</span> 125 <span class="punctuation">(</span><span class="punctuation">$</span><span class="punctuation">(</span><span class="punctuation">$</span>tt<span class="punctuation">:</span>tt<span class="punctuation">)</span><span class="punctuation">*</span><span class="punctuation">)</span> <span class="operator">=</span><span class="punctuation">&gt;</span> <span class="punctuation">{</span><span class="punctuation">$</span><span class="punctuation">(</span><span class="punctuation">$</span>tt<span class="punctuation">)</span><span class="punctuation">*</span><span class="punctuation">}</span>
120<span class="punctuation">}</span> 126<span class="punctuation">}</span>
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index dd43f9dd9..5ea712cf5 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -89,6 +89,12 @@ fn baz<F: Fn() -> ()>(f: F) {
89 f() 89 f()
90} 90}
91 91
92fn foobar() -> impl Copy {}
93
94fn foo() {
95 let bar = foobar();
96}
97
92macro_rules! def_fn { 98macro_rules! def_fn {
93 ($($tt:tt)*) => {$($tt)*} 99 ($($tt:tt)*) => {$($tt)*}
94} 100}