Commit Graph

5146 Commits

Author SHA1 Message Date
bors
8743472386 Auto merge of #84373 - cjgillot:resolve-span, r=michaelwoerister,petrochenkov
Encode spans relative to the enclosing item

The aim of this PR is to avoid recomputing queries when code is moved without modification.

MCP at https://github.com/rust-lang/compiler-team/issues/443

This is achieved by :
1. storing the HIR owner LocalDefId information inside the span;
2. encoding and decoding spans relative to the enclosing item in the incremental on-disk cache;
3. marking a dependency to the `source_span(LocalDefId)` query when we translate a span from the short (`Span`) representation to its explicit (`SpanData`) representation.

Since all client code uses `Span`, step 3 ensures that all manipulations
of span byte positions actually create the dependency edge between
the caller and the `source_span(LocalDefId)`.
This query return the actual absolute span of the parent item.
As a consequence, any source code motion that changes the absolute byte position of a node will either:
- modify the distance to the parent's beginning, so change the relative span's hash;
- dirty `source_span`, and trigger the incremental recomputation of all code that
  depends on the span's absolute byte position.

With this scheme, I believe the dependency tracking to be accurate.

For the moment, the spans are marked during lowering.
I'd rather do this during def-collection,
but the AST MutVisitor is not practical enough just yet.
The only difference is that we attach macro-expanded spans
to their expansion point instead of the macro itself.
2021-09-11 23:35:28 +00:00
Camille GILLOT
127ec9a8c9 Keep a parent LocalDefId in SpanData. 2021-09-10 20:17:33 +02:00
Fabian Wolff
e014277b07 Ignore automatically derived impls of Clone and Debug in dead code analysis 2021-09-09 19:49:07 +02:00
Felix S. Klock II
d647ebfb4a Revert "Allow formatting Anonymous{Struct, Union} declarations"
This reverts commit 64acb7d921.
2021-09-09 09:14:16 -04:00
bors
6271dedd8d Auto merge of #88493 - chenyukang:fix-duplicated-diagnostic, r=estebank
Fix #88256 remove duplicated diagnostics

Fix #88256
2021-09-06 00:14:41 +00:00
yukang
1674eea8ad Fix #88256, remove duplicated diagnostic 2021-09-04 19:26:25 +08:00
Esteban Kuber
48b8e4577a Detect bare blocks with type ascription that were meant to be a struct literal
Address part of #34255.

Potential improvement: silence the other knock down errors in
`issue-34255-1.rs`.
2021-09-03 14:43:04 +00:00
Cameron Steffen
a603756cc5 Temporary fix rustfmt for let-else 2021-08-30 20:18:41 -05:00
Deadbeef
20ddab3def Fix rustfmt test 2021-08-27 11:53:03 +00:00
Deadbeef
076916fe94 Introduce ~const
- [x] Removed `?const` and change uses of `?const`
 - [x] Added `~const` to the AST. It is gated behind const_trait_impl.
 - [x] Validate `~const` in ast_validation.
 - [ ] Add enum `BoundConstness` to the HIR. (With variants `NotConst` and
 `ConstIfConst` allowing future extensions)
 - [ ] Adjust trait selection and pre-existing code to use `BoundConstness`.
 - [ ] Optional steps (*for this PR, obviously*)
      - [ ] Fix #88155
      - [ ] Do something with constness bounds in chalk
2021-08-27 05:07:37 +00:00
Frank Steffahn
9bc0dbeb64 Fix typos “an”→“a” and a few different ones that appeared in the same search 2021-08-22 18:15:49 +02:00
Frank Steffahn
25ebc35f97 Fix more “a”/“an” typos 2021-08-22 16:35:29 +02:00
bors
e1dac88cfe Auto merge of #87119 - jyn514:rustfmt-doc-private, r=Mark-Simulacrum
Document private items for rustfmt

This is possible now that https://github.com/rust-lang/rust/pull/73936 has been merged.
2021-08-17 04:18:55 +00:00
Joshua Nelson
7769ed0484 Document private items for rustfmt
This is possible now that rustdoc allows passing
`--document-private-items` more than once.
2021-08-16 01:46:56 +00:00
Caio
64bf8dfa33 Introduce hir::ExprKind::Let - Take 2 2021-08-15 16:18:26 -03:00
bors
2323cbc231 Auto merge of #87535 - lf-:authors, r=Mark-Simulacrum
rfc3052 followup: Remove authors field from Cargo manifests

Since RFC 3052 soft deprecated the authors field, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information for contributors, we may as well
remove it from crates in this repo.
2021-08-02 05:49:17 +00:00
Jade
e9038b8842 rfc3052: Remove authors field from Cargo manifests
Since RFC 3052 soft deprecated the authors field anyway, hiding it from
crates.io, docs.rs, and making Cargo not add it by default, and it is
not generally up to date/useful information, we should remove it from
crates in this repo.
2021-07-29 14:56:05 -07:00
Caleb Cartwright
e4b8714c09 Merge commit '4236289b75ee55c78538c749512cdbeea5e1c332' into update-rustfmt 2021-07-25 22:57:19 -05:00
Camille GILLOT
277feac1f9 Use LocalExpnId where possible. 2021-07-17 19:41:02 +02:00
Guillaume Gomez
abf449ffa6 Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
Joshua Nelson
33acc960f7 Document rustfmt on nightly-rustc
The recursion_limit attribute avoids the following error:

