Skip to content

ICE when trying to make trait inheritence + 'self region work #8873

@olsonjeffery

Description

@olsonjeffery

Was working on trying to inherit from a trait with a <'self> lifetime parameter, like so:

trait A<'self> { fn foo(&self) -> &'self str; }  trait B : A { fn bar(&self); }

and was getting this compile error:

error: Illegal anonymous lifetime: anonymous lifetimes are not permitted here
trait A<'self> { fn foo(&self) -> &'self str; }  trait B : A { fn bar(&self); }
                                                                              ^~
aborting due to previous error

So I thought maybe I could just annotate the inherited trait with the lifetime:

trait A<'self> { fn foo(&self) -> &'self str; }  trait B<'self> : A<'self> { fn bar(&self); }

which produced this ice:

task <unnamed> failed at 'region parameterization should have inferred that this type is RP', /home/rustbuild/src/rust-buildbot/slave/snap3-linux/build/src/librustc/middle/typeck/rscope.rs:238
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1,::rt::backtrace to get further details and report the results to github.com/mozilla/rust/issues
task <unnamed> failed at 'explicit failure', /home/rustbuild/src/rust-buildbot/slave/snap3-linux/build/src/librustc/rustc.rs:371
make: *** [x86_64-unknown-linux-gnu/stage0/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd.so] Error 101

AFAICT, it's putting <'self> on A when declaring B is what's causing the ICE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions