Fix tests on 32-bit architectures (#19652)

Summary
--

Fixes #19640. I'm not sure these are the exact fixes we really want, but
I
reproduced the issue in a 32-bit Docker container and tracked down the
causes,
so I figured I'd open a PR.

As I commented on the issue, the `goto_references` test depends on the
iteration
order of the files in an `FxHashSet` in `Indexed`. In this case, we can
just
sort the output in test code.

Similarly, the tuple case depended on the order of overloads inserted in
an
`FxHashMap`. `FxIndexMap` seemed like a convenient drop-in replacement,
but I
don't know if that will have other detrimental effects. I did have to
change the
assertion for the tuple test, but I think it should now be stable across
architectures.

Test Plan
--

Running the tests in the aforementioned Docker container
This commit is contained in:
Brent Westbrook 2025-07-31 08:52:19 -04:00 committed by GitHub
parent d2d4b115e3
commit a71513bae1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 7 deletions

View file

@ -27,7 +27,7 @@ use crate::types::{
infer_definition_types,
};
use crate::{
Db, FxOrderSet, KnownModule, Program,
Db, FxIndexMap, FxOrderSet, KnownModule, Program,
module_resolver::file_to_module,
place::{
Boundness, LookupError, LookupResult, Place, PlaceAndQualifiers, class_symbol,
@ -53,7 +53,7 @@ use ruff_db::parsed::{ParsedModuleRef, parsed_module};
use ruff_python_ast::name::Name;
use ruff_python_ast::{self as ast, PythonVersion};
use ruff_text_size::{Ranged, TextRange};
use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
use rustc_hash::{FxHashSet, FxHasher};
type FxOrderMap<K, V> = ordermap::map::OrderMap<K, V, BuildHasherDefault<FxHasher>>;
@ -628,8 +628,8 @@ impl<'db> ClassType<'db> {
.map(|spec| {
let tuple = spec.tuple(db);
let mut element_type_to_indices: FxHashMap<Type<'db>, Vec<i64>> =
FxHashMap::default();
let mut element_type_to_indices: FxIndexMap<Type<'db>, Vec<i64>> =
FxIndexMap::default();
match tuple {
// E.g. for `tuple[int, str]`, we will generate the following overloads: