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 #120336

Closed
wants to merge 29 commits into from

Commits on Nov 23, 2023

  1. Rewrite the BTreeMap cursor API using gaps

    Tracking issue: rust-lang#107540
    
    Currently, a `Cursor` points to a single element in the tree, and allows
    moving to the next or previous element while mutating the tree. However
    this was found to be confusing and hard to use.
    
    This PR completely refactors cursors to instead point to a gap between
    two elements in the tree. This eliminates the need for a "ghost" element
    that exists after the last element and before the first one.
    Additionally, `upper_bound` and `lower_bound` now have a much clearer
    meaning.
    
    The ability to mutate keys is also factored out into a separate
    `CursorMutKey` type which is unsafe to create. This makes the API easier
    to use since it avoids duplicated versions of each method with and
    without key mutation.
    
    API summary:
    
    ```rust
    impl<K, V> BTreeMap<K, V> {
        fn lower_bound<Q>(&self, bound: Bound<&Q>) -> Cursor<'_, K, V>
        where
            K: Borrow<Q> + Ord,
            Q: Ord;
        fn lower_bound_mut<Q>(&mut self, bound: Bound<&Q>) -> CursorMut<'_, K, V>
        where
            K: Borrow<Q> + Ord,
            Q: Ord;
        fn upper_bound<Q>(&self, bound: Bound<&Q>) -> Cursor<'_, K, V>
        where
            K: Borrow<Q> + Ord,
            Q: Ord;
        fn upper_bound_mut<Q>(&mut self, bound: Bound<&Q>) -> CursorMut<'_, K, V>
        where
            K: Borrow<Q> + Ord,
            Q: Ord;
    }
    
    struct Cursor<'a, K: 'a, V: 'a>;
    
    impl<'a, K, V> Cursor<'a, K, V> {
        fn next(&mut self) -> Option<(&'a K, &'a V)>;
        fn prev(&mut self) -> Option<(&'a K, &'a V)>;
        fn peek_next(&self) -> Option<(&'a K, &'a V)>;
        fn peek_prev(&self) -> Option<(&'a K, &'a V)>;
    }
    
    struct CursorMut<'a, K: 'a, V: 'a>;
    
    impl<'a, K, V> CursorMut<'a, K, V> {
        fn next(&mut self) -> Option<(&K, &mut V)>;
        fn prev(&mut self) -> Option<(&K, &mut V)>;
        fn peek_next(&mut self) -> Option<(&K, &mut V)>;
        fn peek_prev(&mut self) -> Option<(&K, &mut V)>;
    
        unsafe fn insert_after_unchecked(&mut self, key: K, value: V);
        unsafe fn insert_before_unchecked(&mut self, key: K, value: V);
        fn insert_after(&mut self, key: K, value: V);
        fn insert_before(&mut self, key: K, value: V);
        fn remove_next(&mut self) -> Option<(K, V)>;
        fn remove_prev(&mut self) -> Option<(K, V)>;
    
        fn as_cursor(&self) -> Cursor<'_, K, V>;
    
        unsafe fn with_mutable_key(self) -> CursorMutKey<'a, K, V, A>;
    }
    
    struct CursorMutKey<'a, K: 'a, V: 'a>;
    
    impl<'a, K, V> CursorMut<'a, K, V> {
        fn next(&mut self) -> Option<(&mut K, &mut V)>;
        fn prev(&mut self) -> Option<(&mut K, &mut V)>;
        fn peek_next(&mut self) -> Option<(&mut K, &mut V)>;
        fn peek_prev(&mut self) -> Option<(&mut K, &mut V)>;
    
        unsafe fn insert_after_unchecked(&mut self, key: K, value: V);
        unsafe fn insert_before_unchecked(&mut self, key: K, value: V);
        fn insert_after(&mut self, key: K, value: V);
        fn insert_before(&mut self, key: K, value: V);
        fn remove_next(&mut self) -> Option<(K, V)>;
        fn remove_prev(&mut self) -> Option<(K, V)>;
    
        fn as_cursor(&self) -> Cursor<'_, K, V>;
    
        unsafe fn with_mutable_key(self) -> CursorMutKey<'a, K, V, A>;
    }
    ```
    Amanieu committed Nov 23, 2023
    Configuration menu
    Copy the full SHA
    8ee9693 View commit details
    Browse the repository at this point in the history
  2. Update library/alloc/src/collections/btree/map.rs

    Co-authored-by: Joe ST <joe@fbstj.net>
    Amanieu and fbstj authored Nov 23, 2023
    Configuration menu
    Copy the full SHA
    166e348 View commit details
    Browse the repository at this point in the history
  3. Add UnorderedKeyError

    Amanieu committed Nov 23, 2023
    Configuration menu
    Copy the full SHA
    d085f34 View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2024

  1. linker: Refactor APIs for linking dynamic libraries

    Rename `link_(dylib,framework)`, remove `link_rust_dylib`.
    petrochenkov committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    50501c6 View commit details
    Browse the repository at this point in the history
  2. linker: Refactor APIs for linking static libraries

    Rename `link(_whole)(staticlib,rlib)` to something more suitable.
    petrochenkov committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    0e38a65 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    14cd3fd View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    859f37a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d15db6b View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    1b8e871 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    03f23c1 View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2024

  1. Bump askama version

    clubby789 committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    da33619 View commit details
    Browse the repository at this point in the history
  2. This commit is part of clone3 clean up. As part of clean up we will

    remove tests/ui/command/command-create-pidfd.rs . But it contains
    very useful comment, so let's move the comment to library/std/src/sys/pal/unix/rand.rs ,
    which contains another instance of the same Docker problem
    Askar Safin committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    57f9d1f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9890c66 View commit details
    Browse the repository at this point in the history
  4. Add NonZero symbol.

    reitermarkus committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    35fffbb View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    94a14e7 View commit details
    Browse the repository at this point in the history
  6. Fix NonZero suggestions.

    reitermarkus committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    5d3699e View commit details
    Browse the repository at this point in the history
  7. Update tests.

    reitermarkus committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    f99dd4d View commit details
    Browse the repository at this point in the history
  8. This commit is part of clone3 clean up. Merge tests from tests/ui/com…

    …mand/command-create-pidfd.rs
    
    to library/std/src/sys/pal/unix/process/process_unix/tests.rs to remove code
    duplication
    Askar Safin committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    1ee773e View commit details
    Browse the repository at this point in the history
  9. Finishing clone3 clean up

    Askar Safin committed Jan 24, 2024
    Configuration menu
    Copy the full SHA
    df0c9c3 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    bdc9ce0 View commit details
    Browse the repository at this point in the history

