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 8 pull requests #108413

Closed
wants to merge 20 commits into from

Commits on Feb 21, 2023

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

Commits on Feb 22, 2023

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

Commits on Feb 23, 2023

  1. Configuration menu
    Copy the full SHA
    6f92031 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    242daf8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    634d8cb View commit details
    Browse the repository at this point in the history
  4. Add stderr

    mejrs committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    4c13a21 View commit details
    Browse the repository at this point in the history
  5. Require literals for some (u)int_impl! parameters

    The point of these is to be seen lexically in the docs, so they should always be passed as the correct literal, not as an expression.
    
    (Otherwise we could just compute `Min`/`Max` from `BITS`, for example.)
    scottmcm committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    5c7ae25 View commit details
    Browse the repository at this point in the history
  6. parser: provide better errors on closures with braces missing

    We currently provide wrong suggestions and unhelpful errors on closure
    bodies with braces missing. For example, given the following code:
    
    ```
    fn main() {
        let _x = Box::new(|x|x+1;);
    }
    ```
    
    the current output is like this:
    
    ```
    error: expected expression, found `)`
     --> ./main.rs:2:30
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                              ^ expected expression
    
    error: closure bodies that contain statements must be surrounded by braces
     --> ./main.rs:2:25
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                         ^
    3 | }
      | ^
      |
    
    ...
    
    help: try adding braces
      |
    2 ~     let _x = Box::new(|x| {x+1;);
    3 ~ }}
    
    ...
    
    error: expected `;`, found `}`
     --> ./main.rs:2:32
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                                ^ help: add `;` here
    3 | }
      | - unexpected token
    
    error: aborting due to 3 previous errors
    ```
    
    This commit allows outputting correct suggestions and errors. The above
    code would output like this:
    
    ```
    error: closure bodies that contain statements must be surrounded by braces
     --> ./main.rs:2:25
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                         ^    ^
      |
    note: statement found outside of a block
     --> ./main.rs:2:29
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                          ---^ this `;` turns the preceding closure into a statement
      |                          |
      |                          this expression is a statement because of the trailing semicolon
    note: the closure body may be incorrectly delimited
     --> ./main.rs:2:23
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                       ^^^^^^ - ...but likely you meant the closure to end here
      |                       |
      |                       this is the parsed closure...
    help: try adding braces
      |
    2 |     let _x = Box::new(|x| {x+1;});
      |                           +    +
    
    error: aborting due to previous error
    ```
    ohno418 committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    0e42298 View commit details
    Browse the repository at this point in the history
  7. Fix is_terminal's handling of long paths on Windows.

    As reported in sunfishcode/is-terminal#18, there are situations where
    `GetFileInformationByHandleEx` can write a file name length that is
    longer than the provided buffer. To avoid deferencing memory past the
    end of the buffer, use a bounds-checked function to form a slice to
    the buffer and handle the out-of-bounds case.
    
    This ports the fix from sunfishcode/is-terminal#19 to std's `is_terminal`
    implementation.
    sunfishcode committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    c0c1925 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    4332a27 View commit details
    Browse the repository at this point in the history
  9. diagnostics: remove inconsistent English article "this" from E0107

    Consider `tests/ui/const-generics/generic_const_exprs/issue-102768.stderr`,
    the error message where it gives additional notes about where the associated
    type is defined, and how the dead code lint doesn't have an article,
    like in `tests/ui/lint/dead-code/issue-85255.stderr`. They don't have
    articles, so it seems unnecessary to have one here.
    notriddle committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    a5b639d View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    0241e49 View commit details
    Browse the repository at this point in the history
  11. Rollup merge of rust-lang#106923 - mejrs:fluent_err, r=davidtwco

    Restore behavior when primary bundle is missing
    
    Fixes rust-lang#106755 by restoring some of the behavior prior to rust-lang#106427
    
    Still, I have no idea how this debug assertion can even hit while using `en-US` as primary  bundle.
    
    r? ``@davidtwco``
    matthiaskrgr committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    f6c606c View commit details
    Browse the repository at this point in the history
  12. Rollup merge of rust-lang#107911 - blyxyas:issue-107231-fix, r=compil…

    …er-errors
    
    Add check for invalid #[macro_export] arguments
    
    Resolves rust-lang#107231
    Sorry if I made something wrong, this is my first contribution to the repo.
    matthiaskrgr committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    a5189f0 View commit details
    Browse the repository at this point in the history
  13. Rollup merge of rust-lang#108287 - compiler-errors:new-solver-bad-cas…

    …t, r=spastorino
    
    Add test for bad cast with deferred projection equality
    
    1. Unification during coercion (`Coerce::unify`) needs to consider deferred projection obligations (at least pass over them with `predicate_may_hold` or something, to disqualify any totally wrong unifications) -- otherwise, we'll shallowly consider `<u8 as Add>::Output` and `char` as coercible during `FnCtxt::try_coerce`, which will fail later when the nested obligations are registered and processed.
    
    2. Cast checking needs to be able to structurally normalize types so it sees `u8` instead of `<u8 as Add>::Output`. Otherwise it'll always consider the latter as part of a non-primitive cast. Currently `FnCtxt::normalize` doesn't do anything useful here, interestingly.
    
    I tried looking into both of these and it's not immediately clear where to refactor existing typeck code to fix this (at least the latter), but I'm gonna commit a test for it at least so we don't forget. This is one of the issues that's keeping us from building larger projects.
    matthiaskrgr committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    4db71a7 View commit details
    Browse the repository at this point in the history
  14. Rollup merge of rust-lang#108299 - scottmcm:literal-bits, r=Nilstrieb

    Require `literal`s for some `(u)int_impl!` parameters
    
    The point of these is to be seen *lexically* in the docs, so they should always be passed as the correct literal, not as an expression.
    
    (Otherwise we could just compute `Min`/`Max` from `BITS`, for example.)
    
    r? Nilstrieb
    matthiaskrgr committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    9ebff9e View commit details
    Browse the repository at this point in the history
  15. Rollup merge of rust-lang#108377 - clubby789:duplicate-diagnostic-ice…

    …, r=compiler-errors
    
    Fix ICE in 'duplicate diagnostic item' diagnostic
    
    Not sure how to add this in a test; I found it by mistakenly running `cargo fix --lib -p std` rather than `x fix` at the root.
    matthiaskrgr committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    3a3c0d5 View commit details
    Browse the repository at this point in the history
  16. Rollup merge of rust-lang#108388 - ohno418:better-suggestion-on-malfo…

    …rmed-closure, r=davidtwco
    
    parser: provide better suggestions and errors on closures with braces missing
    
    We currently provide wrong suggestions and unhelpful errors on closure bodies with braces missing.
    
    For example, given the following code:
    
    ```rust
    fn main() {
        let _x = Box::new(|x|x+1;);
    }
    ```
    
    the current output is:
    
    ```
    error: expected expression, found `)`
     --> ./main.rs:2:30
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                              ^ expected expression
    
    error: closure bodies that contain statements must be surrounded by braces
     --> ./main.rs:2:25
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                         ^
    3 | }
      | ^
      |
    note: statement found outside of a block
     --> ./main.rs:2:29
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                          ---^ this `;` turns the preceding closure into a statement
      |                          |
      |                          this expression is a statement because of the trailing semicolon
    note: the closure body may be incorrectly delimited
     --> ./main.rs:2:23
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                       ^^^^^^ this is the parsed closure...
    3 | }
      | - ...but likely you meant the closure to end here
    help: try adding braces
      |
    2 ~     let _x = Box::new(|x| {x+1;);
    3 ~ }}
      |
    
    error: expected `;`, found `}`
     --> ./main.rs:2:32
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                                ^ help: add `;` here
    3 | }
      | - unexpected token
    
    error: aborting due to 3 previous errors
    ```
    
    We got 3 errors, but all but the second are unnecessary or just wrong.
    
    This commit allows outputting correct suggestions and errors. The above code would output like this:
    
    ```
    error: closure bodies that contain statements must be surrounded by braces
     --> ./main.rs:2:25
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                         ^    ^
      |
    note: statement found outside of a block
     --> ./main.rs:2:29
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                          ---^ this `;` turns the preceding closure into a statement
      |                          |
      |                          this expression is a statement because of the trailing semicolon
    note: the closure body may be incorrectly delimited
     --> ./main.rs:2:23
      |
    2 |     let _x = Box::new(|x|x+1;);
      |                       ^^^^^^ - ...but likely you meant the closure to end here
      |                       |
      |                       this is the parsed closure...
    help: try adding braces
      |
    2 |     let _x = Box::new(|x| {x+1;});
      |                           +    +
    
    error: aborting due to previous error
    ```
    
    Fixes rust-lang#107959.
    
    r? diagnostics
    matthiaskrgr committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    5cf3988 View commit details
    Browse the repository at this point in the history
  17. Rollup merge of rust-lang#108391 - sunfishcode:sunfishcode/is-termina…

    …l-file-length, r=ChrisDenton
    
    Fix `is_terminal`'s handling of long paths on Windows.
    
    As reported in sunfishcode/is-terminal#18, there are situations where `GetFileInformationByHandleEx` can write a file name length that is longer than the provided buffer. To avoid deferencing memory past the end of the buffer, use a bounds-checked function to form a slice to the buffer and handle the out-of-bounds case.
    
    This ports the fix from sunfishcode/is-terminal#19 to std's `is_terminal` implementation.
    matthiaskrgr committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    3c954ae View commit details
    Browse the repository at this point in the history
  18. Rollup merge of rust-lang#108401 - notriddle:notriddle/diagnostics-ar…

    …ticle, r=compiler-errors
    
    diagnostics: remove inconsistent English article "this" from E0107
    
    Consider [`tests/ui/const-generics/generic_const_exprs/issue-102768.stderr`][issue-102768.stderr], the error message where it gives additional notes about where the associated type is defined, and how the dead code lint doesn't have an article, like in [`tests/ui/lint/dead-code/issue-85255.stderr`][issue-85255.stderr]. They don't have articles, so it seems unnecessary to have one here.
    
    [issue-102768.stderr]: https://github.com/rust-lang/rust/blob/07c993eba8b76eae497e98433ae075b00f01be10/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr
    [issue-85255.stderr]: https://github.com/rust-lang/rust/blob/07c993eba8b76eae497e98433ae075b00f01be10/tests/ui/lint/dead-code/issue-85255.stderr
    matthiaskrgr committed Feb 23, 2023
    Configuration menu
    Copy the full SHA
    198c687 View commit details
    Browse the repository at this point in the history