Skip to content

Commit 4284d9f

Browse files
committed
Bump chalk
1 parent c544f9a commit 4284d9f

File tree

7 files changed

+153
-55
lines changed

7 files changed

+153
-55
lines changed

Cargo.lock

+47-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/ra_hir_ty/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ test_utils = { path = "../test_utils" }
2727

2828
scoped-tls = "1"
2929

30-
chalk-solve = "0.11"
31-
chalk-ir = "0.11"
30+
chalk-solve = "0.14"
31+
chalk-ir = "0.14"
3232

3333
[dev-dependencies]
3434
insta = "0.16.0"

crates/ra_hir_ty/src/tests/coercion.rs

+23-19
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ fn test() {
664664
fn coerce_unsize_trait_object() {
665665
assert_snapshot!(
666666
infer_with_mismatches(r#"
667+
#[lang = "sized"]
668+
pub trait Sized {}
667669
#[lang = "unsize"]
668670
pub trait Unsize<T> {}
669671
#[lang = "coerce_unsized"]
@@ -689,19 +691,19 @@ fn test() {
689691
}
690692
"#, true),
691693
@r###"
692-
387..572 '{ ...bj2; }': ()
693-
397..400 'obj': &dyn Baz<i8, i16>
694-
422..424 '&S': &S<i8, i16>
695-
423..424 'S': S<i8, i16>
696-
434..437 'obj': &dyn Bar<usize, i8, i16>
697-
459..462 'obj': &dyn Baz<i8, i16>
698-
472..475 'obj': &dyn Foo<i8, usize>
699-
494..497 'obj': &dyn Bar<usize, i8, i16>
700-
507..511 'obj2': &dyn Baz<i8, i16>
701-
533..535 '&S': &S<i8, i16>
702-
534..535 'S': S<i8, i16>
703-
545..546 '_': &dyn Foo<i8, usize>
704-
565..569 'obj2': &dyn Baz<i8, i16>
694+
424..609 '{ ...bj2; }': ()
695+
434..437 'obj': &dyn Baz<i8, i16>
696+
459..461 '&S': &S<i8, i16>
697+
460..461 'S': S<i8, i16>
698+
471..474 'obj': &dyn Bar<usize, i8, i16>
699+
496..499 'obj': &dyn Baz<i8, i16>
700+
509..512 'obj': &dyn Foo<i8, usize>
701+
531..534 'obj': &dyn Bar<usize, i8, i16>
702+
544..548 'obj2': &dyn Baz<i8, i16>
703+
570..572 '&S': &S<i8, i16>
704+
571..572 'S': S<i8, i16>
705+
582..583 '_': &dyn Foo<i8, usize>
706+
602..606 'obj2': &dyn Baz<i8, i16>
705707
"###
706708
);
707709
}
@@ -710,6 +712,8 @@ fn test() {
710712
fn coerce_unsize_super_trait_cycle() {
711713
assert_snapshot!(
712714
infer_with_mismatches(r#"
715+
#[lang = "sized"]
716+
pub trait Sized {}
713717
#[lang = "unsize"]
714718
pub trait Unsize<T> {}
715719
#[lang = "coerce_unsized"]
@@ -734,12 +738,12 @@ fn test() {
734738
}
735739
"#, true),
736740
@r###"
737-
291..347 '{ ...obj; }': ()
738-
301..304 'obj': &dyn D
739-
315..317 '&S': &S
740-
316..317 'S': S
741-
327..330 'obj': &dyn A
742-
341..344 'obj': &dyn D
741+
328..384 '{ ...obj; }': ()
742+
338..341 'obj': &dyn D
743+
352..354 '&S': &S
744+
353..354 'S': S
745+
364..367 'obj': &dyn A
746+
378..381 'obj': &dyn D
743747
"###
744748
);
745749
}

crates/ra_hir_ty/src/tests/traits.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1753,11 +1753,11 @@ fn test() {
17531753
384..500 '{ ...(f); }': ()
17541754
394..397 'bar': Bar<fn(u8) -> u32>
17551755
423..426 'bar': Bar<fn(u8) -> u32>
1756-
423..432 'bar.foo()': {unknown}
1756+
423..432 'bar.foo()': (u8, u32)
17571757
443..446 'opt': Opt<u8>
17581758
465..466 'f': fn(u8) -> u32
17591759
487..490 'opt': Opt<u8>
1760-
487..497 'opt.map(f)': Opt<FnOnce::Output<fn(u8) -> u32, (u8,)>>
1760+
487..497 'opt.map(f)': Opt<u32>
17611761
495..496 'f': fn(u8) -> u32
17621762
"###
17631763
);
@@ -1830,9 +1830,9 @@ fn test() {
18301830
634..643 'Lazy::new': fn new<Foo, fn() -> Foo>(fn() -> Foo) -> Lazy<Foo, fn() -> Foo>
18311831
634..660 'Lazy::...n_ptr)': Lazy<Foo, fn() -> Foo>
18321832
644..659 'make_foo_fn_ptr': fn() -> Foo
1833-
670..672 'r2': {unknown}
1833+
670..672 'r2': usize
18341834
675..680 'lazy2': Lazy<Foo, fn() -> Foo>
1835-
675..686 'lazy2.foo()': {unknown}
1835+
675..686 'lazy2.foo()': usize
18361836
549..551 '{}': ()
18371837
"###
18381838
);

crates/ra_hir_ty/src/traits/chalk.rs

+68-15
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
128128
well_known_trait: rust_ir::WellKnownTrait,
129129
) -> Option<chalk_ir::TraitId<Interner>> {
130130
let lang_attr = lang_attr_from_well_known_trait(well_known_trait);
131-
let lang_items = self.db.crate_lang_items(self.krate);
132-
let trait_ = match lang_items.target(lang_attr) {
131+
let trait_ = match self.db.lang_item(self.krate, lang_attr.into()) {
133132
Some(LangItemTarget::TraitId(trait_)) => trait_,
134133
_ => return None,
135134
};
@@ -186,6 +185,39 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
186185
// FIXME: implement actual object safety
187186
true
188187
}
188+
189+
fn closure_kind(
190+
&self,
191+
_closure_id: chalk_ir::ClosureId<Interner>,
192+
_substs: &chalk_ir::Substitution<Interner>,
193+
) -> rust_ir::ClosureKind {
194+
// FIXME: implement closure support
195+
unimplemented!()
196+
}
197+
fn closure_inputs_and_output(
198+
&self,
199+
_closure_id: chalk_ir::ClosureId<Interner>,
200+
_substs: &chalk_ir::Substitution<Interner>,
201+
) -> chalk_ir::Binders<rust_ir::FnDefInputsAndOutputDatum<Interner>> {
202+
// FIXME: implement closure support
203+
unimplemented!()
204+
}
205+
fn closure_upvars(
206+
&self,
207+
_closure_id: chalk_ir::ClosureId<Interner>,
208+
_substs: &chalk_ir::Substitution<Interner>,
209+
) -> chalk_ir::Binders<chalk_ir::Ty<Interner>> {
210+
// FIXME: implement closure support
211+
unimplemented!()
212+
}
213+
fn closure_fn_substitution(
214+
&self,
215+
_closure_id: chalk_ir::ClosureId<Interner>,
216+
_substs: &chalk_ir::Substitution<Interner>,
217+
) -> chalk_ir::Substitution<Interner> {
218+
// FIXME: implement closure support
219+
unimplemented!()
220+
}
189221
}
190222

191223
pub(crate) fn program_clauses_for_chalk_env_query(
@@ -250,7 +282,7 @@ pub(crate) fn trait_datum_query(
250282
upstream: trait_.lookup(db.upcast()).container.module(db.upcast()).krate != krate,
251283
non_enumerable: true,
252284
coinductive: false, // only relevant for Chalk testing
253-
// FIXME set these flags correctly
285+
// FIXME: set these flags correctly
254286
marker: false,
255287
fundamental: false,
256288
};
@@ -272,20 +304,28 @@ pub(crate) fn trait_datum_query(
272304

273305
fn well_known_trait_from_lang_attr(name: &str) -> Option<WellKnownTrait> {
274306
Some(match name {
275-
"sized" => WellKnownTrait::SizedTrait,
276-
"copy" => WellKnownTrait::CopyTrait,
277-
"clone" => WellKnownTrait::CloneTrait,
278-
"drop" => WellKnownTrait::DropTrait,
307+
"sized" => WellKnownTrait::Sized,
308+
"copy" => WellKnownTrait::Copy,
309+
"clone" => WellKnownTrait::Clone,
310+
"drop" => WellKnownTrait::Drop,
311+
"fn_once" => WellKnownTrait::FnOnce,
312+
"fn_mut" => WellKnownTrait::FnMut,
313+
"fn" => WellKnownTrait::Fn,
314+
"unsize" => WellKnownTrait::Unsize,
279315
_ => return None,
280316
})
281317
}
282318

283319
fn lang_attr_from_well_known_trait(attr: WellKnownTrait) -> &'static str {
284320
match attr {
285-
WellKnownTrait::SizedTrait => "sized",
286-
WellKnownTrait::CopyTrait => "copy",
287-
WellKnownTrait::CloneTrait => "clone",
288-
WellKnownTrait::DropTrait => "drop",
321+
WellKnownTrait::Sized => "sized",
322+
WellKnownTrait::Copy => "copy",
323+
WellKnownTrait::Clone => "clone",
324+
WellKnownTrait::Drop => "drop",
325+
WellKnownTrait::FnOnce => "fn_once",
326+
WellKnownTrait::FnMut => "fn_mut",
327+
WellKnownTrait::Fn => "fn",
328+
WellKnownTrait::Unsize => "unsize",
289329
}
290330
}
291331

@@ -309,8 +349,9 @@ pub(crate) fn struct_datum_query(
309349
.unwrap_or_else(Vec::new);
310350
let flags = rust_ir::AdtFlags {
311351
upstream,
312-
// FIXME set fundamental flag correctly
352+
// FIXME set fundamental and phantom_data flags correctly
313353
fundamental: false,
354+
phantom_data: false,
314355
};
315356
let struct_datum_bound = rust_ir::AdtDatumBound {
316357
fields: Vec::new(), // FIXME add fields (only relevant for auto traits)
@@ -448,11 +489,23 @@ pub(crate) fn fn_def_datum_query(
448489
let where_clauses = convert_where_clauses(db, callable_def.into(), &bound_vars);
449490
let bound = rust_ir::FnDefDatumBound {
450491
// Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway
451-
argument_types: sig.value.params().iter().map(|ty| ty.clone().to_chalk(db)).collect(),
452-
return_type: sig.value.ret().clone().to_chalk(db),
492+
inputs_and_output: make_binders(
493+
rust_ir::FnDefInputsAndOutputDatum {
494+
argument_types: sig
495+
.value
496+
.params()
497+
.iter()
498+
.map(|ty| ty.clone().to_chalk(db))
499+
.collect(),
500+
return_type: sig.value.ret().clone().to_chalk(db),
501+
}
502+
.shifted_in(&Interner),
503+
0,
504+
),
453505
where_clauses,
454506
};
455-
let datum = FnDefDatum { id: fn_def_id, binders: make_binders(bound, sig.num_binders) };
507+
let datum =
508+
FnDefDatum { id: fn_def_id, binders: make_binders(bound, sig.num_binders), abi: () };
456509
Arc::new(datum)
457510
}
458511

crates/ra_hir_ty/src/traits/chalk/interner.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ impl chalk_ir::interner::Interner for Interner {
4242
type DefId = InternId;
4343
type InternedAdtId = crate::TypeCtorId;
4444
type Identifier = TypeAliasId;
45+
type FnAbi = ();
4546

4647
fn debug_adt_id(type_kind_id: AdtId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
4748
tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt)))

0 commit comments

Comments
 (0)