Commits on Jan 25, 2024

  1. Configuration menu
    Copy the full SHA
    3004e8c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    07b7c77 View commit details
    Browse the repository at this point in the history
  3. Rollup merge of rust-lang#118208 - Amanieu:btree_cursor2, r=dtolnay

    Rewrite the BTreeMap cursor API using gaps
    
    Tracking issue: rust-lang#107540
    
    Currently, a `Cursor` points to a single element in the tree, and allows moving to the next or previous element while mutating the tree. However this was found to be confusing and hard to use.
    
    This PR completely refactors cursors to instead point to a gap between two elements in the tree. This eliminates the need for a "ghost" element that exists after the last element and before the first one. Additionally, `upper_bound` and `lower_bound` now have a much clearer meaning.
    
    The ability to mutate keys is also factored out into a separate `CursorMutKey` type which is unsafe to create. This makes the API easier to use since it avoids duplicated versions of each method with and without key mutation.
    
    API summary:
    
    ```rust
    impl<K, V> BTreeMap<K, V> {
        fn lower_bound<Q>(&self, bound: Bound<&Q>) -> Cursor<'_, K, V>
        where
            K: Borrow<Q> + Ord,
            Q: Ord;
        fn lower_bound_mut<Q>(&mut self, bound: Bound<&Q>) -> CursorMut<'_, K, V>
        where
            K: Borrow<Q> + Ord,
            Q: Ord;
        fn upper_bound<Q>(&self, bound: Bound<&Q>) -> Cursor<'_, K, V>
        where
            K: Borrow<Q> + Ord,
            Q: Ord;
        fn upper_bound_mut<Q>(&mut self, bound: Bound<&Q>) -> CursorMut<'_, K, V>
        where
            K: Borrow<Q> + Ord,
            Q: Ord;
    }
    
    struct Cursor<'a, K: 'a, V: 'a>;
    
    impl<'a, K, V> Cursor<'a, K, V> {
        fn next(&mut self) -> Option<(&'a K, &'a V)>;
        fn prev(&mut self) -> Option<(&'a K, &'a V)>;
        fn peek_next(&self) -> Option<(&'a K, &'a V)>;
        fn peek_prev(&self) -> Option<(&'a K, &'a V)>;
    }
    
    struct CursorMut<'a, K: 'a, V: 'a>;
    
    impl<'a, K, V> CursorMut<'a, K, V> {
        fn next(&mut self) -> Option<(&K, &mut V)>;
        fn prev(&mut self) -> Option<(&K, &mut V)>;
        fn peek_next(&mut self) -> Option<(&K, &mut V)>;
        fn peek_prev(&mut self) -> Option<(&K, &mut V)>;
    
        unsafe fn insert_after_unchecked(&mut self, key: K, value: V);
        unsafe fn insert_before_unchecked(&mut self, key: K, value: V);
        fn insert_after(&mut self, key: K, value: V) -> Result<(), UnorderedKeyError>;
        fn insert_before(&mut self, key: K, value: V) -> Result<(), UnorderedKeyError>;
        fn remove_next(&mut self) -> Option<(K, V)>;
        fn remove_prev(&mut self) -> Option<(K, V)>;
    
        fn as_cursor(&self) -> Cursor<'_, K, V>;
    
        unsafe fn with_mutable_key(self) -> CursorMutKey<'a, K, V, A>;
    }
    
    struct CursorMutKey<'a, K: 'a, V: 'a>;
    
    impl<'a, K, V> CursorMut<'a, K, V> {
        fn next(&mut self) -> Option<(&mut K, &mut V)>;
        fn prev(&mut self) -> Option<(&mut K, &mut V)>;
        fn peek_next(&mut self) -> Option<(&mut K, &mut V)>;
        fn peek_prev(&mut self) -> Option<(&mut K, &mut V)>;
    
        unsafe fn insert_after_unchecked(&mut self, key: K, value: V);
        unsafe fn insert_before_unchecked(&mut self, key: K, value: V);
        fn insert_after(&mut self, key: K, value: V) -> Result<(), UnorderedKeyError>;
        fn insert_before(&mut self, key: K, value: V) -> Result<(), UnorderedKeyError>;
        fn remove_next(&mut self) -> Option<(K, V)>;
        fn remove_prev(&mut self) -> Option<(K, V)>;
    
        fn as_cursor(&self) -> Cursor<'_, K, V>;
    
        unsafe fn with_mutable_key(self) -> CursorMutKey<'a, K, V, A>;
    }
    
    struct UnorderedKeyError;
    ```
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    d32f495 View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#120099 - petrochenkov:linkapi, r=WaffleLapkin

    linker: Refactor library linking methods in `trait Linker`
    
    Linkers are not aware of Rust libraries, they look like regular static or dynamic libraries to them, so Rust-specific methods in `trait Linker` do not make much sense.
    They can be either removed or renamed to something more suitable.
    
    Commits after the second one are cleanups.
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    a87ffe1 View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#120165 - reitermarkus:nonzero-switch-alias-…

    …direction, r=dtolnay
    
    Switch `NonZero` alias direction.
    
    Step 4 mentioned in rust-lang#100428 (review).
    
    Depends on rust-lang#120160.
    
    r? `@dtolnay`
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    c4850d7 View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#120288 - clubby789:bump-askama, r=Guillaume…

    …Gomez
    
    Bump `askama` version
    
    Ran into this while looking at rust-lang#112865 and thought it would be useful to fix it now. Some more details in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/Askama.20parser.20changes)
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    89719eb View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#120306 - safinaskar:clone3-clean-up, r=petr…

    …ochenkov
    
    Clean up after clone3 removal from pidfd code (docs and tests)
    
    rust-lang#113939 removed clone3 from pidfd code. This patchset does necessary clean up: fixes docs and tests
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    3c651fd View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#120316 - GuillaumeGomez:fix-ast-visitor, r=…

    …compiler-errors
    
    Don't call `walk_` functions directly if there is an equivalent `visit_` method
    
    I was working on rust-lang#77773 and realized in one of my experiments that the `visit_path` method was not always called whereas it should have. This fixes it.
    
    r? `@davidtwco`
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    e47ba63 View commit details
    Browse the repository at this point in the history
  9. Rollup merge of rust-lang#120330 - compiler-errors:no-coroutine-info-…

    …in-coroutine-drop-body, r=nnethercote
    
    Remove coroutine info when building coroutine drop body
    
    Coroutine drop shims are not themselves coroutines, so erase the "`coroutine`" field from the body so that helper fns like `yield_ty` and `coroutine_kind` properly return `None` for the drop shim.
    matthiaskrgr authored Jan 25, 2024
    Configuration menu
    Copy the full SHA
    8d3d3a8 View commit details
    Browse the repository at this point in the history