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

Sync rustfmt subtree #95458

Merged
merged 75 commits into from
Mar 30, 2022
Merged

Commits on Dec 30, 2021

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

Commits on Jan 1, 2022

  1. Improve out of line module resolution

    Fixes 5119
    
    When the directory structure was laid out as follows:
    
    ```
    dir
     |---mod_a
     |    |---sub_mod_1.rs
     |    |---sub_mod_2.rs
     |---mod_a.rs
    ```
    
    And ``mod_a.rs`` contains the following content:
    
    ```rust
    mod mod_a {
        mod sub_mod_1;
        mod sub_mod_2;
    }
    ```
    
    rustfmt previously tried to find ``sub_mod_1.rs`` and ``sub_mod_2.rs``
    in ``./mod_a/mod_a/``. This directory does not exist and this caused
    rustfmt to fail with the error message:
    
        Error writing files: failed to resolve mod
    
    Now, both ``sub_mod_1.rs`` and ``sub_mod_2.rs`` are resolved correctly
    and found at ``mod_a/sub_mod_1.rs`` and ``mod_a/sub_mod_2.rs``.
    ytmimi authored and calebcartwright committed Jan 1, 2022
    Configuration menu
    Copy the full SHA
    737e6f7 View commit details
    Browse the repository at this point in the history

