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 4 pull requests #97050

Closed
wants to merge 12 commits into from

Commits on Apr 26, 2022

  1. Configuration menu
    Copy the full SHA
    5765819 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6f10c0a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a03f15a View commit details
    Browse the repository at this point in the history

Commits on May 13, 2022

  1. Configuration menu
    Copy the full SHA
    d369045 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    2b8041f View commit details
    Browse the repository at this point in the history
  3. Test RefCell aliasing

    cuviper committed May 13, 2022
    Configuration menu
    Copy the full SHA
    15d8c00 View commit details
    Browse the repository at this point in the history

Commits on May 14, 2022

  1. Allow the unused_macro_rules lint for now

    This makes the transition easier as e.g. allow directives
    won't fire the unknown lint warning once it is turned to
    warn by default in the future. This is especially
    important compared to other lints in the unused group
    because the _ prefix trick doesn't exist for macro rules,
    so allowing is the only option (either of unused_macro_rules,
    or of the entire unused group, but that is not as informative
    to readers). Allowing the lint also makes it possible to work
    on possible heuristics for disabling the macro in specific
    cases.
    est31 committed May 14, 2022
    Configuration menu
    Copy the full SHA
    015e2ae View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    53b6bf4 View commit details
    Browse the repository at this point in the history
  3. Rollup merge of rust-lang#96455 - dtolnay:writetmp, r=m-ou-se

    Make write/print macros eagerly drop temporaries
    
    This PR fixes the 2 regressions in rust-lang#96434 (`println` and `eprintln`) and changes all the other similar macros (`write`, `writeln`, `print`, `eprint`) to match the old pre-rust-lang#94868 behavior of `println` and `eprintln`.
    
    argument position | before rust-lang#94868 | after rust-lang#94868 | after this PR
    --- |:---:|:---:|:---:
    `write!($tmp, "…", …)` | :rage: | :rage: | :smiley_cat:
    `write!(…, "…", $tmp)` | :rage: | :rage: | :smiley_cat:
    `writeln!($tmp, "…", …)` | :rage: | :rage: | :smiley_cat:
    `writeln!(…, "…", $tmp)` | :rage: | :rage: | :smiley_cat:
    `print!("…", $tmp)` | :rage: | :rage: | :smiley_cat:
    `println!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat:
    `eprint!("…", $tmp)` | :rage: | :rage: | :smiley_cat:
    `eprintln!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat:
    `panic!("…", $tmp)` | :smiley_cat: | :smiley_cat: | :smiley_cat:
    
    Example of code that is affected by this change:
    
    ```rust
    use std::sync::Mutex;
    
    fn main() {
        let mutex = Mutex::new(0);
        print!("{}", mutex.lock().unwrap()) /* no semicolon */
    }
    ```
    
    You can see several real-world examples like this in the Crater links at the top of rust-lang#96434. This code failed to compile prior to this PR as follows, but works after this PR.
    
    ```console
    error[E0597]: `mutex` does not live long enough
     --> src/main.rs:5:18
      |
    5 |     print!("{}", mutex.lock().unwrap()) /* no semicolon */
      |                  ^^^^^^^^^^^^---------
      |                  |
      |                  borrowed value does not live long enough
      |                  a temporary with access to the borrow is created here ...
    6 | }
      | -
      | |
      | `mutex` dropped here while still borrowed
      | ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard`
    ```
    GuillaumeGomez committed May 14, 2022
    Configuration menu
    Copy the full SHA
    0620b2e View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#97027 - cuviper:yesalias-refcell, r=thomcc

    Use pointers in `cell::{Ref,RefMut}` to avoid `noalias`
    
    When `Ref` and `RefMut` were based on references, they would get LLVM `noalias` attributes that were incorrect, because that alias guarantee is only true until the guard drops. A `&RefCell` on the same value can get a new borrow that aliases the previous guard, possibly leading to miscompilation. Using `NonNull` pointers in `Ref` and `RefCell` avoids `noalias`.
    
    Fixes the library side of rust-lang#63787, but we still might want to explore language solutions there.
    GuillaumeGomez committed May 14, 2022
    Configuration menu
    Copy the full SHA
    1e0af98 View commit details
    Browse the repository at this point in the history
  5. Rollup merge of rust-lang#97032 - est31:unused_macro_rules, r=petroch…

    …enkov
    
    Allow the unused_macro_rules lint for now
    
    It was newly added by rust-lang#96150 with warn by default, which is great as it gave exposure to the community, and their feedback gave me ideas for improvements.
    
    Allowing the lint is good for two reasons:
    
    * It makes the transition easier as e.g. allow directives won't fire the unknown lint warning once it is turned to warn by default in the future. The [commit that allowed the lint in fuchsia](https://fuchsia.googlesource.com/fuchsia/+/9d8f96517c3963de2f0e25598fd36061914524cd%5E%21/) had to allow unknown lints for example.
    This is especially important compared to other lints in the unused group,
    because the _ prefix trick doesn't exist for macro rules, allowing is the
    only option (either of unused_macro_rules, or of the entire unused group,
    but that is not as informative to readers). Allowing the lint also makes it
    possible to work on possible heuristics for disabling the macro in specific
    cases.
    * It gives time for implementing heuristics for when to suppress the lint, e.g.
    when `compile_error!` is invoked by that arm (so it's only there to yield an error).
    
    See: rust-lang#96150 (comment)
    
    I would also like this to be backported to the 1.62 beta branch (cc rust-lang#97016).
    GuillaumeGomez committed May 14, 2022
    Configuration menu
    Copy the full SHA
    e1fc39c View commit details
    Browse the repository at this point in the history
  6. Rollup merge of rust-lang#97042 - GuillaumeGomez:eslint-brace-style, …

    …r=notriddle
    
    Add new eslint rule about brace style
    
    It also prevents one liners.
    
    r? `@notriddle`
    GuillaumeGomez committed May 14, 2022
    Configuration menu
    Copy the full SHA
    439ddd4 View commit details
    Browse the repository at this point in the history