Skip to content

Commit 39e049d

Browse files
Merge #5319
5319: Chalk upgrade r=flodiebold a=flodiebold - upgrade Chalk - make use of Chalk's `Unsize` impls, remove ours - use Chalk's built-in array type - search efficiently for impls for an int/float variable - output Chalk tracing logs in hir_ty tests Fixes #2534. Fixes #5057. Fixes #4374. Fixes #4281. Co-authored-by: Florian Diebold <[email protected]> Co-authored-by: Florian Diebold <[email protected]>
2 parents ab1ad19 + d885f38 commit 39e049d

File tree

13 files changed

+420
-353
lines changed

13 files changed

+420
-353
lines changed

Cargo.lock

Lines changed: 75 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_hir_ty/Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ test_utils = { path = "../test_utils" }
2727

2828
scoped-tls = "1"
2929

30-
chalk-solve = { version = "0.15.0" }
31-
chalk-ir = { version = "0.15.0" }
30+
chalk-solve = { version = "0.17.0" }
31+
chalk-ir = { version = "0.17.0" }
32+
chalk-recursive = { version = "0.17.0" }
3233

3334
[dev-dependencies]
3435
insta = "0.16.0"
3536
expect = { path = "../expect" }
37+
38+
tracing = "0.1"
39+
tracing-subscriber = { version = "0.2", default-features = false, features = ["env-filter", "registry"] }
40+
tracing-tree = { version = "0.1.3" }

crates/ra_hir_ty/src/method_resolution.rs

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ use std::{iter, sync::Arc};
66

77
use arrayvec::ArrayVec;
88
use hir_def::{
9-
lang_item::LangItemTarget, type_ref::Mutability, AssocContainerId, AssocItemId, FunctionId,
10-
HasModule, ImplId, Lookup, TraitId,
9+
builtin_type::{IntBitness, Signedness},
10+
lang_item::LangItemTarget,
11+
type_ref::Mutability,
12+
AssocContainerId, AssocItemId, FunctionId, HasModule, ImplId, Lookup, TraitId,
1113
};
1214
use hir_expand::name::Name;
1315
use ra_db::CrateId;
@@ -16,9 +18,12 @@ use rustc_hash::{FxHashMap, FxHashSet};
1618

1719
use super::Substs;
1820
use crate::{
19-
autoderef, db::HirDatabase, primitive::FloatBitness, utils::all_super_traits, ApplicationTy,
20-
Canonical, DebruijnIndex, InEnvironment, TraitEnvironment, TraitRef, Ty, TyKind, TypeCtor,
21-
TypeWalk,
21+
autoderef,
22+
db::HirDatabase,
23+
primitive::{FloatBitness, FloatTy, IntTy},
24+
utils::all_super_traits,
25+
ApplicationTy, Canonical, DebruijnIndex, InEnvironment, TraitEnvironment, TraitRef, Ty, TyKind,
26+
TypeCtor, TypeWalk,
2227
};
2328

2429
/// This is used as a key for indexing impls.
@@ -39,6 +44,62 @@ impl TyFingerprint {
3944
}
4045
}
4146

47+
pub(crate) const ALL_INT_FPS: [TyFingerprint; 12] = [
48+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
49+
signedness: Signedness::Unsigned,
50+
bitness: IntBitness::X8,
51+
})),
52+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
53+
signedness: Signedness::Unsigned,
54+
bitness: IntBitness::X16,
55+
})),
56+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
57+
signedness: Signedness::Unsigned,
58+
bitness: IntBitness::X32,
59+
})),
60+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
61+
signedness: Signedness::Unsigned,
62+
bitness: IntBitness::X64,
63+
})),
64+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
65+
signedness: Signedness::Unsigned,
66+
bitness: IntBitness::X128,
67+
})),
68+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
69+
signedness: Signedness::Unsigned,
70+
bitness: IntBitness::Xsize,
71+
})),
72+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
73+
signedness: Signedness::Signed,
74+
bitness: IntBitness::X8,
75+
})),
76+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
77+
signedness: Signedness::Signed,
78+
bitness: IntBitness::X16,
79+
})),
80+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
81+
signedness: Signedness::Signed,
82+
bitness: IntBitness::X32,
83+
})),
84+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
85+
signedness: Signedness::Signed,
86+
bitness: IntBitness::X64,
87+
})),
88+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
89+
signedness: Signedness::Signed,
90+
bitness: IntBitness::X128,
91+
})),
92+
TyFingerprint::Apply(TypeCtor::Int(IntTy {
93+
signedness: Signedness::Signed,
94+
bitness: IntBitness::Xsize,
95+
})),
96+
];
97+
98+
pub(crate) const ALL_FLOAT_FPS: [TyFingerprint; 2] = [
99+
TyFingerprint::Apply(TypeCtor::Float(FloatTy { bitness: FloatBitness::X32 })),
100+
TyFingerprint::Apply(TypeCtor::Float(FloatTy { bitness: FloatBitness::X64 })),
101+
];
102+
42103
/// Trait impls defined or available in some crate.
43104
#[derive(Debug, Eq, PartialEq)]
44105
pub struct TraitImpls {

crates/ra_hir_ty/src/tests.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ use crate::{
3737
// against snapshots of the expected results using insta. Use cargo-insta to
3838
// update the snapshots.
3939

40+
fn setup_tracing() -> tracing::subscriber::DefaultGuard {
41+
use tracing_subscriber::{layer::SubscriberExt, EnvFilter, Registry};
42+
use tracing_tree::HierarchicalLayer;
43+
let filter = EnvFilter::from_env("CHALK_DEBUG");
44+
let layer = HierarchicalLayer::default().with_indent_amount(2).with_writer(std::io::stderr);
45+
let subscriber = Registry::default().with(filter).with(layer);
46+
tracing::subscriber::set_default(subscriber)
47+
}
48+
4049
fn check_types(ra_fixture: &str) {
4150
check_types_impl(ra_fixture, false)
4251
}
@@ -46,6 +55,7 @@ fn check_types_source_code(ra_fixture: &str) {
4655
}
4756

4857
fn check_types_impl(ra_fixture: &str, display_source: bool) {
58+
let _tracing = setup_tracing();
4959
let db = TestDB::with_files(ra_fixture);
5060
let mut checked_one = false;
5161
for (file_id, annotations) in db.extract_annotations() {
@@ -86,6 +96,7 @@ fn infer(ra_fixture: &str) -> String {
8696
}
8797

8898
fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
99+
let _tracing = setup_tracing();
89100
let (db, file_id) = TestDB::with_single_file(content);
90101

91102
let mut buf = String::new();

0 commit comments

Comments
 (0)