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

How to define panic_fmt is not documented well #33677

Closed
habnabit opened this issue May 16, 2016 · 6 comments
Closed

How to define panic_fmt is not documented well #33677

habnabit opened this issue May 16, 2016 · 6 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Comments

@habnabit
Copy link
Contributor

This includes on https://doc.rust-lang.org/book/no-stdlib.html and https://doc.rust-lang.org/core/. The former has an incorrect signature on panic_fmt and the latter doesn't mention that you need a #[lang] annotation. The relationship between panic_fmt and rust_begin_unwind (the former is a lang item, and the latter is a symbol that the former produces) has been confusing people on #rust recently, and should probably be documented as well.

For reference, the correct way to define it is:

#[lang="panic_fmt"]
#[unwind]
extern fn panic_fmt(args: ::core::fmt::Arguments, file: &'static str, line: u32) -> ! {
    // ...
}

Every part of that signature (except the function name) is necessary; any omission can cause unclear or misleading errors, or lead to the function being called with the wrong ABI.

@oli-obk
Copy link
Contributor

oli-obk commented May 17, 2016

related: #9307

@nagisa nagisa added the A-docs label May 17, 2016
@steveklabnik
Copy link
Member

Sigh, I just ran into this today. Will send a PR tomorrow.

@steveklabnik steveklabnik added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. labels Jun 27, 2016
@steveklabnik
Copy link
Member

apparently tomorrow never came. I am willing to mentor anyone who wants to add this

@steveklabnik steveklabnik added the E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. label Jun 27, 2016
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 15, 2016
1. Fix the sections in the book to have the correct signatures. I've
   also marked them as `ignore`; there's no way to set the `no_std`
   feature for libc, so it pulls in the stdlib, so this wasn't even
   testing the actual thing it was testing. Better to just ignore.
2. Correcting libcore's docs for factual inaccuracy, and add a note
   about language items.

Fixes rust-lang#33677
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Jul 16, 2016
Fix up documentation around no_std

1. Fix the sections in the book to have the correct signatures. I've
   also marked them as `ignore`; there's no way to set the `no_std`
   feature for libc, so it pulls in the stdlib, so this wasn't even
   testing the actual thing it was testing. Better to just ignore.
2. Correcting libcore's docs for factual inaccuracy, and add a note
   about language items.

Fixes rust-lang#33677

r? @alexcrichton
@pepyakin
Copy link
Contributor

It seems https://doc.rust-lang.org/book/no-stdlib.html is no longer exists
So what is preferred way of declaring panic_fmt lang item?

@pepyakin
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-help-wanted Call for participation: Help is requested to fix this issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Projects
None yet
Development

No branches or pull requests

5 participants