-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
pub macro
defined in submodule is shown at the wrong path
#74355
Comments
cc #63268 |
When a macro is marked as reexported, you can use it directly from the "top", so in this regard, isn't it the expected behavior? |
AFAIK that is not true for |
Note that there is no |
Code example: #![feature(raw_ref_macros)]
fn main() {
let mut x = 5;
// This works.
let xptr = core::ptr::raw_const!(x);
// This does not.
let xptr = core::raw_const!(x);
} So I think there is definitely a rustdoc bug here. The path it shows does not work. |
Oh I see. Indeed, it's a bug. |
Not sure if helpful, but the way we got public exports to work in rustdoc in This issue will also affect the upcoming |
@GuillaumeGomez how hard is it to fix this problem, and what does the rustdoc team's prioritization for this look like? We'd like to stabilize #73394, and I am not sure if we want to stabilize this while its docs are rendered incorrectly. |
Sorry but no idea. I don't have much time lately so maybe someone else from the @rust-lang/rustdoc will give it a try? Otherwise I'll try to fix it as soon as I have time. |
Yeah so the problem here is that we have TypeKind::Macro which forces all macros to live at the root. Given a Def or a Res, how do I tell if a macro is MBE or a newstyle macro? (There's a possibility that our current code actually handles this correctly already and we need to remove the special case for TypeKind::Macro) |
Okay so here are the two offending bits of code: rust/src/librustdoc/visit_ast.rs Lines 75 to 77 in ac48e62
rust/src/librustdoc/clean/inline.rs Lines 175 to 179 in ac48e62
The latter is more about linking to these items rather than rendering them. So the problem is that by the time stuff gets to rustdoc, we're looking at the HIR and the two kinds of macros are squashed together on It would be nice if MBEs stayed on I think having newstyle macros live on |
An option to do this purely in rustdoc would be to check the |
@petrochenkov will probably know best how to interpret this information; somehow macro name resolution also has to work with this, after all. |
I don't think name resolution actually operates on the hir that way. But yeah, worth letting him answer. |
I think you can recover the module they came from using the |
You can tell whether it's a |
…s_2_0-paths, r=jyn514,petrochenkov Rustdoc: Fix macros 2.0 and built-in derives being shown at the wrong path Fixes rust-lang#74355 - ~~waiting on author + draft PR since my code ought to be cleaned up _w.r.t._ the way I avoid the `.unwrap()`s:~~ - ~~dummy items may avoid the first `?`,~~ - ~~but within the module traversal some tests did fail (hence the second `?`), meaning the crate did not possess the exact path of the containing module (`extern` / `impl` blocks maybe? I'll look into that).~~ r? `@jyn514`
…-ou-se Stabilize raw ref macros This stabilizes `raw_ref_macros` (rust-lang#73394), which is possible now that rust-lang#74355 is fixed. However, as I already said in rust-lang#73394 (comment), I am not particularly happy with the current names of the macros. So I propose we also change them, which means I am proposing to stabilize the following in `core::ptr`: ```rust pub macro const_addr_of($e:expr) { &raw const $e } pub macro mut_addr_of($e:expr) { &raw mut $e } ``` The macro name change means we need another round of FCP. Cc `````@rust-lang/libs````` Fixes rust-lang#73394
…=m-ou-se Stabilize core::task::ready! _Tracking issue: https://github.com/rust-lang/rust/issues/70922_ This PR stabilizes the `task::ready!` macro. Similar to rust-lang#80886, this PR was waiting on rust-lang#74355 to be fixed. The `task::ready!` API has existed in the futures ecosystem for several years, and was added on nightly last year in rust-lang#70817. The motivation for this macro is the same as it was back then: virtually every single manual future implementation makes use of this; so much so that it's one of the few things included in the [futures-core](https://docs.rs/futures-core/0.3.12/futures_core) library. r? `@tmandry` cc/ `@rust-lang/wg-async-foundations` `@rust-lang/libs` ## Example ```rust use core::task::{Context, Poll}; use core::future::Future; use core::pin::Pin; async fn get_num() -> usize { 42 } pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> { let mut f = get_num(); let f = unsafe { Pin::new_unchecked(&mut f) }; let num = ready!(f.poll(cx)); // ... use num Poll::Ready(()) } ```
…=m-ou-se Stabilize core::task::ready! _Tracking issue: https://github.com/rust-lang/rust/issues/70922_ This PR stabilizes the `task::ready!` macro. Similar to rust-lang#80886, this PR was waiting on rust-lang#74355 to be fixed. The `task::ready!` API has existed in the futures ecosystem for several years, and was added on nightly last year in rust-lang#70817. The motivation for this macro is the same as it was back then: virtually every single manual future implementation makes use of this; so much so that it's one of the few things included in the [futures-core](https://docs.rs/futures-core/0.3.12/futures_core) library. r? ``@tmandry`` cc/ ``@rust-lang/wg-async-foundations`` ``@rust-lang/libs`` ## Example ```rust use core::task::{Context, Poll}; use core::future::Future; use core::pin::Pin; async fn get_num() -> usize { 42 } pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> { let mut f = get_num(); let f = unsafe { Pin::new_unchecked(&mut f) }; let num = ready!(f.poll(cx)); // ... use num Poll::Ready(()) } ```
Stabilize raw ref macros This stabilizes `raw_ref_macros` (rust-lang/rust#73394), which is possible now that rust-lang/rust#74355 is fixed. However, as I already said in rust-lang/rust#73394 (comment), I am not particularly happy with the current names of the macros. So I propose we also change them, which means I am proposing to stabilize the following in `core::ptr`: ```rust pub macro const_addr_of($e:expr) { &raw const $e } pub macro mut_addr_of($e:expr) { &raw mut $e } ``` The macro name change means we need another round of FCP. Cc `````@rust-lang/libs````` Fixes #73394
rustdoc is showing the
raw_mut
macro at the wrong path in libcore: https://doc.rust-lang.org/nightly/core/macro.raw_mut.html sayscore::raw_mut
but really it iscore::ptr::raw_mut
(and the same goes forcore::ptr::raw_const
). Looks likepub macro
is not handled correctly?Cc @rust-lang/rustdoc
The text was updated successfully, but these errors were encountered: