rbs 4.0.1 → 4.1.0.pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +2 -0
- data/.github/workflows/bundle-update.yml +4 -1
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/milestone.yml +80 -0
- data/.github/workflows/ruby.yml +34 -0
- data/.github/workflows/rust.yml +93 -7
- data/.gitignore +4 -0
- data/CHANGELOG.md +21 -0
- data/Rakefile +209 -2
- data/config.yml +24 -0
- data/core/builtin.rbs +1 -0
- data/core/class.rbs +5 -3
- data/core/kernel.rbs +26 -11
- data/core/ruby_vm.rbs +40 -0
- data/docs/inline.md +29 -1
- data/docs/rust.md +96 -0
- data/ext/rbs_extension/ast_translation.c +21 -0
- data/ext/rbs_extension/class_constants.c +2 -0
- data/ext/rbs_extension/class_constants.h +1 -0
- data/ext/rbs_extension/extconf.rb +1 -0
- data/include/rbs/ast.h +314 -297
- data/include/rbs/defines.h +13 -0
- data/include/rbs/lexer.h +1 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +27 -31
- data/lib/rbs/ast/ruby/annotations.rb +42 -0
- data/lib/rbs/ast/ruby/declarations.rb +11 -1
- data/lib/rbs/ast/ruby/members.rb +28 -0
- data/lib/rbs/cli.rb +3 -5
- data/lib/rbs/collection/config/lockfile_generator.rb +16 -3
- data/lib/rbs/environment.rb +6 -0
- data/lib/rbs/inline_parser.rb +49 -25
- data/lib/rbs/rewriter.rb +70 -0
- data/lib/rbs/test/type_check.rb +6 -1
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -0
- data/sig/annotate/rdoc_annotater.rbs +12 -9
- data/sig/ast/ruby/annotations.rbs +49 -0
- data/sig/ast/ruby/members.rbs +15 -0
- data/sig/collection/config/lockfile_generator.rbs +2 -0
- data/sig/inline_parser.rbs +2 -0
- data/sig/manifest.yaml +0 -1
- data/sig/rewriter.rbs +45 -0
- data/src/ast.c +109 -85
- data/src/lexer.c +137 -114
- data/src/lexer.re +1 -0
- data/src/lexstate.c +1 -0
- data/src/parser.c +55 -5
- data/stdlib/openssl/0/openssl.rbs +2 -2
- metadata +7 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ef0d5eb6481b99be0816dbcef78f1cc40371104f4ef3e82b40ffcbbc3e78dccc
|
|
4
|
+
data.tar.gz: a728bc39e8ef49146542b121956fc5555d8eecb066febe271bb04b0beaf56ea3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d0a018f3245ae90e747f649b1e306edf8084147a3db4138b929a74736b86fe8f404b3e0d4aef35b212bf8da149e4d7b0088d22b5c1bd27a006aed253dec82d88
|
|
7
|
+
data.tar.gz: 65a1efb7bc0484e7744c7df1ef70c193918f5a5d5690c00bdadcb5b29bbf8b5b18719643e31b6ea93b2a4ae56874965b5116f43de1569deb5ff24b96e221a7c7
|
data/.github/dependabot.yml
CHANGED
|
@@ -57,4 +57,7 @@ jobs:
|
|
|
57
57
|
--title "bundle update ($(date +'%Y-%m-%d'))" \
|
|
58
58
|
--body "Automated weekly bundle update" \
|
|
59
59
|
--head "$(git rev-parse --abbrev-ref HEAD)" \
|
|
60
|
-
--base "${{ github.event.repository.default_branch }}"
|
|
60
|
+
--base "${{ github.event.repository.default_branch }}" \
|
|
61
|
+
--label "no-milestone"
|
|
62
|
+
|
|
63
|
+
gh pr merge --auto --merge "$(git rev-parse --abbrev-ref HEAD)"
|
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
|
|
15
15
|
steps:
|
|
16
16
|
- name: Dependabot metadata
|
|
17
|
-
uses: dependabot/fetch-metadata@
|
|
17
|
+
uses: dependabot/fetch-metadata@ffa630c65fa7e0ecfa0625b5ceda64399aea1b36 # v3.0.0
|
|
18
18
|
id: metadata
|
|
19
19
|
- name: Checkout repository
|
|
20
20
|
uses: actions/checkout@v6
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
name: Check milestone
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [opened, edited, labeled, unlabeled, milestoned, demilestoned, synchronize]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
check:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v6
|
|
13
|
+
|
|
14
|
+
- name: Extract RBS::Version
|
|
15
|
+
id: version
|
|
16
|
+
run: |
|
|
17
|
+
# Extract version string from lib/rbs/version.rb
|
|
18
|
+
version=$(ruby -e 'load "lib/rbs/version.rb"; print RBS::VERSION')
|
|
19
|
+
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
20
|
+
|
|
21
|
+
# Parse major.minor.patch
|
|
22
|
+
IFS='.' read -r major minor patch _rest <<< "$version"
|
|
23
|
+
echo "major=$major" >> "$GITHUB_OUTPUT"
|
|
24
|
+
echo "minor=$minor" >> "$GITHUB_OUTPUT"
|
|
25
|
+
echo "patch=$patch" >> "$GITHUB_OUTPUT"
|
|
26
|
+
|
|
27
|
+
echo "RBS::VERSION = $version (major=$major, minor=$minor, patch=$patch)"
|
|
28
|
+
|
|
29
|
+
- name: Check milestone
|
|
30
|
+
uses: actions/github-script@v8
|
|
31
|
+
with:
|
|
32
|
+
script: |
|
|
33
|
+
const pr = context.payload.pull_request;
|
|
34
|
+
const milestone = pr.milestone;
|
|
35
|
+
const labels = pr.labels.map(l => l.name);
|
|
36
|
+
|
|
37
|
+
const version = '${{ steps.version.outputs.version }}';
|
|
38
|
+
const major = '${{ steps.version.outputs.major }}';
|
|
39
|
+
const minor = '${{ steps.version.outputs.minor }}';
|
|
40
|
+
const patch = parseInt('${{ steps.version.outputs.patch }}', 10);
|
|
41
|
+
|
|
42
|
+
if (!milestone) {
|
|
43
|
+
if (labels.includes('no-milestone')) {
|
|
44
|
+
core.info('No milestone set, but no-milestone label is present — OK');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
core.setFailed(
|
|
48
|
+
'No milestone set. Add a milestone or add the "no-milestone" label.'
|
|
49
|
+
);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (labels.includes('no-milestone')) {
|
|
54
|
+
core.setFailed(
|
|
55
|
+
'Milestone is set but "no-milestone" label is present. Remove the label or the milestone.'
|
|
56
|
+
);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const milestoneName = milestone.title;
|
|
61
|
+
core.info(`Milestone: "${milestoneName}", RBS::VERSION: ${version}`);
|
|
62
|
+
|
|
63
|
+
// Expected milestone based on version:
|
|
64
|
+
// patch == 0 → "RBS major.minor" (e.g. "RBS 4.0")
|
|
65
|
+
// patch >= 1 → "RBS major.minor.x" (e.g. "RBS 4.0.x")
|
|
66
|
+
let expectedMilestone;
|
|
67
|
+
if (patch === 0) {
|
|
68
|
+
expectedMilestone = `RBS ${major}.${minor}`;
|
|
69
|
+
} else {
|
|
70
|
+
expectedMilestone = `RBS ${major}.${minor}.x`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (milestoneName !== expectedMilestone) {
|
|
74
|
+
core.setFailed(
|
|
75
|
+
`Milestone "${milestoneName}" does not match RBS::VERSION ${version}. ` +
|
|
76
|
+
`Expected milestone: "${expectedMilestone}"`
|
|
77
|
+
);
|
|
78
|
+
} else {
|
|
79
|
+
core.info(`Milestone "${milestoneName}" matches RBS::VERSION ${version}`);
|
|
80
|
+
}
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -110,3 +110,37 @@ jobs:
|
|
|
110
110
|
run: |
|
|
111
111
|
bin/setup
|
|
112
112
|
- run: bundle exec rake clean compile_c99
|
|
113
|
+
|
|
114
|
+
clang_compile:
|
|
115
|
+
runs-on: macos-latest
|
|
116
|
+
strategy:
|
|
117
|
+
fail-fast: false
|
|
118
|
+
matrix:
|
|
119
|
+
ruby: ['4.0', head]
|
|
120
|
+
steps:
|
|
121
|
+
- uses: actions/checkout@v6
|
|
122
|
+
- name: Install dependencies
|
|
123
|
+
run: |
|
|
124
|
+
brew install ruby-build
|
|
125
|
+
- uses: ruby/setup-ruby@v1
|
|
126
|
+
with:
|
|
127
|
+
ruby-version: ${{ matrix.ruby }}
|
|
128
|
+
bundler: none
|
|
129
|
+
- name: Set working directory as safe
|
|
130
|
+
run: git config --global --add safe.directory $(pwd)
|
|
131
|
+
- name: Update rubygems & bundler
|
|
132
|
+
run: |
|
|
133
|
+
ruby -v
|
|
134
|
+
gem update --system
|
|
135
|
+
- name: install erb
|
|
136
|
+
run: gem install erb
|
|
137
|
+
- name: clang version
|
|
138
|
+
run: clang --version
|
|
139
|
+
- name: bundle config set force_ruby_platform true if head
|
|
140
|
+
if: ${{ contains(matrix.ruby, 'head') }}
|
|
141
|
+
run: |
|
|
142
|
+
bundle config set force_ruby_platform true
|
|
143
|
+
- name: bin/setup
|
|
144
|
+
run: |
|
|
145
|
+
bin/setup
|
|
146
|
+
- run: bundle exec rake clean compile
|
data/.github/workflows/rust.yml
CHANGED
|
@@ -8,8 +8,6 @@ on:
|
|
|
8
8
|
paths:
|
|
9
9
|
- ".github/workflows/rust.yml"
|
|
10
10
|
- "rust/**"
|
|
11
|
-
- "include/**"
|
|
12
|
-
- "src/**"
|
|
13
11
|
|
|
14
12
|
env:
|
|
15
13
|
RUSTFLAGS: "-D warnings"
|
|
@@ -24,6 +22,20 @@ jobs:
|
|
|
24
22
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
25
23
|
steps:
|
|
26
24
|
- uses: actions/checkout@v6
|
|
25
|
+
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
|
26
|
+
- name: Set up Ruby
|
|
27
|
+
uses: ruby/setup-ruby@v1
|
|
28
|
+
with:
|
|
29
|
+
ruby-version: ruby
|
|
30
|
+
bundler: none
|
|
31
|
+
- name: Update rubygems & bundler
|
|
32
|
+
run: gem update --system
|
|
33
|
+
- name: Install gems
|
|
34
|
+
run: |
|
|
35
|
+
bundle config set --local without libs:profilers
|
|
36
|
+
bundle install --jobs 4 --retry 3
|
|
37
|
+
- name: Set up vendored RBS source
|
|
38
|
+
run: bundle exec rake rust:rbs:sync
|
|
27
39
|
- name: Install Rust tools
|
|
28
40
|
run: |
|
|
29
41
|
rustup update --no-self-update stable
|
|
@@ -42,12 +54,30 @@ jobs:
|
|
|
42
54
|
cd rust
|
|
43
55
|
cargo test --verbose
|
|
44
56
|
|
|
45
|
-
publish-dry-run:
|
|
46
|
-
name:
|
|
57
|
+
publish-dry-run-ruby-rbs-sys:
|
|
58
|
+
name: rust:publish:ruby-rbs-sys
|
|
47
59
|
runs-on: ubuntu-latest
|
|
48
60
|
continue-on-error: true
|
|
49
61
|
steps:
|
|
50
62
|
- uses: actions/checkout@v6
|
|
63
|
+
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
|
64
|
+
- name: Set up git identity
|
|
65
|
+
run: |
|
|
66
|
+
git config user.name "GitHub Actions"
|
|
67
|
+
git config user.email "actions@github.com"
|
|
68
|
+
- name: Set up Ruby
|
|
69
|
+
uses: ruby/setup-ruby@v1
|
|
70
|
+
with:
|
|
71
|
+
ruby-version: ruby
|
|
72
|
+
bundler: none
|
|
73
|
+
- name: Update rubygems & bundler
|
|
74
|
+
run: gem update --system
|
|
75
|
+
- name: Install gems
|
|
76
|
+
run: |
|
|
77
|
+
bundle config set --local without libs:profilers
|
|
78
|
+
bundle install --jobs 4 --retry 3
|
|
79
|
+
- name: Set up vendored RBS source
|
|
80
|
+
run: bundle exec rake rust:rbs:sync
|
|
51
81
|
- name: Install Rust tools
|
|
52
82
|
run: |
|
|
53
83
|
rustup update --no-self-update stable
|
|
@@ -61,16 +91,72 @@ jobs:
|
|
|
61
91
|
key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
|
|
62
92
|
restore-keys: |
|
|
63
93
|
${{ runner.os }}-cargo-
|
|
64
|
-
- name: Test publish
|
|
94
|
+
- name: Test publish ruby-rbs-sys
|
|
95
|
+
run: bundle exec rake rust:publish:ruby-rbs-sys
|
|
96
|
+
env:
|
|
97
|
+
RBS_RUST_PUBLISH_DRY_RUN: "1"
|
|
98
|
+
|
|
99
|
+
publish-dry-run-ruby-rbs:
|
|
100
|
+
name: rust:publish:ruby-rbs
|
|
101
|
+
runs-on: ubuntu-latest
|
|
102
|
+
continue-on-error: true
|
|
103
|
+
steps:
|
|
104
|
+
- uses: actions/checkout@v6
|
|
105
|
+
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
|
106
|
+
- name: Set up git identity
|
|
65
107
|
run: |
|
|
66
|
-
|
|
67
|
-
|
|
108
|
+
git config user.name "GitHub Actions"
|
|
109
|
+
git config user.email "actions@github.com"
|
|
110
|
+
- name: Set up Ruby
|
|
111
|
+
uses: ruby/setup-ruby@v1
|
|
112
|
+
with:
|
|
113
|
+
ruby-version: ruby
|
|
114
|
+
bundler: none
|
|
115
|
+
- name: Update rubygems & bundler
|
|
116
|
+
run: gem update --system
|
|
117
|
+
- name: Install gems
|
|
118
|
+
run: |
|
|
119
|
+
bundle config set --local without libs:profilers
|
|
120
|
+
bundle install --jobs 4 --retry 3
|
|
121
|
+
- name: Set up vendored RBS source
|
|
122
|
+
run: bundle exec rake rust:rbs:sync
|
|
123
|
+
- name: Install Rust tools
|
|
124
|
+
run: |
|
|
125
|
+
rustup update --no-self-update stable
|
|
126
|
+
rustup default stable
|
|
127
|
+
- uses: actions/cache@v5
|
|
128
|
+
with:
|
|
129
|
+
path: |
|
|
130
|
+
~/.cargo/registry
|
|
131
|
+
~/.cargo/git
|
|
132
|
+
rust/target
|
|
133
|
+
key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }}
|
|
134
|
+
restore-keys: |
|
|
135
|
+
${{ runner.os }}-cargo-
|
|
136
|
+
- name: Test publish ruby-rbs
|
|
137
|
+
run: bundle exec rake rust:publish:ruby-rbs
|
|
138
|
+
env:
|
|
139
|
+
RBS_RUST_PUBLISH_DRY_RUN: "1"
|
|
68
140
|
|
|
69
141
|
lint:
|
|
70
142
|
name: cargo:lint
|
|
71
143
|
runs-on: ubuntu-latest
|
|
72
144
|
steps:
|
|
73
145
|
- uses: actions/checkout@v6
|
|
146
|
+
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
|
147
|
+
- name: Set up Ruby
|
|
148
|
+
uses: ruby/setup-ruby@v1
|
|
149
|
+
with:
|
|
150
|
+
ruby-version: ruby
|
|
151
|
+
bundler: none
|
|
152
|
+
- name: Update rubygems & bundler
|
|
153
|
+
run: gem update --system
|
|
154
|
+
- name: Install gems
|
|
155
|
+
run: |
|
|
156
|
+
bundle config set --local without libs:profilers
|
|
157
|
+
bundle install --jobs 4 --retry 3
|
|
158
|
+
- name: Set up vendored RBS source
|
|
159
|
+
run: bundle exec rake rust:rbs:sync
|
|
74
160
|
- name: Install Rust tools
|
|
75
161
|
run: |
|
|
76
162
|
rustup update --no-self-update stable
|
data/.gitignore
CHANGED
|
@@ -25,3 +25,7 @@ doc/
|
|
|
25
25
|
# For clangd's editor integration
|
|
26
26
|
ext/rbs_extension/compile_commands.json
|
|
27
27
|
ext/rbs_extension/.cache
|
|
28
|
+
|
|
29
|
+
# Rust crate vendored RBS source (managed by rake rust:rbs:sync or rust:rbs:symlink)
|
|
30
|
+
rust/ruby-rbs-sys/vendor/rbs/
|
|
31
|
+
rust/ruby-rbs/vendor/rbs/
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 4.0.2 (2026-03-25)
|
|
4
|
+
|
|
5
|
+
### Library changes
|
|
6
|
+
|
|
7
|
+
#### rbs collection
|
|
8
|
+
|
|
9
|
+
* Fix: pathname not written to lockfile. ([#2889](https://github.com/ruby/rbs/pull/2889))
|
|
10
|
+
|
|
11
|
+
### Miscellaneous
|
|
12
|
+
|
|
13
|
+
* Fix test failure on Windows in `ruby/ruby` ([#2900](https://github.com/ruby/rbs/pull/2900))
|
|
14
|
+
* Fix test for Ruby 4.1 ([#2899](https://github.com/ruby/rbs/pull/2899))
|
|
15
|
+
|
|
3
16
|
## 4.0.1 (2026-03-23)
|
|
4
17
|
|
|
5
18
|
This is a minor release to fix Ruby CI failure, which was caused by symlinks included in the `rust` directory.
|
|
@@ -221,6 +234,14 @@ This release also introduces two language changes: type argument support for sin
|
|
|
221
234
|
* Skip loading ruby_memcheck ([#2349](https://github.com/ruby/rbs/pull/2349))
|
|
222
235
|
* Forcibly uninstall gems even if there is a dependency problem. ([#2346](https://github.com/ruby/rbs/pull/2346))
|
|
223
236
|
|
|
237
|
+
## 3.10.4 (2026-03-25)
|
|
238
|
+
|
|
239
|
+
### Library changes
|
|
240
|
+
|
|
241
|
+
#### rbs collection
|
|
242
|
+
|
|
243
|
+
* [Backport] [3.10] Fix: pathname not written to lockfile. ([#2896](https://github.com/ruby/rbs/pull/2896))
|
|
244
|
+
|
|
224
245
|
## 3.10.3 (2026-01-30)
|
|
225
246
|
|
|
226
247
|
This is a minor fix around the dependency to `tsort`.
|
data/Rakefile
CHANGED
|
@@ -199,12 +199,15 @@ task :validate => :compile do
|
|
|
199
199
|
libs << "rbs"
|
|
200
200
|
end
|
|
201
201
|
|
|
202
|
+
libs.delete("bigdecimal-math") or raise
|
|
203
|
+
libs.delete("bigdecimal") or raise
|
|
204
|
+
|
|
202
205
|
libs.each do |lib|
|
|
203
206
|
args = ["-r", lib]
|
|
204
207
|
|
|
205
208
|
if lib == "rbs"
|
|
206
|
-
args << "-r"
|
|
207
|
-
args << "
|
|
209
|
+
args << "-r" << "prism"
|
|
210
|
+
args << "-r" << "logger"
|
|
208
211
|
end
|
|
209
212
|
|
|
210
213
|
sh "#{ruby} #{rbs} #{args.join(' ')} validate"
|
|
@@ -545,3 +548,207 @@ task :prepare_profiling do
|
|
|
545
548
|
Rake::Task[:"templates"].invoke
|
|
546
549
|
Rake::Task[:"compile"].invoke
|
|
547
550
|
end
|
|
551
|
+
|
|
552
|
+
namespace :rust do
|
|
553
|
+
namespace :rbs do
|
|
554
|
+
RUST_DIR = File.expand_path("rust", __dir__)
|
|
555
|
+
RBS_VERSION_FILE = File.join(RUST_DIR, "rbs_version")
|
|
556
|
+
|
|
557
|
+
VENDOR_TARGETS = {
|
|
558
|
+
"ruby-rbs-sys" => %w[include src],
|
|
559
|
+
"ruby-rbs" => %w[config.yml],
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
desc "Sync vendored RBS source from the pinned version"
|
|
563
|
+
task :sync do
|
|
564
|
+
unless File.exist?(RBS_VERSION_FILE)
|
|
565
|
+
raise "#{RBS_VERSION_FILE} not found. Run `rake rust:rbs:pin[VERSION]` first."
|
|
566
|
+
end
|
|
567
|
+
|
|
568
|
+
version = File.read(RBS_VERSION_FILE).strip
|
|
569
|
+
raise "#{RBS_VERSION_FILE} is empty" if version.empty?
|
|
570
|
+
|
|
571
|
+
puts "Syncing vendor/rbs/ from #{version}..."
|
|
572
|
+
|
|
573
|
+
VENDOR_TARGETS.each do |crate, entries|
|
|
574
|
+
vendor_dir = File.join(RUST_DIR, crate, "vendor", "rbs")
|
|
575
|
+
|
|
576
|
+
puts " Copying files for #{crate}:"
|
|
577
|
+
chmod_R "u+w", vendor_dir, verbose: false if File.exist?(vendor_dir)
|
|
578
|
+
rm_rf vendor_dir, verbose: false
|
|
579
|
+
mkdir_p vendor_dir, verbose: false
|
|
580
|
+
|
|
581
|
+
entries.each do |entry|
|
|
582
|
+
target = File.join(vendor_dir, entry)
|
|
583
|
+
|
|
584
|
+
# Extract the entry from the pinned git tag using git archive
|
|
585
|
+
IO.popen(["git", "archive", "--format=tar", version, "--", entry], "rb") do |tar|
|
|
586
|
+
IO.popen(["tar", "xf", "-", "-C", vendor_dir], "wb") do |extract|
|
|
587
|
+
IO.copy_stream(tar, extract)
|
|
588
|
+
end
|
|
589
|
+
end
|
|
590
|
+
|
|
591
|
+
raise "Failed to extract #{entry} from #{version}" unless File.exist?(target)
|
|
592
|
+
puts " #{entry}"
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
# Make files read-only to prevent accidental edits
|
|
596
|
+
chmod_R "a-w", vendor_dir, verbose: false
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
puts "📦 Synced vendor/rbs/ from #{version} (read-only)"
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
desc "Pin a specific RBS version for Rust crates (e.g., rake rust:rbs:pin[v4.0.3])"
|
|
603
|
+
task :pin, [:version] do |_t, args|
|
|
604
|
+
version = args[:version] or raise "Usage: rake rust:rbs:pin[VERSION]"
|
|
605
|
+
|
|
606
|
+
# Verify the tag exists
|
|
607
|
+
unless system("git", "rev-parse", "--verify", "#{version}^{commit}", out: File::NULL, err: File::NULL)
|
|
608
|
+
raise "Tag #{version} not found"
|
|
609
|
+
end
|
|
610
|
+
|
|
611
|
+
File.write(RBS_VERSION_FILE, "#{version}\n")
|
|
612
|
+
puts "📌 Pinned RBS version to #{version}"
|
|
613
|
+
|
|
614
|
+
Rake::Task["rust:rbs:sync"].invoke
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
desc "Create symlinks from vendor/rbs/ to the repository root (for development/CI)"
|
|
618
|
+
task :symlink do
|
|
619
|
+
VENDOR_TARGETS.each do |crate, entries|
|
|
620
|
+
vendor_dir = File.join(RUST_DIR, crate, "vendor", "rbs")
|
|
621
|
+
|
|
622
|
+
puts "Setting up symlinks for #{crate}..."
|
|
623
|
+
entries.each do |entry|
|
|
624
|
+
puts " #{entry} -> repository root"
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
chmod_R "u+w", vendor_dir, verbose: false if File.exist?(vendor_dir)
|
|
628
|
+
rm_rf vendor_dir, verbose: false
|
|
629
|
+
mkdir_p vendor_dir, verbose: false
|
|
630
|
+
|
|
631
|
+
entries.each do |entry|
|
|
632
|
+
ln_s File.join("..", "..", "..", "..", entry), File.join(vendor_dir, entry), verbose: false
|
|
633
|
+
end
|
|
634
|
+
end
|
|
635
|
+
|
|
636
|
+
puts "🔗 Symlinked vendor/rbs/ to repository root"
|
|
637
|
+
end
|
|
638
|
+
end
|
|
639
|
+
|
|
640
|
+
namespace :publish do
|
|
641
|
+
def self.prepare_publish_branch(crate_name)
|
|
642
|
+
dry_run = ENV["RBS_RUST_PUBLISH_DRY_RUN"]
|
|
643
|
+
|
|
644
|
+
version_file = File.join(RUST_DIR, "rbs_version")
|
|
645
|
+
|
|
646
|
+
unless File.exist?(version_file)
|
|
647
|
+
raise "#{version_file} not found. Run `rake rust:rbs:pin[VERSION]` first."
|
|
648
|
+
end
|
|
649
|
+
|
|
650
|
+
rbs_version = File.read(version_file).strip
|
|
651
|
+
raise "#{version_file} is empty" if rbs_version.empty?
|
|
652
|
+
|
|
653
|
+
crate_version = File.read(File.join(RUST_DIR, crate_name, "Cargo.toml"))[/^version\s*=\s*"(.+)"/, 1]
|
|
654
|
+
release_branch = "rust/release-#{crate_name}-#{Time.now.strftime('%Y%m%d%H%M%S')}"
|
|
655
|
+
|
|
656
|
+
puts "=" * 60
|
|
657
|
+
puts "Rust crate publish: #{crate_name}#{dry_run ? " (DRY RUN)" : ""}"
|
|
658
|
+
puts "=" * 60
|
|
659
|
+
puts " RBS source version: #{rbs_version}"
|
|
660
|
+
puts " #{crate_name}: #{crate_version} (tag: #{crate_name}-v#{crate_version})"
|
|
661
|
+
puts " Release branch: #{release_branch}"
|
|
662
|
+
puts "=" * 60
|
|
663
|
+
|
|
664
|
+
# Check that vendor dirs contain real files, not symlinks
|
|
665
|
+
entries = VENDOR_TARGETS.fetch(crate_name)
|
|
666
|
+
entries.each do |entry|
|
|
667
|
+
path = File.join(RUST_DIR, crate_name, "vendor", "rbs", entry)
|
|
668
|
+
if File.symlink?(path)
|
|
669
|
+
raise "#{path} is a symlink. Run `rake rust:rbs:sync` first."
|
|
670
|
+
end
|
|
671
|
+
unless File.exist?(path)
|
|
672
|
+
raise "#{path} does not exist. Run `rake rust:rbs:sync` first."
|
|
673
|
+
end
|
|
674
|
+
end
|
|
675
|
+
|
|
676
|
+
# Ensure working tree is clean before publishing
|
|
677
|
+
unless `git status --porcelain`.strip.empty?
|
|
678
|
+
raise "💢 Working tree is dirty. Please commit or stash your changes before publishing."
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
# Create a release branch with vendor files committed
|
|
682
|
+
original_branch = `git rev-parse --abbrev-ref HEAD`.strip
|
|
683
|
+
|
|
684
|
+
sh "git", "checkout", "-b", release_branch, verbose: false
|
|
685
|
+
vendor_path = File.join("rust", crate_name, "vendor", "rbs")
|
|
686
|
+
sh "git", "add", "-f", vendor_path, verbose: false
|
|
687
|
+
sh "git", "commit", "-m", "Publish #{crate_name} (RBS #{rbs_version})", verbose: false
|
|
688
|
+
|
|
689
|
+
[dry_run, crate_version, original_branch]
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
desc "Publish ruby-rbs-sys crate to crates.io (set RBS_RUST_PUBLISH_DRY_RUN=1 for dry-run only)"
|
|
693
|
+
task :"ruby-rbs-sys" do
|
|
694
|
+
crate_name = "ruby-rbs-sys"
|
|
695
|
+
dry_run, crate_version, original_branch = prepare_publish_branch(crate_name)
|
|
696
|
+
|
|
697
|
+
begin
|
|
698
|
+
puts "🔰 Dry-run publishing..."
|
|
699
|
+
|
|
700
|
+
Dir.chdir(File.join(RUST_DIR, crate_name)) do
|
|
701
|
+
sh "cargo", "publish", "--dry-run"
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
puts "✅ Dry-run succeeded!"
|
|
705
|
+
|
|
706
|
+
unless dry_run
|
|
707
|
+
puts "💪 Publishing #{crate_name} for real..."
|
|
708
|
+
|
|
709
|
+
Dir.chdir(File.join(RUST_DIR, crate_name)) do
|
|
710
|
+
sh "cargo", "publish"
|
|
711
|
+
end
|
|
712
|
+
|
|
713
|
+
sh "git", "tag", "#{crate_name}-v#{crate_version}"
|
|
714
|
+
sh "git", "push", "origin", "#{crate_name}-v#{crate_version}"
|
|
715
|
+
|
|
716
|
+
puts "🎉 Published #{crate_name} successfully!"
|
|
717
|
+
end
|
|
718
|
+
ensure
|
|
719
|
+
sh "git", "checkout", original_branch, verbose: false
|
|
720
|
+
end
|
|
721
|
+
end
|
|
722
|
+
|
|
723
|
+
desc "Publish ruby-rbs crate to crates.io (set RBS_RUST_PUBLISH_DRY_RUN=1 for dry-run only)"
|
|
724
|
+
task :"ruby-rbs" do
|
|
725
|
+
crate_name = "ruby-rbs"
|
|
726
|
+
dry_run, crate_version, original_branch = prepare_publish_branch(crate_name)
|
|
727
|
+
|
|
728
|
+
begin
|
|
729
|
+
puts "🔰 Dry-run publishing..."
|
|
730
|
+
|
|
731
|
+
Dir.chdir(File.join(RUST_DIR, crate_name)) do
|
|
732
|
+
sh "cargo", "publish", "--dry-run", "--no-verify"
|
|
733
|
+
end
|
|
734
|
+
|
|
735
|
+
puts "✅ Dry-run succeeded!"
|
|
736
|
+
|
|
737
|
+
unless dry_run
|
|
738
|
+
puts "💪 Publishing #{crate_name} for real..."
|
|
739
|
+
|
|
740
|
+
Dir.chdir(File.join(RUST_DIR, crate_name)) do
|
|
741
|
+
sh "cargo", "publish"
|
|
742
|
+
end
|
|
743
|
+
|
|
744
|
+
sh "git", "tag", "#{crate_name}-v#{crate_version}"
|
|
745
|
+
sh "git", "push", "origin", "#{crate_name}-v#{crate_version}"
|
|
746
|
+
|
|
747
|
+
puts "🎉 Published #{crate_name} successfully!"
|
|
748
|
+
end
|
|
749
|
+
ensure
|
|
750
|
+
sh "git", "checkout", original_branch, verbose: false
|
|
751
|
+
end
|
|
752
|
+
end
|
|
753
|
+
end
|
|
754
|
+
end
|
data/config.yml
CHANGED
|
@@ -784,6 +784,30 @@ nodes:
|
|
|
784
784
|
- name: type_name_location
|
|
785
785
|
c_type: rbs_location_range
|
|
786
786
|
optional: true
|
|
787
|
+
- name: RBS::AST::Ruby::Annotations::ModuleSelfAnnotation
|
|
788
|
+
rust_name: ModuleSelfAnnotationNode
|
|
789
|
+
fields:
|
|
790
|
+
- name: prefix_location
|
|
791
|
+
c_type: rbs_location_range
|
|
792
|
+
- name: keyword_location
|
|
793
|
+
c_type: rbs_location_range
|
|
794
|
+
- name: colon_location
|
|
795
|
+
c_type: rbs_location_range
|
|
796
|
+
- name: name
|
|
797
|
+
c_type: rbs_type_name
|
|
798
|
+
- name: args
|
|
799
|
+
c_type: rbs_node_list
|
|
800
|
+
- name: open_bracket_location
|
|
801
|
+
c_type: rbs_location_range
|
|
802
|
+
optional: true
|
|
803
|
+
- name: close_bracket_location
|
|
804
|
+
c_type: rbs_location_range
|
|
805
|
+
optional: true
|
|
806
|
+
- name: args_comma_locations
|
|
807
|
+
c_type: rbs_location_range_list
|
|
808
|
+
- name: comment_location
|
|
809
|
+
c_type: rbs_location_range
|
|
810
|
+
optional: true
|
|
787
811
|
- name: RBS::AST::Ruby::Annotations::ParamTypeAnnotation
|
|
788
812
|
rust_name: ParamTypeAnnotationNode
|
|
789
813
|
fields:
|
data/core/builtin.rbs
CHANGED
|
@@ -225,6 +225,7 @@ type int = Integer | _ToInt
|
|
|
225
225
|
|
|
226
226
|
# Represents a `Float`, or a type convertible to it (via `.to_f`).
|
|
227
227
|
#
|
|
228
|
+
%a{deprecated: Use `_ToF` directly}
|
|
228
229
|
type float = Float | _ToF
|
|
229
230
|
|
|
230
231
|
# Represents a `Range[T]`, or a type that acts like it (via `.begin`, `.end`, and `.exclude_end?`).
|
data/core/class.rbs
CHANGED
|
@@ -83,7 +83,7 @@ class Class < Module
|
|
|
83
83
|
# Assign the class to a constant (name starting uppercase) if you want to treat
|
|
84
84
|
# it like a regular class.
|
|
85
85
|
#
|
|
86
|
-
def initialize: (?Class superclass) ?{ (Class newclass) -> void } -> void
|
|
86
|
+
def initialize: (?Class superclass) ?{ (Class newclass) [self: Class] -> void } -> void
|
|
87
87
|
|
|
88
88
|
# <!--
|
|
89
89
|
# rdoc-file=object.c
|
|
@@ -107,6 +107,8 @@ class Class < Module
|
|
|
107
107
|
#
|
|
108
108
|
def allocate: () -> untyped
|
|
109
109
|
|
|
110
|
+
def self.allocate: () -> untyped
|
|
111
|
+
|
|
110
112
|
# <!--
|
|
111
113
|
# rdoc-file=object.c
|
|
112
114
|
# - attached_object -> object
|
|
@@ -150,7 +152,7 @@ class Class < Module
|
|
|
150
152
|
# New subclass: Bar
|
|
151
153
|
# New subclass: Baz
|
|
152
154
|
#
|
|
153
|
-
def inherited: (Class
|
|
155
|
+
private def inherited: (Class subclass) -> void
|
|
154
156
|
|
|
155
157
|
# <!--
|
|
156
158
|
# rdoc-file=object.c
|
|
@@ -160,7 +162,7 @@ class Class < Module
|
|
|
160
162
|
# object's #initialize method, passing it *args*. This is the method that ends
|
|
161
163
|
# up getting called whenever an object is constructed using <code>.new</code>.
|
|
162
164
|
#
|
|
163
|
-
def new: () -> untyped
|
|
165
|
+
def new: (*untyped, **untyped) ?{ (?) -> untyped } -> untyped
|
|
164
166
|
|
|
165
167
|
# <!--
|
|
166
168
|
# rdoc-file=object.c
|