Skip to content

Commit

Permalink
rustdoc-search: simplify rules for generics and type params
Browse files Browse the repository at this point in the history
This commit is a response to feedback on the displayed type
signatures results, by making generics act stricter.

Generics are tightened by making order significant. This means
`Vec<Allocator>` now matches only with a true vector of allocators,
instead of matching the second type param. It also makes unboxing
within generics stricter, so `Result<A, B>` only matches if `B`
is in the error type and `A` is in the success type. The top level
of the function search is unaffected.

Find the discussion on:

* <https://rust-lang.zulipchat.com/#narrow/stream/393423-t-rustdoc.2Fmeetings/topic/meeting.202024-07-08/near/449965149>
* <rust-lang#124544 (comment)>
* <https://rust-lang.zulipchat.com/#narrow/channel/266220-t-rustdoc/topic/deciding.20on.20semantics.20of.20generics.20in.20rustdoc.20search/near/476841363>
  • Loading branch information
notriddle committed Oct 30, 2024
1 parent 8c0bdb3 commit c353337
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions alloc/src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ pub use thin::ThinBox;
#[fundamental]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_insignificant_dtor]
#[cfg_attr(not(bootstrap), doc(search_unbox))]
// The declaration of the `Box` struct must be kept in sync with the
// compiler or ICEs will happen.
pub struct Box<
Expand Down
1 change: 1 addition & 0 deletions alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ fn rc_inner_layout_for_value_layout(layout: Layout) -> Layout {
/// `value.get_mut()`. This avoids conflicts with methods of the inner type `T`.
///
/// [get_mut]: Rc::get_mut
#[cfg_attr(not(bootstrap), doc(search_unbox))]
#[cfg_attr(not(test), rustc_diagnostic_item = "Rc")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_insignificant_dtor]
Expand Down
1 change: 1 addition & 0 deletions alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ macro_rules! acquire {
/// counting in general.
///
/// [rc_examples]: crate::rc#examples
#[cfg_attr(not(bootstrap), doc(search_unbox))]
#[cfg_attr(not(test), rustc_diagnostic_item = "Arc")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_insignificant_dtor]
Expand Down
1 change: 1 addition & 0 deletions core/src/future/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::task::{Context, Poll};
/// [`async`]: ../../std/keyword.async.html
/// [`Waker`]: crate::task::Waker
#[doc(notable_trait)]
#[cfg_attr(not(bootstrap), doc(search_unbox))]
#[must_use = "futures do nothing unless you `.await` or poll them"]
#[stable(feature = "futures_api", since = "1.36.0")]
#[lang = "future_trait"]
Expand Down
1 change: 1 addition & 0 deletions core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ use crate::pin::Pin;
use crate::{cmp, convert, hint, mem, slice};

/// The `Option` type. See [the module level documentation](self) for more.
#[cfg_attr(not(bootstrap), doc(search_unbox))]
#[derive(Copy, Eq, Debug, Hash)]
#[rustc_diagnostic_item = "Option"]
#[lang = "Option"]
Expand Down
1 change: 1 addition & 0 deletions core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ use crate::{convert, fmt, hint};
/// `Result` is a type that represents either success ([`Ok`]) or failure ([`Err`]).
///
/// See the [module documentation](self) for details.
#[cfg_attr(not(bootstrap), doc(search_unbox))]
#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
#[must_use = "this `Result` may be an `Err` variant, which should be handled"]
#[rustc_diagnostic_item = "Result"]
Expand Down

0 comments on commit c353337

Please sign in to comment.