Stream: project-error-handling

Topic: specialization fix for Error/Debug


view this post on Zulip Jane Lusby (Apr 27 2021 at 18:48):

@Jakub Duchniewicz from the meeting, you asked about the examples niko gave for the possible work around to the specialization soundness issue

view this post on Zulip Jane Lusby (Apr 27 2021 at 18:48):

here are the notes I took in the meeting

view this post on Zulip Jane Lusby (Apr 27 2021 at 18:48):

Spec(Error) means ‘I implement Error in a lifetime agnostic way’

Impl<’a> error for mytype<’a> // ok

Struct mytype<’a, ‘b> { }
impl<’a> error for mytype<’a, ‘a> // not ok, requiring ‘b = ‘a

impl<T> Error for Box<T> where T: Error

Impl Error for MyType<’static>

view this post on Zulip Jane Lusby (Apr 27 2021 at 18:49):

so the first line was a random throw away syntax for what it would look like

view this post on Zulip Jane Lusby (Apr 27 2021 at 18:49):

and then the rest of them are examples of the issue

view this post on Zulip Jane Lusby (Apr 27 2021 at 18:49):

where the first one implements error for all lifetimes

view this post on Zulip Jane Lusby (Apr 27 2021 at 18:49):

but the other 3 potentially implement error conditionally based on lifetimes

view this post on Zulip Jane Lusby (Apr 27 2021 at 18:50):

so the idea would be that we would specialize only for error impls that don't condition the impl on any lifetimes, and we would probably also add a lint to warn on impls that are conditional and might not specialize

view this post on Zulip Jakub Duchniewicz (Apr 27 2021 at 18:57):

thanks, this makes it much clearer. Did not know about this soundness before you mentioned it recently!


Last updated: Jan 26 2022 at 14:20 UTC