Skip to content

Can't expand/contract Rustdoc's [-] symbol if "cookies" disabled #55079

Closed
@thanatos

Description

@thanatos

The output from rustdoc, at the top of the page for a struct or a const, etc., includes a line like,

Struct crate::MyStruct [-][src]

Clicking the [-] on a browser w/ restrictive cookie settings (which typically includes localStorage) results in an error similar to the following:

storage.js:11 Uncaught DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document.
at updateLocalStorage (file:///home/[...]/target/doc/storage.js:11:343)
at HTMLAnchorElement.toggleAllDocs (file:///home/[...]/target/doc/main.js:13:997)

Additionally, the section fails to expand or contract, as the exception isn't handled.

rustdoc is attempting to store the collapse/expand state, s.t. later visits to the page presumably maintain that state for the user's convenience.

I browse the web with an admittedly somewhat atypical setup: I whitelist cookies. localStorage, in most browsers, counts, since it is a similar mechanism of persistence. I think Rust's use of localStorage here is fine, but I would request that, if localStorage is forbidden by the user agent, that the documentation gracefully "degrade" to just expanding or contracting the requested item, but not persist it. As it is, the JS crashes while storing the state, and appears to never make it to actually expanding/contracting the item.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions