Skip to content

where clause in generic associated types causes no output #47206

Closed
@sunjay

Description

@sunjay

I'm working on implementing generic associated types in the compiler with mentoring by @nikomatsakis. He recently discovered an interesting issue that we're haven't found the source of yet. It seems that having a where clause like the one below results in a compilation error but no output.

The feature isn't actually fully finished yet, so we expect a compilation error. It just isn't clear why the compiler isn't actually reporting any specific problems. The message says that it failed due to a previous error but doesn't list any errors at all.

Here's the code that reproduces the issue: (Playground link)

#![feature(generic_associated_types)]

trait Foo {
    type Assoc3<T>;
}

struct Bar;

impl Foo for Bar {
    type Assoc3<T> where T: Iterator = Vec<T>;
}

fn main() {}

Here's the output:

   Compiling playground v0.0.1 (file:///playground)
error: cannot continue compilation due to previous error

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

This is on the nightly compiler because the feature is gated while we're still working on it. If you try to run this on stable or beta, you get a normal error message.

If you delete the where T: Iterator you get an ICE which I think is expected given what I still have left to implement for the generic associated types feature.

It might be that this gets fixed while we keep implementing generic associated types. Creating this issue will make sure that this doesn't get forgotten along the way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-GATsArea: Generic associated types (GATs)A-associated-itemsArea: Associated items (types, constants & functions)C-bugCategory: This is a bug.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATsP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions