Repository: rust-analyzer/rust-analyzer
Pull request #10897 (2021-12-01 10:24:33)

internal: Try to fix Code tests
It looks like `--noEmit` broke our unit tests:

![image](https://user-images.githubusercontent.com/308347/144217192-a8133a6b-880f-4852-846b-b45527485336.png)

r? @ChayimFriedman2

I suppose we might still:

 - compile stuff twice
 - not detect failing tests on CI (since we didn't notice this)


Patch:
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index f781e0987a..192ef11be3 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -112,7 +112,11 @@ jobs:
     - name: Install Nodejs
       uses: actions/setup-node@v1
       with:
-        node-version: 12.x
+        node-version: 14.x
+
+    - name: Install xvfb
+      if: matrix.os == 'ubuntu-latest'
+      run: sudo apt-get install -y xvfb
 
     - run: npm ci
       working-directory: ./editors/code
@@ -124,13 +128,19 @@ jobs:
     - run: npm run lint
       working-directory: ./editors/code
 
-    - name: Run vscode tests
-      uses: GabrielBB/xvfb-action@v1.2
+    - name: Run VS Code tests (Linux)
+      if: matrix.os == 'ubuntu-latest'
       env:
         VSCODE_CLI: 1
-      with:
-        run: npm --prefix ./editors/code test
-        # working-directory: ./editors/code  # does not work: https://github.com/GabrielBB/xvfb-action/issues/8
+      run: xvfb-run npm test
+      working-directory: ./editors/code
+
+    - name: Run VS Code tests (Windows)
+      if: matrix.os == 'windows-latest'
+      env:
+        VSCODE_CLI: 1
+      run: npm test
+      working-directory: ./editors/code
 
     - run: npm run pretest
       working-directory: ./editors/code
diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs
index 23fcd02b57..b12461818e 100644
--- a/crates/hir/src/source_analyzer.rs
+++ b/crates/hir/src/source_analyzer.rs
@@ -16,7 +16,7 @@ use hir_def::{
     expr::{ExprId, Pat, PatId},
     path::{ModPath, Path, PathKind},
     resolver::{resolver_for_scope, Resolver, TypeNs, ValueNs},
-    AsMacroCall, DefWithBodyId, FieldId, FunctionId, LocalFieldId, ModuleDefId, VariantId,
+    AsMacroCall, DefWithBodyId, FieldId, FunctionId, LocalFieldId, VariantId,
 };
 use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile};
 use hir_ty::{
@@ -544,17 +544,6 @@ fn resolve_hir_path_(
                 }
             }
         }?;
-
-        // If we are in a TypeNs for a Trait, and we have an unresolved name, try to resolve it as a type
-        // within the trait's associated types.
-        if let (Some(unresolved), &TypeNs::TraitId(trait_id)) = (&unresolved, &ty) {
-            if let Some(type_alias_id) =
-                db.trait_data(trait_id).associated_type_by_name(&unresolved.name)
-            {
-                return Some(PathResolution::Def(ModuleDefId::from(type_alias_id).into()));
-            }
-        }
-
         let res = match ty {
             TypeNs::SelfType(it) => PathResolution::SelfType(it.into()),
             TypeNs::GenericParam(id) => PathResolution::TypeParam(TypeParam { id }),
diff --git a/editors/code/package.json b/editors/code/package.json
index 52ba132745..d10cea8237 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -32,7 +32,7 @@
         "watch": "npm run build-base -- --sourcemap --watch",
         "lint": "tsfmt --verify && eslint -c .eslintrc.js --ext ts ./src ./tests",
         "fix": " tsfmt -r       && eslint -c .eslintrc.js --ext ts ./src ./tests --fix",
-        "pretest": "tsc --noEmit && npm run build",
+        "pretest": "tsc && npm run build",
         "test": "node ./out/tests/runTests.js"
     },
     "dependencies": {


Test patch:
diff --git a/crates/ide/src/syntax_highlighting/test_data/highlighting.html b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
index d8c9827b5e..ab810aceca 100644
--- a/crates/ide/src/syntax_highlighting/test_data/highlighting.html
+++ b/crates/ide/src/syntax_highlighting/test_data/highlighting.html
@@ -265,13 +265,4 @@ proc_macros::<span class="macro">mirror!</span> <span class="brace">{</span>
 <span class="brace">}</span>
 <span class="keyword">const</span> <span class="constant declaration">USAGE_OF_BOOL</span><span class="colon">:</span><span class="builtin_type">bool</span> <span class="operator">=</span> <span class="enum public">Bool</span><span class="operator">::</span><span class="enum_variant public">True</span><span class="operator">.</span><span class="function associated consuming public">to_primitive</span><span class="parenthesis">(</span><span class="parenthesis">)</span><span class="semicolon">;</span>
 
-<span class="keyword">trait</span> <span class="trait declaration">Baz</span> <span class="brace">{</span>
-    <span class="keyword">type</span> <span class="type_alias associated declaration trait">Qux</span><span class="semicolon">;</span>
-<span class="brace">}</span>
-
-<span class="keyword">fn</span> <span class="function declaration">baz</span><span class="angle">&lt;</span><span class="type_param declaration">T</span><span class="angle">&gt;</span><span class="parenthesis">(</span><span class="value_param declaration">t</span><span class="colon">:</span> <span class="type_param">T</span><span class="parenthesis">)</span>
-<span class="keyword">where</span>
-    <span class="type_param">T</span><span class="colon">:</span> <span class="trait">Baz</span><span class="comma">,</span>
-    <span class="angle">&lt;</span><span class="type_param">T</span> <span class="keyword">as</span> <span class="trait">Baz</span><span class="angle">&gt;</span><span class="operator">::</span><span class="type_alias associated trait">Qux</span><span class="colon">:</span> <span class="trait">Bar</span> <span class="brace">{</span><span class="brace">}</span>
-
 </code></pre>
\ No newline at end of file
diff --git a/crates/ide/src/syntax_highlighting/tests.rs b/crates/ide/src/syntax_highlighting/tests.rs
index e74f39a865..05158c169e 100644
--- a/crates/ide/src/syntax_highlighting/tests.rs
+++ b/crates/ide/src/syntax_highlighting/tests.rs
@@ -238,15 +238,6 @@ impl Bool {
 }
 const USAGE_OF_BOOL:bool = Bool::True.to_primitive();
 
-trait Baz {
-    type Qux;
-}
-
-fn baz<T>(t: T)
-where
-    T: Baz,
-    <T as Baz>::Qux: Bar {}
-
 //- /foo.rs crate:foo
 pub struct Person {
     pub name: &'static str,