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

Rollup of 7 pull requests #107472

Merged
merged 22 commits into from
Jan 30, 2023
Merged

Rollup of 7 pull requests #107472

merged 22 commits into from
Jan 30, 2023

Commits on Jan 20, 2023

  1. Configuration menu
    Copy the full SHA
    70f9d52 View commit details
    Browse the repository at this point in the history

Commits on Jan 21, 2023

  1. This function appears to be unused

    The comment says that it is called from main.js, but there don't seem to
    be any references to it in main.js.
    
    A quick ripgrep says there are no references in all of librustdoc.
    thanatos committed Jan 21, 2023
    Configuration menu
    Copy the full SHA
    ee9e8cd View commit details
    Browse the repository at this point in the history
  2. Fix typo in comment

    thanatos committed Jan 21, 2023
    Configuration menu
    Copy the full SHA
    fa214c3 View commit details
    Browse the repository at this point in the history

Commits on Jan 28, 2023

  1. slice: Add a specialization for clone_into when T is Copy

    The implementation for the ToOwned::clone_into method on [T] is a copy
    of the code for vec::clone_from. In 3613980 the code for
    vec::clone_from gained a specialization for when T is Copy. This commit
    copies that specialization over to the clone_into implementation.
    bpeel committed Jan 28, 2023
    Configuration menu
    Copy the full SHA
    ba80c66 View commit details
    Browse the repository at this point in the history
  2. vec: Use SpecCloneIntoVec::clone_into to implement Vec::clone_from

    In the past, Vec::clone_from was implemented using slice::clone_into.
    The code from clone_into was later duplicated into clone_from in
    8725e4c, which is the commit that adds custom allocator support to
    Vec. Presumably this was done because the slice::clone_into only works
    for vecs with the default allocator so it would have the wrong type to
    clone into Vec<T, A>.
    
    Now that the clone_into implementation is moved out into a specializable
    trait anyway we might as well use that to share the code between the two
    methods.
    bpeel committed Jan 28, 2023
    Configuration menu
    Copy the full SHA
    a34f11c View commit details
    Browse the repository at this point in the history

Commits on Jan 29, 2023

  1. Configuration menu
    Copy the full SHA
    a9aed86 View commit details
    Browse the repository at this point in the history
  2. Remove obsolete comment.

    cjgillot committed Jan 29, 2023
    Configuration menu
    Copy the full SHA
    b456307 View commit details
    Browse the repository at this point in the history

