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

docs: Have panic!() and compile_error!() point to each other in docs #47275

Closed
ghost opened this issue Jan 8, 2018 · 4 comments
Closed

docs: Have panic!() and compile_error!() point to each other in docs #47275

ghost opened this issue Jan 8, 2018 · 4 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@ghost
Copy link

ghost commented Jan 8, 2018

While viewing the docs for each:
https://doc.rust-lang.org/beta/std/macro.panic.html
https://doc.rust-lang.org/beta/std/macro.compile_error.html
would be real nice to have them link to each other, like an "See also" thing, but probably not as simple as only two words.

(I don't know how to do that or even how to word it, hopefully someone will take this task)

For your consideration.
Thank you.

@kennytm kennytm added C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Jan 8, 2018
@alilleybrinker
Copy link
Contributor

I'd love to work on this.

@alilleybrinker
Copy link
Contributor

So, the relationship between "panic" and "compile_error" is that panic is meant to signal a run time error from which the thread cannot recover, while compile_error is meant to signal an error in compilation. Generally, compile_error is used in a few select contexts:

  1. For better error messages in writing your own macros.
  2. For better errors with conditional compilation.

Thinking about it more, it may make sense to have the compile_error docs reference panic, but not the other way around. Because confusion in the other direction seems unlikely.

@ghost
Copy link
Author

ghost commented Jan 11, 2018

Thinking about it more, it may make sense to have the compile_error docs reference panic, but not the other way around. Because confusion in the other direction seems unlikely.

I usually only remember the existence of panic! but I do know there's an equivalent for erroring during compile time, so I would just go ahead look up panic! and "expect" to find a link to compile_error! :)

I personally don't think they'd be any confusion between the two, mainly because I assume the wording would be slightly more verbose than simply "See also: panic!" or "See also: compile_error!", it'd be more like: "For throwing an error at compile-time, see compile_error!", or "For throwing an error at runtime, see panic!".

Hey, thanks for considering it ;)

ogham added a commit to ogham/rust that referenced this issue May 29, 2018
Fixes rust-lang#47275. These two macros are similar, but different, and could do with documentation links to each other.
@ogham
Copy link
Contributor

ogham commented May 29, 2018

I had a go at this today!

Thinking about it more, it may make sense to have the compile_error docs reference panic, but not the other way around.

I agree with the sentiment that panic!() is the “main” macro, and compile_error!() is the “secondary” macro. So I’ve tried to word it to say that the latter is the compiler version of the former, rather than giving them equal documentation footing.

kennytm added a commit to kennytm/rust that referenced this issue May 30, 2018
… r=GuillaumeGomez

Link panic and compile_error docs

This adds documentation links between `panic!()` and `compile_error!()` as per rust-lang#47275, which points out that they’re similar. It also adds a sentence to the `compile_error()` docs I thought could be added.
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jun 25, 2018
… r=GuillaumeGomez

Link panic and compile_error docs

This adds documentation links between `panic!()` and `compile_error!()` as per rust-lang#47275, which points out that they’re similar. It also adds a sentence to the `compile_error()` docs I thought could be added.
pietroalbini added a commit to pietroalbini/rust that referenced this issue Jun 26, 2018
… r=GuillaumeGomez

Link panic and compile_error docs

This adds documentation links between `panic!()` and `compile_error!()` as per rust-lang#47275, which points out that they’re similar. It also adds a sentence to the `compile_error()` docs I thought could be added.
@bors bors closed this as completed in 2d3c369 Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants