summaryrefslogtreecommitdiffstats
path: root/src/etc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /src/etc
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/etc')
-rwxr-xr-x[-rw-r--r--]src/etc/dec2flt_table.py4
-rw-r--r--src/etc/gdb_load_rust_pretty_printers.py14
-rwxr-xr-xsrc/etc/generate-deriving-span-tests.py4
-rwxr-xr-x[-rw-r--r--]src/etc/htmldocck.py62
-rw-r--r--src/etc/lldb_batchmode.py2
-rw-r--r--src/etc/lldb_providers.py2
-rwxr-xr-xsrc/etc/pre-push.sh8
-rw-r--r--src/etc/rust_analyzer_settings.json9
-rw-r--r--src/etc/test-float-parse/Cargo.toml1
-rwxr-xr-x[-rw-r--r--]src/etc/test-float-parse/runtests.py2
10 files changed, 91 insertions, 17 deletions
diff --git a/src/etc/dec2flt_table.py b/src/etc/dec2flt_table.py
index aa5188d96..9264a8439 100644..100755
--- a/src/etc/dec2flt_table.py
+++ b/src/etc/dec2flt_table.py
@@ -14,8 +14,7 @@ Adapted from Daniel Lemire's fast_float ``table_generation.py``,
available here: <https://github.com/fastfloat/fast_float/blob/main/script/table_generation.py>.
"""
from __future__ import print_function
-from math import ceil, floor, log, log2
-from fractions import Fraction
+from math import ceil, floor, log
from collections import deque
HEADER = """
@@ -97,7 +96,6 @@ def print_proper_powers(min_exp, max_exp, bias):
print('#[rustfmt::skip]')
typ = '[(u64, u64); N_POWERS_OF_FIVE]'
print('pub static POWER_OF_FIVE_128: {} = ['.format(typ))
- lo_mask = (1 << 64) - 1
for c, exp in powers:
hi = '0x{:x}'.format(c // (1 << 64))
lo = '0x{:x}'.format(c % (1 << 64))
diff --git a/src/etc/gdb_load_rust_pretty_printers.py b/src/etc/gdb_load_rust_pretty_printers.py
index 856b5df2d..e05039ce4 100644
--- a/src/etc/gdb_load_rust_pretty_printers.py
+++ b/src/etc/gdb_load_rust_pretty_printers.py
@@ -1,3 +1,15 @@
+# Add this folder to the python sys path; GDB Python-interpreter will now find modules in this path
+import sys
+from os import path
+self_dir = path.dirname(path.realpath(__file__))
+sys.path.append(self_dir)
+
+# ruff: noqa: E402
import gdb
import gdb_lookup
-gdb_lookup.register_printers(gdb.current_objfile())
+
+# current_objfile can be none; even with `gdb foo-app`; sourcing this file after gdb init now works
+try:
+ gdb_lookup.register_printers(gdb.current_objfile())
+except Exception:
+ gdb_lookup.register_printers(gdb.selected_inferior().progspace)
diff --git a/src/etc/generate-deriving-span-tests.py b/src/etc/generate-deriving-span-tests.py
index d38f5add7..d61693460 100755
--- a/src/etc/generate-deriving-span-tests.py
+++ b/src/etc/generate-deriving-span-tests.py
@@ -102,7 +102,9 @@ for (trait, supers, errs) in [('Clone', [], 1),
traits[trait] = (ALL, supers, errs)
for (trait, (types, super_traits, error_count)) in traits.items():
- mk = lambda ty: create_test_case(ty, trait, super_traits, error_count)
+ def mk(ty, t=trait, st=super_traits, ec=error_count):
+ return create_test_case(ty, t, st, ec)
+
if types & ENUM:
write_file(trait + '-enum', mk(ENUM_TUPLE))
write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py
index c97fb4b80..5ab1874e9 100644..100755
--- a/src/etc/htmldocck.py
+++ b/src/etc/htmldocck.py
@@ -110,6 +110,9 @@ There are a number of supported commands:
* `@has-dir PATH` checks for the existence of the given directory.
+* `@files FOLDER_PATH [ENTRIES]`, checks that `FOLDER_PATH` contains exactly
+ `[ENTRIES]`.
+
All conditions can be negated with `!`. `@!has foo/type.NoSuch.html`
checks if the given file does not exist, for example.
@@ -144,7 +147,7 @@ VOID_ELEMENTS = {'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'ke
# Python 2 -> 3 compatibility
try:
- unichr
+ unichr # noqa: B018 FIXME: py2
except NameError:
unichr = chr
@@ -321,12 +324,15 @@ class CachedFiles(object):
else:
return self.last_path
+ def get_absolute_path(self, path):
+ return os.path.join(self.root, path)
+
def get_file(self, path):
path = self.resolve_path(path)
if path in self.files:
return self.files[path]
- abspath = os.path.join(self.root, path)
+ abspath = self.get_absolute_path(path)
if not(os.path.exists(abspath) and os.path.isfile(abspath)):
raise FailedCheck('File does not exist {!r}'.format(path))
@@ -340,7 +346,7 @@ class CachedFiles(object):
if path in self.trees:
return self.trees[path]
- abspath = os.path.join(self.root, path)
+ abspath = self.get_absolute_path(path)
if not(os.path.exists(abspath) and os.path.isfile(abspath)):
raise FailedCheck('File does not exist {!r}'.format(path))
@@ -348,13 +354,15 @@ class CachedFiles(object):
try:
tree = ET.fromstringlist(f.readlines(), CustomHTMLParser())
except Exception as e:
- raise RuntimeError('Cannot parse an HTML file {!r}: {}'.format(path, e))
+ raise RuntimeError( # noqa: B904 FIXME: py2
+ 'Cannot parse an HTML file {!r}: {}'.format(path, e)
+ )
self.trees[path] = tree
return self.trees[path]
def get_dir(self, path):
path = self.resolve_path(path)
- abspath = os.path.join(self.root, path)
+ abspath = self.get_absolute_path(path)
if not(os.path.exists(abspath) and os.path.isdir(abspath)):
raise FailedCheck('Directory does not exist {!r}'.format(path))
@@ -422,7 +430,7 @@ def check_snapshot(snapshot_name, actual_tree, normalize_to_text):
if bless:
expected_str = None
else:
- raise FailedCheck('No saved snapshot value')
+ raise FailedCheck('No saved snapshot value') # noqa: B904 FIXME: py2
if not normalize_to_text:
actual_str = ET.tostring(actual_tree).decode('utf-8')
@@ -536,6 +544,41 @@ def get_nb_matching_elements(cache, c, regexp, stop_at_first):
return check_tree_text(cache.get_tree(c.args[0]), pat, c.args[2], regexp, stop_at_first)
+def check_files_in_folder(c, cache, folder, files):
+ files = files.strip()
+ if not files.startswith('[') or not files.endswith(']'):
+ raise InvalidCheck("Expected list as second argument of @{} (ie '[]')".format(c.cmd))
+
+ folder = cache.get_absolute_path(folder)
+
+ # First we create a set of files to check if there are duplicates.
+ files = shlex.split(files[1:-1].replace(",", ""))
+ files_set = set()
+ for file in files:
+ if file in files_set:
+ raise InvalidCheck("Duplicated file `{}` in @{}".format(file, c.cmd))
+ files_set.add(file)
+ folder_set = set([f for f in os.listdir(folder) if f != "." and f != ".."])
+
+ # Then we remove entries from both sets (we clone `folder_set` so we can iterate it while
+ # removing its elements).
+ for entry in set(folder_set):
+ if entry in files_set:
+ files_set.remove(entry)
+ folder_set.remove(entry)
+
+ error = 0
+ if len(files_set) != 0:
+ print_err(c.lineno, c.context, "Entries not found in folder `{}`: `{}`".format(
+ folder, files_set))
+ error += 1
+ if len(folder_set) != 0:
+ print_err(c.lineno, c.context, "Extra entries in folder `{}`: `{}`".format(
+ folder, folder_set))
+ error += 1
+ return error == 0
+
+
ERR_COUNT = 0
@@ -564,6 +607,13 @@ def check_command(c, cache):
else:
raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd))
+ elif c.cmd == 'files': # check files in given folder
+ if len(c.args) != 2: # @files <folder path> <file list>
+ raise InvalidCheck("Invalid number of @{} arguments".format(c.cmd))
+ elif c.negated:
+ raise InvalidCheck("@{} doesn't support negative check".format(c.cmd))
+ ret = check_files_in_folder(c, cache, c.args[0], c.args[1])
+
elif c.cmd == 'count': # count test
if len(c.args) == 3: # @count <path> <pat> <count> = count test
expected = int(c.args[2])
diff --git a/src/etc/lldb_batchmode.py b/src/etc/lldb_batchmode.py
index fc355c87b..db1e0035e 100644
--- a/src/etc/lldb_batchmode.py
+++ b/src/etc/lldb_batchmode.py
@@ -124,7 +124,7 @@ def start_breakpoint_listener(target):
breakpoint = lldb.SBBreakpoint.GetBreakpointFromEvent(event)
print_debug("breakpoint added, id = " + str(breakpoint.id))
new_breakpoints.append(breakpoint.id)
- except:
+ except BaseException: # explicitly catch ctrl+c/sysexit
print_debug("breakpoint listener shutting down")
# Start the listener and let it run as a daemon
diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py
index c4381e202..4c86b2146 100644
--- a/src/etc/lldb_providers.py
+++ b/src/etc/lldb_providers.py
@@ -1,6 +1,6 @@
import sys
-from lldb import SBValue, SBData, SBError, eBasicTypeLong, eBasicTypeUnsignedLong, \
+from lldb import SBData, SBError, eBasicTypeLong, eBasicTypeUnsignedLong, \
eBasicTypeUnsignedChar
# from lldb.formatters import Logger
diff --git a/src/etc/pre-push.sh b/src/etc/pre-push.sh
index ff1793111..c9e1a2733 100755
--- a/src/etc/pre-push.sh
+++ b/src/etc/pre-push.sh
@@ -5,7 +5,7 @@
# and remove it from .git/hooks to deactivate.
#
-set -Eeuo pipefail
+set -Euo pipefail
# https://github.com/rust-lang/rust/issues/77620#issuecomment-705144570
unset GIT_DIR
@@ -14,4 +14,8 @@ ROOT_DIR="$(git rev-parse --show-toplevel)"
echo "Running pre-push script $ROOT_DIR/x test tidy"
cd "$ROOT_DIR"
-CARGOFLAGS="--locked" ./x test tidy
+./x test tidy --set build.locked-deps=true
+if [ $? -ne 0 ]; then
+ echo "You may use \`git push --no-verify\` to skip this check."
+ exit 1
+fi
diff --git a/src/etc/rust_analyzer_settings.json b/src/etc/rust_analyzer_settings.json
index dd01bfaa7..d9c4645f0 100644
--- a/src/etc/rust_analyzer_settings.json
+++ b/src/etc/rust_analyzer_settings.json
@@ -7,7 +7,14 @@
"check",
"--json-output"
],
- "rust-analyzer.linkedProjects": ["src/bootstrap/Cargo.toml", "Cargo.toml"],
+ "rust-analyzer.linkedProjects": [
+ "Cargo.toml",
+ "src/tools/x/Cargo.toml",
+ "src/bootstrap/Cargo.toml",
+ "src/tools/rust-analyzer/Cargo.toml",
+ "compiler/rustc_codegen_cranelift/Cargo.toml",
+ "compiler/rustc_codegen_gcc/Cargo.toml"
+ ],
"rust-analyzer.rustfmt.overrideCommand": [
"./build/host/rustfmt/bin/rustfmt",
"--edition=2021"
diff --git a/src/etc/test-float-parse/Cargo.toml b/src/etc/test-float-parse/Cargo.toml
index 7ee19a0b6..6d7b227d0 100644
--- a/src/etc/test-float-parse/Cargo.toml
+++ b/src/etc/test-float-parse/Cargo.toml
@@ -5,6 +5,7 @@ edition = "2021"
publish = false
[workspace]
+resolver = "1"
[dependencies]
rand = "0.4"
diff --git a/src/etc/test-float-parse/runtests.py b/src/etc/test-float-parse/runtests.py
index cf7279534..cc5e31a05 100644..100755
--- a/src/etc/test-float-parse/runtests.py
+++ b/src/etc/test-float-parse/runtests.py
@@ -127,7 +127,7 @@ def write_errors():
if not have_seen_error:
have_seen_error = True
msg("Something is broken:", *args)
- msg("Future errors logged to errors.txt")
+ msg("Future errors will be logged to errors.txt")
exit_status = 101