How to get entire type in rustc error message?

I'm trying to come up with the type bounds that are necessary for a highly generic function. Usually, I rely on the compiler error messages to tell me what bounds are missing, but it's replacing part of the type with _, even with cargo build --verbose.

error[E0277]: the trait bound `&FilterRel<RelProxy<&R>, _>: IntoIterator` is not satisfied
  --> src/relation/peerjoin.rs:69:22
   |
69 |                     .where_eq(key).iter_all()
   |                      ^^^^^^^^ the trait `IntoIterator` is not implemented for `&FilterRel<RelProxy<&R>, _>`
   |
   = help: the following implementations were found:
             <&'a FilterRel<R, F> as IntoIterator>
   = note: required because of the requirements on the impl of `RealizedQuery<'_, <R as RelationImpl>::Cols>` for `&FilterRel<RelProxy<&R>, _>`
   = note: required because of the requirements on the impl of `SelfQuery<'_>` for `FilterRel<RelProxy<&R>, _>`
   = note: required because of the requirements on the impl of `Relation<'_>` for `FilterRel<RelProxy<&R>, _>`

Is there some way I can supress this behavior to get the full type name that needs to be constrained?

I don't think there's a way to show the full type. However, the _ part is irrelevant. The compiler has determined that this bit is either correct, or changing it would not fix the problem.

My guess is that in your case it's because a shared borrow (&…) can't be an iterator. Iterators have to be mutable, so try &mut FilterRel<… or owned FilterRel<.

But they can be IntoIterator, which is the bound I actually need. As it turns out, the _ was the incorrect part. I had written

for<'b> FilterRel<RelProxy<&'a R>, <K as IntoFilter>::Result>: SelfQuery<'b>

But the actual bound I needed was:

for<'b> FilterRel<RelProxy<&'a R>, <K::Cols as IntoFilter>::Result>: SelfQuery<'b>

(Plus a bunch more bounds that didn't change)

In practice, I didn't have a bound specified at all for the type it was looking for. I had specified it for a type the compiler didn't care about instead.

(Still working on other issues getting this function working, so I might still have something wrong here)

EDIT I got it to compile; I'll see if I can actually call it successfully tomorrow, or if I've somehow written a set of unsatisfiable bounds. For the curious, here's what I've been working on:

Probably-unintelligible code
impl<'a, L, R, K, RCols> IntoIterator for &'a PeerJoin<L, R>
where
    L: Relation<'a> + SelfQuery<'a>,
    L::Item: Clone,
    R: Relation<'a>,
    K: Header + Eq + ProjectFrom<L::Cols> + Record + IntoFilter,
    <K as RecordImpl>::Cols: IntoFilter,
    for<'b> FilterRel<RelProxy<&'a R>, <K::Cols as IntoFilter>::Result>:
        SelfQuery<'b, Cols = R::Cols>,
    sexpr! {Intersect, {Phantom, @L::Cols}, @R::Cols}: Eval<Result = K>,
    PeerJoin<L, R>: RelationImpl,
    sexpr! {Remove, {Phantom, @K}, @R::Cols=r}:
        Calc<sexpr_quoted_types! {Remove, {Phantom, @K}, @R::Cols=r}, Result = RCols>,
    RCols: Header,
    (L::Item, RCols): Record,
    <PeerJoin<L, R> as RelationImpl>::Cols: ProjectFrom<<(L::Item, RCols) as RecordImpl>::Cols>,
{
    type Item = Projection<(L::Item, RCols), <PeerJoin<L, R> as RelationImpl>::Cols>;
    type IntoIter = impl 'a + Iterator<Item = Self::Item>;
    fn into_iter(self) -> Self::IntoIter {
        self.left.iter_all().flat_map(move |l| {
            let key: K = (&l).project().into_cols();
            let tmp: Vec<_> = self
                .right
                .as_ref()
                .where_eq(key)
                .iter_all()
                .map(|r| calc! {Remove, {Phantom, @K}, @R::Cols=r.into_cols()})
                .collect();
            tmp.into_iter().map(move |r| (l.clone(), r).project())
        })
    }
}
1 Like

Oh, that's a deficiency in the compiler then. Maybe file a bug?

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.