Skip to content

Commit bac3910

Browse files
committed
Bump chalk
1 parent 5a0331e commit bac3910

File tree

7 files changed

+168
-70
lines changed

7 files changed

+168
-70
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-
388..573 '{ ...bj2; }': ()
693-
398..401 'obj': &dyn Baz<i8, i16>
694-
423..425 '&S': &S<i8, i16>
695-
424..425 'S': S<i8, i16>
696-
435..438 'obj': &dyn Bar<usize, i8, i16>
697-
460..463 'obj': &dyn Baz<i8, i16>
698-
473..476 'obj': &dyn Foo<i8, usize>
699-
495..498 'obj': &dyn Bar<usize, i8, i16>
700-
508..512 'obj2': &dyn Baz<i8, i16>
701-
534..536 '&S': &S<i8, i16>
702-
535..536 'S': S<i8, i16>
703-
546..547 '_': &dyn Foo<i8, usize>
704-
566..570 'obj2': &dyn Baz<i8, i16>
694+
425..610 '{ ...bj2; }': ()
695+
435..438 'obj': &dyn Baz<i8, i16>
696+
460..462 '&S': &S<i8, i16>
697+
461..462 'S': S<i8, i16>
698+
472..475 'obj': &dyn Bar<usize, i8, i16>
699+
497..500 'obj': &dyn Baz<i8, i16>
700+
510..513 'obj': &dyn Foo<i8, usize>
701+
532..535 'obj': &dyn Bar<usize, i8, i16>
702+
545..549 'obj2': &dyn Baz<i8, i16>
703+
571..573 '&S': &S<i8, i16>
704+
572..573 'S': S<i8, i16>
705+
583..584 '_': &dyn Foo<i8, usize>
706+
603..607 '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-
292..348 '{ ...obj; }': ()
738-
302..305 'obj': &dyn D
739-
316..318 '&S': &S
740-
317..318 'S': S
741-
328..331 'obj': &dyn A
742-
342..345 'obj': &dyn D
741+
329..385 '{ ...obj; }': ()
742+
339..342 'obj': &dyn D
743+
353..355 '&S': &S
744+
354..355 'S': S
745+
365..368 'obj': &dyn A
746+
379..382 'obj': &dyn D
743747
"###
744748
);
745749
}

crates/ra_hir_ty/src/tests/traits.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -1742,24 +1742,24 @@ fn test() {
17421742
}
17431743
"#),
17441744
@r###"
1745-
75..79 'self': Self
1746-
81..85 'args': Args
1747-
140..144 'self': &Self
1748-
244..248 'self': &Bar<F>
1749-
261..263 '{}': ()
1750-
347..351 'self': Opt<T>
1751-
353..354 'f': F
1752-
369..371 '{}': ()
1753-
385..501 '{ ...(f); }': ()
1754-
395..398 'bar': Bar<fn(u8) -> u32>
1755-
424..427 'bar': Bar<fn(u8) -> u32>
1756-
424..433 'bar.foo()': {unknown}
1757-
444..447 'opt': Opt<u8>
1758-
466..467 'f': fn(u8) -> u32
1759-
488..491 'opt': Opt<u8>
1760-
488..498 'opt.map(f)': Opt<FnOnce::Output<fn(u8) -> u32, (u8,)>>
1761-
496..497 'f': fn(u8) -> u32
1762-
"###
1745+
75..79 'self': Self
1746+
81..85 'args': Args
1747+
140..144 'self': &Self
1748+
244..248 'self': &Bar<F>
1749+
261..263 '{}': ()
1750+
347..351 'self': Opt<T>
1751+
353..354 'f': F
1752+
369..371 '{}': ()
1753+
385..501 '{ ...(f); }': ()
1754+
395..398 'bar': Bar<fn(u8) -> u32>
1755+
424..427 'bar': Bar<fn(u8) -> u32>
1756+
424..433 'bar.foo()': (u8, u32)
1757+
444..447 'opt': Opt<u8>
1758+
466..467 'f': fn(u8) -> u32
1759+
488..491 'opt': Opt<u8>
1760+
488..498 'opt.map(f)': Opt<u32>
1761+
496..497 'f': fn(u8) -> u32
1762+
"###
17631763
);
17641764
}
17651765

@@ -1830,9 +1830,9 @@ fn test() {
18301830
635..644 'Lazy::new': fn new<Foo, fn() -> Foo>(fn() -> Foo) -> Lazy<Foo, fn() -> Foo>
18311831
635..661 'Lazy::...n_ptr)': Lazy<Foo, fn() -> Foo>
18321832
645..660 'make_foo_fn_ptr': fn() -> Foo
1833-
671..673 'r2': {unknown}
1833+
671..673 'r2': usize
18341834
676..681 'lazy2': Lazy<Foo, fn() -> Foo>
1835-
676..687 'lazy2.foo()': {unknown}
1835+
676..687 'lazy2.foo()': usize
18361836
550..552 '{}': ()
18371837
"###
18381838
);

crates/ra_hir_ty/src/traits/chalk.rs

+67-14
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(
@@ -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)