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

#[track_caller] on fns in extern "Rust" #70830

Closed
Centril opened this issue Apr 6, 2020 · 1 comment · Fixed by #70916
Closed

#[track_caller] on fns in extern "Rust" #70830

Centril opened this issue Apr 6, 2020 · 1 comment · Fixed by #70916
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. F-track_caller `#![feature(track_caller)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@Centril
Copy link
Contributor

Centril commented Apr 6, 2020

Context: #69251 (comment)

Suppose we have:

extern "Rust" {
    #[track_caller]
    fn bar();
}

This currently produces an error, but @eddyb suggested that it could be allowed.
Then comes the question of what this would mean. One way to imagine this is that we'd alter the ABI of fn bar, as we usually do for #[track_caller] functions, to accept an additional parameter for the Location. When calling bar() we'd then propagate the location, again as usual.

However, the place which actually defines fn bar() { ... } would not be aware of the #[track_caller] annotation, so it seems to me that we'd have to insert a shim where the extern "Rust" block resides.

I've opened this issue to seek some clarity on what @eddyb meant as neither me nor @anp fully understood.

@Centril Centril added T-lang Relevant to the language team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. F-track_caller `#![feature(track_caller)]` labels Apr 6, 2020
@eddyb
Copy link
Member

eddyb commented Apr 6, 2020

However, the place which actually defines fn bar() { ... } would not be aware of the #[track_caller] annotation

It would be UB for the definition to not have it, just like unwinding is UB when the extern "Rust" { fn ... } import opted out of unwinding (or didn't opt in, not sure what's the default nowadays).

@Centril Centril added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Apr 6, 2020
@bors bors closed this as completed in 4f00396 Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. F-track_caller `#![feature(track_caller)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants