Skip to content

Commit 47fad0e

Browse files
bors[bot]lnicolaVeykril
authored
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]>
3 parents a979378 + 89cecff + e76e0e8 commit 47fad0e

File tree

9 files changed

+81
-46
lines changed

9 files changed

+81
-46
lines changed

.github/workflows/release.yaml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,25 @@ jobs:
100100
- run: npm ci
101101
working-directory: editors/code
102102

103-
- run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }}
103+
- name: Package Extension (release)
104+
if: github.ref == 'refs/heads/release'
105+
run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }}
106+
working-directory: editors/code
107+
108+
- name: Package Extension (nightly)
109+
if: github.ref != 'refs/heads/release'
110+
run: npx vsce package -o "../../dist/rust-analyzer-${{ matrix.code-target }}.vsix" --target ${{ matrix.code-target }} --pre-release
104111
working-directory: editors/code
105112

106113
- if: matrix.target == 'x86_64-unknown-linux-gnu'
107114
run: rm -rf editors/code/server
108115

109-
- if: matrix.target == 'x86_64-unknown-linux-gnu'
110-
run: npx vsce package -o ../../dist/rust-analyzer.vsix
116+
- if: matrix.target == 'x86_64-unknown-linux-gnu' && github.ref == 'refs/heads/release'
117+
run: npx vsce package -o ../../dist/rust-analyzer-no-server.vsix
118+
working-directory: editors/code
119+
120+
- if: matrix.target == 'x86_64-unknown-linux-gnu' && github.ref != 'refs/heads/release'
121+
run: npx vsce package -o ../../dist/rust-analyzer-no-server.vsix --pre-release
111122
working-directory: editors/code
112123

113124
- name: Run analysis-stats on rust-analyzer
@@ -151,7 +162,14 @@ jobs:
151162
- run: npm ci
152163
working-directory: editors/code
153164

154-
- run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64
165+
- name: Publish Extension (release)
166+
if: github.ref == 'refs/heads/release'
167+
run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64
168+
working-directory: editors/code
169+
170+
- name: Publish Extension (nightly)
171+
if: github.ref != 'refs/heads/release'
172+
run: npx vsce package -o "../../dist/rust-analyzer-alpine-x64.vsix" --target alpine-x64 --pre-release
155173
working-directory: editors/code
156174

157175
- run: rm -rf editors/code/server
@@ -223,11 +241,19 @@ jobs:
223241
name: ${{ env.TAG }}
224242
token: ${{ secrets.GITHUB_TOKEN }}
225243

244+
- run: rm dist/rust-analyzer-no-server.vsix
245+
226246
- run: npm ci
227247
working-directory: ./editors/code
228248

229-
- name: Publish Extension
249+
- name: Publish Extension (release)
230250
if: github.ref == 'refs/heads/release'
231251
working-directory: ./editors/code
232252
# token from https://dev.azure.com/rust-analyzer/
233253
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix
254+
255+
- name: Publish Extension (nightly)
256+
# check specifically for nightly in case someone triggers a release on a feature branch
257+
if: github.ref == 'refs/heads/nightly'
258+
working-directory: ./editors/code
259+
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix --pre-release

