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 6 pull requests #113188

Merged
merged 13 commits into from
Jun 30, 2023
Merged

Rollup of 6 pull requests #113188

merged 13 commits into from
Jun 30, 2023

Commits on Jun 1, 2023

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

Commits on Jun 26, 2023

  1. Configuration menu
    Copy the full SHA
    26cd548 View commit details
    Browse the repository at this point in the history
  2. migrate lifetime too

    compiler-errors committed Jun 26, 2023
    Configuration menu
    Copy the full SHA
    724f3ff View commit details
    Browse the repository at this point in the history

Commits on Jun 29, 2023

  1. Configuration menu
    Copy the full SHA
    0506250 View commit details
    Browse the repository at this point in the history
  2. add slice::swap suggestion

    y21 committed Jun 29, 2023
    Configuration menu
    Copy the full SHA
    679c5be View commit details
    Browse the repository at this point in the history

Commits on Jun 30, 2023

  1. Use structured suggestion when telling user about for<'a>

    ```
    error[E0637]: `&` without an explicit lifetime name cannot be used here
      --> $DIR/E0637.rs:13:13
       |
    LL |     T: Into<&u32>,
       |             ^ explicit lifetime name needed here
       |
    help: consider introducing a higher-ranked lifetime here
       |
    LL |     T: for<'a> Into<&'a u32>,
       |        +++++++       ++
    ```
    estebank committed Jun 30, 2023
    Configuration menu
    Copy the full SHA
    7d33094 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a104063 View commit details
    Browse the repository at this point in the history
  3. Rollup merge of rust-lang#107624 - tgross35:const-cstr-methods, r=dto…

    …lnay
    
    Stabilize `const_cstr_methods`
    
    This PR seeks to stabilize `const_cstr_methods`. Fixes most of rust-lang#101719
    
    ## New const stable API
    
    ```rust
    impl CStr {
        // depends: memchr
        pub const fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, FromBytesWithNulError> {...}
        // depends: const_slice_index
        pub const fn to_bytes(&self) -> &[u8] {}
        // depends: pointer casts
        pub const fn to_bytes_with_nul(&self) -> &[u8] {}
        // depends: str::from_utf8
        pub const fn to_str(&self) -> Result<&str, str::Utf8Error> {}
    }
    ```
    
    I don't think any of these methods will have any issue when `CStr` becomes a thin pointer as long as `memchr` is const  (which also allows for const `strlen`) .
    
    ## Notes
    
    - `from_bytes_until_nul` relies on `const_slice_index`, which relies on `const_trait_impls`, and generally this should be avoided. After talking with Oli, it should be OK in this case because we could replace the ranges with pointer tricks if needed (worst case being those feature gates disappear). rust-lang#107624 (comment)
    - Making `from_ptr` const is deferred because it depends on `const_eval_select`. I have moved this under the new flag `const_cstr_from_ptr` rust-lang#107624 (comment)
    
    cc ``@oli-obk`` I think you're the const expert
    
    ``@rustbot`` modify labels: +T-libs-api +needs-fcp
    matthiaskrgr authored Jun 30, 2023
    Configuration menu
    Copy the full SHA
    016c306 View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#111403 - y21:suggest-slice-swap, r=compiler…

    …-errors
    
    suggest `slice::swap` for `mem::swap(&mut x[0], &mut x[1])` borrowck error
    
    Recently saw someone ask why this code (example slightly modified):
    ```rs
    fn main() {
      let mut foo = [1, 2];
      std::mem::swap(&mut foo[0], &mut foo[1]);
    }
    ```
    triggers this error and how to fix it:
    ```
    error[E0499]: cannot borrow `foo[_]` as mutable more than once at a time
     --> src/main.rs:4:33
      |
    4 |     std::mem::swap(&mut foo[0], &mut foo[1]);
      |     -------------- -----------  ^^^^^^^^^^^ second mutable borrow occurs here
      |     |              |
      |     |              first mutable borrow occurs here
      |     first borrow later used by call
      |
      = help: consider using `.split_at_mut(position)` or similar method to obtain two mutable non-overlapping sub-slices
    ```
    The current help message is nice and goes in the right direction, but I think we can do better for this specific instance and suggest `slice::swap`, which makes this compile
    matthiaskrgr authored Jun 30, 2023
    Configuration menu
    Copy the full SHA
    6c22e04 View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#113071 - compiler-errors:no-parent-non-life…

    …time-args-in-apit, r=eholk
    
    Account for late-bound vars from parent arg-position impl trait
    
    We should be reporting an error like we do for late-bound args coming from a parent APIT.
    
    Fixes rust-lang#113016
    matthiaskrgr authored Jun 30, 2023
    Configuration menu
    Copy the full SHA
    0b96b25 View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#113165 - compiler-errors:rpitits-foreign-bo…

    …unds, r=spastorino
    
    Encode item bounds for `DefKind::ImplTraitPlaceholder`
    
    This was lost in a refactoring -- `hir::ItemKind::OpaqueTy` doesn't always map to `DefKind::Opaque`, specifically for RPITITs, so the check was migrated subtly wrong, and unfortunately I never had a test for this 🙃
    
    Fixes rust-lang#113155
    
    r? ``@cjgillot``
    matthiaskrgr authored Jun 30, 2023
    Configuration menu
    Copy the full SHA
    c8f50ee View commit details
    Browse the repository at this point in the history
  7. Rollup merge of rust-lang#113171 - spastorino:new-rpitit-25, r=compil…

    …er-errors
    
    Properly implement variances_of for RPITIT GAT
    
    This fixes some of the issues found by crater run in rust-lang#112988 (comment)
    
    r? ``@compiler-errors``
    matthiaskrgr authored Jun 30, 2023
    Configuration menu
    Copy the full SHA
    38e6bba View commit details
    Browse the repository at this point in the history
  8. Rollup merge of rust-lang#113177 - estebank:hrlt-sugg, r=compiler-errors

    Use structured suggestion when telling user about `for<'a>`
    
    ```
    error[E0637]: `&` without an explicit lifetime name cannot be used here
      --> $DIR/E0637.rs:13:13
       |
    LL |     T: Into<&u32>,
       |             ^ explicit lifetime name needed here
       |
    help: consider introducing a higher-ranked lifetime here
       |
    LL |     T: for<'a> Into<&'a u32>,
       |        +++++++       ++
    ```
    matthiaskrgr authored Jun 30, 2023
    Configuration menu
    Copy the full SHA
    207b244 View commit details
    Browse the repository at this point in the history