]>
Commit | Line | Data |
---|---|---|
0731742a | 1 | use rustc_data_structures::sync::Lrc; |
9fa01778 XL |
2 | use crate::infer::canonical::{Canonical, QueryResponse}; |
3 | use crate::ty::Ty; | |
0731742a XL |
4 | |
5 | #[derive(Debug)] | |
6 | pub struct CandidateStep<'tcx> { | |
7 | pub self_ty: Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, | |
8 | pub autoderefs: usize, | |
9 | // true if the type results from a dereference of a raw pointer. | |
10 | // when assembling candidates, we include these steps, but not when | |
11 | // picking methods. This so that if we have `foo: *const Foo` and `Foo` has methods | |
12 | // `fn by_raw_ptr(self: *const Self)` and `fn by_ref(&self)`, then | |
13 | // `foo.by_raw_ptr()` will work and `foo.by_ref()` won't. | |
14 | pub from_unsafe_deref: bool, | |
15 | pub unsize: bool, | |
16 | } | |
17 | ||
18 | #[derive(Clone, Debug)] | |
19 | pub struct MethodAutoderefStepsResult<'tcx> { | |
20 | /// The valid autoderef steps that could be find. | |
21 | pub steps: Lrc<Vec<CandidateStep<'tcx>>>, | |
22 | /// If Some(T), a type autoderef reported an error on. | |
23 | pub opt_bad_ty: Option<Lrc<MethodAutoderefBadTy<'tcx>>>, | |
24 | /// If `true`, `steps` has been truncated due to reaching the | |
25 | /// recursion limit. | |
26 | pub reached_recursion_limit: bool, | |
27 | } | |
28 | ||
29 | #[derive(Debug)] | |
30 | pub struct MethodAutoderefBadTy<'tcx> { | |
31 | pub reached_raw_pointer: bool, | |
32 | pub ty: Canonical<'tcx, QueryResponse<'tcx, Ty<'tcx>>>, | |
33 | } | |
34 | ||
35 | impl_stable_hash_for!(struct MethodAutoderefBadTy<'tcx> { | |
36 | reached_raw_pointer, ty | |
37 | }); | |
38 | ||
39 | impl_stable_hash_for!(struct MethodAutoderefStepsResult<'tcx> { | |
40 | reached_recursion_limit, steps, opt_bad_ty | |
41 | }); | |
42 | ||
43 | impl_stable_hash_for!(struct CandidateStep<'tcx> { | |
44 | self_ty, autoderefs, from_unsafe_deref, unsize | |
45 | }); |