Skip to content

Commit 6903a84

Browse files
authored
Rollup merge of #101497 - lnicola:rust-analyzer-2022-09-06, r=lnicola
⬆️ rust-analyzer r? `@ghost`
2 parents 1bc6110 + d058800 commit 6903a84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2934
-908
lines changed

src/tools/rust-analyzer/.github/workflows/ci.yaml

+78-78
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66
pull_request:
77
push:
88
branches:
9-
- auto
10-
- try
9+
- auto
10+
- try
1111

1212
env:
1313
CARGO_INCREMENTAL: 0
1414
CARGO_NET_RETRY: 10
1515
CI: 1
1616
RUST_BACKTRACE: short
17-
RUSTFLAGS: "-D warnings -W unreachable-pub -W rust-2021-compatibility"
17+
RUSTFLAGS: "-D warnings -W unreachable-pub -W bare-trait-objects"
1818
RUSTUP_MAX_RETRIES: 10
1919

2020
jobs:
@@ -31,25 +31,25 @@ jobs:
3131
os: [ubuntu-latest, windows-latest, macos-latest]
3232

3333
steps:
34-
- name: Checkout repository
35-
uses: actions/checkout@v3
36-
with:
37-
ref: ${{ github.event.pull_request.head.sha }}
38-
fetch-depth: 20
34+
- name: Checkout repository
35+
uses: actions/checkout@v3
36+
with:
37+
ref: ${{ github.event.pull_request.head.sha }}
38+
fetch-depth: 20
3939

40-
- name: Install Rust toolchain
41-
run: |
42-
rustup update --no-self-update stable
43-
rustup component add rustfmt rust-src
40+
- name: Install Rust toolchain
41+
run: |
42+
rustup update --no-self-update stable
43+
rustup component add rustfmt rust-src
4444
45-
- name: Cache Dependencies
46-
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
45+
- name: Cache Dependencies
46+
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
4747

48-
- name: Compile
49-
run: cargo test --no-run --locked
48+
- name: Compile
49+
run: cargo test --no-run --locked
5050

51-
- name: Test
52-
run: cargo test -- --nocapture --quiet
51+
- name: Test
52+
run: cargo test -- --nocapture --quiet
5353

5454
# Weird targets to catch non-portable code
5555
rust-cross:
@@ -64,25 +64,25 @@ jobs:
6464
targets_ide: "wasm32-unknown-unknown"
6565

6666
steps:
67-
- name: Checkout repository
68-
uses: actions/checkout@v3
69-
70-
- name: Install Rust toolchain
71-
run: |
72-
rustup update --no-self-update stable
73-
rustup target add ${{ env.targets }} ${{ env.targets_ide }}
74-
75-
- name: Cache Dependencies
76-
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
77-
78-
- name: Check
79-
run: |
80-
for target in ${{ env.targets }}; do
81-
cargo check --target=$target --all-targets
82-
done
83-
for target in ${{ env.targets_ide }}; do
84-
cargo check -p ide --target=$target --all-targets
85-
done
67+
- name: Checkout repository
68+
uses: actions/checkout@v3
69+
70+
- name: Install Rust toolchain
71+
run: |
72+
rustup update --no-self-update stable
73+
rustup target add ${{ env.targets }} ${{ env.targets_ide }}
74+
75+
- name: Cache Dependencies
76+
uses: Swatinem/rust-cache@ce325b60658c1b38465c06cc965b79baf32c1e72
77+
78+
- name: Check
79+
run: |
80+
for target in ${{ env.targets }}; do
81+
cargo check --target=$target --all-targets
82+
done
83+
for target in ${{ env.targets_ide }}; do
84+
cargo check -p ide --target=$target --all-targets
85+
done
8686
8787
typescript:
8888
if: github.repository == 'rust-lang/rust-analyzer'
@@ -95,47 +95,47 @@ jobs:
9595
runs-on: ${{ matrix.os }}
9696

9797
steps:
98-
- name: Checkout repository
99-
uses: actions/checkout@v3
100-
101-
- name: Install Nodejs
102-
uses: actions/setup-node@v1
103-
with:
104-
node-version: 16.x
105-
106-
- name: Install xvfb
107-
if: matrix.os == 'ubuntu-latest'
108-
run: sudo apt-get install -y xvfb
109-
110-
- run: npm ci
111-
working-directory: ./editors/code
112-
113-
# - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
114-
# if: runner.os == 'Linux'
115-
# working-directory: ./editors/code
116-
117-
- run: npm run lint
118-
working-directory: ./editors/code
119-
120-
- name: Run VS Code tests (Linux)
121-
if: matrix.os == 'ubuntu-latest'
122-
env:
123-
VSCODE_CLI: 1
124-
run: xvfb-run npm test
125-
working-directory: ./editors/code
126-
127-
- name: Run VS Code tests (Windows)
128-
if: matrix.os == 'windows-latest'
129-
env:
130-
VSCODE_CLI: 1
131-
run: npm test
132-
working-directory: ./editors/code
133-
134-
- run: npm run pretest
135-
working-directory: ./editors/code
136-
137-
- run: npm run package --scripts-prepend-node-path
138-
working-directory: ./editors/code
98+
- name: Checkout repository
99+
uses: actions/checkout@v3
100+
101+
- name: Install Nodejs
102+
uses: actions/setup-node@v1
103+
with:
104+
node-version: 16.x
105+
106+
- name: Install xvfb
107+
if: matrix.os == 'ubuntu-latest'
108+
run: sudo apt-get install -y xvfb
109+
110+
- run: npm ci
111+
working-directory: ./editors/code
112+
113+
# - run: npm audit || { sleep 10 && npm audit; } || { sleep 30 && npm audit; }
114+
# if: runner.os == 'Linux'
115+
# working-directory: ./editors/code
116+
117+
- run: npm run lint
118+
working-directory: ./editors/code
119+
120+
- name: Run VS Code tests (Linux)
121+
if: matrix.os == 'ubuntu-latest'
122+
env:
123+
VSCODE_CLI: 1
124+
run: xvfb-run npm test
125+
working-directory: ./editors/code
126+
127+
- name: Run VS Code tests (Windows)
128+
if: matrix.os == 'windows-latest'
129+
env:
130+
VSCODE_CLI: 1
131+
run: npm test
132+
working-directory: ./editors/code
133+
134+
- run: npm run pretest
135+
working-directory: ./editors/code
136+
137+
- run: npm run package --scripts-prepend-node-path
138+
working-directory: ./editors/code
139139

140140
end-success:
141141
name: bors build finished

src/tools/rust-analyzer/.github/workflows/release.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ jobs:
248248
if: github.ref == 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
249249
working-directory: ./editors/code
250250
# token from https://dev.azure.com/rust-analyzer/
251-
run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix
251+
run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix || true
252252

253253
- name: Publish Extension (Code Marketplace, nightly)
254254
if: github.ref != 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
@@ -258,4 +258,4 @@ jobs:
258258
- name: Publish Extension (OpenVSX, nightly)
259259
if: github.ref != 'refs/heads/release' && (github.repository == 'rust-analyzer/rust-analyzer' || github.repository == 'rust-lang/rust-analyzer')
260260
working-directory: ./editors/code
261-
run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix
261+
run: npx ovsx publish --pat ${{ secrets.OPENVSX_TOKEN }} --packagePath ../../dist/rust-analyzer-*.vsix || true

src/tools/rust-analyzer/crates/hir-def/src/body.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ pub type PatSource = InFile<PatPtr>;
250250

251251
pub type LabelPtr = AstPtr<ast::Label>;
252252
pub type LabelSource = InFile<LabelPtr>;
253+
254+
pub type FieldPtr = AstPtr<ast::RecordExprField>;
255+
pub type FieldSource = InFile<FieldPtr>;
256+
253257
/// An item body together with the mapping from syntax nodes to HIR expression
254258
/// IDs. This is needed to go from e.g. a position in a file to the HIR
255259
/// expression containing it; but for type inference etc., we want to operate on
@@ -264,18 +268,18 @@ pub type LabelSource = InFile<LabelPtr>;
264268
#[derive(Default, Debug, Eq, PartialEq)]
265269
pub struct BodySourceMap {
266270
expr_map: FxHashMap<ExprSource, ExprId>,
267-
expr_map_back: ArenaMap<ExprId, Result<ExprSource, SyntheticSyntax>>,
271+
expr_map_back: ArenaMap<ExprId, ExprSource>,
268272

269273
pat_map: FxHashMap<PatSource, PatId>,
270-
pat_map_back: ArenaMap<PatId, Result<PatSource, SyntheticSyntax>>,
274+
pat_map_back: ArenaMap<PatId, PatSource>,
271275

272276
label_map: FxHashMap<LabelSource, LabelId>,
273277
label_map_back: ArenaMap<LabelId, LabelSource>,
274278

275279
/// We don't create explicit nodes for record fields (`S { record_field: 92 }`).
276280
/// Instead, we use id of expression (`92`) to identify the field.
277-
field_map: FxHashMap<InFile<AstPtr<ast::RecordExprField>>, ExprId>,
278-
field_map_back: FxHashMap<ExprId, InFile<AstPtr<ast::RecordExprField>>>,
281+
field_map: FxHashMap<FieldSource, ExprId>,
282+
field_map_back: FxHashMap<ExprId, FieldSource>,
279283

280284
expansions: FxHashMap<InFile<AstPtr<ast::MacroCall>>, HirFileId>,
281285

@@ -420,7 +424,7 @@ impl Index<LabelId> for Body {
420424
// Perhaps `expr_syntax` and `expr_id`?
421425
impl BodySourceMap {
422426
pub fn expr_syntax(&self, expr: ExprId) -> Result<ExprSource, SyntheticSyntax> {
423-
self.expr_map_back[expr].clone()
427+
self.expr_map_back.get(expr).cloned().ok_or(SyntheticSyntax)
424428
}
425429

426430
pub fn node_expr(&self, node: InFile<&ast::Expr>) -> Option<ExprId> {
@@ -434,7 +438,7 @@ impl BodySourceMap {
434438
}
435439

436440
pub fn pat_syntax(&self, pat: PatId) -> Result<PatSource, SyntheticSyntax> {
437-
self.pat_map_back[pat].clone()
441+
self.pat_map_back.get(pat).cloned().ok_or(SyntheticSyntax)
438442
}
439443

440444
pub fn node_pat(&self, node: InFile<&ast::Pat>) -> Option<PatId> {
@@ -456,9 +460,10 @@ impl BodySourceMap {
456460
self.label_map.get(&src).cloned()
457461
}
458462

459-
pub fn field_syntax(&self, expr: ExprId) -> InFile<AstPtr<ast::RecordExprField>> {
463+
pub fn field_syntax(&self, expr: ExprId) -> FieldSource {
460464
self.field_map_back[&expr].clone()
461465
}
466+
462467
pub fn node_field(&self, node: InFile<&ast::RecordExprField>) -> Option<ExprId> {
463468
let src = node.map(AstPtr::new);
464469
self.field_map.get(&src).cloned()

0 commit comments

Comments
 (0)