Commits on Jan 30, 2023

  1. use a more descriptive name

    tshepang committed Jan 30, 2023
    Configuration menu
    Copy the full SHA
    f7cc20a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a4aebf0 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b2ef837 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    883145f View commit details
    Browse the repository at this point in the history
  5. Keep all theme-updating logic together

    Prior to this PR, if the page is restored from the browser bfcache¹, we
    call `switchToSavedTheme`. But `switchToSavedTheme` never looks at the
    `use-system-theme` preference. Further, if it can't find a saved theme,
    it will fall back to the default of "light".
    
    For a user with cookies disabled² whose preferred color scheme is dark,
    this means the theme will wobble back and forth between dark and light.
    The sequence that occurs is,
    
    1. The page is loaded. During a page load, we consult
       `use-system-theme`: as cookies are disabled, this preference is
       unset. The default is true.
    
       Because the default is true, we look at the preferred color scheme:
       for our example user, that's "dark". **The page theme is set to
       dark.** We'll attempt to store these preferences in localStorage, but
       fail due to cookies being disabled.
    
    2. The user navigates through the docs. Subsequent page loads happen,
       and the same process in step 1 recurs. Previous pages are
       (potentially) put into the bfcache.
    
    3. The user navigates backwards/forwards, causing a page in bfcache to
       be pulled out of cache. The `pageShow` event handler is triggered.
       However, this calls `switchToSavedTheme`: this doesn't consider the
       system theme, as noted above. Instead, it only looks for a saved
       theme. However, with cookies disabled, there is none. It defaults to
       light. **The page theme is set to light!** The user wonders why the
       dark theme is lost.
    
    There are effectively two functions trying to determine and apply the
    correct theme: `updateSystemTheme` and `switchToSavedTheme`. Thus, we
    merge them into just one: `updateTheme`. This function contains all the
    logic for determining the correct theme, and is called in all
    circumstances where we need to set the theme:
    
    * The initial page load
    * If the browser preferred color scheme (i.e., light/dark mode) is
      changed
    * If the page is restored from bfcache
    * If the user updates the theme preferences (i.e., in `settings.js`)
    
    Fixes rust-lang#94250.
    
    ¹bfcache: https://web.dev/bfcache/ The bfcache is used to sleep a page,
    if the user navigates away from it, and to restore it from cache if the
    user returns to it.
    
    ²Note that the browser preference that enables/disables cookies really
    controls many forms of storage. The same preference thus also affects
    localStorage. (This is so a normal browser user doesn't need to
    understand the distinction between "cookies" and "localStorage".)
    thanatos committed Jan 30, 2023
    Configuration menu
    Copy the full SHA
    727a1fd View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d458540 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    48af3a9 View commit details
    Browse the repository at this point in the history
  8. Update bastion-of-the-turbofish.rs

    The original tweet in the chain linked to, and thus the through line of links back to Anna's tweet where she named the turbofish (https://web.archive.org/web/20210911061514/https://twitter.com/whoisaldeka/status/914914008225816576) are lost as the user whoisaldeka has deleted their twitter account.
    
    Switching to an archive link preserves this through line, allowing someone to browse back to see the point at which Anna created the turbofish, as was the original intent of including this context.
    LLBlumire authored Jan 30, 2023
    Configuration menu
    Copy the full SHA
    8348f25 View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#107125 - WaffleLapkin:expect_an_item_in_you…

    …r_hir_by_the_next_morning, r=Nilstrieb
    
    Add and use expect methods to hir.
    
    [The future has come](https://github.com/rust-lang/rust/pull/106090/files#r1070062462).
    
    r? `@Nilstrieb`
    
    tbh I'm not even sure if it's worth it
    matthiaskrgr authored Jan 30, 2023
    Configuration menu
    Copy the full SHA
    4ac1796 View commit details
    Browse the repository at this point in the history
  10. Rollup merge of rust-lang#107172 - cjgillot:no-nal, r=nagisa

    Reimplement NormalizeArrayLen based on SsaLocals
    
    Based on rust-lang#106908
    Fixes rust-lang#105929
    
    Only the last commit "Reimplement NormalizeArrayLen" is relevant.
    matthiaskrgr authored Jan 30, 2023
    Configuration menu
    Copy the full SHA
    db97749 View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#107177 - thanatos:fix-doc-errant-light-them…

    …e, r=notriddle
    
    Keep all theme-updating logic together
    
    Prior to this PR, if the page is restored from the browser bfcache¹, we call `switchToSavedTheme`. But `switchToSavedTheme` never looks at the `use-system-theme` preference. Further, if it can't find a saved theme, it will fall back to the default of "light".
    
    For a user with cookies disabled² whose preferred color scheme is dark, this means the theme will wobble back and forth between dark and light. The sequence that occurs is,
    
    1. The page is loaded. During a page load, we consult `use-system-theme`: as cookies are disabled, this preference is unset. The default is true.
    
       Because the default is true, we look at the preferred color scheme: for our example user, that's "dark". **The page theme is set to dark.** We'll attempt to store these preferences in localStorage, but fail due to cookies being disabled.
    
    2. The user navigates through the docs. Subsequent page loads happen, and the same process in step 1 recurs. Previous pages are (potentially) put into the bfcache.
    
    3. The user navigates backwards/forwards, causing a page in bfcache to be pulled out of cache. The `pageShow` event handler is triggered. However, this calls `switchToSavedTheme`: this doesn't consider the system theme, as noted above. Instead, it only looks for a saved theme. However, with cookies disabled, there is none. It defaults to light. **The page theme is set to light!** The user wonders why the dark theme is lost.
    
    There are effectively two functions trying to determine and apply the correct theme: `updateSystemTheme` and `switchToSavedTheme`. Thus, we merge them into just one: `updateTheme`. This function contains all the logic for determining the correct theme, and is called in all circumstances where we need to set the theme:
    
    * The initial page load
    * If the browser preferred color scheme (i.e., light/dark mode) is changed
    * If the page is restored from bfcache
    * If the user updates the theme preferences (i.e., in `settings.js`)
    
    Fixes rust-lang#94250.
    
    ¹bfcache: https://web.dev/bfcache/ The bfcache is used to sleep a page, if the user navigates away from it, and to restore it from cache if the user returns to it.
    
    ²Note that the browser preference that enables/disables cookies really controls many forms of storage. The same preference thus also affects localStorage. (This is so a normal browser user doesn't need to understand the distinction between "cookies" and "localStorage".)
    matthiaskrgr authored Jan 30, 2023
    Configuration menu
    Copy the full SHA
    d1320a5 View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#107424 - bpeel:clone-into-from-share-code, …

    …r=scottmcm
    
    Make Vec::clone_from and slice::clone_into share the same code
    
    In the past, `Vec::clone_from` was implemented using `slice::clone_into`. The code from `clone_into` was later duplicated into `clone_from` in 8725e4c, which is the commit that adds custom allocator support to Vec. Presumably this was done because the `slice::clone_into` method only works for vecs with the default allocator so it would have the wrong type to clone into `Vec<T, A>`.
    
    Later on in 3613980 the code for the two methods diverged because the `Vec::clone_from` version gained a specialization to optimize the case when T is Copy. In order to reduce code duplication and make them both be able to take advantage of this specialization, this PR moves the specialization into the slice module and makes vec use it again.
    matthiaskrgr authored Jan 30, 2023
    Configuration menu
    Copy the full SHA
    b3b9383 View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#107455 - tshepang:better-name, r=wesleywiser

    use a more descriptive name
    
    I found it hard to distinguish between the two method names.
    
    Also, the comment just repeats the `expect` string.
    matthiaskrgr authored Jan 30, 2023
    Configuration menu
    Copy the full SHA
    c3b1f54 View commit details
    Browse the repository at this point in the history
  14. Rollup merge of rust-lang#107465 - WaffleLapkin:has_allow_dead_code_o…

    …r_lang_attr, r=Nilstrieb
    
    `has_allow_dead_code_or_lang_attr` micro refactor
    
    r? `@Nilstrieb`
    matthiaskrgr authored Jan 30, 2023
    Configuration menu
    Copy the full SHA
    3c155dc View commit details
    Browse the repository at this point in the history
  15. Rollup merge of rust-lang#107469 - LLBlumire:master, r=jyn514

    Change turbofish context link to an archive link
    
    The original tweet in the chain linked to (via quote tweet), and thus the through line of links back to Anna's tweet where she named the turbofish (https://web.archive.org/web/20210911061514/https://twitter.com/whoisaldeka/status/914914008225816576) are lost as the user whoisaldeka has deleted their twitter account.
    
    Switching to an archive link preserves this through line, allowing someone to browse back to see the point at which Anna created the turbofish, as was the original intent of including this context.
    
    I was sharing this test with some friends as I often do, and noticed the changes (I had only seen the version from before her death previously). Looking for context myself, I realized the deleted twitter account was breaking an important link in the chain for the context of who Anna was to begin with, and the exact moment the turbofish was so named.
    
    As an alternative to using an archive, we could link to both the tweet where Anna names the turbofish, and the tweet where she refers to herself as its guardian, as two separate links - not requiring the quote tweet to connect them.
    matthiaskrgr authored Jan 30, 2023
    Configuration menu
    Copy the full SHA
    d79a40d View commit details
    Browse the repository at this point in the history