Commits on Jan 2, 2022

  1. Make --check work when running from stdin. (rust-lang#3896)

    # Conflicts:
    #	src/bin/main.rs
    jugglerchris authored and calebcartwright committed Jan 2, 2022
    Configuration menu
    Copy the full SHA
    93b7de5 View commit details
    Browse the repository at this point in the history
  2. Fix --check -l with stdin. (rust-lang#3910)

    * Fix some possible panics when using `--check` with stdin.
    
    One case which doesn't work is when there are only line ending fixes;
    with stdin rustfmt is unable to detect the difference as it stores
    the input with Unix line endings.
    
    * Add test for `rustfmt --check -l` with stdin.
    jugglerchris authored and calebcartwright committed Jan 2, 2022
    Configuration menu
    Copy the full SHA
    34263cd View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    776baf9 View commit details
    Browse the repository at this point in the history
  4. Fix newlines in JSON output (rust-lang#4262)

    * Fix newlines in JSON output
    
    This changes the JSON output to be more consistent about where newlines are included. Previously it only included them between lines in a multiline diff. That meant single line changes were treated a bit weirdly. This changes it to append a newline to every line.
    
    When feeding the results into `arc lint` this behaves correctly. I have only done limited testing though, in particular there's a possibility it might not work with files with `\r\n` endings (though that would have been the case before too).
    
    Fixes rust-lang#4259
    
    * Update tests
    # Conflicts:
    #	tests/writemode/target/output.json
    Timmmm authored and calebcartwright committed Jan 2, 2022
    Configuration menu
    Copy the full SHA
    894a3c0 View commit details
    Browse the repository at this point in the history
  5. Use <stdin> when emitting stdin as filename (rust-lang#4298)

    # Conflicts:
    #	src/config/file_lines.rs
    #	src/rustfmt/main.rs
    #	src/test/mod.rs
    topecongiro authored and calebcartwright committed Jan 2, 2022
    Configuration menu
    Copy the full SHA
    34d374e View commit details
    Browse the repository at this point in the history

Commits on Jan 5, 2022

  1. some minor clippy fixes

    matthiaskrgr authored and calebcartwright committed Jan 5, 2022
    Configuration menu
    Copy the full SHA
    5056f4c View commit details
    Browse the repository at this point in the history

Commits on Jan 9, 2022

  1. Compute most of Public/Exported access level in rustc_resolve

    Mak DefId to AccessLevel map in resolve for export
    
    hir_id to accesslevel in resolve and applied in privacy
    using local def id
    removing tracing probes
    making function not recursive and adding comments
    
    Move most of Exported/Public res to rustc_resolve
    
    moving public/export res to resolve
    
    fix missing stability attributes in core, std and alloc
    
    move code to access_levels.rs
    
    return for some kinds instead of going through them
    
    Export correctness, macro changes, comments
    
    add comment for import binding
    
    add comment for import binding
    
    renmae to access level visitor, remove comments, move fn as closure, remove new_key
    
    fmt
    
    fix rebase
    
    fix rebase
    
    fmt
    
    fmt
    
    fix: move macro def to rustc_resolve
    
    fix: reachable AccessLevel for enum variants
    
    fmt
    
    fix: missing stability attributes for other architectures
    
    allow unreachable pub in rustfmt
    
    fix: missing impl access level + renaming export to reexport
    
    Missing impl access level was found thanks to a test in clippy
    lambinoo authored and Lamb committed Jan 9, 2022
    Configuration menu
    Copy the full SHA
    6e63002 View commit details
    Browse the repository at this point in the history

Commits on Jan 12, 2022

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

Commits on Jan 15, 2022

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

Commits on Jan 17, 2022

  1. Auto merge of rust-lang#92816 - tmiasko:rm-llvm-asm, r=Amanieu

    Remove deprecated LLVM-style inline assembly
    
    The `llvm_asm!` was deprecated back in rust-lang#87590 1.56.0, with intention to remove
    it once `asm!` was stabilized, which already happened in rust-lang#91728 1.59.0. Now it
    is time to remove `llvm_asm!` to avoid continued maintenance cost.
    
    Closes rust-lang#70173.
    Closes rust-lang#92794.
    Closes rust-lang#87612.
    Closes rust-lang#82065.
    
    cc `@rust-lang/wg-inline-asm`
    
    r? `@Amanieu`
    bors committed Jan 17, 2022
    Configuration menu
    Copy the full SHA
    8ae2312 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f5ce84e View commit details
    Browse the repository at this point in the history
  3. Add term

    Instead of having a separate enum variant for types and consts have one but have either a const
    or type.
    JulianKnodt committed Jan 17, 2022
    Configuration menu
    Copy the full SHA
    cf86d53 View commit details
    Browse the repository at this point in the history
  4. Add term to ExistentialProjection

    Also prevent ICE when adding a const in associated const equality.
    JulianKnodt committed Jan 17, 2022
    Configuration menu
    Copy the full SHA
    7913f13 View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2022

  1. Configuration menu
    Copy the full SHA
    9b454a5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9e1973f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5c558e2 View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2022

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

Commits on Jan 29, 2022

  1. Fix formatting of comments in empty structs (rust-lang#5171)

    * Fix formatting of comments in empty structs
    
    * Add tests
    
    * Add single line tests
    
    * Fix block comments
    
    * Revert changes of test source files
    Szymongib authored Jan 29, 2022
    Configuration menu
    Copy the full SHA
    b4a4bf0 View commit details
    Browse the repository at this point in the history
  2. Prevent adding trailing whitespace when rewriting ast::Param

    Fixes 5125
    
    Previously, a newline was always added, even if the parameter name was
    not preceded by any param attrs.
    
    Now a newline is only added if there were param attrs.
    ytmimi authored and calebcartwright committed Jan 29, 2022
    Configuration menu
    Copy the full SHA
    8b0b213 View commit details
    Browse the repository at this point in the history

Commits on Feb 2, 2022

  1. Handle non-ascii character at boundary (rust-lang#5089)

    * Handle non-ascii character at boundary
    
    * Replace substraction underflow check with early termination
    scampi authored Feb 2, 2022
    Configuration menu
    Copy the full SHA
    368a9b7 View commit details
    Browse the repository at this point in the history

Commits on Feb 4, 2022

  1. Retain trailing separator when extracting the last inline post comment

    Fixes 5042
    
    Previously, trailing commas were removed from the last inline comment.
    This lead to rustfmt refusing to format code snippets because
    the original comment did not match the rewritten comment.
    
    Now, when rustfmt extracts the last inline comment it leaves trailing
    separators alone. Rustfmt does not need to remove these separators
    because they are commented out.
    ytmimi authored and calebcartwright committed Feb 4, 2022
    Configuration menu
    Copy the full SHA
    606894e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b2c7a52 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    fd6e11c View commit details
    Browse the repository at this point in the history

Commits on Feb 7, 2022

  1. Fix doc of generic items formmating error (rust-lang#5124)

    * Fix doc of generic items formmating error
    
    * Remove tracked `attrs_end_with_doc_comment` flag in `RewriteContext`
    
    * Fix duplicated doc comments of const generic params
    
    * Fix `<ast::GenericParam as Spanned>::span()`
    
    * Remove duplicated source file of `doc-of-generic-item.rs`
    frank-king authored Feb 7, 2022
    Configuration menu
    Copy the full SHA
    5df8c8f View commit details
    Browse the repository at this point in the history

Commits on Feb 11, 2022

  1. Configuration menu
    Copy the full SHA
    ace7241 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    813d127 View commit details
    Browse the repository at this point in the history
  3. chore(rustfmt): remove executable path from usage string (rust-lang#5216

    )
    
    * chore(rustfmt): remove executable path from usage string
    
    * add unit test for usage string
    
    * rename test and check usage text in a single assert
    tharun208 authored Feb 11, 2022
    Configuration menu
    Copy the full SHA
    b05b313 View commit details
    Browse the repository at this point in the history
  4. Leverage itemized blocks to support formatting markdown block quotes

    Fixes 5157
    
    Doc comments support markdown, but rustfmt didn't previously assign any
    semantic value to leading '> ' in comments. This lead to poor formatting
    when using ``wrap_comments=true``.
    
    Now, rustfmt treats block quotes as itemized blocks, which greatly
    improves how block quotes are formatted when ``wrap_comments=true``.
    ytmimi authored and calebcartwright committed Feb 11, 2022
    Configuration menu
    Copy the full SHA
    1e78a2b View commit details
    Browse the repository at this point in the history

Commits on Feb 15, 2022

  1. Add context to get_toml_path() error (rust-lang#5207)

    * rustfmt: print full error chain
    
    * Add context to get_toml_path() error
    
    Instead of an error like:
    
    ```
    Permission denied (os error 13)
    ```
    
    Gives error like:
    
    ```
    Failed to get metadata for config file "/root/.rustfmt.toml": Permission denied (os error 13)
    ```
    tmfink authored Feb 15, 2022
    Configuration menu
    Copy the full SHA
    6c47612 View commit details
    Browse the repository at this point in the history

Commits on Feb 16, 2022

  1. Format code

    camsteffen authored and calebcartwright committed Feb 16, 2022
    Configuration menu
    Copy the full SHA
    d5aabcc View commit details
    Browse the repository at this point in the history
  2. Use cargo-fmt in self_tests

    camsteffen authored and calebcartwright committed Feb 16, 2022
    Configuration menu
    Copy the full SHA
    c63d42e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    281bf03 View commit details
    Browse the repository at this point in the history

Commits on Feb 23, 2022

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

Commits on Feb 24, 2022

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

Commits on Feb 25, 2022

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

Commits on Mar 1, 2022

  1. fallback to dir_path when relative external mod resolution fails

    We only want to fall back if two conditions are met:
    
    1) Initial module resolution is performed relative to some nested
       directory.
    2) Module resolution fails because of a ModError::FileNotFound error.
    
    When these conditions are met we can try to fallback to searching for
    the module's file relative to the dir_path instead of the nested
    relative directory.
    
    Fixes 5198
    
    As demonstrated by 5198, it's possible that a directory name conflicts
    with a rust file name. For example, src/lib/ and src/lib.rs.
    
    If src/lib.rs references an external module like ``mod foo;``, then
    module resolution will try to resolve ``foo`` to src/lib/foo.rs or
    src/lib/foo/mod.rs. Module resolution would fail with a file not
    found error if the ``foo`` module were defined at src/foo.rs.
    
    When encountering these kinds of module resolution issues we now fall
    back to the current directory and attempt to resolve the module again.
    
    Given the current example, this means that if we can't find the module
    ``foo`` at src/lib/foo.rs or src/lib/foo/mod.rs, we'll attempt
    to resolve the module to src/foo.rs.
    ytmimi authored and calebcartwright committed Mar 1, 2022
    Configuration menu
    Copy the full SHA
    12048e4 View commit details
    Browse the repository at this point in the history
  2. Prevent wrapping markdown headers in doc comments

    Fixes 5238
    
    A markdown header is defined by a string that starts with `#`.
    
    Previously, rustfmt would wrap long markdown headers when
    `wrap_comments=true`. This lead to issues when rendering these headers
    in HTML using rustdoc.
    
    Now, rustfmt leaves markdown headers alone when wrapping comments.
    ytmimi authored and calebcartwright committed Mar 1, 2022
    Configuration menu
    Copy the full SHA
    272fb42 View commit details
    Browse the repository at this point in the history

Commits on Mar 3, 2022

  1. Configuration menu
    Copy the full SHA
    4edb757 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    74876ef View commit details
    Browse the repository at this point in the history
  3. Adjusted diagnostic output so that if there is no use in a item seq…

    …uence,
    
    then we just suggest the first legal position where you could inject a use.
    
    To do this, I added `inject_use_span` field to `ModSpans`, and populate it in
    parser (it is the span of the first token found after inner attributes, if any).
    Then I rewrote the use-suggestion code to utilize it, and threw out some stuff
    that is now unnecessary with this in place. (I think the result is easier to
    understand.)
    
    Then I added a test of issue 87613.
    pnkfelix committed Mar 3, 2022
    Configuration menu
    Copy the full SHA
    651f463 View commit details
    Browse the repository at this point in the history

Commits on Mar 4, 2022

  1. Update itertools

    Update to 0.10.1
    pierwill committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    0be8931 View commit details
    Browse the repository at this point in the history
  2. Placate tidy in submodule.

    pnkfelix committed Mar 4, 2022
    Configuration menu
    Copy the full SHA
    ce301d9 View commit details
    Browse the repository at this point in the history

Commits on Mar 5, 2022

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

Commits on Mar 6, 2022

  1. Rollup merge of rust-lang#94617 - pierwill:update-itertools, r=Mark-S…

    …imulacrum
    
    Update `itertools`
    
    Update to 0.10.1
    matthiaskrgr authored Mar 6, 2022
    Configuration menu
    Copy the full SHA
    6a2dae6 View commit details
    Browse the repository at this point in the history
  2. Fix missing struct field separators under certain conditions

    When struct_field_align_threshold is non-zero and trailing_comma is set to
    "Never," struct field separators are omitted between field groups. This issue is
    resolved by forcing separators between groups.
    
    Fixes rust-lang#4791.
    
    A test is included with a minimal reproducible example.
    cassaundra authored and calebcartwright committed Mar 6, 2022
    Configuration menu
    Copy the full SHA
    ee13051 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ab9f2a8 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    58de414 View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2022

  1. placate rustfmt in rustfmt.

    pnkfelix committed Mar 7, 2022
    Configuration menu
    Copy the full SHA
    003eaf8 View commit details
    Browse the repository at this point in the history

Commits on Mar 9, 2022

  1. Improve mod resolution error for mods with multiple candidate files

    Fixes 5167
    
    When ``a.rs`` and ``a/mod.rs`` are both present we would emit an error
    message telling the user that the module couldn't be found. However,
    this behavior is misleading because we're dealing with an ambiguous
    module path, not a "file not found" error.
    
    Is the file ``a.rs`` or is it ``a/mod.rs``? Rustfmt can't decide, and
    the user needs to resolve this ambiguity themselves.
    
    Now, the error message displayed to the user is in line with what they
    would see if they went to compile their code with these conflicting
    module names.
    ytmimi authored and calebcartwright committed Mar 9, 2022
    Configuration menu
    Copy the full SHA
    18c0369 View commit details
    Browse the repository at this point in the history

Commits on Mar 12, 2022

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

Commits on Mar 15, 2022

  1. Auto merge of rust-lang#94584 - pnkfelix:inject-use-suggestion-sites,…

    … r=ekuber
    
    More robust fallback for `use` suggestion
    
    Our old way to suggest where to add `use`s would first look for pre-existing `use`s in the relevant crate/module, and if there are *no* uses, it would fallback on trying to use another item as the basis for the suggestion.
    
    But this was fragile, as illustrated in issue rust-lang#87613
    
    This PR instead identifies span of the first token after any inner attributes, and uses *that* as the fallback for the `use` suggestion.
    
    Fix rust-lang#87613
    bors committed Mar 15, 2022
    Configuration menu
    Copy the full SHA
    a918d8b View commit details
    Browse the repository at this point in the history

Commits on Mar 16, 2022

  1. Correct tracking issue link for skip_children

    Update the issue link to point to issue 3389
    ytmimi authored and calebcartwright committed Mar 16, 2022
    Configuration menu
    Copy the full SHA
    9c65db6 View commit details
    Browse the repository at this point in the history
  2. Add test to verify tracking issue links

    Now, tracking issue links are checked against the reference number
    listed in the link text to ensure they match.
    ytmimi authored and calebcartwright committed Mar 16, 2022
    Configuration menu
    Copy the full SHA
    5696e38 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1bb85bd View commit details
    Browse the repository at this point in the history
  4. resolve the conflict in compiler/rustc_session/src/parse.rs

    Signed-off-by: codehorseman <cricis@yeah.net>
    codehorseman committed Mar 16, 2022
    Configuration menu
    Copy the full SHA
    c0861d3 View commit details
    Browse the repository at this point in the history
  5. rustc_error: make ErrorReported impossible to construct

    There are a few places were we have to construct it, though, and a few
    places that are more invasive to change. To do this, we create a
    constructor with a long obvious name.
    mark-i-m committed Mar 16, 2022
    Configuration menu
    Copy the full SHA
    c1d351f View commit details
    Browse the repository at this point in the history

Commits on Mar 17, 2022

  1. Configuration menu
    Copy the full SHA
    c801367 View commit details
    Browse the repository at this point in the history
  2. Rollup merge of rust-lang#94960 - codehorseman:master, r=oli-obk

    Fix many spelling mistakes
    
    Signed-off-by: codehorseman <cricis@yeah.net>
    Dylan-DPC authored Mar 17, 2022
    Configuration menu
    Copy the full SHA
    cce0d50 View commit details
    Browse the repository at this point in the history
  3. chore: bump toolchain

    calebcartwright committed Mar 17, 2022
    Configuration menu
    Copy the full SHA
    432b8de View commit details
    Browse the repository at this point in the history

Commits on Mar 18, 2022

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

Commits on Mar 20, 2022

  1. Take &mut Diagnostic in emit_diagnostic.

    Taking a Diagnostic by move would break the usual pattern
    `diag.label(..).emit()`.
    cjgillot committed Mar 20, 2022
    Configuration menu
    Copy the full SHA
    4f89c51 View commit details
    Browse the repository at this point in the history

Commits on Mar 21, 2022

  1. Search for struct body span after any generic arguments

    Fixes 5273
    
    Previously, rustfmt searched for the start of a struct body after the
    opening `{`. In most cases this works just fine, but const values can
    also be defined between `{ }`, which lead to issues when rewriting the
    struct body.
    
    Now, rustfmt will search for the `{` after the generic argument list to
    guarantee that the `{` it finds is the start of the struct body.
    ytmimi authored and calebcartwright committed Mar 21, 2022
    Configuration menu
    Copy the full SHA
    e41329c View commit details
    Browse the repository at this point in the history
  2. Add short_item_threshold config option

    Allow custom short item threshold values via config
    123vivekr authored and calebcartwright committed Mar 21, 2022
    Configuration menu
    Copy the full SHA
    0dba01a View commit details
    Browse the repository at this point in the history
  3. Honor #[rustfmt::skip::attributes(derive)] attribute

    Fixes 5270
    
    Previously, rustfmt only checked the `merge_derives` configuration value
    to determine if it should merge_derives. This lead to derives being
    merged even when annotated with the `rustfmt::skip` attribute.
    
    Now, rustfmt also checks if derives are explicitly being skipped in the
    current context via the `rustfmt::skip` attribute.
    ytmimi authored and calebcartwright committed Mar 21, 2022
    Configuration menu
    Copy the full SHA
    8984438 View commit details
    Browse the repository at this point in the history

Commits on Mar 28, 2022

  1. Configuration menu
    Copy the full SHA
    5731f1d View commit details
    Browse the repository at this point in the history
  2. chore: bump toolchain

    calebcartwright committed Mar 28, 2022
    Configuration menu
    Copy the full SHA
    c2039d9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    63acf90 View commit details
    Browse the repository at this point in the history

Commits on Mar 29, 2022

  1. Revert "Use cargo-fmt in self_tests"

    This reverts commit c63d42e.
    calebcartwright committed Mar 29, 2022
    Configuration menu
    Copy the full SHA
    4fecede View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e0c7b7d View commit details
    Browse the repository at this point in the history

Commits on Mar 30, 2022

  1. Configuration menu
    Copy the full SHA
    8e94761 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5ff7b63 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    419df99 View commit details
    Browse the repository at this point in the history