Make Res::SelfTy a struct variant and update docs#93938
Make Res::SelfTy a struct variant and update docs#93938bors merged 4 commits intorust-lang:masterfrom
Res::SelfTy a struct variant and update docs#93938Conversation
|
Some changes occurred in cc @camelid Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
| Res::SelfTy { trait_: Some(trait_def_id), alias_to: _ } => (trait_def_id, ItemType::Trait), | ||
| // This is an inherent impl; it doesn't have its own page. | ||
| Res::SelfTy(None, Some((impl_def_id, _))) => return impl_def_id, | ||
| Res::SelfTy(None, None) | ||
| Res::SelfTy { trait_: None, alias_to: Some((impl_def_id, _)) } => return impl_def_id, | ||
| Res::SelfTy { trait_: None, alias_to: None } |
There was a problem hiding this comment.
I am not familiar with rustdoc so am not sure if this is actually a bug but these comments seem wrong 😅
the trait_: Some(trait) case is not just for trait definitions and is also there in impl Trait for Foo blocks
the trait_: None, alias_to: Some(..) is not just for inherent impls and is also there in struct defs (struct Foo(Box<Self>))
There was a problem hiding this comment.
If you can, please go ahead and update these comments so they're correct :)
There was a problem hiding this comment.
i think it makes sense to add a fixme to potentially change this to
Res::SelfTy { trait_: Some(trait_def_id), alias_to: None } => (trait_def_id, ItemType::Trait),i think the mention of impl Send for [u8] might be caused by this https://doc.rust-lang.org/nightly/std/marker/trait.Send.html#impl-Send-80
but i don't want to add functionality changes to rustdoc in this PR
This comment has been minimized.
This comment has been minimized.
| /// The trait this `Self` is a generic arg for. | ||
| trait_: Option<DefId>, | ||
| /// The item introducing the `Self` type alias. Can be used in the `type_of` query | ||
| /// to get the underlying type. Additionally whether the `Self` type is disallowed | ||
| /// from mentioning generics (i.e. when used in an anonymous constant). | ||
| alias_to: Option<(DefId, bool)>, |
There was a problem hiding this comment.
Thanks for naming these fields and improving the docs! I had a lot of trouble understanding this when I wrote the current version of the docs.
Why is alias_to an Option, though? When would it be None?
There was a problem hiding this comment.
inside of a trait def alias_to is None
trait Foo {
fn foo() -> Self;
// `Res::SelfTy { trait_: Some(Foo), alias_to: None }`
}There was a problem hiding this comment.
Ah, makes sense, thanks :)
Could you add a comment about that?
There was a problem hiding this comment.
Oops, just realized this was already merged 😅
There was a problem hiding this comment.
There's a comment about this if you look at the examples above the SelfTy variant
| Res::SelfTy { trait_: Some(trait_def_id), alias_to: _ } => (trait_def_id, ItemType::Trait), | ||
| // This is an inherent impl; it doesn't have its own page. | ||
| Res::SelfTy(None, Some((impl_def_id, _))) => return impl_def_id, | ||
| Res::SelfTy(None, None) | ||
| Res::SelfTy { trait_: None, alias_to: Some((impl_def_id, _)) } => return impl_def_id, | ||
| Res::SelfTy { trait_: None, alias_to: None } |
There was a problem hiding this comment.
If you can, please go ahead and update these comments so they're correct :)
|
after adding a fixme to rustdoc, r=me |
|
@bors r=lcnr |
|
📌 Commit 48a79bc has been approved by |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (b321742): comparison url. Summary: This benchmark run did not return any relevant results. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Make `Res::SelfTy` a struct variant and update docs I found pattern matching on a `(Option<DefId>, Option<(DefId, bool)>)` to not be super readable, additionally the doc comments on the types in a tuple variant aren't visible anywhere at use sites as far as I can tell (using rust analyzer + vscode) The docs incorrectly assumed that the `DefId` in `Option<(DefId, bool)>` would only ever be for an impl item and I also found the code examples to be somewhat unclear about which `DefId` was being talked about. r? `@lcnr` since you reviewed the last PR changing these docs
I found pattern matching on a
(Option<DefId>, Option<(DefId, bool)>)to not be super readable, additionally the doc comments on the types in a tuple variant aren't visible anywhere at use sites as far as I can tell (using rust analyzer + vscode)The docs incorrectly assumed that the
DefIdinOption<(DefId, bool)>would only ever be for an impl item and I also found the code examples to be somewhat unclear about whichDefIdwas being talked about.r? @lcnr since you reviewed the last PR changing these docs