crates/hir_def/src/import_map.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,29 +72,33 @@ impl ImportMap {
7272

7373
let mut import_map = collect_import_map(db, krate);
7474

75-
let mut importables = import_map.map.iter().collect::<Vec<_>>();
76-
importables.sort_by_cached_key(|(_, import_info)| fst_path(&import_info.path));
75+
let mut importables = import_map
76+
.map
77+
.iter()
78+
.map(|(item, info)| (item, fst_path(&info.path)))
79+
.collect::<Vec<_>>();
80+
importables.sort_by(|(_, fst_path), (_, fst_path2)| fst_path.cmp(fst_path2));
7781

7882
// Build the FST, taking care not to insert duplicate values.
7983

8084
let mut builder = fst::MapBuilder::memory();
8185
let mut last_batch_start = 0;
8286

8387
for idx in 0..importables.len() {
84-
let key = fst_path(&importables[last_batch_start].1.path);
85-
if let Some((_, next_import_info)) = importables.get(idx + 1) {
86-
if key == fst_path(&next_import_info.path) {
88+
let key = &importables[last_batch_start].1;
89+
if let Some((_, fst_path)) = importables.get(idx + 1) {
90+
if key == fst_path {
8791
continue;
8892
}
8993
}
9094

91-
builder.insert(key, last_batch_start as u64).unwrap();
95+
let _ = builder.insert(key, last_batch_start as u64);
9296

9397
last_batch_start = idx + 1;
9498
}
9599

96-
import_map.fst = fst::Map::new(builder.into_inner().unwrap()).unwrap();
97-
import_map.importables = importables.iter().map(|(item, _)| **item).collect();
100+
import_map.fst = builder.into_map();
101+
import_map.importables = importables.iter().map(|&(&item, _)| item).collect();
98102

99103
Arc::new(import_map)
100104
}

crates/hir_def/src/item_tree.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ use la_arena::{Arena, Idx, IdxRange, RawIdx};
5656
use profile::Count;
5757
use rustc_hash::FxHashMap;
5858
use smallvec::SmallVec;
59+
use stdx::never;
5960
use syntax::{ast, match_ast, SyntaxKind};
6061

6162
use crate::{
@@ -109,18 +110,17 @@ impl ItemTree {
109110
Some(node) => node,
110111
None => return Default::default(),
111112
};
112-
if syntax.kind() == SyntaxKind::ERROR {
113+
if never!(syntax.kind() == SyntaxKind::ERROR) {
113114
// FIXME: not 100% sure why these crop up, but return an empty tree to avoid a panic
114115
return Default::default();
115116
}
116117

117-
let hygiene = Hygiene::new(db.upcast(), file_id);
118-
let ctx = lower::Ctx::new(db, hygiene.clone(), file_id);
118+
let ctx = lower::Ctx::new(db, file_id);
119119
let mut top_attrs = None;
120120
let mut item_tree = match_ast! {
121121
match syntax {
122122
ast::SourceFile(file) => {
123-
top_attrs = Some(RawAttrs::new(db, &file, &hygiene));
123+
top_attrs = Some(RawAttrs::new(db, &file, ctx.hygiene()));
124124
ctx.lower_module_items(&file)
125125
},
126126
ast::MacroItems(items) => {
@@ -147,8 +147,7 @@ impl ItemTree {
147147
fn block_item_tree(db: &dyn DefDatabase, block: BlockId) -> Arc<ItemTree> {
148148
let loc = db.lookup_intern_block(block);
149149
let block = loc.ast_id.to_node(db.upcast());
150-
let hygiene = Hygiene::new(db.upcast(), loc.ast_id.file_id);
151-
let ctx = lower::Ctx::new(db, hygiene, loc.ast_id.file_id);
150+
let ctx = lower::Ctx::new(db, loc.ast_id.file_id);
152151
Arc::new(ctx.lower_block(&block))
153152
}
154153

crates/hir_def/src/item_tree/lower.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,26 @@ fn id<N: ItemTreeNode>(index: Idx<N>) -> FileItemTreeId<N> {
1919
pub(super) struct Ctx<'a> {
2020
db: &'a dyn DefDatabase,
2121
tree: ItemTree,
22-
hygiene: Hygiene,
2322
source_ast_id_map: Arc<AstIdMap>,
2423
body_ctx: crate::body::LowerCtx<'a>,
2524
forced_visibility: Option<RawVisibilityId>,
2625
}
2726

2827
impl<'a> Ctx<'a> {
29-
pub(super) fn new(db: &'a dyn DefDatabase, hygiene: Hygiene, file: HirFileId) -> Self {
28+
pub(super) fn new(db: &'a dyn DefDatabase, file: HirFileId) -> Self {
3029
Self {
3130
db,
3231
tree: ItemTree::default(),
33-
hygiene,
3432
source_ast_id_map: db.ast_id_map(file),
3533
body_ctx: crate::body::LowerCtx::new(db, file),
3634
forced_visibility: None,
3735
}
3836
}
3937

38+
pub(super) fn hygiene(&self) -> &Hygiene {
39+
self.body_ctx.hygiene()
40+
}
41+
4042
pub(super) fn lower_module_items(mut self, item_owner: &dyn HasModuleItem) -> ItemTree {
4143
self.tree.top_level =
4244
item_owner.items().flat_map(|item| self.lower_mod_item(&item)).collect();
@@ -88,7 +90,7 @@ impl<'a> Ctx<'a> {
8890
}
8991

9092
fn lower_mod_item(&mut self, item: &ast::Item) -> Option<ModItem> {
91-
let attrs = RawAttrs::new(self.db, item, &self.hygiene);
93+
let attrs = RawAttrs::new(self.db, item, self.hygiene());
9294
let item: ModItem = match item {
9395
ast::Item::Struct(ast) => self.lower_struct(ast)?.into(),
9496
ast::Item::Union(ast) => self.lower_union(ast)?.into(),
@@ -162,7 +164,7 @@ impl<'a> Ctx<'a> {
162164
for field in fields.fields() {
163165
if let Some(data) = self.lower_record_field(&field) {
164166
let idx = self.data().fields.alloc(data);
165-
self.add_attrs(idx.into(), RawAttrs::new(self.db, &field, &self.hygiene));
167+
self.add_attrs(idx.into(), RawAttrs::new(self.db, &field, self.hygiene()));
166168
}
167169
}
168170
let end = self.next_field_idx();
@@ -182,7 +184,7 @@ impl<'a> Ctx<'a> {
182184
for (i, field) in fields.fields().enumerate() {
183185
let data = self.lower_tuple_field(i, &field);
184186
let idx = self.data().fields.alloc(data);
185-
self.add_attrs(idx.into(), RawAttrs::new(self.db, &field, &self.hygiene));
187+
self.add_attrs(idx.into(), RawAttrs::new(self.db, &field, self.hygiene()));
186188
}
187189
let end = self.next_field_idx();
188190
IdxRange::new(start..end)
@@ -227,7 +229,7 @@ impl<'a> Ctx<'a> {
227229
for variant in variants.variants() {
228230
if let Some(data) = self.lower_variant(&variant) {
229231
let idx = self.data().variants.alloc(data);
230-
self.add_attrs(idx.into(), RawAttrs::new(self.db, &variant, &self.hygiene));
232+
self.add_attrs(idx.into(), RawAttrs::new(self.db, &variant, self.hygiene()));
231233
}
232234
}
233235
let end = self.next_variant_idx();
@@ -270,7 +272,7 @@ impl<'a> Ctx<'a> {
270272
};
271273
let ty = Interned::new(self_type);
272274
let idx = self.data().params.alloc(Param::Normal(None, ty));
273-
self.add_attrs(idx.into(), RawAttrs::new(self.db, &self_param, &self.hygiene));
275+
self.add_attrs(idx.into(), RawAttrs::new(self.db, &self_param, self.hygiene()));
274276
has_self_param = true;
275277
}
276278
for param in param_list.params() {
@@ -294,7 +296,7 @@ impl<'a> Ctx<'a> {
294296
self.data().params.alloc(Param::Normal(name, ty))
295297
}
296298
};
297-
self.add_attrs(idx.into(), RawAttrs::new(self.db, &param, &self.hygiene));
299+
self.add_attrs(idx.into(), RawAttrs::new(self.db, &param, self.hygiene()));
298300
}
299301
}
300302
let end_param = self.next_param_idx();
@@ -427,7 +429,7 @@ impl<'a> Ctx<'a> {
427429
self.with_inherited_visibility(visibility, |this| {
428430
list.assoc_items()
429431
.filter_map(|item| {
430-
let attrs = RawAttrs::new(db, &item, &this.hygiene);
432+
let attrs = RawAttrs::new(db, &item, this.hygiene());
431433
this.lower_assoc_item(&item).map(|item| {
432434
this.add_attrs(ModItem::from(item).into(), attrs);
433435
item
@@ -465,7 +467,7 @@ impl<'a> Ctx<'a> {
465467
.flat_map(|it| it.assoc_items())
466468
.filter_map(|item| {
467469
let assoc = self.lower_assoc_item(&item)?;
468-
let attrs = RawAttrs::new(self.db, &item, &self.hygiene);
470+
let attrs = RawAttrs::new(self.db, &item, self.hygiene());
469471
self.add_attrs(ModItem::from(assoc).into(), attrs);
470472
Some(assoc)
471473
})
@@ -478,7 +480,7 @@ impl<'a> Ctx<'a> {
478480
fn lower_use(&mut self, use_item: &ast::Use) -> Option<FileItemTreeId<Import>> {
479481
let visibility = self.lower_visibility(use_item);
480482
let ast_id = self.source_ast_id_map.ast_id(use_item);
481-
let (use_tree, _) = lower_use_tree(self.db, &self.hygiene, use_item.use_tree()?)?;
483+
let (use_tree, _) = lower_use_tree(self.db, self.hygiene(), use_item.use_tree()?)?;
482484

483485
let res = Import { visibility, ast_id, use_tree };
484486
Some(id(self.data().imports.alloc(res)))
@@ -500,7 +502,7 @@ impl<'a> Ctx<'a> {
500502
}
501503

502504
fn lower_macro_call(&mut self, m: &ast::MacroCall) -> Option<FileItemTreeId<MacroCall>> {
503-
let path = Interned::new(ModPath::from_src(self.db, m.path()?, &self.hygiene)?);
505+
let path = Interned::new(ModPath::from_src(self.db, m.path()?, self.hygiene())?);
504506
let ast_id = self.source_ast_id_map.ast_id(m);
505507
let expand_to = hir_expand::ExpandTo::from_call_site(m);
506508
let res = MacroCall { path, ast_id, expand_to };
@@ -535,7 +537,7 @@ impl<'a> Ctx<'a> {
535537
// (in other words, the knowledge that they're in an extern block must not be used).
536538
// This is because an extern block can contain macros whose ItemTree's top-level items
537539
// should be considered to be in an extern block too.
538-
let attrs = RawAttrs::new(self.db, &item, &self.hygiene);
540+
let attrs = RawAttrs::new(self.db, &item, self.hygiene());
539541
let id: ModItem = match item {
540542
ast::ExternItem::Fn(ast) => {
541543
let func_id = self.lower_function(&ast)?;
@@ -616,7 +618,9 @@ impl<'a> Ctx<'a> {
616618
fn lower_visibility(&mut self, item: &dyn ast::HasVisibility) -> RawVisibilityId {
617619
let vis = match self.forced_visibility {
618620
Some(vis) => return vis,
619-
None => RawVisibility::from_ast_with_hygiene(self.db, item.visibility(), &self.hygiene),
621+
None => {
622+
RawVisibility::from_ast_with_hygiene(self.db, item.visibility(), self.hygiene())
623+
}
620624
};
621625

622626
self.data().vis.alloc(vis)

crates/ide_completion/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ impl<'a> CompletionContext<'a> {
302302

303303
/// A version of [`SemanticsScope::process_all_names`] that filters out `#[doc(hidden)]` items.
304304
pub(crate) fn process_all_names(&self, f: &mut dyn FnMut(Name, ScopeDef)) {
305+
let _p = profile::span("CompletionContext::process_all_names");
305306
self.scope.process_all_names(&mut |name, def| {
306307
if self.is_scope_def_hidden(def) {
307308
return;
@@ -422,6 +423,7 @@ impl<'a> CompletionContext<'a> {
422423
mut offset: TextSize,
423424
mut fake_ident_token: SyntaxToken,
424425
) {
426+
let _p = profile::span("CompletionContext::expand_and_fill");
425427
loop {
426428
// Expand attributes
427429
if let (Some(actual_item), Some(item_with_fake_ident)) = (

editors/code/package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editors/code/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"Programming Languages"
2222
],
2323
"engines": {
24-
"vscode": "^1.62.0"
24+
"vscode": "^1.63.0"
2525
},
2626
"enableProposedApi": true,
2727
"scripts": {
@@ -44,7 +44,7 @@
4444
},
4545
"devDependencies": {
4646
"@types/node": "~14.17.5",
47-
"@types/vscode": "~1.62.0",
47+
"@types/vscode": "~1.63.0",
4848
"@typescript-eslint/eslint-plugin": "^5.5.0",
4949
"@typescript-eslint/parser": "^5.5.0",
5050
"@vscode/test-electron": "^1.6.2",

editors/code/src/ast_inspector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class AstInspector implements vscode.HoverProvider, vscode.DefinitionProv
5959
}
6060
}
6161

62-
private onDidChangeVisibleTextEditors(editors: vscode.TextEditor[]) {
62+
private onDidChangeVisibleTextEditors(editors: readonly vscode.TextEditor[]) {
6363
if (!this.findAstTextEditor()) {
6464
this.setRustEditor(undefined);
6565
return;

editors/code/src/lsp_ext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export interface SsrParams {
125125
parseOnly: boolean;
126126
textDocument: lc.TextDocumentIdentifier;
127127
position: lc.Position;
128-
selections: lc.Range[];
128+
selections: readonly lc.Range[];
129129
}
130130
export const ssr = new lc.RequestType<SsrParams, lc.WorkspaceEdit, void>('experimental/ssr');
131131

0 commit comments

Comments
 (0)