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

Make an "I just want to use ?" type for use as a main return type #2367

Open
scottmcm opened this issue Mar 22, 2018 · 7 comments
Open

Make an "I just want to use ?" type for use as a main return type #2367

scottmcm opened this issue Mar 22, 2018 · 7 comments
Labels
T-lang Relevant to the language team, which will review and decide on the RFC. T-libs-api Relevant to the library API team, which will review and decide on the RFC.

Comments

@scottmcm
Copy link
Member

scottmcm commented Mar 22, 2018

Inspired by rust-lang/rust#49162 (comment)

With ?-in-main about to stabilize, it would be nice to have an "it just works" return type for main so that one can start a bin with fn main() -> InsertSomethingEasyHere { until you care about doing something else.

Edit: Would also be nice for tests, since they never care about the error type, just whether there was one. (cc rust-lang/rust#48854)

Tagging lang in case this needs tweaks to ? to work well with heterogeneous error types.
Tagging libs in case this should be an alias for something like Result<(), Box<Error>> or involve failure in some way.

@scottmcm scottmcm added T-lang Relevant to the language team, which will review and decide on the RFC. T-libs-api Relevant to the library API team, which will review and decide on the RFC. labels Mar 22, 2018
@JustAPerson
Copy link

Does impl Termination not suffice?

@scottmcm
Copy link
Member Author

@JustAPerson It's currently incompatible with ?, see rust-lang/rust#43301 (comment)

@clarfonthey
Copy link
Contributor

Wouldn't Result<(), impl Debug> suffice?

@scottmcm
Copy link
Member Author

@clarcharr That also doesn't work today, for the same reason as impl Termination.

@sgrif
Copy link
Contributor

sgrif commented Apr 1, 2018

Something like fn main() -> ? does seem like it'd be nice to have (not as nice as fn main() { just "working" when ? is used, but that sounds significantly more complicated and would have greater implications)

@Centril
Copy link
Contributor

Centril commented Apr 1, 2018

@sgrif Personally I'd like to reserve ? in such situations for typed toles (as used in Agda, etc.)

@scottmcm
Copy link
Member Author

I put some thoughts about how changing the desugaring of ? could help support this in the try_trait tracking issue: rust-lang/rust#42327 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC. T-libs-api Relevant to the library API team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

5 participants