Skip to content

⬆️ rust-analyzer #112784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 104 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
67f1c3c
autopublish: Offset version number
davidlattimore May 17, 2023
fe8f862
made the `add_missing_impl_members` and `add_missing_default_members`…
ponyii May 22, 2023
7f45ccc
lifetime transformation: refactoring & a new test
ponyii May 28, 2023
e6e72bf
Migrate `add_missing_impl_members` to mutable ast
DropDemBits Jun 5, 2023
dd5f055
Migrate `extract_type_alias` to mutable ast
DropDemBits Jun 5, 2023
c48062f
Merge commit 'aa9bc8612514d216f84eec218dfd19ab83f3598a' into sync-fro…
lnicola Jun 5, 2023
bbd6955
Merge commit 'ed87e0a20a9d196a5ea659ea46ae9574be666d4f' into sync-fro…
lnicola Jun 5, 2023
338f969
Merge remote-tracking branch 'upstream/master' into sync-from-rust
lnicola Jun 5, 2023
d42d55f
Auto merge of #14988 - lnicola:sync-from-rust, r=lnicola
bors Jun 5, 2023
094c1e7
feat: inline const expr as static str
viktorlott May 29, 2023
8103a10
update assist to include more literals
viktorlott May 30, 2023
2d4cb78
fix: Use render_eval for all builtins
viktorlott Jun 4, 2023
eef716d
fix: use render_eval instead of inlined expr
viktorlott Jun 5, 2023
ef09558
fix: Fix ci never running on nightly when proc-macro things change
Veykril Jun 6, 2023
f3145dc
Auto merge of #14994 - Veykril:ci-fix, r=Veykril
bors Jun 6, 2023
058e2d2
Auto merge of #14925 - viktorlott:inline-const-expr-as-static-str, r=…
bors Jun 6, 2023
a6bef78
fix: Fix proc-macro slow test
Veykril Jun 7, 2023
1c25885
Auto merge of #14995 - Veykril:proc-macro-slow-test, r=lnicola
bors Jun 7, 2023
08ef169
Fix dependency warning
lnicola Jun 7, 2023
4f0c6fa
fix: only generate trait bound for associated types in field types
lowr Jun 7, 2023
085a311
Auto merge of #15000 - lowr:fix/builtin-derive-bound-for-assoc, r=HKa…
bors Jun 7, 2023
cdab350
Add span to group.
jneem Jun 3, 2023
ad2a0d1
Add configurable proc-macro-srv path for diagnostics
jneem Jun 6, 2023
dac660d
Fix typo in reload.rs
beyarkay Jun 7, 2023
dcab226
Auto merge of #15005 - beyarkay:rebuild-to-rebuilt-typo, r=lnicola
bors Jun 7, 2023
30e16e2
Fix unwrap on None in expanding format args
HKalbasi Jun 7, 2023
9157927
Auto merge of #15006 - HKalbasi:format-panic, r=HKalbasi
bors Jun 7, 2023
32768fe
Infer return type for async function in `generate_function`
lowr Jun 8, 2023
9c03aa1
Auto merge of #14997 - lnicola:fix-warning, r=Veykril
bors Jun 8, 2023
5da1423
Document the sysroot field in JsonProject
Wilfred Jun 8, 2023
9973b11
Auto merge of #15012 - lowr:patch/generate-fn-async-ret-ty, r=HKalbasi
bors Jun 9, 2023
a02b9b2
internal: Lazy eager macros
Veykril Jun 7, 2023
2796851
Auto merge of #14998 - Veykril:eager-mapping, r=Veykril
bors Jun 9, 2023
425619d
Auto merge of #15014 - Wilfred:document_sysroot, r=Veykril
bors Jun 9, 2023
60d952e
Auto merge of #14979 - DropDemBits:structure-snippets-migrate-1, r=Ve…
bors Jun 9, 2023
6fbf6ef
Fix panic in displaying const trait objects
HKalbasi Jun 9, 2023
993299e
Auto merge of #15019 - HKalbasi:nightly-mir-eval-panic, r=HKalbasi
bors Jun 9, 2023
b6fb35f
Shrink hir_expand::attr::AttrInput by boxing a variant
Veykril Jun 9, 2023
ccce893
Count query entries in memory usage command
Veykril Jun 9, 2023
5f8a6f6
Auto merge of #15020 - Veykril:perf2, r=Veykril
bors Jun 9, 2023
1dd76e8
Fix panic in displaying unsized structs
HKalbasi Jun 10, 2023
49b4f15
Auto merge of #15022 - HKalbasi:nightly-mir-eval-panic, r=HKalbasi
bors Jun 10, 2023
489eeab
Auto merge of #14960 - jneem:group-delim-span, r=Veykril
bors Jun 10, 2023
cee7a72
Auto merge of #14827 - davidlattimore:autopublish-offset, r=Veykril
bors Jun 10, 2023
95228d2
Auto merge of #14875 - ponyii:fix/implement-missing-members-do-not-tr…
bors Jun 10, 2023
78fab7d
format documentation for `SignatureHelpRequest`s
max-heller Jun 4, 2023
68bdf60
Auto merge of #14974 - max-heller:issue-14958, r=lowr
bors Jun 10, 2023
a481e00
Lower const params with a bad id
HKalbasi Jun 5, 2023
d9136df
Handle return types for in type const bodies
HKalbasi Jun 6, 2023
f8594f7
Use `ConstArg` instead of `Expr` for `AstId` of `InTypeConstId`
HKalbasi Jun 8, 2023
e83b567
Flatten the `TypeOwnerId`
HKalbasi Jun 10, 2023
008f506
fix(assist): derive source scope from syntax node to be transformed
lowr Jun 5, 2023
d091991
fix(completion): derive source scope from syntax node to be transformed
lowr Jun 5, 2023
c3bab96
Auto merge of #14989 - lowr:fix/nested-macro-in-assoc-item-panic, r=V…
bors Jun 11, 2023
ed8c58a
Remove commented out conflicts
lowr Jun 11, 2023
b7497fc
Auto merge of #15025 - lowr:fix/nested-macro-in-assoc-item-panic, r=l…
bors Jun 11, 2023
b479550
autoderef: completely resolve and deduplicate types
lowr Jun 11, 2023
42eab5e
Deduplicate field names for completion
lowr Jun 11, 2023
52bb94d
internal: Give rustfmt jobs a separate thread
Veykril Jun 11, 2023
179b8d7
Formatting
Veykril Jun 11, 2023
d567091
Auto merge of #15028 - Veykril:rustfmt-thread, r=Veykril
bors Jun 11, 2023
a469578
Add a bunch of fixme comments
HKalbasi Jun 11, 2023
942b392
Exclude Markdown injection grammar from .vscodeignore.
AndreasBackx Jun 12, 2023
38c47df
Auto merge of #15032 - AndreasBackx:fix/vscode-markdown, r=lnicola
bors Jun 12, 2023
dcd3155
Auto merge of #14932 - HKalbasi:dev, r=HKalbasi
bors Jun 12, 2023
6b3659d
Auto merge of #15026 - lowr:fix/deduplicate-compl-fields, r=Veykril
bors Jun 12, 2023
5ce65a1
the "implement missing members" assist's const transformation impleme…
ponyii Jun 12, 2023
abe2495
internal: Give ConstBlockId and InTypeConstId named Location types
Veykril Jun 12, 2023
1f1fe81
Auto merge of #15036 - Veykril:const-param-intern-cleanup, r=Veykril
bors Jun 12, 2023
0b441ca
Use a more obscure hasher name in derive expansion
lnicola Jun 13, 2023
07bc6cb
Auto merge of #15040 - lnicola:hash-state-name, r=Veykril
bors Jun 13, 2023
d01283b
Deduplicate tuple indices for completion
lowr Jun 13, 2023
25f1c72
Auto merge of #15044 - lowr:fix/deduplicate-compl-fields, r=lnicola
bors Jun 13, 2023
b322805
internal: Record file dependencies in crate graph construction
Veykril Jun 13, 2023
f8dec25
Auto merge of #15047 - Veykril:crate-graph-root-deps, r=Veykril
bors Jun 13, 2023
6d6354e
Rename minicore ArgumentV1 to match libcore
lnicola Jun 14, 2023
51939db
Auto merge of #15052 - lnicola:fmt-arguments, r=Veykril
bors Jun 14, 2023
b07490f
made the `add_missing_impl_members` and `add_missing_default_members`…
ponyii Jun 14, 2023
cf178cb
internal: Add a CrateRootModuleId that encodes a module id that is al…
Veykril Jun 13, 2023
9c967d3
Auto merge of #15053 - Veykril:crate-root-module-id, r=Veykril
bors Jun 14, 2023
922be87
Add more log in "terminator is none" assert
HKalbasi Jun 15, 2023
ff864fb
Auto merge of #15058 - HKalbasi:more-log, r=HKalbasi
bors Jun 15, 2023
8a3c214
refactoring
ponyii Jun 15, 2023
8cc55bf
doc: remove duplicated words
AlPha5130 Jun 16, 2023
689f964
Auto merge of #15062 - AlPha5130:master, r=lnicola
bors Jun 16, 2023
527dfed
Support `Pointee` trait
HKalbasi Apr 30, 2023
0cad484
Auto merge of #14693 - HKalbasi:pointee-trait, r=HKalbasi
bors Jun 16, 2023
7e08933
the "implement missing members" assist's const transformation patched
ponyii Jun 15, 2023
3484b5a
internal: Do not allocate unnecessarily when importing macros from pa…
Veykril Jun 16, 2023
bd093d1
Sort methods in generate_delegate_methods listing
Veykril Jun 16, 2023
4143890
Auto merge of #15065 - Veykril:remove-alloc, r=Veykril
bors Jun 16, 2023
76acf3b
internal: Analyze all bodies in analysis-stats, not just functions
Veykril Jun 16, 2023
bd762e6
internal: Add more context to overly long loop turn message
Veykril Jun 16, 2023
a5a71c7
Auto merge of #15067 - Veykril:loop-turn-msgh, r=Veykril
bors Jun 16, 2023
fdba1b6
Auto merge of #15066 - Veykril:analysis-stats, r=Veykril
bors Jun 17, 2023
64a8887
Add body lowering step, track time of each step separtely
Veykril Jun 17, 2023
b5e0452
Lazy progress reporting
Veykril Jun 17, 2023
fcfc6af
Auto merge of #15069 - Veykril:analysis-stat-stuff, r=Veykril
bors Jun 17, 2023
a1b536e
Auto merge of #15054 - ponyii:fix/implement-missing-members-do-not-tr…
bors Jun 18, 2023
83d7724
fix: Add binding definition for for-expr iterator desugared binding
Veykril Jun 18, 2023
5dccf30
Auto merge of #15075 - Veykril:bindings, r=Veykril
bors Jun 18, 2023
c318620
Shrink size of hir::Binding
Veykril Jun 18, 2023
cd3bf9f
Auto merge of #15076 - Veykril:bindings, r=Veykril
bors Jun 18, 2023
4004f5a
Merge commit 'cd3bf9fe51676b520c546460e6d8919b8c8ff99f' into sync-fro…
lnicola Jun 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/tools/rust-analyzer/.github/workflows/autopublish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Publish Crates
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
PATCH: ${{ github.run_number }}
RUN_NUMBER: ${{ github.run_number }}
shell: bash
run: |
git config --global user.email "[email protected]"
Expand All @@ -53,4 +53,4 @@ jobs:
# Remove library crates from the workspaces so we don't auto-publish them as well
sed -i 's/ "lib\/\*",//' ./Cargo.toml
find crates/rust-analyzer -type f -name '*.rs' -exec sed -i 's/rust_analyzer/ra_ap_rust_analyzer/g' {} +
cargo workspaces publish --yes --force '*' --exact --no-git-commit --allow-dirty --skip-published custom 0.0.$PATCH
cargo workspaces publish --yes --force '*' --exact --no-git-commit --allow-dirty --skip-published custom 0.0.$(($RUN_NUMBER + 133))
8 changes: 5 additions & 3 deletions src/tools/rust-analyzer/.github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
pull-requests: read
outputs:
typescript: ${{ steps.filter.outputs.typescript }}
proc_macros: ${{ steps.filter.outputs.proc_macros }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@4067d885736b84de7c414f582ac45897079b0a78
Expand All @@ -45,8 +46,8 @@ jobs:
runs-on: ${{ matrix.os }}
env:
CC: deny_c
RUST_CHANNEL: "${{ needs.changes.outputs.proc_macros == 'true' && 'nightly' || 'stable'}}"
USE_SYSROOT_ABI: "${{ needs.changes.outputs.proc_macros == 'true' && '--features sysroot-abi' || ''}}"
RUST_CHANNEL: "${{ needs.changes.outputs.proc_macros == 'true' && 'nightly' || 'stable' }}"
USE_SYSROOT_ABI: "${{ needs.changes.outputs.proc_macros == 'true' && '--features sysroot-abi' || '' }}"

strategy:
fail-fast: false
Expand All @@ -62,7 +63,8 @@ jobs:
- name: Install Rust toolchain
run: |
rustup update --no-self-update ${{ env.RUST_CHANNEL }}
rustup component add rustfmt rust-src
rustup component add --toolchain ${{ env.RUST_CHANNEL }} rustfmt rust-src
rustup default ${{ env.RUST_CHANNEL }}

- name: Cache Dependencies
uses: Swatinem/rust-cache@988c164c3d0e93c4dbab36aaf5bbeb77425b2894
Expand Down
48 changes: 29 additions & 19 deletions src/tools/rust-analyzer/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "chalk-derive"
version = "0.89.0"
version = "0.91.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea176c50987dc4765961aa165001e8eb5a722a26308c5797a47303ea91686aab"
checksum = "c59178fded594fe78c47b841520e5a4399d00fe15fffee19b945958a878cd02d"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.15",
"synstructure",
]

[[package]]
name = "chalk-ir"
version = "0.89.0"
version = "0.91.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "473b480241695428c14e8f84f1c9a47ef232450a50faf3a4041e5c9dc11e0a3b"
checksum = "8824be92876823b828d551bb792f79eb1f69c69d1948abf69fccbf84e448e57b"
dependencies = [
"bitflags 1.3.2",
"chalk-derive",
Expand All @@ -200,9 +200,9 @@ dependencies = [

[[package]]
name = "chalk-recursive"
version = "0.89.0"
version = "0.91.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6764b4fe67cac3a3758185084efbfbd39bf0352795824ba849ddd2b64cd4bb28"
checksum = "1e110d1260809c238072d1c8ef84060e39983e8ea9d4c6f74b19b0ebbf8904dc"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand All @@ -213,9 +213,9 @@ dependencies = [

[[package]]
name = "chalk-solve"
version = "0.89.0"
version = "0.91.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55a7e6160966eceb6e7dcc2f479a2af4c477aaf5bccbc640d82515995ab1a6cc"
checksum = "12200b19abf4b0633095f7bd099f3ef609d314754b6adb358c68cc04d10589e5"
dependencies = [
"chalk-derive",
"chalk-ir",
Expand Down Expand Up @@ -327,7 +327,7 @@ checksum = "f3cdeb9ec472d588e539a818b2dee436825730da08ad0017c4b1a17676bdc8b7"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]

[[package]]
Expand Down Expand Up @@ -1505,7 +1505,6 @@ dependencies = [
"parking_lot 0.12.1",
"parking_lot_core 0.9.6",
"proc-macro-api",
"proc-macro-srv-cli",
"profile",
"project-model",
"rayon",
Expand Down Expand Up @@ -1578,7 +1577,7 @@ dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]

[[package]]
Expand Down Expand Up @@ -1637,7 +1636,7 @@ checksum = "d7e29c4601e36bcec74a223228dce795f4cd3616341a4af93520ca1a837c087d"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]

[[package]]
Expand All @@ -1660,7 +1659,7 @@ checksum = "395627de918015623b32e7669714206363a7fc00382bf477e72c1f7533e8eafc"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]

[[package]]
Expand Down Expand Up @@ -1730,15 +1729,26 @@ dependencies = [
"unicode-ident",
]

[[package]]
name = "syn"
version = "2.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]

[[package]]
name = "synstructure"
version = "0.12.6"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f"
checksum = "285ba80e733fac80aa4270fbcdf83772a79b80aa35c97075320abfee4a915b06"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.15",
"unicode-xid",
]

Expand Down Expand Up @@ -1811,7 +1821,7 @@ checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]

[[package]]
Expand Down Expand Up @@ -1913,7 +1923,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]

[[package]]
Expand Down
6 changes: 3 additions & 3 deletions src/tools/rust-analyzer/crates/base-db/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl ChangeFixture {
None,
default_cfg,
Default::default(),
Env::default(),
Env::new_for_test_fixture(),
false,
CrateOrigin::Local { repo: None, name: None },
default_target_data_layout
Expand Down Expand Up @@ -259,7 +259,7 @@ impl ChangeFixture {
None,
Default::default(),
Default::default(),
Env::default(),
Env::new_for_test_fixture(),
false,
CrateOrigin::Lang(LangCrateOrigin::Core),
target_layout.clone(),
Expand Down Expand Up @@ -298,7 +298,7 @@ impl ChangeFixture {
None,
Default::default(),
Default::default(),
Env::default(),
Env::new_for_test_fixture(),
true,
CrateOrigin::Local { repo: None, name: None },
target_layout,
Expand Down
23 changes: 23 additions & 0 deletions src/tools/rust-analyzer/crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ pub enum CrateOrigin {
Lang(LangCrateOrigin),
}

impl CrateOrigin {
pub fn is_local(&self) -> bool {
matches!(self, CrateOrigin::Local { .. })
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum LangCrateOrigin {
Alloc,
Expand Down Expand Up @@ -333,6 +339,17 @@ pub struct Env {
entries: FxHashMap<String, String>,
}

impl Env {
pub fn new_for_test_fixture() -> Self {
Env {
entries: FxHashMap::from_iter([(
String::from("__ra_is_test_fixture"),
String::from("__ra_is_test_fixture"),
)]),
}
}
}

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Dependency {
pub crate_id: CrateId,
Expand Down Expand Up @@ -456,6 +473,12 @@ impl CrateGraph {
self.arena.iter().map(|(idx, _)| idx)
}

// FIXME: used for `handle_hack_cargo_workspace`, should be removed later
#[doc(hidden)]
pub fn iter_mut(&mut self) -> impl Iterator<Item = (CrateId, &mut CrateData)> + '_ {
self.arena.iter_mut()
}

/// Returns an iterator over all transitive dependencies of the given crate,
/// including the crate itself.
pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> {
Expand Down
50 changes: 36 additions & 14 deletions src/tools/rust-analyzer/crates/hir-def/src/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub struct Body {
pub pats: Arena<Pat>,
pub bindings: Arena<Binding>,
pub labels: Arena<Label>,
/// Id of the closure/generator that owns the corresponding binding. If a binding is owned by the
/// top level expression, it will not be listed in here.
pub binding_owners: FxHashMap<BindingId, ExprId>,
/// The patterns for the function's parameters. While the parameter types are
/// part of the function signature, the patterns are not (they don't change
/// the external type of the function).
Expand Down Expand Up @@ -118,7 +121,8 @@ impl Body {
let _p = profile::span("body_with_source_map_query");
let mut params = None;

let (file_id, module, body, is_async_fn) = {
let mut is_async_fn = false;
let InFile { file_id, value: body } = {
match def {
DefWithBodyId::FunctionId(f) => {
let data = db.function_data(f);
Expand All @@ -138,31 +142,27 @@ impl Body {
}),
)
});
(
src.file_id,
f.module(db),
src.value.body().map(ast::Expr::from),
data.has_async_kw(),
)
is_async_fn = data.has_async_kw();
src.map(|it| it.body().map(ast::Expr::from))
}
DefWithBodyId::ConstId(c) => {
let c = c.lookup(db);
let src = c.source(db);
(src.file_id, c.module(db), src.value.body(), false)
src.map(|it| it.body())
}
DefWithBodyId::StaticId(s) => {
let s = s.lookup(db);
let src = s.source(db);
(src.file_id, s.module(db), src.value.body(), false)
src.map(|it| it.body())
}
DefWithBodyId::VariantId(v) => {
let e = v.parent.lookup(db);
let src = v.parent.child_source(db);
let variant = &src.value[v.local_id];
(src.file_id, e.container, variant.expr(), false)
src.map(|it| it[v.local_id].expr())
}
DefWithBodyId::InTypeConstId(c) => c.lookup(db).id.map(|_| c.source(db).expr()),
}
};
let module = def.module(db);
let expander = Expander::new(db, file_id, module);
let (mut body, source_map) =
Body::new(db, def, expander, params, body, module.krate, is_async_fn);
Expand Down Expand Up @@ -209,14 +209,24 @@ impl Body {
}

fn shrink_to_fit(&mut self) {
let Self { _c: _, body_expr: _, block_scopes, exprs, labels, params, pats, bindings } =
self;
let Self {
_c: _,
body_expr: _,
block_scopes,
exprs,
labels,
params,
pats,
bindings,
binding_owners,
} = self;
block_scopes.shrink_to_fit();
exprs.shrink_to_fit();
labels.shrink_to_fit();
params.shrink_to_fit();
pats.shrink_to_fit();
bindings.shrink_to_fit();
binding_owners.shrink_to_fit();
}

pub fn walk_bindings_in_pat(&self, pat_id: PatId, mut f: impl FnMut(BindingId)) {
Expand Down Expand Up @@ -260,6 +270,17 @@ impl Body {
f(pat_id);
self.walk_pats_shallow(pat_id, |p| self.walk_pats(p, f));
}

pub fn is_binding_upvar(&self, binding: BindingId, relative_to: ExprId) -> bool {
match self.binding_owners.get(&binding) {
Some(x) => {
// We assign expression ids in a way that outer closures will receive
// a lower id
x.into_raw() < relative_to.into_raw()
}
None => true,
}
}
}

impl Default for Body {
Expand All @@ -272,6 +293,7 @@ impl Default for Body {
labels: Default::default(),
params: Default::default(),
block_scopes: Default::default(),
binding_owners: Default::default(),
_c: Default::default(),
}
}
Expand Down
Loading