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

primitive docs should show core/alloc/std accessibility #62909

Open
cuviper opened this issue Jul 23, 2019 · 4 comments
Open

primitive docs should show core/alloc/std accessibility #62909

cuviper opened this issue Jul 23, 2019 · 4 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@cuviper
Copy link
Member

cuviper commented Jul 23, 2019

In #61851, I tried to generate primitive docs in core, similar to those in std. My main motivation was to clearly see what f64 methods are available in core alone, under #[no_std], since a lot of them require std and libm support. However, I had trouble making that work because of broken documentation links between core and std-specific methods.

So I think instead, rustdoc could put some kind of marker on primitive methods to indicate what crate added them, so the accessibility is known. Apart from floating point, there are also a few slice methods that are only added in alloc. Maybe there are more that I don't know yet!

@cuviper cuviper added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Jul 23, 2019
@cuviper cuviper changed the title primitive docs should core/alloc/std accessibility primitive docs should show core/alloc/std accessibility Jul 23, 2019
@Mark-Simulacrum
Copy link
Member

I'm going to move this to T-doc as I personally don't think we should special case things even more in rustdoc (and it seems much simpler to just add a line to the primitive docs in the relevant files today).

@Mark-Simulacrum Mark-Simulacrum added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools and removed T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Aug 30, 2019
@Mark-Simulacrum
Copy link
Member

Ah, I missed that this is about methods, not types. In that case yeah this probably needs to be in rustdoc (and I guess only applies to primitives since those bypass coherence).

@Mark-Simulacrum Mark-Simulacrum added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Aug 30, 2019
@jyn514
Copy link
Member

jyn514 commented Aug 25, 2020

Maybe there are more that I don't know yet!

map! {
Isize => single(lang_items.isize_impl()),
I8 => single(lang_items.i8_impl()),
I16 => single(lang_items.i16_impl()),
I32 => single(lang_items.i32_impl()),
I64 => single(lang_items.i64_impl()),
I128 => single(lang_items.i128_impl()),
Usize => single(lang_items.usize_impl()),
U8 => single(lang_items.u8_impl()),
U16 => single(lang_items.u16_impl()),
U32 => single(lang_items.u32_impl()),
U64 => single(lang_items.u64_impl()),
U128 => single(lang_items.u128_impl()),
F32 => both(lang_items.f32_impl(), lang_items.f32_runtime_impl()),
F64 => both(lang_items.f64_impl(), lang_items.f64_runtime_impl()),
Char => single(lang_items.char_impl()),
Bool => single(lang_items.bool_impl()),
Str => both(lang_items.str_impl(), lang_items.str_alloc_impl()),
Slice => {
lang_items
.slice_impl()
.into_iter()
.chain(lang_items.slice_u8_impl())
.chain(lang_items.slice_alloc_impl())
.chain(lang_items.slice_u8_alloc_impl())
.collect()
},
Array => single(lang_items.array_impl()),
Tuple => smallvec![],
Unit => smallvec![],
RawPointer => {
lang_items
.const_ptr_impl()
.into_iter()
.chain(lang_items.mut_ptr_impl())
.chain(lang_items.const_slice_ptr_impl())
.chain(lang_items.mut_slice_ptr_impl())
.collect()
},
Reference => smallvec![],
Fn => smallvec![],
Never => smallvec![],
}

@jyn514
Copy link
Member

jyn514 commented Jul 2, 2021

Rustdoc could do this by checking def_id.krate for each of these impls. I think this should go on the impl block itself, not the method, since it's impossible for the same impl to span multiple crates.

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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants