Skip to content

ICE with trait alias when alias refers to bare Self #59029

Closed
@seanmonstar

Description

@seanmonstar
Contributor
trait Svc<Req> {
    type Res;
}

// ICEs:
trait MkSvc<Target, Req> = Svc<Target> where Self::Res: Svc<Req>;

// works:
// trait MkSvc<Target, Req> = Svc<Target> where <Self as Svc<Target>>::Res: Svc<Req>;

Related playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e29c998d2dc1d0c0ef60f4f3bd5ae934

The compiler outputs:

error: internal compiler error: src/librustc/hir/map/mod.rs:546: ty_param_owner: trait alias MkSvc (id=17) not a type parameter

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:620:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error

note: the compiler unexpectedly panicked. this is a bug.

note: rustc 1.35.0-nightly (88f755f8a 2019-03-07) running on x86_64-unknown-linux-gnu

cc #41517

Activity

added
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
on Mar 8, 2019
alexreg

alexreg commented on Mar 8, 2019

@alexreg
Contributor

Thanks for the report. I don't think the fix for this is too difficult judging by your example. Unfortunately, I'm very busy right now. You've contributed to rustc before, if I'm not mistaken... would you be interested in taking up this fix if I mentored/reviewed?

seanmonstar

seanmonstar commented on Mar 8, 2019

@seanmonstar
ContributorAuthor

@alexreg I'd be happy to help. I spent a couple hours last night trying to figure out how to work on the related "import methods" issue, and was completely at a loss of how to find it.

alexreg

alexreg commented on Mar 9, 2019

@alexreg
Contributor

@seanmonstar Super! I'd like to tackle method importing for both trait aliases and maybe type aliases too, but due to my lack of experience in that area, I'll probably need to chat it over with someone first. (@rust-lang/compiler, any ideas who would be good for this?)

This issue should be no problem though. Would you like me to post some general suggestions/pointers here, or chat about it? I'm on Discord/Zulip if you prefer the latter.

seanmonstar

seanmonstar commented on Mar 9, 2019

@seanmonstar
ContributorAuthor

@alexreg If you wouldn't mind leaving pointers here, it'll be easier to find later (like Monday). Or maybe someone can beat me to it. I got to this line from the panic message at least:

_ => bug!("ty_param_owner: {} not a type parameter", self.hir_to_string(id))

alexreg

alexreg commented on Mar 11, 2019

@alexreg
Contributor

@seanmonstar Unfortunately I didn't get a chance to have a proper look at this on the weekend, but I've just looked quickly, and I'm hoping the fix may be as easy as matching ItemKind::TraitAlias as well as ItemKind::Trait on

Node::Item(&Item { node: ItemKind::Trait(..), .. }) => id,

If that's not enough to fix it (may well not be), have a peek around the type_param_predicates fn in collect.rs and try handling trait aliases in an analogous way to traits.

Let me know what this yields.

alexreg

alexreg commented on Mar 11, 2019

@alexreg
Contributor

@Centril Did you nominate this because of my questions about importing or what?

Centril

Centril commented on Mar 11, 2019

@Centril
Contributor

@alexreg I-ICEs are generally nominated for triage I think.

alexreg

alexreg commented on Mar 11, 2019

@alexreg
Contributor

Okay.

13 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-trait-systemArea: Trait systemC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @seanmonstar@alexreg@pnkfelix@Centril@jonas-schievink

      Issue actions

        ICE with trait alias when alias refers to bare Self · Issue #59029 · rust-lang/rust