```
error[E0275]: overflow evaluating the requirement `std::ptr::Unique<rustc_ast::Pat>: std::marker::Send`
  |
  = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`rustfmt_nightly`)
```
2021-07-01 19:39:47 -04:00
Yuki Okushi
0b8a26f507 Rollup merge of #86424 - calebcartwright:rustfmt-mod-resolution, r=Mark-Simulacrum
rustfmt: load nested out-of-line mods correctly

This should address https://github.com/rust-lang/rustfmt/issues/4874

r? `@Mark-Simulacrum`

Decided to make the change directly in tree here for expediency/to minimize any potential backporting issues, and because there's some subtree sync items I need to get resolved before pulling from r-l/rustfmt
2021-06-22 00:00:41 +09:00
Yuki Okushi
d13020cd31 Rollup merge of #86274 - alexander-melentyev:spaces, r=bjorn3
Spaces
2021-06-22 00:00:38 +09:00
Alexander Melentyev
71f01d1974 Delete spaces 2021-06-21 12:11:37 +03:00
Caleb Cartwright
2608f2c63b fix(rustfmt): load nested out-of-line mods correctly 2021-06-17 22:35:19 -05:00
Yuki Okushi
1e2258ffa9 Use AttrVec for Arm, FieldDef, and Variant 2021-06-17 08:04:54 +09:00
Ryan Levick
58c63cf8de Add support for using qualified paths with structs in expression and pattern
position.
2021-06-10 13:18:41 +02:00
jedel1043
e243be6ada Allow formatting Anonymous{Struct, Union} declarations 2021-05-16 22:13:38 -05:00
Joshua Nelson
d67f1a48ef Update log to 0.4.14
This avoids the following warning:

```
warning: trailing semicolon in macro used in expression position
   --> /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.11/src/macros.rs:152:45
    |
147 | / macro_rules! debug {
148 | |     (target: $target:expr, $($arg:tt)+) => (
149 | |         log!(target: $target, $crate::Level::Debug, $($arg)+);
150 | |     );
151 | |     ($($arg:tt)+) => (
152 | |         log!($crate::Level::Debug, $($arg)+);
    | |                                             ^
153 | |     )
154 | | }
    | |_- in this expansion of `debug!`
    |
   ::: src/tools/rustfmt/src/modules/visitor.rs:36:23
    |
36  |               Err(e) => debug!("{}", e),
    |                         --------------- in this macro invocation
    |
    = note: requested on the command line with `-W semicolon-in-expressions-from-macros`
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
```
2021-05-14 21:54:43 -05:00
Caleb Cartwright
7872306edf chore: update gitattributes for files with windows style line endings 2021-05-14 18:50:25 -05:00
Andy Wang
927561ace1 Bump nightly version 2021-05-12 22:12:43 -05:00
Andy Wang
ef31361766 Rename RealFileName::Named to LocalPath 2021-05-12 22:12:43 -05:00
Andy Wang
e4b5621b0e Only deal with LocalPath in conversion 2021-05-12 22:12:43 -05:00
Andy Wang
8526acee21 Rename span_to_string to span_to_diagnostic_string 2021-05-12 22:12:43 -05:00
Caleb Cartwright
2a3635d5d1 tests: remove snippets with inner attrs on non-block expressions 2021-05-04 18:38:22 -05:00
Caleb Cartwright
f87414729f fix: backport changes for latest rustc api comaptibility 2021-05-02 10:37:43 -05:00
Yuki Okushi
ddb224a173
Upgrade annotate-snippets to 0.8 (#4762) 2021-04-22 08:33:36 -05:00
ChinYing-Li
84ff0013c2 Add the case in duplicate issue (#4806) to the idempotent tests 2021-04-21 21:30:42 -05:00
ChinYing-Li
dac2423f3f Recognize when a block comment has been ended inside a string literal (#4312) 2021-04-21 21:30:42 -05:00
Joseph Birr-Pixton
58157bb4b7 Add some basic tests for chain_width use 2021-04-21 21:27:50 -05:00
Caleb Cartwright
78b0728887 refactor: remove panics on misconfigured widths 2021-04-21 21:27:50 -05:00
Caleb Cartwright
a168d92f9a tests: augment heuristics tests 2021-04-21 21:27:50 -05:00
Caleb Cartwright
1bcc1f8df5 refactor: apply heuristic config changes in lib 2021-04-21 21:27:50 -05:00
Caleb Cartwright
ea1611c06e feat(config): expose all width heurstic options 2021-04-21 21:27:50 -05:00
Caleb Cartwright
0269eb1c5f docs: update configuration info 2021-04-21 21:27:50 -05:00
Joshua Nelson
26fb3fa737 Use rustup in CI to automatically determine the toolchain version needed
This also removes the (now unused) `RUSTC_RELEASE` and
`RUSTC_RELEASE_CHANNEL` variables.
2021-04-21 21:17:36 -05:00
Joshua Nelson
943b97c3ae Fix errors when parallel_compiler is enabled 2021-04-21 21:17:36 -05:00
Joshua Nelson
61ee1089f0 Use rustc_private instead of crates.io dependencies
- Update rust-toolchain to also install `rustc-dev` component
2021-04-21 21:17:36 -05:00
Joshua Nelson
6767c1d051 Don't show CRLF tests as modified in the working directory
This was being overriden by `lf=eof` in `.gitattributes` in the root
directory. Override it again to avoid warnings like this:

```
$ git diff src/tools/rustfmt/tests/target/issue-3494/crlf.rs
warning: CRLF will be replaced by LF in src/tools/rustfmt/tests/target/issue-3494/crlf.rs.
The file will have its original line endings in your working directory
```
2021-04-21 21:17:36 -05:00
Caleb Cartwright
0bd2b1927c chore: bump version and changelog 2021-04-03 00:30:12 -05:00