Skip to content
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

error: allow backtrace Option to be Display on stable #258

Merged

Conversation

Fishrock123
Copy link
Member

This prevents the need for users to do backtrace feature-checking for code that wishes to use Display for a backtrace and also compile on stable.

@jbr
Copy link
Member

jbr commented Oct 9, 2020

Why wouldn't the user just test if the option is None?

@jbr
Copy link
Member

jbr commented Oct 9, 2020

Ohhh… I see what's going on. What if we just used some already available type like Option<String> (which also implements Display)

@Fishrock123
Copy link
Member Author

I don't understand? Option<Option<?>>? Option only implements Display if T also does.
The idea here is to have the same traits as Backtrace so the type system doesn't complain on stable.

@jbr
Copy link
Member

jbr commented Oct 10, 2020

@Fishrock123 sorry, forgot that comments don't auto escape < — typed Option<String>. the String part is what would change. Pretty much any built-in-type that's Display+Debug, because writing code that will never be executed seems a little weird. At the very least, we could unreachable!() it to make clear it shouldn't ever get called

This prevents the need for users to do backtrace feature-checking for code that wishes to use `Display` for a backtrace and also compile on stable.
@Fishrock123 Fishrock123 force-pushed the error-backtrace-stable-display branch from b05488c to 10c3f60 Compare October 13, 2020 20:00
@Fishrock123
Copy link
Member Author

I would rather it be a type that implements exactly the same traits as Backtrace, personally.

@Fishrock123
Copy link
Member Author

Fishrock123 commented Oct 13, 2020

Ultimately, the correct answer here is that it would be Option<!>, using the experimental never type to denote that it will only ever be None. (And also because never is able to auto-implement all basic traits. Or something.)

@jbr
Copy link
Member

jbr commented Oct 14, 2020

Yep, agreed that ! would be ideal if stable

Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is a fun patch. Looking good!

@yoshuawuyts yoshuawuyts merged commit 4599842 into http-rs:main Nov 27, 2020
@Fishrock123 Fishrock123 deleted the error-backtrace-stable-display branch November 27, 2020 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants