Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 30 additions & 15 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -3149,41 +3149,56 @@ find_destination(INSN *i)
static int
remove_unreachable_chunk(rb_iseq_t *iseq, LINK_ELEMENT *i)
{
LINK_ELEMENT *first = i, *end;
LINK_ELEMENT *first = i, *end, *scan;
int *unref_counts = 0, nlabels = ISEQ_COMPILE_DATA(iseq)->label_no;

if (!i) return 0;
unref_counts = ALLOCA_N(int, nlabels);
MEMZERO(unref_counts, int, nlabels);
end = i;

scan = i;
do {
LABEL *lab;
if (IS_INSN(i)) {
if (IS_INSN_ID(i, leave)) {
end = i;
if (IS_INSN(scan)) {
if (IS_INSN_ID(scan, leave)) {
break;
}
else if ((lab = find_destination((INSN *)i)) != 0) {
else if ((lab = find_destination((INSN *)scan)) != 0) {
unref_counts[lab->label_no]++;
}
}
else if (IS_LABEL(i)) {
lab = (LABEL *)i;
else if (IS_LABEL(scan)) {
lab = (LABEL *)scan;
if (lab->unremovable) return 0;
}
else if (IS_ADJUST(scan)) {
return 0;
}
} while ((scan = scan->next) != 0);

end = i;
scan = i;
do {
LABEL *lab;
if (IS_INSN(scan)) {
if (IS_INSN_ID(scan, leave)) {
end = scan;
break;
}
}
else if (IS_LABEL(scan)) {
lab = (LABEL *)scan;
if (lab->refcnt > unref_counts[lab->label_no]) {
if (i == first) return 0;
if (scan == first) return 0;
break;
}
continue;
}
else if (IS_TRACE(i)) {
/* do nothing */
}
else if (IS_ADJUST(i)) {
else if (IS_ADJUST(scan)) {
return 0;
}
end = i;
} while ((i = i->next) != 0);
end = scan;
} while ((scan = scan->next) != 0);
i = first;
do {
if (IS_INSN(i)) {
Expand Down
5 changes: 4 additions & 1 deletion doc/syntax/refinements.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ invokes that method since +foo+ does not exist on Integer.

When +super+ is invoked, method lookup starts:

* If the method is in a refinement, at the refined class or module
* If the method is in a refinement:
* At the next active refinement in scope at the +super+ call site,
excluding the current refinement, if such a refinement exists
* Otherwise, at the refined class or module
* Otherwise, at the next ancestor

Method lookup then proceeds as described in the Method Lookup section
Expand Down
7 changes: 5 additions & 2 deletions lib/bundler/bundler.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Gem::Specification.new do |s|

s.metadata = {
"bug_tracker_uri" => "https://github.com/ruby/rubygems/issues?q=is%3Aopen+is%3Aissue+label%3ABundler",
"changelog_uri" => "https://github.com/ruby/rubygems/blob/master/bundler/CHANGELOG.md",
"changelog_uri" => "https://github.com/ruby/rubygems/blob/master/CHANGELOG-bundler.md",
"homepage_uri" => "https://bundler.io/",
"source_code_uri" => "https://github.com/ruby/rubygems/tree/master/bundler",
"source_code_uri" => "https://github.com/ruby/rubygems",
}

s.required_ruby_version = ">= 3.2.0"
Expand All @@ -39,6 +39,9 @@ Gem::Specification.new do |s|
# include the gemspec itself because warbler breaks w/o it
s.files += %w[lib/bundler/bundler.gemspec]

# These live next to the gemspec when Bundler ships as a gem, but not when
# it is synced into Ruby core, where the gemspec moves under lib/bundler.
s.files += %w[CHANGELOG-bundler.md LICENSE-bundler.md README-bundler.md].select {|f| File.file?(f) }
s.bindir = "exe"
s.executables = %w[bundle bundler]
s.require_paths = ["lib"]
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/ci_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Bundler
module CIDetector
# NOTE: Any changes made here will need to be made to both lib/rubygems/ci_detector.rb and
# bundler/lib/bundler/ci_detector.rb (which are enforced duplicates).
# lib/bundler/ci_detector.rb (which are enforced duplicates).
# TODO: Drop that duplication once bundler drops support for RubyGems 3.4
#
# ## Recognized CI providers, their signifiers, and the relevant docs ##
Expand Down
2 changes: 1 addition & 1 deletion lib/rubygems/ci_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Gem
module CIDetector
# NOTE: Any changes made here will need to be made to both lib/rubygems/ci_detector.rb and
# bundler/lib/bundler/ci_detector.rb (which are enforced duplicates).
# lib/bundler/ci_detector.rb (which are enforced duplicates).
# TODO: Drop that duplication once bundler drops support for RubyGems 3.4
#
# ## Recognized CI providers, their signifiers, and the relevant docs ##
Expand Down
43 changes: 20 additions & 23 deletions lib/rubygems/commands/setup_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ def shebang

def install_lib(lib_dir)
libs = { "RubyGems" => "lib" }
libs["Bundler"] = "bundler/lib"
libs.each do |tool, path|
say "Installing #{tool}" if @verbose

Expand Down Expand Up @@ -366,7 +365,7 @@ def install_default_bundler_gem(bin_dir)
target_specs_dir
end

new_bundler_spec = Dir.chdir("bundler") { Gem::Specification.load("bundler.gemspec") }
new_bundler_spec = Gem::Specification.load("bundler.gemspec")
full_name = new_bundler_spec.full_name
gemspec_path = "#{full_name}.gemspec"

Expand All @@ -390,26 +389,24 @@ def install_default_bundler_gem(bin_dir)

require_relative "../installer"

Dir.chdir("bundler") do
built_gem = Gem::Package.build(new_bundler_spec)
begin
installer = Gem::Installer.at(
built_gem,
env_shebang: options[:env_shebang],
format_executable: options[:format_executable],
force: options[:force],
bin_dir: bin_dir,
install_dir: default_dir,
wrappers: true
)
# We need to install only executable and default spec files.
# lib/bundler.rb and lib/bundler/* are available under the site_ruby directory.
installer.extract_bin
installer.generate_bin
installer.write_default_spec
ensure
FileUtils.rm_f built_gem
end
built_gem = Gem::Package.build(new_bundler_spec)
begin
installer = Gem::Installer.at(
built_gem,
env_shebang: options[:env_shebang],
format_executable: options[:format_executable],
force: options[:force],
bin_dir: bin_dir,
install_dir: default_dir,
wrappers: true
)
# We need to install only executable and default spec files.
# lib/bundler.rb and lib/bundler/* are available under the site_ruby directory.
installer.extract_bin
installer.generate_bin
installer.write_default_spec
ensure
FileUtils.rm_f built_gem
end

new_bundler_spec.executables.each {|executable| bin_file_names << target_bin_path(bin_dir, executable) }
Expand Down Expand Up @@ -499,7 +496,7 @@ def remove_old_bin_files(bin_dir)

def remove_old_lib_files(lib_dir)
lib_dirs = { File.join(lib_dir, "rubygems") => "lib/rubygems" }
lib_dirs[File.join(lib_dir, "bundler")] = "bundler/lib/bundler"
lib_dirs[File.join(lib_dir, "bundler")] = "lib/bundler"
lib_dirs.each do |old_lib_dir, new_lib_dir|
lib_files = files_in(new_lib_dir)

Expand Down
4 changes: 2 additions & 2 deletions lib/rubygems/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def hash # :nodoc:
# the runtime platform.
#
#--
# NOTE: Until it can be removed, changes to this method must also be reflected in `bundler/lib/bundler/rubygems_ext.rb`
# NOTE: Until it can be removed, changes to this method must also be reflected in `lib/bundler/rubygems_ext.rb`

def ===(other)
return nil unless Gem::Platform === other
Expand All @@ -221,7 +221,7 @@ def ===(other)
end

#--
# NOTE: Until it can be removed, changes to this method must also be reflected in `bundler/lib/bundler/rubygems_ext.rb`
# NOTE: Until it can be removed, changes to this method must also be reflected in `lib/bundler/rubygems_ext.rb`

def normalized_linux_version
return nil unless @version
Expand Down
6 changes: 5 additions & 1 deletion ractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -615,14 +615,18 @@ def value

#
# call-seq:
# ractor.monitor(port) -> self
# ractor.monitor(port) -> true or false
#
# Registers the port as a monitoring port for this ractor. When the ractor terminates,
# the port receives a Symbol object.
#
# * +:exited+ is sent if the ractor terminates without an unhandled exception.
# * +:aborted+ is sent if the ractor terminates by an unhandled exception.
#
# Returns +true+ if the monitor was registered (the ractor is still running).
# Returns +false+ if the ractor had already terminated; in that case the
# termination message (+:exited+ or +:aborted+) is sent to the port immediately.
#
# r = Ractor.new{ some_task() }
# r.monitor(port = Ractor::Port.new)
# port.receive #=> :exited and r is terminated
Expand Down
1 change: 1 addition & 0 deletions spec/bin/bundle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../bundler/support/switch_rubygems"
require_relative "../bundler/support/activate"

load File.expand_path("bundle", Spec::Path.exedir)
14 changes: 10 additions & 4 deletions spec/bundler/commands/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1582,8 +1582,11 @@
999.0.0
L

expect(the_bundle).to include_gems "bundler 999.0.0"
expect(the_bundle).to include_gems "myrack 1.0"
bundle "--version"
expect(out).to include("999.0.0")

bundle "list"
expect(out).to include("myrack (1.0)")
end

it "does not claim to update to Bundler version to a wrong version when cached gems are present" do
Expand Down Expand Up @@ -1665,8 +1668,11 @@
9.9.9
L

expect(the_bundle).to include_gems "bundler 9.9.9"
expect(the_bundle).to include_gems "myrack 1.0"
bundle "--version"
expect(out).to include("9.9.9")

bundle "list"
expect(out).to include("myrack (1.0)")
end

it "errors if the explicit target version does not exist" do
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/install/gemfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def source(source, *args, &blk)
it "shows culprit file and line" do
skip "ruby-core test setup has always \"lib\" in $LOAD_PATH so `require \"bundler\"` always activates the local version rather than using RubyGems gem activation stuff, causing conflicts" if ruby_core?

install_gemfile "source 'https://gem.repo1'", requires: [bundler_bug], artifice: nil, raise_on_error: false
install_gemfile "source 'https://gem.repo1'", requires: [bundler_bug], artifice: nil, raise_on_error: false, bundle_bin: dev_binstub
expect(err).to include("bundler_bug.rb:6")
end
end
Expand Down
19 changes: 12 additions & 7 deletions spec/bundler/runtime/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def clean_load_path(lp)

ruby <<-RUBY
require 'bundler'
gem "bundler", "#{Bundler::VERSION}" if #{ruby_core?}
gem "bundler", "#{Bundler::VERSION}"
Bundler.setup
puts $LOAD_PATH
RUBY
Expand Down Expand Up @@ -987,7 +987,8 @@ def clean_load_path(lp)
puts Bundler.rubygems.installed_specs.map(&:name)
R

expect(out).to eq("activesupport\nbundler\nactivesupport\nbundler")
expect(out).to include("activesupport")
expect(out).not_to include("myrack")
end

describe "when a vendored gem specification uses the :path option" do
Expand Down Expand Up @@ -1309,12 +1310,16 @@ def lock_with(ruby_version = nil)
end

context "is not present" do
# Skipped on ruby-core because `ruby "require 'bundler/setup'"` does not
# activate bundler as a gem there, so Source::Metadata falls back to a
# synthetic spec whose cache_file does not exist on disk and
# LockfileGenerator#bundler_checksum drops the bundler checksum, while
# the on-disk lockfile still has it.
# Skipped on ruby-core, and on the release-version CI variant, because
# `ruby "require 'bundler/setup'"` does not activate bundler as a gem
# there, so Source::Metadata falls back to a synthetic spec whose
# cache_file does not exist on disk and LockfileGenerator#bundler_checksum
# drops the bundler checksum, while the on-disk lockfile still has it.
# In-development (.dev) versions never write a bundler checksum, so the
# regular suite stays unaffected.
it "does not change the lock", :ruby_repo do
skip "bundler is loaded from the source tree, not installed as a gem" unless Bundler::VERSION.end_with?(".dev")

expect { ruby "require 'bundler/setup'" }.not_to change { lockfile }
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/support/build_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def git_commit_sha
end

def release_date_for(version, dir:)
changelog = File.expand_path("CHANGELOG.md", dir)
changelog = File.expand_path("CHANGELOG-bundler.md", dir)
File.readlines(changelog)[2].scan(/^## #{Regexp.escape(version)} \((.*)\)/).first&.first if File.exist?(changelog)
end

Expand Down
Loading