-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE with GATs #50115
Comments
Similar situation with this, what's the right way to instantiate the GAT (with types this time)? pub trait ToOther {
type Other<P: AsPitch, V: AsVal, B: AsPitchBend>;
fn to_other<Pitch: AsPitch, Val: AsVal, Pb: AsPitchBend>(&self) -> Self::Other/*<Pitch, Val, Pb>*/;
}
impl<Pitch: AsPitch, Val: AsVal, Pb: AsPitchBend> ToOther for HighLvlMsg<Pitch, Val, Pb> {
type Other<P, V, B> = HighLvlMsg<P, V, B>;
fn to_other<Pitch2: AsPitch, Val2: AsVal, Pb2: AsPitchBend>(&self) -> Self::Other/*<Pitch2, Val2, Pb2>*/ {
use HighLvlMsg::*;
match *self {
NoteOn { pitch, vel, len } => NoteOn { pitch: AsPitch::conv(pitch), vel, len },
NoteOff { pitch, vel } => NoteOff { pitch: AsPitch::conv(pitch), vel },
ControlChange { cc, val } => ControlChange { cc, val: AsVal::conv(val) },
ProgramChange { prog } => ProgramChange { prog },
PitchBend { semitones } => PitchBend { semitones: AsPitchBend::conv(semitones) },
PolyphonicAftertouch { pitch, val } => PolyphonicAftertouch { pitch: AsPitch::conv(pitch), val: AsVal::conv(val) },
ChannelAftertouch { val } => ChannelAftertouch { val: AsVal::conv(val) },
}
}
}
|
Thanks for reporting this! Can you provide a small example to reproduce the ICE? With the custom types you used it's difficult for us to bisect/reproduce ourself :) |
#![feature(generic_associated_types)]
#![feature(associated_type_defaults)]
struct Foo;
struct Bar;
struct Baz;
struct A<'a> {
foo: &'a Foo,
}
struct B<'a> {
inherited: A<'a>,
own: Bar,
}
trait Trait: Clone + Default {
type Ctx<'a> = A<'a>;
fn process<'a>(&mut self, ctx: &Self::Ctx/*<'a>*/);
}
impl Trait for Baz {
type Ctx<'a> = B<'a>;
fn process<'a>(&mut self, ctx: &Self::Ctx/*<'a>*/) {}
}
fn main() {} https://play.rust-lang.org/?gist=5fc07e14a633f3ec4db4de1c421053ff&version=nightly |
This seems to be a known issue. GAT (#44265) is a WIP feature and probably not supposed to be usable yet.
|
Closing as a duplicate of #49362. |
What is the right way to do this?
It's underlinining
&Self::Ctx<'a>
but how else am I supposed to instantiate the GAT with a lifetime?Now I tried to omit the
<'a>
:But I get this (ICE):
What is the correct way to instantiate the GAT with a lifetime here?
The text was updated successfully, but these errors were encountered: