Commit Graph

5260 Commits

Author SHA1 Message Date
Caleb Cartwright
9e1973f1d9 chore: bump toolchain, update test 2022-01-23 11:18:17 -06:00
Caleb Cartwright
9b454a5990 Merge remote-tracking branch 'upstream/master' into subtree-sync-2022-01-23 2022-01-23 11:07:20 -06:00
kadmin
7913f130d3 Add term to ExistentialProjection
Also prevent ICE when adding a const in associated const equality.
2022-01-17 20:01:22 +00:00
kadmin
cf86d53202 Add term
Instead of having a separate enum variant for types and consts have one but have either a const
or type.
2022-01-17 17:20:57 +00:00
kadmin
f5ce84e4f2 add eq constraints on associated constants 2022-01-17 17:20:57 +00:00
bors
8ae2312e34 Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu
Remove deprecated LLVM-style inline assembly

The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove
it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it
is time to remove `llvm_asm!` to avoid continued maintenance cost.

Closes #70173.
Closes #92794.
Closes #87612.
Closes #82065.

cc `@rust-lang/wg-inline-asm`

r? `@Amanieu`
2022-01-17 09:40:29 +00:00
Caleb Cartwright
bfbf42cecb fix(rustfmt): resolve generated file formatting issue 2022-01-14 18:18:37 -06:00
Tomasz Miąsko
04670a1404 Remove LLVM-style inline assembly from rustfmt 2022-01-12 21:43:35 +01:00
Lamb
6e6300207f 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
2022-01-09 21:33:14 +00:00
Matthias Krüger
5056f4cfb3 some minor clippy fixes 2022-01-05 17:53:27 -06:00
Seiichi Uchida
34d374ee5d Use <stdin> when emitting stdin as filename (#4298)
# Conflicts:
#	src/config/file_lines.rs
#	src/rustfmt/main.rs
#	src/test/mod.rs
2022-01-02 10:06:06 -06:00
Tim
894a3c0e77 Fix newlines in JSON output (#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 #4259

* Update tests
# Conflicts:
#	tests/writemode/target/output.json
2022-01-02 10:06:06 -06:00
Caleb Cartwright
776baf93f8 refactor: update json emitter to better handle errors (#3953) 2022-01-02 10:06:06 -06:00
Chris Emerson
34263cd6bd Fix --check -l with stdin. (#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.
2022-01-02 10:06:06 -06:00
Chris Emerson
93b7de5b01 Make --check work when running from stdin. (#3896)
# Conflicts:
#	src/bin/main.rs
2022-01-02 10:06:06 -06:00
Yacin Tmimi
737e6f7046 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``.
2022-01-01 10:27:49 -06:00
Caleb Cartwright
6db6bafc61 Merge commit '4a053f206fd6799a25823c307f7d7f9d897be118' into sync-rustfmt-subtree 2021-12-29 20:49:39 -06:00
David Lattimore
4a053f206f Do not flatten match arm block with leading attributes
This is a backport of #4124.

Fixes #4109
2021-12-29 17:43:58 -06:00
Caleb Cartwright
f935f0cf89 feat: support parsing asm! args 2021-12-28 20:25:17 -06:00
Caleb Cartwright
50bbb43dab chore: bump toolchain 2021-12-28 20:25:17 -06:00
Caleb Cartwright
e8afb62c71 chore: reduce some vis. for updated unreachable_pub lint 2021-12-27 18:16:04 -06:00
Yacin Tmimi
76eb077fb2 Retain qualified path when rewriting struct literals
Fixes 5151

Details about the qualified path are now passed along so that rustfmt
can include them when formatting struct literals.
2021-12-23 23:04:26 -06:00
David Tolnay
0b2fd9b132 Fix static async closure qualifier order 2021-12-23 23:03:49 -06:00
Caleb Cartwright
7b8303d479 chore: cleanup unused imports 2021-12-21 10:55:39 -06:00
Caleb Cartwright
97c3e48834 refactor: encapsulate cfg_if parsing within parse mod 2021-12-21 10:55:39 -06:00
Caleb Cartwright
62987562e2 refactor: extract final rustc_parse touchpoint from macros.rs 2021-12-21 10:55:39 -06:00
Caleb Cartwright
c8cf454173 refactor: move lazy_static parsing to parse mod 2021-12-21 10:55:39 -06:00
Caleb Cartwright
9ce5470a8c refactor: move macro arg parsing to parse mod 2021-12-21 10:55:39 -06:00
Caleb Cartwright
40b73d8fee refactor: rename syntux mod to parse 2021-12-21 10:55:39 -06:00
Caleb Cartwright
0346bc74a7
Merge pull request #5140 from calebcartwright/subtree-sync-2021-12-19
Subtree sync
2021-12-20 16:40:50 -06:00
Caleb Cartwright
b214938ff3 chore: bump toolchain 2021-12-20 11:58:27 -06:00
Caleb Cartwright
8bf82aeb83 Merge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-19 2021-12-19 15:22:45 -06:00
Nicholas Nethercote
122e1c3802 Remove unnecessary sigils around Ident::as_str() calls. 2021-12-15 17:32:42 +11:00
Nicholas Nethercote
3bb5f81d8d Remove unnecessary sigils around Symbol::as_str() calls. 2021-12-15 17:32:14 +11:00
Nicholas Nethercote
b4afb38f2f Remove SymbolStr.
By changing `as_str()` to take `&self` instead of `self`, we can just
return `&str`. We're still lying about lifetimes, but it's a smaller lie
than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-15 13:30:26 +11:00
Yacin Tmimi
57ac92bf16 Prevent duplicate comma when formatting struct pattern with ".."
Fixes 5066

When a struct pattern that contained a ".." was formatted, it was
assumed that a trailing comma should always be added if the struct
fields weren't formatted vertically.

Now, a trailing comma is only added if not already included in the
reformatted struct fields.
2021-12-14 13:28:25 -06:00
Matthias Krüger
740fb57f5d clippy fixes 2021-12-13 20:36:12 -06:00
Yacin Tmimi
f40b1d9f1a Backport: Do not touch module with #![rustfmt::skip] (4297)
Although the implementation is slightly different than the original PR,
the general idea is the same. After collecting all modules we want to
exclude formatting those that contain the #![rustfmt::skip] attribute.
2021-12-07 18:45:00 -06:00
Caleb Cartwright
0167c5303f Merge commit '8da837185714cefbb261e93e9846afb11c1dc60e' into sync-rustfmt-subtree 2021-12-02 21:35:30 -06:00
Caleb Cartwright
8da8371857
Merge pull request #5121 from calebcartwright/subtree-sync-2021-12-02
subtree sync
2021-12-02 21:29:47 -06:00
Caleb Cartwright
e305322557 Merge remote-tracking branch 'upstream/master' into subtree-sync-2021-12-02 2021-12-02 21:02:14 -06:00
Yacin Tmimi
ec46ffd981 Determine when new comment lines are needed for itemized blocks
Fixes 5088

Previously, rustfmt would add a new comment line anytime it reformatted
an itemized block within a comment when ``wrap_comments=true``. This
would lead to rustfmt adding empty comments with trailing whitespace.

Now, new comment lines are only added if the original comment spanned
multiple lines, if the comment needs to be wrapped, or if the comment
originally started with an empty comment line.
2021-12-01 18:31:10 -06:00
Yacin Tmimi
1f28683ffa Update nightly only test with #[nightly_only_test] attribute 2021-11-29 14:02:02 -06:00
Caleb Cartwright
0fc846f979 refactor: maintain more AST info when formatting a RHS 2021-11-28 23:25:06 -06:00
Yacin Tmimi
a21f1b6c2a Conditionally compile tests based on CFG_RELEASE_CHANNEL env var
Adds the ``nightly_only_test`` and ``stable_only_test`` attribute macros
that prevent or allow certain tests to compile on nightly and stable
respectively. This is achieved through conditionally outputting the
tests TokenStream.

If CFG_RELEASE_CHANNEL is not set, it's assumed that we're running in a
nightly environment.

To mark a test as nightly only:

    #[nightly_only_test]
    #[test]
    fn only_run_on_nightly() {
        ...
    }

To mark a test a stable only:

    #[stable_only_test]
    #[test]
    fn only_run_on_stable() {
        ...
    }
2021-11-27 17:36:18 -06:00
Yacin Tmimi
67fd9ec300 Run Windows, Linux, and Mac CI tests with nightly and stable channels 2021-11-27 13:19:02 -06:00
mujpao
ea042b90c9 Add more tests for comments in lists 2021-11-27 11:38:36 -06:00
Fabian Keller
243cec7a0b Update README.md 2021-11-26 16:47:45 -06:00
Esteban Kuber
f99469d7c4 Change how the fn params span is calculated
Use the available Generics span field to avoid issues with `T: Fn()` bounds.

This is necessary to land #85346.
2021-11-24 20:02:16 +00:00
Dom
4389a4ce49 fix: do not wrap reference-style doc links
Prevents wrap_comments from incorrectly wrapping reference-style doc
links.
2021-11-23 16:17:52 -06:00