Unnamed repository; edit this file 'description' to name the repository.
Merge #11071 #11090
11071: feat: Build and publish pre-release Code extension versions r=matklad a=lnicola
Closes #11026
11090: internal: Deduplicate lower ctx hygiene field r=Veykril a=Veykril
bors r+
Co-authored-by: Laurențiu Nicola <[email protected]>
Co-authored-by: Lukas Wirth <[email protected]>
| -rw-r--r-- | .github/workflows/release.yaml | 36 | ||||
| -rw-r--r-- | crates/hir_def/src/import_map.rs | 20 | ||||
| -rw-r--r-- | crates/hir_def/src/item_tree.rs | 11 | ||||
| -rw-r--r-- | crates/hir_def/src/item_tree/lower.rs | 34 | ||||
| -rw-r--r-- | crates/ide_completion/src/context.rs | 2 | ||||
| -rw-r--r-- | editors/code/package-lock.json | 16 | ||||
| -rw-r--r-- | editors/code/package.json | 4 | ||||
| -rw-r--r-- | editors/code/src/ast_inspector.ts | 2 | ||||
| -rw-r--r-- | editors/code/src/lsp_ext.ts | 2 |
9 files changed, 81 insertions, 46 deletions
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 91a6210d26..ad647d045c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -100,14 +100,25 @@ jobs: - run: npm ci working-directory: editors/code - - run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }} + - name: Package Extension (release) + if: github.ref == 'refs/heads/release' + run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }} + working-directory: editors/code + + - name: Package Extension (nightly) + if: github.ref != 'refs/heads/release' + run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }} --pre-release working-directory: editors/code - if: matrix.target == 'x86_64-unknown-linux-gnu' run: rm -rf editors/code/server - - if: matrix.target == 'x86_64-unknown-linux-gnu' - run: npx vsce package -o ../../dist/rust-analyzer.vsix + - if: matrix.target == 'x86_64-unknown-linux-gnu' && github.ref == 'refs/heads/release' + run: npx vsce package -o ../../dist/rust-analyzer-no-server.vsix + working-directory: editors/code + + - if: matrix.target == 'x86_64-unknown-linux-gnu' && github.ref != 'refs/heads/release' + run: npx vsce package -o ../../dist/rust-analyzer-no-server.vsix --pre-release working-directory: editors/code - name: Run analysis-stats on rust-analyzer @@ -151,7 +162,14 @@ jobs: - run: npm ci working-directory: editors/code - - run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64 + - name: Publish Extension (release) + if: github.ref == 'refs/heads/release' + run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64 + working-directory: editors/code + + - name: Publish Extension (nightly) + if: github.ref != 'refs/heads/release' + run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64 --pre-release working-directory: editors/code - run: rm -rf editors/code/server @@ -223,11 +241,19 @@ jobs: name: ${{ env.TAG }} token: ${{ secrets.GITHUB_TOKEN }} + - run: rm dist/rust-analyzer-no-server.vsix + - run: npm ci working-directory: ./editors/code - - name: Publish Extension + - name: Publish Extension (release) if: github.ref == 'refs/heads/release' working-directory: ./editors/code # token from https://dev.azure.com/rust-analyzer/ run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix + + - name: Publish Extension (nightly) + # check specifically for nightly in case someone triggers a release on a feature branch + if: github.ref == 'refs/heads/nightly' + working-directory: ./editors/code + run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix --pre-release diff --git a/crates/hir_def/src/import_map.rs b/crates/hir_def/src/import_map.rs index 27a05b87c1..5e91a3df0a 100644 --- a/crates/hir_def/src/import_map.rs +++ b/crates/hir_def/src/import_map.rs @@ -72,8 +72,12 @@ impl ImportMap { let mut import_map = collect_import_map(db, krate); - let mut importables = import_map.map.iter().collect::<Vec<_>>(); - importables.sort_by_cached_key(|(_, import_info)| fst_path(&import_info.path)); + let mut importables = import_map + .map + .iter() + .map(|(item, info)| (item, fst_path(&info.path))) + .collect::<Vec<_>>(); + importables.sort_by(|(_, fst_path), (_, fst_path2)| fst_path.cmp(fst_path2)); // Build the FST, taking care not to insert duplicate values. @@ -81,20 +85,20 @@ impl ImportMap { let mut last_batch_start = 0; for idx in 0..importables.len() { - let key = fst_path(&importables[last_batch_start].1.path); - if let Some((_, next_import_info)) = importables.get(idx + 1) { - if key == fst_path(&next_import_info.path) { + let key = &importables[last_batch_start].1; + if let Some((_, fst_path)) = importables.get(idx + 1) { + if key == fst_path { continue; } } - builder.insert(key, last_batch_start as u64).unwrap(); + let _ = builder.insert(key, last_batch_start as u64); last_batch_start = idx + 1; } - import_map.fst = fst::Map::new(builder.into_inner().unwrap()).unwrap(); - import_map.importables = importables.iter().map(|(item, _)| **item).collect(); + import_map.fst = builder.into_map(); + import_map.importables = importables.iter().map(|&(&item, _)| item).collect(); Arc::new(import_map) } diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index aafda49693..45b374f338 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs @@ -56,6 +56,7 @@ use la_arena::{Arena, Idx, IdxRange, RawIdx}; use profile::Count; use rustc_hash::FxHashMap; use smallvec::SmallVec; +use stdx::never; use syntax::{ast, match_ast, SyntaxKind}; use crate::{ @@ -109,18 +110,17 @@ impl ItemTree { Some(node) => node, None => return Default::default(), }; - if syntax.kind() == SyntaxKind::ERROR { + if never!(syntax.kind() == SyntaxKind::ERROR) { // FIXME: not 100% sure why these crop up, but return an empty tree to avoid a panic return Default::default(); } - let hygiene = Hygiene::new(db.upcast(), file_id); - let ctx = lower::Ctx::new(db, hygiene.clone(), file_id); + let ctx = lower::Ctx::new(db, file_id); let mut top_attrs = None; let mut item_tree = match_ast! { match syntax { ast::SourceFile(file) => { - top_attrs = Some(RawAttrs::new(db, &file, &hygiene)); + top_attrs = Some(RawAttrs::new(db, &file, ctx.hygiene())); ctx.lower_module_items(&file) }, ast::MacroItems(items) => { @@ -147,8 +147,7 @@ impl ItemTree { fn block_item_tree(db: &dyn DefDatabase, block: BlockId) -> Arc<ItemTree> { let loc = db.lookup_intern_block(block); let block = loc.ast_id.to_node(db.upcast()); - let hygiene = Hygiene::new(db.upcast(), loc.ast_id.file_id); - let ctx = lower::Ctx::new(db, hygiene, loc.ast_id.file_id); + let ctx = lower::Ctx::new(db, loc.ast_id.file_id); Arc::new(ctx.lower_block(&block)) } diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index acc26bcf63..f31fcf0d97 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -19,24 +19,26 @@ fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> { pub(super) struct Ctx<'a> { db: &'a dyn DefDatabase, tree: ItemTree, - hygiene: Hygiene, source_ast_id_map: Arc<AstIdMap>, body_ctx: crate::body::LowerCtx<'a>, forced_visibility: Option<RawVisibilityId>, } impl<'a> Ctx<'a> { - pub(super) fn new(db: &'a dyn DefDatabase, hygiene: Hygiene, file: HirFileId) -> Self { + pub(super) fn new(db: &'a dyn DefDatabase, file: HirFileId) -> Self { Self { db, tree: ItemTree::default(), - hygiene, source_ast_id_map: db.ast_id_map(file), body_ctx: crate::body::LowerCtx::new(db, file), forced_visibility: None, } } + pub(super) fn hygiene(&self) -> &Hygiene { + self.body_ctx.hygiene() + } + pub(super) fn lower_module_items(mut self, item_owner: &dyn HasModuleItem) -> ItemTree { self.tree.top_level = item_owner.items().flat_map(|item| self.lower_mod_item(&item)).collect(); @@ -88,7 +90,7 @@ impl<'a> Ctx<'a> { } fn lower_mod_item(&mut self, item: &ast::Item) -> Option<ModItem> { - let attrs = RawAttrs::new(self.db, item, &self.hygiene); + let attrs = RawAttrs::new(self.db, item, self.hygiene()); let item: ModItem = match item { ast::Item::Struct(ast) => self.lower_struct(ast)?.into(), ast::Item::Union(ast) => self.lower_union(ast)?.into(), @@ -162,7 +164,7 @@ impl<'a> Ctx<'a> { for field in fields.fields() { if let Some(data) = self.lower_record_field(&field) { let idx = self.data().fields.alloc(data); - self.add_attrs(idx.into(), RawAttrs::new(self.db, &field, &self.hygiene)); + self.add_attrs(idx.into(), RawAttrs::new(self.db, &field, self.hygiene())); } } let end = self.next_field_idx(); @@ -182,7 +184,7 @@ impl<'a> Ctx<'a> { for (i, field) in fields.fields().enumerate() { let data = self.lower_tuple_field(i, &field); let idx = self.data().fields.alloc(data); - self.add_attrs(idx.into(), RawAttrs::new(self.db, &field, &self.hygiene)); + self.add_attrs(idx.into(), RawAttrs::new(self.db, &field, self.hygiene())); } let end = self.next_field_idx(); IdxRange::new(start..end) @@ -227,7 +229,7 @@ impl<'a> Ctx<'a> { for variant in variants.variants() { if let Some(data) = self.lower_variant(&variant) { let idx = self.data().variants.alloc(data); - self.add_attrs(idx.into(), RawAttrs::new(self.db, &variant, &self.hygiene)); + self.add_attrs(idx.into(), RawAttrs::new(self.db, &variant, self.hygiene())); } } let end = self.next_variant_idx(); @@ -270,7 +272,7 @@ impl<'a> Ctx<'a> { }; let ty = Interned::new(self_type); let idx = self.data().params.alloc(Param::Normal(None, ty)); - self.add_attrs(idx.into(), RawAttrs::new(self.db, &self_param, &self.hygiene)); + self.add_attrs(idx.into(), RawAttrs::new(self.db, &self_param, self.hygiene())); has_self_param = true; } for param in param_list.params() { @@ -294,7 +296,7 @@ impl<'a> Ctx<'a> { self.data().params.alloc(Param::Normal(name, ty)) } }; - self.add_attrs(idx.into(), RawAttrs::new(self.db, ¶m, &self.hygiene)); + self.add_attrs(idx.into(), RawAttrs::new(self.db, ¶m, self.hygiene())); } } let end_param = self.next_param_idx(); @@ -427,7 +429,7 @@ impl<'a> Ctx<'a> { self.with_inherited_visibility(visibility, |this| { list.assoc_items() .filter_map(|item| { - let attrs = RawAttrs::new(db, &item, &this.hygiene); + let attrs = RawAttrs::new(db, &item, this.hygiene()); this.lower_assoc_item(&item).map(|item| { this.add_attrs(ModItem::from(item).into(), attrs); item @@ -465,7 +467,7 @@ impl<'a> Ctx<'a> { .flat_map(|it| it.assoc_items()) .filter_map(|item| { let assoc = self.lower_assoc_item(&item)?; - let attrs = RawAttrs::new(self.db, &item, &self.hygiene); + let attrs = RawAttrs::new(self.db, &item, self.hygiene()); self.add_attrs(ModItem::from(assoc).into(), attrs); Some(assoc) }) @@ -478,7 +480,7 @@ impl<'a> Ctx<'a> { fn lower_use(&mut self, use_item: &ast::Use) -> Option<FileItemTreeId<Import>> { let visibility = self.lower_visibility(use_item); let ast_id = self.source_ast_id_map.ast_id(use_item); - let (use_tree, _) = lower_use_tree(self.db, &self.hygiene, use_item.use_tree()?)?; + let (use_tree, _) = lower_use_tree(self.db, self.hygiene(), use_item.use_tree()?)?; let res = Import { visibility, ast_id, use_tree }; Some(id(self.data().imports.alloc(res))) @@ -500,7 +502,7 @@ impl<'a> Ctx<'a> { } fn lower_macro_call(&mut self, m: &ast::MacroCall) -> Option<FileItemTreeId<MacroCall>> { - let path = Interned::new(ModPath::from_src(self.db, m.path()?, &self.hygiene)?); + let path = Interned::new(ModPath::from_src(self.db, m.path()?, self.hygiene())?); let ast_id = self.source_ast_id_map.ast_id(m); let expand_to = hir_expand::ExpandTo::from_call_site(m); let res = MacroCall { path, ast_id, expand_to }; @@ -535,7 +537,7 @@ impl<'a> Ctx<'a> { // (in other words, the knowledge that they're in an extern block must not be used). // This is because an extern block can contain macros whose ItemTree's top-level items // should be considered to be in an extern block too. - let attrs = RawAttrs::new(self.db, &item, &self.hygiene); + let attrs = RawAttrs::new(self.db, &item, self.hygiene()); let id: ModItem = match item { ast::ExternItem::Fn(ast) => { let func_id = self.lower_function(&ast)?; @@ -616,7 +618,9 @@ impl<'a> Ctx<'a> { fn lower_visibility(&mut self, item: &dyn ast::HasVisibility) -> RawVisibilityId { let vis = match self.forced_visibility { Some(vis) => return vis, - None => RawVisibility::from_ast_with_hygiene(self.db, item.visibility(), &self.hygiene), + None => { + RawVisibility::from_ast_with_hygiene(self.db, item.visibility(), self.hygiene()) + } }; self.data().vis.alloc(vis) diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index d0ed988989..2a1891c76b 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -302,6 +302,7 @@ impl<'a> CompletionContext<'a> { /// A version of [`SemanticsScope::process_all_names`] that filters out `#[doc(hidden)]` items. pub(crate) fn process_all_names(&self, f: &mut dyn FnMut(Name, ScopeDef)) { + let _p = profile::span("CompletionContext::process_all_names"); self.scope.process_all_names(&mut |name, def| { if self.is_scope_def_hidden(def) { return; @@ -422,6 +423,7 @@ impl<'a> CompletionContext<'a> { mut offset: TextSize, mut fake_ident_token: SyntaxToken, ) { + let _p = profile::span("CompletionContext::expand_and_fill"); loop { // Expand attributes if let (Some(actual_item), Some(item_with_fake_ident)) = ( diff --git a/editors/code/package-lock.json b/editors/code/package-lock.json index 038a07c75a..8728654662 100644 --- a/editors/code/package-lock.json +++ b/editors/code/package-lock.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@types/node": "~14.17.5", - "@types/vscode": "~1.62.0", + "@types/vscode": "~1.63.0", "@typescript-eslint/eslint-plugin": "^5.5.0", "@typescript-eslint/parser": "^5.5.0", "@vscode/test-electron": "^1.6.2", @@ -29,7 +29,7 @@ "vsce": "^2.5.1" }, "engines": { - "vscode": "^1.62.0" + "vscode": "^1.63.0" } }, "node_modules/@eslint/eslintrc": { @@ -143,9 +143,9 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.62.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.62.0.tgz", - "integrity": "sha512-iGlQJ1w5e3qPUryroO6v4lxg3ql1ztdTCwQW3xEwFawdyPLoeUSv48SYfMwc7kQA7h6ThUqflZIjgKAykeF9oA==", + "version": "1.63.1", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.63.1.tgz", + "integrity": "sha512-Z+ZqjRcnGfHP86dvx/BtSwWyZPKQ/LBdmAVImY82TphyjOw2KgTKcp7Nx92oNwCTsHzlshwexAG/WiY2JuUm3g==", "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { @@ -4053,9 +4053,9 @@ "dev": true }, "@types/vscode": { - "version": "1.62.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.62.0.tgz", - "integrity": "sha512-iGlQJ1w5e3qPUryroO6v4lxg3ql1ztdTCwQW3xEwFawdyPLoeUSv48SYfMwc7kQA7h6ThUqflZIjgKAykeF9oA==", + "version": "1.63.1", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.63.1.tgz", + "integrity": "sha512-Z+ZqjRcnGfHP86dvx/BtSwWyZPKQ/LBdmAVImY82TphyjOw2KgTKcp7Nx92oNwCTsHzlshwexAG/WiY2JuUm3g==", "dev": true }, "@typescript-eslint/eslint-plugin": { diff --git a/editors/code/package.json b/editors/code/package.json index d70ac9aacb..9ab57d7dc5 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -21,7 +21,7 @@ "Programming Languages" ], "engines": { - "vscode": "^1.62.0" + "vscode": "^1.63.0" }, "enableProposedApi": true, "scripts": { @@ -44,7 +44,7 @@ }, "devDependencies": { "@types/node": "~14.17.5", - "@types/vscode": "~1.62.0", + "@types/vscode": "~1.63.0", "@typescript-eslint/eslint-plugin": "^5.5.0", "@typescript-eslint/parser": "^5.5.0", "@vscode/test-electron": "^1.6.2", diff --git a/editors/code/src/ast_inspector.ts b/editors/code/src/ast_inspector.ts index 4fdd167bd5..28d8b2a5fd 100644 --- a/editors/code/src/ast_inspector.ts +++ b/editors/code/src/ast_inspector.ts @@ -59,7 +59,7 @@ export class AstInspector implements vscode.HoverProvider, vscode.DefinitionProv } } - private onDidChangeVisibleTextEditors(editors: vscode.TextEditor[]) { + private onDidChangeVisibleTextEditors(editors: readonly vscode.TextEditor[]) { if (!this.findAstTextEditor()) { this.setRustEditor(undefined); return; diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index a21a742a57..9248bd1b6f 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts @@ -125,7 +125,7 @@ export interface SsrParams { parseOnly: boolean; textDocument: lc.TextDocumentIdentifier; position: lc.Position; - selections: lc.Range[]; + selections: readonly lc.Range[]; } export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr'); |