diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-27 10:50:08 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-27 10:50:08 +0100 |
commit | 18a6dd4635be18ebe73eb25ffa34a33f0ec8203f (patch) | |
tree | 38c2e2b9aaf1d721c8ab04b4f03ca29b27df4e85 /crates/ra_hir_ty/src/traits | |
parent | dd3f9eaceb17f5686f6377250cbe510b348af318 (diff) | |
parent | 7e104ea4a885c8fd6f348a0d7d30911fe49d91e8 (diff) |
Merge #4982
4982: Bump chalk r=matklad a=lnicola
This passes the tests, but fails in a weird way on `analysis-stats`:
```
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/chalk-solve-0.14.0/src/clauses/builtin_traits/fn_family.rs:96:20
stack backtrace:
0: backtrace::backtrace::libunwind::trace
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
1: backtrace::backtrace::trace_unsynchronized
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
2: std::sys_common::backtrace::_print_fmt
at src/libstd/sys_common/backtrace.rs:78
3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
at src/libstd/sys_common/backtrace.rs:59
4: core::fmt::write
at src/libcore/fmt/mod.rs:1076
5: std::io::Write::write_fmt
at src/libstd/io/mod.rs:1537
6: std::sys_common::backtrace::_print
at src/libstd/sys_common/backtrace.rs:62
7: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:49
8: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:198
9: std::panicking::default_hook
at src/libstd/panicking.rs:218
10: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:477
11: rust_begin_unwind
at src/libstd/panicking.rs:385
12: core::panicking::panic_fmt
at src/libcore/panicking.rs:86
13: core::panicking::panic
at src/libcore/panicking.rs:51
14: chalk_solve::clauses::builtin_traits::fn_family::add_fn_trait_program_clauses
15: chalk_solve::clauses::builder::ClauseBuilder<I>::push_binders
16: chalk_solve::clauses::program_clauses_that_could_match
17: chalk_solve::clauses::program_clauses_for_goal
18: chalk_solve::recursive::Solver<I>::solve_new_subgoal
19: <chalk_solve::recursive::Solver<I> as chalk_solve::recursive::solve::SolveDatabase<I>>::solve_goal
20: chalk_solve::recursive::Solver<I>::solve_root_goal
21: chalk_solve::solve::Solver<I>::solve_limited
22: ra_hir_ty::traits::trait_solve_query
23: salsa::runtime::Runtime<DB>::execute_query_implementation
24: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade
25: salsa::derived::slot::Slot<DB,Q,MP>::read
26: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch
27: salsa::QueryTable<DB,Q>::get
28: <T as ra_hir_ty::db::HirDatabase>::trait_solve
29: ra_hir_ty::infer::InferenceContext::resolve_ty_as_possible
30: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
31: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce
32: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::check_call_arguments
33: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_method_call
34: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
35: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr
36: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_method_call
37: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
38: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce
39: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
40: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
41: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce
42: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_inner
43: ra_hir_ty::infer::expr::<impl ra_hir_ty::infer::InferenceContext>::infer_expr_coerce
44: ra_hir_ty::infer::infer_query
45: salsa::runtime::Runtime<DB>::execute_query_implementation
46: salsa::derived::slot::Slot<DB,Q,MP>::read_upgrade
47: salsa::derived::slot::Slot<DB,Q,MP>::read
48: <salsa::derived::DerivedStorage<DB,Q,MP> as salsa::plumbing::QueryStorageOps<DB,Q>>::try_fetch
49: ra_hir_ty::db::infer_wait
50: rust_analyzer::cli::analysis_stats::analysis_stats
51: rust_analyzer::main
52: std::rt::lang_start::{{closure}}
53: std::rt::lang_start_internal::{{closure}}
at src/libstd/rt.rs:52
54: std::panicking::try::do_call
at src/libstd/panicking.rs:297
55: std::panicking::try
at src/libstd/panicking.rs:274
56: std::panic::catch_unwind
at src/libstd/panic.rs:394
57: std::rt::lang_start_internal
at src/libstd/rt.rs:51
58: main
59: __libc_start_main
60: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```
It's as if we're returning `None` for a well-known trait that `chalk` asks about. That seems to happen for `Deref`, `CoerceUnsized` and `Try`.
r? @flodiebold
Co-authored-by: Laurențiu Nicola <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/traits')
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 86 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk/interner.rs | 1 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk/mapping.rs | 9 |
3 files changed, 80 insertions, 16 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 2f35d6d49..8ef4941c0 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs | |||
@@ -48,6 +48,9 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
48 | fn adt_datum(&self, struct_id: AdtId) -> Arc<StructDatum> { | 48 | fn adt_datum(&self, struct_id: AdtId) -> Arc<StructDatum> { |
49 | self.db.struct_datum(self.krate, struct_id) | 49 | self.db.struct_datum(self.krate, struct_id) |
50 | } | 50 | } |
51 | fn adt_repr(&self, _struct_id: AdtId) -> rust_ir::AdtRepr { | ||
52 | unreachable!() | ||
53 | } | ||
51 | fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> { | 54 | fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> { |
52 | self.db.impl_datum(self.krate, impl_id) | 55 | self.db.impl_datum(self.krate, impl_id) |
53 | } | 56 | } |
@@ -128,8 +131,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
128 | well_known_trait: rust_ir::WellKnownTrait, | 131 | well_known_trait: rust_ir::WellKnownTrait, |
129 | ) -> Option<chalk_ir::TraitId<Interner>> { | 132 | ) -> Option<chalk_ir::TraitId<Interner>> { |
130 | let lang_attr = lang_attr_from_well_known_trait(well_known_trait); | 133 | let lang_attr = lang_attr_from_well_known_trait(well_known_trait); |
131 | let lang_items = self.db.crate_lang_items(self.krate); | 134 | let trait_ = match self.db.lang_item(self.krate, lang_attr.into()) { |
132 | let trait_ = match lang_items.target(lang_attr) { | ||
133 | Some(LangItemTarget::TraitId(trait_)) => trait_, | 135 | Some(LangItemTarget::TraitId(trait_)) => trait_, |
134 | _ => return None, | 136 | _ => return None, |
135 | }; | 137 | }; |
@@ -186,6 +188,39 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
186 | // FIXME: implement actual object safety | 188 | // FIXME: implement actual object safety |
187 | true | 189 | true |
188 | } | 190 | } |
191 | |||
192 | fn closure_kind( | ||
193 | &self, | ||
194 | _closure_id: chalk_ir::ClosureId<Interner>, | ||
195 | _substs: &chalk_ir::Substitution<Interner>, | ||
196 | ) -> rust_ir::ClosureKind { | ||
197 | // FIXME: implement closure support | ||
198 | unimplemented!() | ||
199 | } | ||
200 | fn closure_inputs_and_output( | ||
201 | &self, | ||
202 | _closure_id: chalk_ir::ClosureId<Interner>, | ||
203 | _substs: &chalk_ir::Substitution<Interner>, | ||
204 | ) -> chalk_ir::Binders<rust_ir::FnDefInputsAndOutputDatum<Interner>> { | ||
205 | // FIXME: implement closure support | ||
206 | unimplemented!() | ||
207 | } | ||
208 | fn closure_upvars( | ||
209 | &self, | ||
210 | _closure_id: chalk_ir::ClosureId<Interner>, | ||
211 | _substs: &chalk_ir::Substitution<Interner>, | ||
212 | ) -> chalk_ir::Binders<chalk_ir::Ty<Interner>> { | ||
213 | // FIXME: implement closure support | ||
214 | unimplemented!() | ||
215 | } | ||
216 | fn closure_fn_substitution( | ||
217 | &self, | ||
218 | _closure_id: chalk_ir::ClosureId<Interner>, | ||
219 | _substs: &chalk_ir::Substitution<Interner>, | ||
220 | ) -> chalk_ir::Substitution<Interner> { | ||
221 | // FIXME: implement closure support | ||
222 | unimplemented!() | ||
223 | } | ||
189 | } | 224 | } |
190 | 225 | ||
191 | pub(crate) fn program_clauses_for_chalk_env_query( | 226 | pub(crate) fn program_clauses_for_chalk_env_query( |
@@ -250,7 +285,7 @@ pub(crate) fn trait_datum_query( | |||
250 | upstream: trait_.lookup(db.upcast()).container.module(db.upcast()).krate != krate, | 285 | upstream: trait_.lookup(db.upcast()).container.module(db.upcast()).krate != krate, |
251 | non_enumerable: true, | 286 | non_enumerable: true, |
252 | coinductive: false, // only relevant for Chalk testing | 287 | coinductive: false, // only relevant for Chalk testing |
253 | // FIXME set these flags correctly | 288 | // FIXME: set these flags correctly |
254 | marker: false, | 289 | marker: false, |
255 | fundamental: false, | 290 | fundamental: false, |
256 | }; | 291 | }; |
@@ -272,20 +307,28 @@ pub(crate) fn trait_datum_query( | |||
272 | 307 | ||
273 | fn well_known_trait_from_lang_attr(name: &str) -> Option<WellKnownTrait> { | 308 | fn well_known_trait_from_lang_attr(name: &str) -> Option<WellKnownTrait> { |
274 | Some(match name { | 309 | Some(match name { |
275 | "sized" => WellKnownTrait::SizedTrait, | 310 | "sized" => WellKnownTrait::Sized, |
276 | "copy" => WellKnownTrait::CopyTrait, | 311 | "copy" => WellKnownTrait::Copy, |
277 | "clone" => WellKnownTrait::CloneTrait, | 312 | "clone" => WellKnownTrait::Clone, |
278 | "drop" => WellKnownTrait::DropTrait, | 313 | "drop" => WellKnownTrait::Drop, |
314 | "fn_once" => WellKnownTrait::FnOnce, | ||
315 | "fn_mut" => WellKnownTrait::FnMut, | ||
316 | "fn" => WellKnownTrait::Fn, | ||
317 | "unsize" => WellKnownTrait::Unsize, | ||
279 | _ => return None, | 318 | _ => return None, |
280 | }) | 319 | }) |
281 | } | 320 | } |
282 | 321 | ||
283 | fn lang_attr_from_well_known_trait(attr: WellKnownTrait) -> &'static str { | 322 | fn lang_attr_from_well_known_trait(attr: WellKnownTrait) -> &'static str { |
284 | match attr { | 323 | match attr { |
285 | WellKnownTrait::SizedTrait => "sized", | 324 | WellKnownTrait::Sized => "sized", |
286 | WellKnownTrait::CopyTrait => "copy", | 325 | WellKnownTrait::Copy => "copy", |
287 | WellKnownTrait::CloneTrait => "clone", | 326 | WellKnownTrait::Clone => "clone", |
288 | WellKnownTrait::DropTrait => "drop", | 327 | WellKnownTrait::Drop => "drop", |
328 | WellKnownTrait::FnOnce => "fn_once", | ||
329 | WellKnownTrait::FnMut => "fn_mut", | ||
330 | WellKnownTrait::Fn => "fn", | ||
331 | WellKnownTrait::Unsize => "unsize", | ||
289 | } | 332 | } |
290 | } | 333 | } |
291 | 334 | ||
@@ -309,8 +352,9 @@ pub(crate) fn struct_datum_query( | |||
309 | .unwrap_or_else(Vec::new); | 352 | .unwrap_or_else(Vec::new); |
310 | let flags = rust_ir::AdtFlags { | 353 | let flags = rust_ir::AdtFlags { |
311 | upstream, | 354 | upstream, |
312 | // FIXME set fundamental flag correctly | 355 | // FIXME set fundamental and phantom_data flags correctly |
313 | fundamental: false, | 356 | fundamental: false, |
357 | phantom_data: false, | ||
314 | }; | 358 | }; |
315 | let struct_datum_bound = rust_ir::AdtDatumBound { | 359 | let struct_datum_bound = rust_ir::AdtDatumBound { |
316 | fields: Vec::new(), // FIXME add fields (only relevant for auto traits) | 360 | fields: Vec::new(), // FIXME add fields (only relevant for auto traits) |
@@ -448,11 +492,23 @@ pub(crate) fn fn_def_datum_query( | |||
448 | let where_clauses = convert_where_clauses(db, callable_def.into(), &bound_vars); | 492 | let where_clauses = convert_where_clauses(db, callable_def.into(), &bound_vars); |
449 | let bound = rust_ir::FnDefDatumBound { | 493 | let bound = rust_ir::FnDefDatumBound { |
450 | // Note: Chalk doesn't actually use this information yet as far as I am aware, but we provide it anyway | 494 | // 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(), | 495 | inputs_and_output: make_binders( |
452 | return_type: sig.value.ret().clone().to_chalk(db), | 496 | rust_ir::FnDefInputsAndOutputDatum { |
497 | argument_types: sig | ||
498 | .value | ||
499 | .params() | ||
500 | .iter() | ||
501 | .map(|ty| ty.clone().to_chalk(db)) | ||
502 | .collect(), | ||
503 | return_type: sig.value.ret().clone().to_chalk(db), | ||
504 | } | ||
505 | .shifted_in(&Interner), | ||
506 | 0, | ||
507 | ), | ||
453 | where_clauses, | 508 | where_clauses, |
454 | }; | 509 | }; |
455 | let datum = FnDefDatum { id: fn_def_id, binders: make_binders(bound, sig.num_binders) }; | 510 | let datum = |
511 | FnDefDatum { id: fn_def_id, binders: make_binders(bound, sig.num_binders), abi: () }; | ||
456 | Arc::new(datum) | 512 | Arc::new(datum) |
457 | } | 513 | } |
458 | 514 | ||
diff --git a/crates/ra_hir_ty/src/traits/chalk/interner.rs b/crates/ra_hir_ty/src/traits/chalk/interner.rs index 56aab640c..15426b022 100644 --- a/crates/ra_hir_ty/src/traits/chalk/interner.rs +++ b/crates/ra_hir_ty/src/traits/chalk/interner.rs | |||
@@ -42,6 +42,7 @@ impl chalk_ir::interner::Interner for Interner { | |||
42 | type DefId = InternId; | 42 | type DefId = InternId; |
43 | type InternedAdtId = crate::TypeCtorId; | 43 | type InternedAdtId = crate::TypeCtorId; |
44 | type Identifier = TypeAliasId; | 44 | type Identifier = TypeAliasId; |
45 | type FnAbi = (); | ||
45 | 46 | ||
46 | fn debug_adt_id(type_kind_id: AdtId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { | 47 | fn debug_adt_id(type_kind_id: AdtId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { |
47 | tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt))) | 48 | tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt))) |
diff --git a/crates/ra_hir_ty/src/traits/chalk/mapping.rs b/crates/ra_hir_ty/src/traits/chalk/mapping.rs index 18e5c9c16..ac82ea831 100644 --- a/crates/ra_hir_ty/src/traits/chalk/mapping.rs +++ b/crates/ra_hir_ty/src/traits/chalk/mapping.rs | |||
@@ -65,7 +65,10 @@ impl ToChalk for Ty { | |||
65 | &Interner, | 65 | &Interner, |
66 | predicates.iter().filter(|p| !p.is_error()).cloned().map(|p| p.to_chalk(db)), | 66 | predicates.iter().filter(|p| !p.is_error()).cloned().map(|p| p.to_chalk(db)), |
67 | ); | 67 | ); |
68 | let bounded_ty = chalk_ir::DynTy { bounds: make_binders(where_clauses, 1) }; | 68 | let bounded_ty = chalk_ir::DynTy { |
69 | bounds: make_binders(where_clauses, 1), | ||
70 | lifetime: LIFETIME_PLACEHOLDER.to_lifetime(&Interner), | ||
71 | }; | ||
69 | chalk_ir::TyData::Dyn(bounded_ty).intern(&Interner) | 72 | chalk_ir::TyData::Dyn(bounded_ty).intern(&Interner) |
70 | } | 73 | } |
71 | Ty::Opaque(opaque_ty) => { | 74 | Ty::Opaque(opaque_ty) => { |
@@ -319,6 +322,10 @@ impl ToChalk for TypeCtor { | |||
319 | // this should not be reached, since we don't represent TypeName::Error with TypeCtor | 322 | // this should not be reached, since we don't represent TypeName::Error with TypeCtor |
320 | unreachable!() | 323 | unreachable!() |
321 | } | 324 | } |
325 | TypeName::Closure(_) => { | ||
326 | // FIXME: implement closure support | ||
327 | unreachable!() | ||
328 | } | ||
322 | } | 329 | } |
323 | } | 330 | } |
324 | } | 331 | } |