Compare commits

...

200 Commits

Author SHA1 Message Date
a94d4d57de
Update to latest rustc 2024-09-27 18:23:56 -05:00
cf4c629a2b
Merge branch 'master' of https://github.com/rust-lang/rust 2024-09-23 20:36:05 -05:00
bors
7042c269c1 Auto merge of #125645 - RalfJung:unclear_local_imports, r=nnethercote
add unqualified_local_imports lint

This lint helps deal with https://github.com/rust-lang/rustfmt/issues/4709 by having the compiler detect imports of local items that are not syntactically distinguishable from imports from other cates. Making them  syntactically distinguishable ensures rustfmt can consistently apply the desired import grouping.
2024-09-23 19:27:33 +00:00
bors
9d6039ccae Auto merge of #130755 - workingjubilee:rollup-zpja9b3, r=workingjubilee
Rollup of 7 pull requests

Successful merges:

 - #129201 (std: implement the `random` feature (alternative version))
 - #130536 (bootstrap: Set the dylib path when building books with rustdoc)
 - #130551 (Fix `break_last_token`.)
 - #130657 (Remove x86_64-fuchsia and aarch64-fuchsia target aliases)
 - #130721 (Add more test cases for block-no-opening-brace)
 - #130736 (Add rustfmt 2024 reformatting to git blame ignore)
 - #130746 (readd `@tgross35` and `@joboet` to the review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-23 16:40:39 +00:00
Jubilee
c7abc85181
Rollup merge of #130746 - joboet:hello_again, r=joboet
readd @tgross35 and @joboet to the review rotation

We're both (nearly) back from vacation.

CC ``@tgross35``
2024-09-23 07:54:46 -07:00
Jubilee
7ea391956f
Rollup merge of #130736 - Kobzol:rustfmt-2024-git-blame, r=compiler-errors
Add rustfmt 2024 reformatting to git blame ignore

https://github.com/rust-lang/rust/pull/130724 essentially reformatted the world, so we should add it to the git blame ignore list.

Tested with `git blame compiler/rustc_abi/src/lib.rs -L1137,1146`. I first thought that I have to ignore the merge commit, but it seems like the actual commit that did the reformatting should be ignored instead.

r? ``@compiler-errors``
2024-09-23 07:54:46 -07:00
Jubilee
6feefdb513
Rollup merge of #130721 - GrigorenkoPV:block-no-opening-brace, r=jieyouxu
Add more test cases for block-no-opening-brace

Also add FIXME's for #80931 & #78168
2024-09-23 07:54:45 -07:00
Jubilee
021ae2c7fd
Rollup merge of #130657 - arttet:fix/fuchsia, r=jieyouxu
Remove x86_64-fuchsia and aarch64-fuchsia target aliases

Closes #106649.
2024-09-23 07:54:45 -07:00
Jubilee
515bdcda01
Rollup merge of #130551 - nnethercote:fix-break-last-token, r=petrochenkov
Fix `break_last_token`.

It currently doesn't handle the three-char tokens `>>=` and `<<=` correctly. These can be broken twice, resulting in three individual tokens. This is a latent bug that currently doesn't cause any problems, but does cause problems for #124141, because that PR increases the usage of lazy token streams.

r? `@petrochenkov`
2024-09-23 07:54:44 -07:00
Jubilee
c58e3cb1e2
Rollup merge of #130536 - cuviper:rustbook-dylib-path, r=Mark-Simulacrum
bootstrap: Set the dylib path when building books with rustdoc

The library path is needed when the toolchain has been configured with
`[rust] rpath = false`. Otherwise, building the reference book will get
an error when it tries to run rustdoc, like:

    rustdoc: error while loading shared libraries: librustc_driver-2ec457c3b8826b72.so
2024-09-23 07:54:43 -07:00
Jubilee
1d369312e4
Rollup merge of #129201 - joboet:random_faster_sources, r=joshtriplett
std: implement the `random` feature (alternative version)

Implements the ACP rust-lang/libs-team#393.

This PR is an alternative version of #129120 that replaces `getentropy` with `CCRandomGenerateBytes` (on macOS) and `arc4random_buf` (other BSDs), since that function is not suited for generating large amounts of data and should only be used to seed other CPRNGs. `CCRandomGenerateBytes`/`arc4random_buf` on the other hand is (on modern platforms) just as secure and uses its own, very strong CPRNG (ChaCha20 on the BSDs, AES on macOS) periodically seeded with `getentropy`.
2024-09-23 07:54:43 -07:00
bors
648d024a78 Auto merge of #130716 - bjorn3:sync_cg_clif-2024-09-22, r=bjorn3
Subtree sync for rustc_codegen_cranelift

The main highlight this time is a fix for a miscompilation of RwLock on macOS. Also a Cranelift update and a couple of extra vendor intrinsics on arm64.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2024-09-23 13:39:07 +00:00
joboet
b0c2c9372a
readd @tgross35 and @joboet to the review rotation 2024-09-23 13:37:52 +02:00
bjorn3
6b042f5b5d Rustfmt 2024-09-23 11:28:15 +00:00
bjorn3
9456ff13c9 Revert change to apply_patches to fix panic 2024-09-23 11:20:56 +00:00
bjorn3
b40fe1ee28 Merge commit '6d35b4c9a04580366fd800692a5b5db79d766530' into sync_cg_clif-2024-09-22 2024-09-23 11:20:46 +00:00
bjorn3
6d35b4c9a0 Rustup to rustc 1.83.0-nightly (6c6d21008 2024-09-22) 2024-09-23 11:11:08 +00:00
bjorn3
faeede3881 Merge branch 'sync_from_rust' 2024-09-23 11:04:43 +00:00
bors
c22a4215a0 Auto merge of #130641 - cuviper:llvm-19.1.0, r=nikic
Update to LLVM 19.1.0

This is a branch rebase of the submodule, now that LLVM 19.1.0 is final.
Our *only* extra patch right now is the one we're carrying for SGX unwind.
2024-09-23 10:54:29 +00:00
Ralf Jung
1eb51e717e fix unqualified_local_imports in rustc_const_eval 2024-09-23 11:57:32 +02:00
Ralf Jung
4c43757e43 fix unqualified_local_imports in Miri 2024-09-23 11:57:32 +02:00
Ralf Jung
584c5cf7ae add unqualified_local_imports lint 2024-09-23 11:57:28 +02:00
joboet
3ff09a05c8
update miri test 2024-09-23 10:36:17 +02:00
joboet
e94dd9b712
random: add tracking issue, address other comments 2024-09-23 10:36:16 +02:00
joboet
a21ff017f4
miri: shim CCRandomGenerateBytes 2024-09-23 10:36:16 +02:00
joboet
b9d47cfa9b
std: switch to faster random sources on macOS and most BSDs 2024-09-23 10:36:16 +02:00
joboet
5c1c725724
std: implement the random feature
Implements the ACP https://github.com/rust-lang/libs-team/issues/393.
2024-09-23 10:29:51 +02:00
Jakub Beránek
f7735f99cf
Add rustfmt 2024 reformatting to git blame ignore 2024-09-23 10:02:04 +02:00
bors
a772336fb3 Auto merge of #129047 - DianQK:early_otherwise_branch_scalar, r=cjgillot
Apply `EarlyOtherwiseBranch` to scalar value

In the future, I'm thinking of hoisting discriminant via GVN so that we only need to write very little code here.

r? `@cjgillot`
2024-09-23 07:22:29 +00:00
bors
702987f75b Auto merge of #130732 - matthiaskrgr:rollup-ke1j314, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #129550 (Add str.as_str() for easy Deref to string slices)
 - #130344 (Handle unsized consts with type `str`  in v0 symbol mangling)
 - #130659 (Support `char::encode_utf16` in const scenarios.)
 - #130705 (No longer mark RTN as incomplete)
 - #130712 (Don't call `ty::Const::normalize` in error reporting)
 - #130713 (Mark `u8::make_ascii_uppercase` and `u8::make_ascii_lowercase` as const.)
 - #130714 (Introduce `structurally_normalize_const`, use it in `rustc_hir_typeck`)
 - #130715 (Replace calls to `ty::Const::{try_}eval` in mir build/pattern analysis)
 - #130723 (Add test for `available_parallelism()`)
 - #130726 (tests: Remove spuriously failing vec-tryinto-array codegen test)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-23 04:56:10 +00:00
Matthias Krüger
693269b2be
Rollup merge of #130726 - workingjubilee:put-the-spurs-to-this-test, r=BoxyUwU
tests: Remove spuriously failing vec-tryinto-array codegen test

This has failed more than a couple of times now. It costs real time, money, and energy to deal with this, far more than this test is saving us.
2024-09-23 06:45:37 +02:00
Matthias Krüger
004213b77d
Rollup merge of #130723 - D0liphin:master, r=workingjubilee
Add test for `available_parallelism()`

This is a redo of [this PR](https://github.com/rust-lang/rust/pull/104095).

I changed the location of the test as per comments in the original thread. Otherwise the test is practically the same.

try-job: test-various
2024-09-23 06:45:37 +02:00
Matthias Krüger
0e08d7002b
Rollup merge of #130715 - compiler-errors:mir-build-const-eval, r=BoxyUwU
Replace calls to `ty::Const::{try_}eval` in mir build/pattern analysis

We normalize consts in writeback: #130645. This means that consts are gonna be as normalized as they're ever gonna get in MIR building and pattern analysis. Therefore we can just use `try_to_target_usize` rather than calling `eval_target_usize`.

Regarding the `.expect` calls, I'm not totally certain whether they're correct given rigid unevaluated consts. But this PR shouldn't make *more* ICEs occur; we may have to squash these ICEs when mGCE comes around, tho 😺
2024-09-23 06:45:36 +02:00
Matthias Krüger
2bca5c4fc1
Rollup merge of #130714 - compiler-errors:try-structurally-resolve-const, r=BoxyUwU
Introduce `structurally_normalize_const`, use it in `rustc_hir_typeck`

Introduces `structurally_normalize_const` to typecking to separate the "eval a const" step from the "try to turn a valtree into a target usize" in HIR typeck, where we may still have infer vars and stuff around.

I also changed `check_expr_repeat` to move a double evaluation of a const into a single one. I'll leave inline comments.

r? ```@BoxyUwU```

I hesitated to really test this on the new solver where it probably matters for unevaluated consts. If you're worried about the side-effects, I'd be happy to craft some more tests 😄
2024-09-23 06:45:36 +02:00
Matthias Krüger
8bb69b1861
Rollup merge of #130713 - bjoernager:const-char-make-ascii, r=Noratrieb
Mark `u8::make_ascii_uppercase` and `u8::make_ascii_lowercase` as const.

Relevant tracking issue: #130698

This PR extends #130697 by also marking the `make_ascii_uppercase` and `make_ascii_lowercase` methods in `u8` as const.

The `const_char_make_ascii` feature gate is additionally renamed to `const_make_ascii`.
2024-09-23 06:45:35 +02:00
Matthias Krüger
82060368e6
Rollup merge of #130712 - compiler-errors:const-eval-error-reporting, r=BoxyUwU
Don't call `ty::Const::normalize` in error reporting

We do this to ensure that trait refs with unevaluated consts have those consts simplified to their evaluated forms. Instead, use `try_normalize_erasing_regions`.

**NOTE:** This has the side-effect of erasing regions from all of our trait refs. If this is too much to review or you think it's too opinionated of a diagnostics change, then I could split out the effective change (i.e. erasing regions from this impl suggestion) into another PR and have someone else review it.
2024-09-23 06:45:34 +02:00
Matthias Krüger
9f5cbfb455
Rollup merge of #130705 - compiler-errors:rtn-complete, r=jackh726
No longer mark RTN as incomplete

The RFC is accepted and the feature is basically fully implemented. This doesn't mean it's necesarily *ready* for stabiliation; there's probably some diagnostic improvements to be made, and as always, users uncover the most creative bugs.

But marking this feature as incomplete no longer serves any purpose, so let's fix that.
2024-09-23 06:45:34 +02:00
Matthias Krüger
c1ccdb7d0c
Rollup merge of #130659 - bjoernager:const-char-encode-utf16, r=dtolnay
Support `char::encode_utf16` in const scenarios.

Relevant tracking issue: #130660

The method `char::encode_utf16` should be marked "const" to allow compile-time conversions.

This PR additionally rewrites the `encode_utf16_raw` function for better readability whilst also reducing the amount of unsafe code.

try-job: x86_64-msvc
2024-09-23 06:45:33 +02:00
Matthias Krüger
23393de793
Rollup merge of #130344 - Jaic1:fix-116306, r=BoxyUwU
Handle unsized consts with type `str`  in v0 symbol mangling

This PR fixes #116303 by handling consts with type `str` in v0 symbol mangling as partial support for unsized consts.

This PR is related to `#![feature(adt_const_params)]` (#95174) and `#![feature(unsized_const_params)]` (#128028).

r? ``@BoxyUwU``
2024-09-23 06:45:33 +02:00
Matthias Krüger
510fc3432e
Rollup merge of #129550 - kornelski:boxasstr, r=joshtriplett,dtolnay
Add str.as_str() for easy Deref to string slices

Working with `Box<str>` is cumbersome, because in places like `iter.filter()` it can end up being `&Box<str>` or even `&&Box<str>`, and such type doesn't always get auto-dereferenced as expected.

Dereferencing such box to `&str` requires ugly syntax like `&**boxed_str` or `&***boxed_str`, with the exact amount of `*`s.

`Box<str>` is [not easily comparable with other string types](https://github.com/rust-lang/rust/pull/129852) via `PartialEq`. `Box<str>` won't work for lookups in types like `HashSet<String>`, because `Borrow<String>` won't take types like `&Box<str>`. OTOH `set.contains(s.as_str())` works nicely regardless of levels of indirection.

`String` has a simple solution for this: the `as_str()` method, and `Box<str>` should too.
2024-09-23 06:45:32 +02:00
bors
66b0b29e65 Auto merge of #130724 - compiler-errors:bump, r=Mark-Simulacrum
Bump stage0 to beta-2024-09-22 and rustfmt to nightly-2024-09-22

I'm doing this to apply the changes to version sorting (https://github.com/rust-lang/rustfmt/pull/6284) that have occurred since rustfmt last upgraded (and a few other miscellaneous changes, like changes to expression overflowing: https://github.com/rust-lang/rustfmt/pull/6260). Eagerly updating rustfmt and formatting-the-world will ideally move some of the pressure off of the beta bump which will happen at the beginning of the next release cycle.

You can verify this is correct by checking out the changes, reverting the last commit, reapplying them, and diffing the changes:

```
git fetch git@github.com:compiler-errors/rust.git bump
git checkout -b bump FETCH_HEAD
git reset --hard HEAD~5
./x.py fmt --all
git diff FETCH_HEAD
# ignore the changes to stage0, and rustfmt.toml,
# and test file changes in rustdoc-js-std, run-make.
```

Or just take my word for it? Up to the reviewer.

r? release
2024-09-23 02:02:22 +00:00
Michael Goulet
9132770c8f Fix hard-coded stderr in run-make test 2024-09-22 21:56:38 -04:00
Michael Goulet
3be34a8b53 Bless rustdoc-js-std test 2024-09-22 20:35:10 -04:00
Jubilee Young
ff3a9f4e2a tests: Remove spuriously failing vec-tryinto-array codegen test 2024-09-22 16:46:10 -07:00
Nicholas Nethercote
73cc575177 Fix break_last_token.
It currently doesn't handle the three-char tokens `>>=` and `<<=`
correctly. These can be broken twice, resulting in three individual
tokens. This is a latent bug that currently doesn't cause any problems,
but does cause problems for #124141, because that PR increases the usage
of lazy token streams.
2024-09-23 09:14:30 +10:00
bors
d14c1c75ab Auto merge of #130680 - saethlin:module-name-to-str, r=jieyouxu
Call module_name_to_str instead of just unwrapping

This makes the ICE message in https://github.com/rust-lang/rust/issues/130678 more clear. It looks like not calling this function was just an oversight in https://github.com/rust-lang/rust/pull/76859, but clearly not a major one because it's taken us 4 years to notice.

try-job: i686-msvc
2024-09-22 23:14:12 +00:00
Michael Goulet
02b0f3b5ab Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
Michael Goulet
1173204b36 Use style_edition over version 2024-09-22 19:11:28 -04:00
Michael Goulet
624bc65665 Bump stage0 2024-09-22 19:04:19 -04:00
Oli Iliffe
e9b0bc9432 Add test for available_parallelism()
This is a redo of (this PR)[https://github.com/rust-lang/rust/pull/104095].

Add test for available_parallelism

Add test for available_parallelism

Add test for

Add test for
2024-09-22 23:46:08 +01:00
Pavel Grigorenko
8d2809957e Add more test cases for block-no-opening-brace 2024-09-22 23:29:25 +03:00
bors
6c6d210089 Auto merge of #130710 - GuillaumeGomez:rollup-mfuha68, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #130658 (Fix docs of compare_bytes)
 - #130670 (delay uncapping the max_read_size in File::read_to_end)
 - #130690 (interpret: remove outdated FIXME)
 - #130692 (make unstable Result::flatten a const fn)
 - #130702 (Add some missing unstable book tracking issue links)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-22 19:41:01 +00:00
Michael Goulet
2273aeed9d Replace calls to Const::eval in mir build 2024-09-22 14:12:37 -04:00
bjorn3
ab7777f982 Fix rustc test suite 2024-09-22 18:10:08 +00:00
Michael Goulet
01d19d7be9 Don't call try_eval_target_usize in error reporting 2024-09-22 13:55:06 -04:00
Michael Goulet
8f579497f7 Don't call const normalize in error reporting 2024-09-22 13:55:06 -04:00
Gabriel Bjørnager Jensen
2daf076fd8 Mark 'make_ascii_uppercase' and 'make_ascii_lowercase' in 'u8' as const; Rename 'const_char_make_ascii' feature gate to 'const_make_ascii'; 2024-09-22 19:54:35 +02:00
Michael Goulet
3b8089a320 Introduce structurally_normalize_const, use it in hir_typeck 2024-09-22 13:54:16 -04:00
bjorn3
27b21af624 Rustup to rustc 1.83.0-nightly (1d68e6dd1 2024-09-21) 2024-09-22 17:35:29 +00:00
Guillaume Gomez
a34e0f5600
Rollup merge of #130702 - clubby789:unstable-book-docs, r=ehuss
Add some missing unstable book tracking issue links
2024-09-22 19:19:16 +02:00
Guillaume Gomez
c43a9ea146
Rollup merge of #130692 - RalfJung:result-flatten, r=Noratrieb
make unstable Result::flatten a const fn

This method is still unstable (tracked at https://github.com/rust-lang/rust/issues/70142), but there's no reason I can see for it not to be const -- after all, `Option::flatten` is const. So let's make the `Result` one `const` as well, under the same feature gate.

Cc https://github.com/rust-lang/rust/issues/70142
2024-09-22 19:19:16 +02:00
Guillaume Gomez
f40efa44ab
Rollup merge of #130690 - RalfJung:interpret-abi-compat-fixme, r=jieyouxu
interpret: remove outdated FIXME

The rule about `repr(C)` types with compatible fields got removed from the ABI compat docs before they landed, so this FIXME here is no longer correct. (So this is basically a follow-up to https://github.com/rust-lang/rust/pull/130185, doing some more cleanup around deciding not to guarantee ABI compatibility for structurally compatible `repr(C)` types.)
2024-09-22 19:19:15 +02:00
Guillaume Gomez
82b4177395
Rollup merge of #130670 - the8472:read-to-end-heuristics, r=ChrisDenton
delay uncapping the max_read_size in File::read_to_end

In https://github.com/rust-lang/rust/issues/130600#issuecomment-2365136985 I realized that we're likely still passing too-large buffers to the OS, at least once at the end.

Previous issues and PRs:
* #110650
* #110655
* #118222

r? ChrisDenton
2024-09-22 19:19:15 +02:00
Guillaume Gomez
cbf23960ea
Rollup merge of #130658 - EqualMa:patch-1, r=scottmcm
Fix docs of compare_bytes

The docs of `compare_bytes`. The return value is positive if <del>`right`</del> `left` is greater
2024-09-22 19:19:14 +02:00
bors
8ed95d1d9e Auto merge of #130709 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2024-09-22 17:17:11 +00:00
bjorn3
1d53572570 Sync from rust 1d68e6dd1d 2024-09-22 17:14:10 +00:00
bors
599b3295f5 Auto merge of #3852 - tiif:rwrefactor, r=RalfJung
Refactor fd read/write

This PR passed the responsibility of reading to user supplied buffer and dest place to each implementation of ``FileDescription::read/write/pread/pwrite``.

This is part of #3665.
2024-09-22 14:54:30 +00:00
Ralf Jung
d70fd882ef simplify eventfd handling a bit 2024-09-22 16:50:38 +02:00
Ralf Jung
ed24426824 remove some unnecessary to_owned 2024-09-22 16:50:38 +02:00
Ralf Jung
5dee646aea read, write: move cast-to-usize logic up and deduplicate it 2024-09-22 16:50:37 +02:00
Ralf Jung
fb1193078d further tweak FileDescription comments 2024-09-22 16:50:37 +02:00
tiif
d29be1f90a Pass pointer and len to FileDescription::write and change the type of len in read to usize 2024-09-22 16:50:36 +02:00
tiif
503b6af065 Use &[u8] instead of Vec<u8> and improve docs 2024-09-22 16:50:17 +02:00
Michael Goulet
95469dc09a No longer mark RTN as incomplete 2024-09-22 10:46:59 -04:00
clubby789
0510f06ad7 Add some missing tracking issue links 2024-09-22 14:03:48 +00:00
bors
0af7f0f4c4 Auto merge of #130697 - bjoernager:const-char-make-ascii, r=dtolnay
Mark `char::make_ascii_uppercase` and `char::make_ascii_lowercase` as const.

Relevant tracking issue: #130698

The `make_ascii_uppercase` and `make_ascii_lowercase` methods in `char` should be marked "const."

With the stabilisation of [`const_mut_refs`](https://github.com/rust-lang/rust/issues/57349/), this simply requires adding the `const` specifier to the function signatures.
2024-09-22 13:55:07 +00:00
nora
f5686e3cc9
Write return value for ptr_mask intrinsic (#1536)
This was forgotten. Without it, ptr_mask just always returns null.
2024-09-22 15:46:44 +02:00
Gabriel Bjørnager Jensen
be9b3b459a Mark 'make_ascii_uppercase' and 'make_ascii_lowercase' in 'char' as const; 2024-09-22 14:26:29 +02:00
bors
8243a8ca93 Auto merge of #3903 - RalfJung:auto-prs, r=RalfJung
try to give the CI job permission to create PRs

See the discussion [here](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/did.20github.20token.20permissions.20change.3F).

`@rust-lang/infra` just a heads-up that we are doing this -- I have no idea if this could cause any issues elsewhere, or if it is important that we limit the permissions here somehow, or so.
2024-09-22 10:53:45 +00:00
Ralf Jung
2859f2bafc try to give the CI job permission to create PRs 2024-09-22 12:51:11 +02:00
bors
4ae36d906f Auto merge of #130689 - RalfJung:rustc_nonnull_optimization_guaranteed, r=jieyouxu
fix rustc_nonnull_optimization_guaranteed docs

As far as I can tell, even back when this was [added](https://github.com/rust-lang/rust/pull/60300) it never *enabled* any optimizations. It just indicates that the FFI compat lint should accept those types for NPO.
2024-09-22 10:18:59 +00:00
Ralf Jung
8103505a4d fix rustc_nonnull_optimization_guaranteed docs 2024-09-22 10:00:24 +02:00
bors
80aa6fa731 Auto merge of #130688 - workingjubilee:rollup-ovre6p7, r=workingjubilee
Rollup of 5 pull requests

Successful merges:

 - #130648 (move enzyme flags from general cargo to rustc-specific cargo)
 - #130650 (Fixup Apple target's description strings)
 - #130664 (Generate line numbers for non-rust code examples as well)
 - #130665 (Prevent Deduplication of `LongRunningWarn`)
 - #130669 (tests: Test that `extern "C" fn` ptrs lint on slices)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-22 07:48:56 +00:00
Ralf Jung
89c3cbafb8 make unstable Result::flatten a const fn 2024-09-22 08:40:25 +02:00
bors
ee20c86282 Auto merge of #3902 - RalfJung:rustup, r=RalfJung
Rustup
2024-09-22 06:31:10 +00:00
Ralf Jung
d877ec2a3e rustfmt: switch over to setting style_edition 2024-09-22 08:29:28 +02:00
Ralf Jung
96cb08d499 Merge from rustc 2024-09-22 08:22:27 +02:00
Ralf Jung
b4c7ce55a7 Preparing for merge from rustc 2024-09-22 08:22:18 +02:00
Ralf Jung
27400ea4ed interpret: remove outdated FIXME 2024-09-22 08:18:30 +02:00
Jubilee
f314db6d6b
Rollup merge of #130669 - workingjubilee:slicing-fnptr-tests-finely, r=compiler-errors
tests: Test that `extern "C" fn` ptrs lint on slices

This seems to have slipped past the `improper_ctypes_definitions` lint at some point. I found similar tests but not one with this exact combination, so test the semi-unique combination.
2024-09-21 22:34:34 -07:00
Jubilee
b0208640c6
Rollup merge of #130665 - veera-sivarajan:fix-118612, r=compiler-errors
Prevent Deduplication of `LongRunningWarn`

Fixes #118612

As mention in the issue, `LongRunningWarn` is meant to be repeated multiple times.

Therefore, this PR stores a unique number in every instance of `LongRunningWarn` so that it's not hashed into the same value and omitted by the deduplication mechanism.
2024-09-21 22:34:34 -07:00
Jubilee
825b22fab2
Rollup merge of #130664 - GuillaumeGomez:generate-line-numbers-on-non-rust, r=notriddle
Generate line numbers for non-rust code examples as well

Currently, the "enable line numbers" setting only generated it for rust code examples. Found this limitation a bit strange so I decided to remove it.

You can test it [here](https://rustdoc.crud.net/imperio/generate-line-number-non-rust/doc/lib2/sub_mod/struct.Foo.html).

r? ``@notriddle``
2024-09-21 22:34:33 -07:00
Jubilee
2875d6f98e
Rollup merge of #130650 - BlackHoleFox:apple-target-desc-consistency, r=jieyouxu
Fixup Apple target's description strings

Noticed this inconsistency in how the Apple target's had their new descriptions written while looking at https://github.com/rust-lang/rust/pull/130614, and figured it was easy enough to fixup shortly. I think prefixing every OS with `Apple` is clearer, especially for less known ones like `visionOS` and `watchOS`; so that's what was done here along with making the architecture names more consistent and then some other small tweaks.

~~r​? `@thomcc~~`

cc `@madsmtm`
2024-09-21 22:34:32 -07:00
Jubilee
959f33ac85
Rollup merge of #130648 - onur-ozkan:enzyme-linking, r=Kobzol
move enzyme flags from general cargo to rustc-specific cargo

Resolves #130637.
2024-09-21 22:34:32 -07:00
bors
1f9a018fa3 Auto merge of #130446 - durin42:llvm-20-fix-CommandLineArgs, r=workingjubilee
rustc_llvm: adapt to flattened CLI args in LLVM

This changed in
llvm/llvm-project@e190d074a0. I decided to stick with more duplication between the ifdef blocks to make the code easier to read for the next two years before we can plausibly drop LLVM 19.

`@rustbot` label: +llvm-main

try-job: x86_64-msvc
2024-09-22 05:26:41 +00:00
bors
6ce376774c Auto merge of #130246 - dianne:issue-97589-fix, r=petrochenkov
rustc_expand: remember module `#[path]`s during expansion

During invocation collection, if a module item parsed from a `#[path]` attribute needed a second pass after parsing, its path wouldn't get added to the file path stack, so cycle detection broke. This checks the `#[path]` in such cases, so that it gets added appropriately. I think it should work identically to the case for external modules that don't need a second pass, but I'm not 100% sure.

Fixes #97589
2024-09-22 02:59:38 +00:00
bors
55043f067d Auto merge of #130337 - BoxyUwU:anon_const_macro_call, r=camelid
Fix anon const def-creation when macros are involved take 2

Fixes #130321

There were two cases that #129137 did not handle correctly:

- Given a const argument `Foo<{ bar!() }>` in which `bar!()` expands to `N`, we would visit the anon const and then visit the `{ bar() }` expression instead of visiting the macro call. This meant that we would build a def for the anon const as `{ bar!() }` is not a trivial const argument as `bar!()` is not a path.
- Given a const argument `Foo<{ bar!() }>` is which `bar!()` expands to `{ qux!() }` in which `qux!()` expands to `N`, it should not be considered a trivial const argument as `{{ N }}` has two pairs of braces.  If we only looked at `qux`'s expansion it would *look* like a trivial const argument even though it is not. We have to track whether we have "unwrapped" a brace already when recursing into the expansions of `bar`/`qux`/any macro

r? `@camelid`
2024-09-22 00:31:03 +00:00
Ben Kimock
6419aeb1ec Call module_name_to_str instead of just unwrapping 2024-09-21 18:42:51 -04:00
Guillaume Gomez
f451a410e3 Add GUI regression test for non-rust code blocks line numbers 2024-09-22 00:18:44 +02:00
Guillaume Gomez
54efd132ae Generate line numbers for non-rust code examples as well 2024-09-22 00:18:44 +02:00
Guillaume Gomez
7c35266552 Strip last backline from non-rust code examples 2024-09-22 00:18:44 +02:00
Boxy
781ec111b7 Handle macro calls in anon const def creation take 2 2024-09-21 22:17:18 +01:00
Jubilee Young
e62b5e64a3 tests: Test that extern "C" fn ptrs lint on slices 2024-09-21 09:51:14 -07:00
The 8472
ca1a2a6457 wait for two short reads before uncapping the max read size
for disk IO:
1st short read = probably at end of file
2nd short read = confirming that it's indeed EOF
2024-09-21 18:50:29 +02:00
BlackHoleFox
114093cdf1 Fixup Apple target's description strings 2024-09-21 10:59:01 -05:00
Veera
669f610f74 Prevent Deduplication of LongRunningWarn 2024-09-21 11:23:34 -04:00
Veera
a35da65409 Update Tests 2024-09-21 11:11:11 -04:00
Folkert de Vries
90300ef40b add C-cmse-nonsecure-entry ABI 2024-09-21 13:04:14 +02:00
Gabriel Bjørnager Jensen
f48c5ec235 Mark and implement 'char::encode_utf16' as const; Rewrite 'encode_utf16_raw'; 2024-09-21 12:53:28 +02:00
EqualMa
d44a5fd00b
Fix docs of compare_bytes 2024-09-21 18:27:49 +08:00
Artyom Tetyukhin
019435b265
Remove x86_64-fuchsia and aarch64-fuchsia target aliases 2024-09-21 13:29:00 +04:00
bors
a3fea24971 Auto merge of #3901 - RalfJung:rustup, r=RalfJung
Rustup

This has a larger large "fmt" diff, probably there was a bug rustfmt update. For some reason the automatic `./miri fmt` on CI failed so this PR had to be created by hand -- it is unclear to me why this occurred.
2024-09-21 07:44:18 +00:00
Ralf Jung
7d9a4a7d3a fmt (with a huge diff for some reason) 2024-09-21 09:40:40 +02:00
Ralf Jung
90854b7670 Merge from rustc 2024-09-21 09:29:53 +02:00
Ralf Jung
c7e6284cf9 Preparing for merge from rustc 2024-09-21 09:29:28 +02:00
onur-ozkan
f23d0b9c9d move enzyme flags from general cargo to rustc-specific cargo
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2024-09-21 07:35:27 +03:00
Michael Goulet
460abead20 Do not unnecessarily eval consts in codegen 2024-09-20 20:38:11 -04:00
Josh Stone
a5b9605cea Update to LLVM 19.1.0 2024-09-20 14:41:36 -07:00
Jaic1
c2ccd89ce4 handle unsized consts with type str in v0 symbol mangling 2024-09-20 09:41:16 +08:00
Turki Al-Marri
753271ce7e
aarch64 neon intrinsics: vmaxq_f32, vminq_f32, vaddvq_f32, vrndnq_f32 (#1533) 2024-09-19 18:11:24 +02:00
Kornel
3dcb5a3962
Add str.as_str() for easy dereferencing of Box<str> 2024-09-19 16:25:56 +01:00
Josh Stone
de4c8975aa bootstrap: Set the dylib path when building books with rustdoc
The library path is needed when the toolchain has been configured with
`[rust] rpath = false`. Otherwise, building the reference book will get
an error when it tries to run rustdoc, like:

    rustdoc: error while loading shared libraries: librustc_driver-2ec457c3b8826b72.so
2024-09-18 15:01:22 -07:00
DianQK
e3a9eaf928
Apply EarlyOtherwiseBranch to scalar value 2024-09-18 21:42:07 +08:00
bors
3d4d5e1c10 Auto merge of #3897 - eduardosm:sse-tests, r=RalfJung
Use `@only-target` in SSE and SSE2 tests too

It looks cleaner and makes it consistent with other X86 tests.

The huge diffs are mostly indentation changes.
2024-09-17 19:04:45 +00:00
Eduardo Sánchez Muñoz
57f6563858 Use @only-target in SSE and SSE2 tests too
It looks cleaner and makes it consistent with other X86 tests
2024-09-17 20:33:30 +02:00
bors
62ccf6a434 Auto merge of #3896 - RalfJung:ptr_offset_unsigned_overflow, r=RalfJung
ptr_offset_unsigned_overflow: extend test

Test that indeed, the signed version works before the unsigned version is UB.
2024-09-17 17:25:43 +00:00
Ralf Jung
4854ca7411 ptr_offset_unsigned_overflow: extend test 2024-09-17 19:24:14 +02:00
Nicholas Nethercote
37204ee563 Use associative type defaults in {Layout,FnAbi}OfHelpers.
This avoids some repetitive boilerplate code.
2024-09-17 10:25:06 +10:00
Augie Fackler
86d67b7933 PassWrapper: clang-format has spoken 2024-09-16 20:06:50 -04:00
Augie Fackler
ad0ecebf43 rustc_llvm: adapt to flattened CLI args in LLVM
This changed in
llvm/llvm-project@e190d074a0. I decided to
stick with more duplication between the ifdef blocks to make the code
easier to read for the next two years before we can plausibly drop LLVM
19.

@rustbot label: +llvm-main
2024-09-16 19:58:05 -04:00
tiif
f392648c15 Refactor FileDescription::read/write 2024-09-17 00:37:16 +08:00
bjorn3
5349365566 Use unconditional download-ci-llvm in setup_rust_fork.sh
For whatever reason someone decided to make the default if-changed
always checkout the llvm-project submodule, which takes a while.
2024-09-15 17:40:12 +00:00
bjorn3
eee42f2679 Fix rustc test suite 2024-09-15 17:34:45 +00:00
bjorn3
16cee899d1 Avoid mir_operand_get_const_val hack for simd_insert and simd_extract 2024-09-15 17:27:12 +00:00
bjorn3
1e960213e8 Add test for _mm_cmpestri 2024-09-15 17:24:43 +00:00
bjorn3
cebdfe40ad Slightly simplify the simd_shuffle impl 2024-09-15 17:07:29 +00:00
bjorn3
c7b49987a6 Fix rustc test suite 2024-09-15 16:59:35 +00:00
bjorn3
61d3b59f58 Rustup to rustc 1.83.0-nightly (9b72238eb 2024-09-14) 2024-09-15 16:49:17 +00:00
bjorn3
ab989ac7cb Sync from rust 9b72238eb8 2024-09-15 16:43:21 +00:00
bjorn3
6fbe4d90b8 Rename remove_dir_if_exists to ensure_empty_dir and create the dir in this function
This avoids removing the directory, which may conflict with sandbox
systems like Landlock.
2024-09-14 17:34:24 +00:00
Ralf Jung
15848f3f08 simd_shuffle: require index argument to be a vector 2024-09-14 14:43:24 +02:00
bjorn3
b7272c236a Remove unnecessary -Zunstable-options 2024-09-13 16:45:11 +00:00
bjorn3
41f6d55398 Refactor command runner handling 2024-09-13 16:38:05 +00:00
bjorn3
652b00430d Remove unnecessary special case 2024-09-13 15:30:56 +00:00
bjorn3
d5e2e23f48 Misc cleanups 2024-09-13 15:17:22 +00:00
bjorn3
bc67321c6d Reduce usage of RelPath in build_sysroot 2024-09-13 14:45:29 +00:00
bjorn3
f204181112 Install git-tiny on Cirrus CI
This avoids pulling in perl.
2024-09-12 19:55:06 +00:00
bjorn3
4e38767320 Use plain sh for y.sh, test.sh and clean_all.sh
FreeBSD by default doesn't install bash.
2024-09-12 19:55:06 +00:00
bjorn3
1aa0cf930a Unconditionally use git to download test repos
It no longer saves much download time while still complicating the code
and requiring curl and tar to be installed.
2024-09-12 19:29:43 +00:00
bjorn3
45be990167 Inline prepare_stdlib into the sysroot build code
Also reduce visibility of a couple of statics
2024-09-12 19:04:11 +00:00
dianne
a187d0a90c add regression test for #97589 2024-09-11 13:29:25 -07:00
bjorn3
ade0e38b5e Fix building rustc and the rustc test suite 2024-09-11 19:41:00 +00:00
dianne
9a7644e171 rustc_expand: remember module #[path]s during expansion
this fixes cycle detection for modules that need a second invocation collection pass after parsing
2024-09-11 12:36:40 -07:00
bjorn3
dcae9acda0 Rustup to rustc 1.83.0-nightly (0ee7cb5e3 2024-09-10) 2024-09-11 19:31:20 +00:00
bjorn3
17bcb2ff46 Sync from rust 0ee7cb5e36 2024-09-11 19:13:40 +00:00
bjorn3
b4d55a8799 Add missing dbghelp link directive for windows 2024-09-11 17:38:03 +00:00
Scott McMurray
fe5183e627 Fix the examples in cg_clif 2024-09-09 19:39:43 -07:00
bors
cf7c0554f1 Auto merge of #128939 - bjorn3:windows_cg_clif_component, r=albertlarsan68
Distribute rustc_codegen_cranelift for Windows

With support for raw-dylib recently added to cg_clif, and inline assembly support working on Windows for quite a while now, all blockers for distributing cg_clif on Windows that I mentioned in https://github.com/rust-lang/rust/pull/81746#issuecomment-1774099637 are fixed now.
2024-09-09 16:09:06 +00:00
bjorn3
b7ed9ad226 Remove test exclusion for fixed rustc test 2024-09-03 11:08:17 +00:00
bjorn3
39defb1c9c Rustup to rustc 1.83.0-nightly (bd53aa3bf 2024-09-02) 2024-09-03 11:01:25 +00:00
bjorn3
c31f7b9785 Sync from rust bd53aa3bf7 2024-09-03 10:53:37 +00:00
Rémy Rakic
0fba9b4dbb introduce PrettyPrintMirOptions for cosmetic MIR dump options
initially starting with `-Z mir-include-spans` because we want them in
the NLL mir dump pass
2024-08-30 07:07:28 +00:00
bjorn3
7e4cafb653 Fix rustc test suite 2024-08-28 12:36:34 +00:00
bjorn3
36c126f94a Rustup to rustc 1.82.0-nightly (1f12b9b0f 2024-08-27) 2024-08-28 10:25:03 +00:00
bjorn3
217b005dd1 Sync from rust 1f12b9b0fd 2024-08-28 10:18:51 +00:00
Trevor Gross
8a26d21ce2 Rollup merge of #128731 - RalfJung:simd-shuffle-vector, r=workingjubilee
simd_shuffle intrinsic: allow argument to be passed as vector

See https://github.com/rust-lang/rust/issues/128738 for context.

I'd like to get rid of [this hack](6c0b89dfac/compiler/rustc_codegen_ssa/src/mir/block.rs (L922-L935)). https://github.com/rust-lang/rust/pull/128537 almost lets us do that since constant SIMD vectors will then be passed as immediate arguments. However, simd_shuffle for some reason actually takes an *array* as argument, not a vector, so the hack is still required to ensure that the array becomes an immediate (which then later stages of codegen convert into a vector, as that's what LLVM needs).

This PR prepares simd_shuffle to also support a vector as the `idx` argument. Once this lands, stdarch can hopefully be updated to pass `idx` as a vector, and then support for arrays can be removed, which finally lets us get rid of that hack.
2024-08-27 01:46:50 -05:00
bjorn3
19757ecb9d Update Cranelift to 0.111 2024-08-22 19:39:43 +00:00
bjorn3
87e74fe80b Rustup to rustc 1.82.0-nightly (a32d4a0e8 2024-08-21) 2024-08-22 19:24:47 +00:00
bjorn3
46b7db19ae Sync from rust a32d4a0e82 2024-08-22 11:08:13 +00:00
bjorn3
01f873990a Rustup to rustc 1.82.0-nightly (6de928dce 2024-08-18) 2024-08-19 17:21:56 +00:00
bjorn3
c1e7b0068d Sync from rust 6de928dce9 2024-08-19 17:15:21 +00:00
Ralf Jung
8e7b3b5c2b rename AddressOf -> RawBorrow inside the compiler 2024-08-18 19:46:53 +02:00
Ralf Jung
f1fadb8ba2 stabilize raw_ref_op 2024-08-18 19:46:53 +02:00
Chris Denton
d7198a541d Always use ar_archive_writer for import libs 2024-08-17 19:10:46 +00:00
bjorn3
69cec6faea Rustup to rustc 1.82.0-nightly (13a52890d 2024-08-14) 2024-08-15 17:53:20 +00:00
bjorn3
c7d43c333a Sync from rust 13a52890dd 2024-08-15 17:46:33 +00:00
bors
e2acda7447 Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errors
Shrink `TyKind::FnPtr`.

By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.

r? `@compiler-errors`
2024-08-14 00:56:53 +00:00
Ralf Jung
6906793db8 simd_shuffle intrinsic: allow argument to be passed as vector (not just as array) 2024-08-13 07:51:17 +02:00
Guillaume Gomez
ef74616e44 Rollup merge of #128149 - RalfJung:nontemporal_store, r=jieyouxu,Amanieu,Jubilee
nontemporal_store: make sure that the intrinsic is truly just a hint

The `!nontemporal` flag for stores in LLVM *sounds* like it is just a hint, but actually, it is not -- at least on x86, non-temporal stores need very special treatment by the programmer or else the Rust memory model breaks down. LLVM still treats these stores as-if they were normal stores for optimizations, which is [highly dubious](https://github.com/llvm/llvm-project/issues/64521). Let's avoid all that dubiousness by making our own non-temporal stores be truly just a hint, which is possible on some targets (e.g. ARM). On all other targets, non-temporal stores become regular stores.

~~Blocked on https://github.com/rust-lang/stdarch/pull/1541 propagating to the rustc repo, to make sure the `_mm_stream` intrinsics are unaffected by this change.~~

Fixes https://github.com/rust-lang/rust/issues/114582
Cc `@Amanieu` `@workingjubilee`
2024-08-12 17:09:14 +02:00
bjorn3
b4e46de5f3 Fix clif ir text format emission 2024-08-11 20:21:39 +00:00
bjorn3
918e11d14d Fix clean_all.sh 2024-08-11 11:52:23 +00:00
bjorn3
fabb29821a Rustup to rustc 1.82.0-nightly (730d5d409 2024-08-10) 2024-08-11 11:52:08 +00:00
bjorn3
65369af4df Sync from rust 730d5d4095 2024-08-11 11:44:15 +00:00
bjorn3
060811a602 Distribute rustc_codegen_cranelift for Windows 2024-08-10 21:16:44 +00:00
bjorn3
ab1da46e45 Fix source path for portable-simd
To avoid overriding the source for coretests every time.
2024-08-10 16:33:36 +00:00
bjorn3
aa918f02e4 Stop ignoring some portable-simd tests 2024-08-10 16:31:22 +00:00
bjorn3
52aa24ed4a Move cleaning of y.bin to the "to be removed" section in clean_all.sh 2024-08-10 15:29:17 +00:00
bjorn3
e55c630133 Add back bench job dependency for the release job 2024-08-10 15:20:58 +00:00
bjorn3
a33f731df7 Couple of minor build system changes 2024-08-10 15:18:04 +00:00
bjorn3
1b9645853a Remove --debug argument of y.sh
I rarely need a debug build of cg_clif, and even if I actually need one,
using package overrides in Cargo.toml to only do a debug build for the
rustc_codegen_cranelift crate works much better.
2024-08-10 14:16:53 +00:00
Nadrieril
3de829e4e5 Fixes in various places 2024-08-10 12:08:46 +02:00
bjorn3
bb6571fd63 Rustup to rustc 1.82.0-nightly (ca5d25e2c 2024-08-09) 2024-08-10 06:53:16 +00:00
bjorn3
aec3786ead Apply missed change from subtree sync 2024-08-09 17:34:52 +00:00
bjorn3
78abc36ac0 Merge branch 'sync_from_rust' 2024-08-09 17:33:55 +00:00
bjorn3
0174cb1932 Use ar_archive_writer from sysroot for cg_clif 2024-08-09 17:23:50 +00:00
bjorn3
3ea9313de3 Merge commit '69b3f5a426a5c1c05236a45b36f6679d95fbe01b' into sync_cg_clif-2024-08-09 2024-08-09 17:18:46 +00:00
Nicholas Nethercote
b8b3a9328f Shrink TyKind::FnPtr.
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and
`FnHeader`, which can be packed more efficiently. This reduces the size
of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms.
This reduces peak memory usage by a few percent on some benchmarks. It
also reduces cache misses and page faults similarly, though this doesn't
translate to clear cycles or wall-time improvements on CI.
2024-08-09 14:33:25 +10:00
Michael Goulet
e96ece7c0b Rename struct_tail_erasing_lifetimes to struct_tail_for_codegen 2024-08-08 12:15:16 -04:00
Ralf Jung
80a7d5f61d nontemporal_store: make sure that the intrinsic is truly just a hint 2024-08-05 10:57:14 +02:00
1817 changed files with 13791 additions and 13933 deletions

View File

@ -27,3 +27,5 @@ ec2cc761bc7067712ecc7734502f703fe3b024c8
84ac80f1921afc243d71fd0caaa4f2838c294102
# bless mir-opt tests to add `copy`
99cb0c6bc399fb94a0ddde7e9b38e9c00d523bad
# reformat with rustfmt edition 2024
c682aa162b0d41e21cc6748f4fecfe01efb69d1f

2
.gitmodules vendored
View File

@ -33,7 +33,7 @@
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
branch = rustc/19.1-2024-07-30
branch = rustc/19.1-2024-09-17
shallow = true
[submodule "src/doc/embedded-book"]
path = src/doc/embedded-book

View File

@ -999,8 +999,8 @@ fn univariant_biased<
if repr.can_randomize_type_layout() && cfg!(feature = "randomize") {
#[cfg(feature = "randomize")]
{
use rand::seq::SliceRandom;
use rand::SeedableRng;
use rand::seq::SliceRandom;
// `ReprOptions.field_shuffle_seed` is a deterministic seed we can use to randomize field
// ordering.
let mut rng =

View File

@ -1138,13 +1138,10 @@ impl Scalar {
#[inline]
pub fn is_bool(&self) -> bool {
use Integer::*;
matches!(
self,
Scalar::Initialized {
value: Primitive::Int(I8, false),
valid_range: WrappingRange { start: 0, end: 1 }
}
)
matches!(self, Scalar::Initialized {
value: Primitive::Int(I8, false),
valid_range: WrappingRange { start: 0, end: 1 }
})
}
/// Get the primitive representation of this type, ignoring the valid range and whether the

View File

@ -21,19 +21,19 @@
use std::borrow::Cow;
use std::{cmp, fmt, mem};
pub use GenericArgs::*;
pub use UnsafeSource::*;
pub use rustc_ast_ir::{Movability, Mutability};
use rustc_data_structures::packed::Pu128;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::Lrc;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::source_map::{respan, Spanned};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
pub use rustc_span::AttrId;
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
use thin_vec::{thin_vec, ThinVec};
pub use GenericArgs::*;
pub use UnsafeSource::*;
use rustc_span::source_map::{Spanned, respan};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
use thin_vec::{ThinVec, thin_vec};
pub use crate::format::*;
use crate::ptr::P;
@ -288,7 +288,7 @@ pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs {
}
}
pub use crate::node_id::{NodeId, CRATE_NODE_ID, DUMMY_NODE_ID};
pub use crate::node_id::{CRATE_NODE_ID, DUMMY_NODE_ID, NodeId};
/// Modifiers on a trait bound like `~const`, `?` and `!`.
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
@ -1187,8 +1187,8 @@ impl Expr {
/// `min_const_generics` as more complex expressions are not supported.
///
/// Does not ensure that the path resolves to a const param, the caller should check this.
pub fn is_potential_trivial_const_arg(&self) -> bool {
let this = self.maybe_unwrap_block();
pub fn is_potential_trivial_const_arg(&self, strip_identity_block: bool) -> bool {
let this = if strip_identity_block { self.maybe_unwrap_block().1 } else { self };
if let ExprKind::Path(None, path) = &this.kind
&& path.is_potential_trivial_const_arg()
@ -1199,14 +1199,15 @@ pub fn is_potential_trivial_const_arg(&self) -> bool {
}
}
pub fn maybe_unwrap_block(&self) -> &Expr {
/// Returns an expression with (when possible) *one* outter brace removed
pub fn maybe_unwrap_block(&self) -> (bool, &Expr) {
if let ExprKind::Block(block, None) = &self.kind
&& let [stmt] = block.stmts.as_slice()
&& let StmtKind::Expr(expr) = &stmt.kind
{
expr
(true, expr)
} else {
self
(false, self)
}
}

View File

@ -4,15 +4,15 @@
use std::sync::atomic::{AtomicU32, Ordering};
use rustc_index::bit_set::GrowableBitSet;
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use smallvec::{smallvec, SmallVec};
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Ident, Symbol, sym};
use smallvec::{SmallVec, smallvec};
use thin_vec::{ThinVec, thin_vec};
use crate::ast::{
AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, DelimArgs,
Expr, ExprKind, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NormalAttr, Path,
PathSegment, Safety, DUMMY_NODE_ID,
AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, DUMMY_NODE_ID,
DelimArgs, Expr, ExprKind, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem,
NormalAttr, Path, PathSegment, Safety,
};
use crate::ptr::P;
use crate::token::{self, CommentKind, Delimiter, Token};

View File

@ -1,7 +1,7 @@
use rustc_span::symbol::sym;
use rustc_span::Symbol;
use rustc_span::symbol::sym;
use crate::{attr, Attribute};
use crate::{Attribute, attr};
#[derive(Debug)]
pub enum EntryPointType {

View File

@ -1,5 +1,5 @@
use rustc_macros::HashStable_Generic;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::symbol::{Symbol, sym};
#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable_Generic)]
pub enum AllocatorKind {

View File

@ -1,10 +1,10 @@
use rustc_data_structures::fx::FxHashMap;
use rustc_macros::{Decodable, Encodable};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::Span;
use rustc_span::symbol::{Ident, Symbol};
use crate::ptr::P;
use crate::Expr;
use crate::ptr::P;
// Definitions:
//

View File

@ -13,10 +13,10 @@
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_data_structures::sync::Lrc;
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Ident;
use rustc_span::Span;
use smallvec::{smallvec, Array, SmallVec};
use smallvec::{Array, SmallVec, smallvec};
use thin_vec::ThinVec;
use crate::ast::*;

View File

@ -1,21 +1,21 @@
use std::borrow::Cow;
use std::fmt;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::edition::Edition;
use rustc_span::symbol::{kw, sym};
#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint.
#[allow(hidden_glob_reexports)]
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
pub use BinOpToken::*;
pub use LitKind::*;
pub use Nonterminal::*;
pub use NtExprKind::*;
pub use NtPatKind::*;
pub use TokenKind::*;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_data_structures::sync::Lrc;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_span::edition::Edition;
#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint.
#[allow(hidden_glob_reexports)]
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::symbol::{kw, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
use crate::ast;
use crate::ptr::P;
@ -385,35 +385,41 @@ pub fn lit(kind: LitKind, symbol: Symbol, suffix: Option<Symbol>) -> TokenKind {
Literal(Lit::new(kind, symbol, suffix))
}
/// An approximation to proc-macro-style single-character operators used by rustc parser.
/// If the operator token can be broken into two tokens, the first of which is single-character,
/// then this function performs that operation, otherwise it returns `None`.
pub fn break_two_token_op(&self) -> Option<(TokenKind, TokenKind)> {
Some(match *self {
Le => (Lt, Eq),
EqEq => (Eq, Eq),
Ne => (Not, Eq),
Ge => (Gt, Eq),
AndAnd => (BinOp(And), BinOp(And)),
OrOr => (BinOp(Or), BinOp(Or)),
BinOp(Shl) => (Lt, Lt),
BinOp(Shr) => (Gt, Gt),
BinOpEq(Plus) => (BinOp(Plus), Eq),
BinOpEq(Minus) => (BinOp(Minus), Eq),
BinOpEq(Star) => (BinOp(Star), Eq),
BinOpEq(Slash) => (BinOp(Slash), Eq),
BinOpEq(Percent) => (BinOp(Percent), Eq),
BinOpEq(Caret) => (BinOp(Caret), Eq),
BinOpEq(And) => (BinOp(And), Eq),
BinOpEq(Or) => (BinOp(Or), Eq),
BinOpEq(Shl) => (Lt, Le),
BinOpEq(Shr) => (Gt, Ge),
DotDot => (Dot, Dot),
DotDotDot => (Dot, DotDot),
PathSep => (Colon, Colon),
RArrow => (BinOp(Minus), Gt),
LArrow => (Lt, BinOp(Minus)),
FatArrow => (Eq, Gt),
/// An approximation to proc-macro-style single-character operators used by
/// rustc parser. If the operator token can be broken into two tokens, the
/// first of which has `n` (1 or 2) chars, then this function performs that
/// operation, otherwise it returns `None`.
pub fn break_two_token_op(&self, n: u32) -> Option<(TokenKind, TokenKind)> {
assert!(n == 1 || n == 2);
Some(match (self, n) {
(Le, 1) => (Lt, Eq),
(EqEq, 1) => (Eq, Eq),
(Ne, 1) => (Not, Eq),
(Ge, 1) => (Gt, Eq),
(AndAnd, 1) => (BinOp(And), BinOp(And)),
(OrOr, 1) => (BinOp(Or), BinOp(Or)),
(BinOp(Shl), 1) => (Lt, Lt),
(BinOp(Shr), 1) => (Gt, Gt),
(BinOpEq(Plus), 1) => (BinOp(Plus), Eq),
(BinOpEq(Minus), 1) => (BinOp(Minus), Eq),
(BinOpEq(Star), 1) => (BinOp(Star), Eq),
(BinOpEq(Slash), 1) => (BinOp(Slash), Eq),
(BinOpEq(Percent), 1) => (BinOp(Percent), Eq),
(BinOpEq(Caret), 1) => (BinOp(Caret), Eq),
(BinOpEq(And), 1) => (BinOp(And), Eq),
(BinOpEq(Or), 1) => (BinOp(Or), Eq),
(BinOpEq(Shl), 1) => (Lt, Le), // `<` + `<=`
(BinOpEq(Shl), 2) => (BinOp(Shl), Eq), // `<<` + `=`
(BinOpEq(Shr), 1) => (Gt, Ge), // `>` + `>=`
(BinOpEq(Shr), 2) => (BinOp(Shr), Eq), // `>>` + `=`
(DotDot, 1) => (Dot, Dot),
(DotDotDot, 1) => (Dot, DotDot), // `.` + `..`
(DotDotDot, 2) => (DotDot, Dot), // `..` + `.`
(DotDotEq, 2) => (DotDot, Eq),
(PathSep, 1) => (Colon, Colon),
(RArrow, 1) => (BinOp(Minus), Gt),
(LArrow, 1) => (Lt, BinOp(Minus)),
(FatArrow, 1) => (Eq, Gt),
_ => return None,
})
}

View File

@ -20,7 +20,7 @@
use rustc_data_structures::sync::{self, Lrc};
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_serialize::{Decodable, Encodable};
use rustc_span::{sym, Span, SpanDecoder, SpanEncoder, Symbol, DUMMY_SP};
use rustc_span::{DUMMY_SP, Span, SpanDecoder, SpanEncoder, Symbol, sym};
use crate::ast::{AttrStyle, StmtKind};
use crate::ast_traits::{HasAttrs, HasTokens};

View File

@ -3,10 +3,10 @@
use std::{ascii, fmt, str};
use rustc_lexer::unescape::{
byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode, MixedUnit, Mode,
MixedUnit, Mode, byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode,
};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::Span;
use rustc_span::symbol::{Symbol, kw, sym};
use tracing::debug;
use crate::ast::{self, LitKind, MetaItemLit, StrStyle};

View File

@ -15,8 +15,8 @@
pub use rustc_ast_ir::visit::VisitorResult;
pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list};
use rustc_span::symbol::Ident;
use rustc_span::Span;
use rustc_span::symbol::Ident;
use crate::ast::*;
use crate::ptr::P;

View File

@ -8,9 +8,10 @@
use rustc_hir::def::{DefKind, Res};
use rustc_session::parse::feature_err;
use rustc_span::symbol::kw;
use rustc_span::{sym, Span};
use rustc_span::{Span, sym};
use rustc_target::asm;
use super::LoweringContext;
use super::errors::{
AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported,
InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst,
@ -18,10 +19,9 @@
InvalidAsmTemplateModifierRegClassSub, InvalidAsmTemplateModifierSym, InvalidRegister,
InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict,
};
use super::LoweringContext;
use crate::{
fluent_generated as fluent, AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition,
ParamMode, ResolverAstLoweringExt,
AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, ParamMode,
ResolverAstLoweringExt, fluent_generated as fluent,
};
impl<'a, 'hir> LoweringContext<'a, 'hir> {
@ -221,7 +221,7 @@ pub(crate) fn lower_inline_asm(
let parent_def_id = self.current_def_id_parent;
let node_id = self.next_node_id();
// HACK(min_generic_const_args): see lower_anon_const
if !expr.is_potential_trivial_const_arg() {
if !expr.is_potential_trivial_const_arg(true) {
self.create_def(
parent_def_id,
node_id,

View File

@ -46,8 +46,8 @@
use rustc_hir::def_id::DefId;
use rustc_middle::span_bug;
use rustc_middle::ty::{Asyncness, ResolverAstLowering};
use rustc_span::symbol::Ident;
use rustc_span::Span;
use rustc_span::symbol::Ident;
use rustc_target::spec::abi;
use {rustc_ast as ast, rustc_hir as hir};

View File

@ -4,14 +4,14 @@
use rustc_ast::*;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::HirId;
use rustc_hir::def::{DefKind, Res};
use rustc_middle::span_bug;
use rustc_session::errors::report_lit_error;
use rustc_span::source_map::{respan, Spanned};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{DesugaringKind, Span, DUMMY_SP};
use thin_vec::{thin_vec, ThinVec};
use rustc_span::source_map::{Spanned, respan};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, DesugaringKind, Span};
use thin_vec::{ThinVec, thin_vec};
use super::errors::{
AsyncCoroutinesNotSupported, AwaitOnlyInAsyncFnAndBlocks, BaseExpressionDoubleDot,
@ -23,7 +23,7 @@
GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode, ResolverAstLoweringExt,
};
use crate::errors::YieldInClosure;
use crate::{fluent_generated, AllowReturnTypeNotation, FnDeclKind, ImplTraitPosition};
use crate::{AllowReturnTypeNotation, FnDeclKind, ImplTraitPosition, fluent_generated};
impl<'hir> LoweringContext<'_, 'hir> {
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
@ -389,7 +389,7 @@ fn lower_legacy_const_generics(
let node_id = self.next_node_id();
// HACK(min_generic_const_args): see lower_anon_const
if !arg.is_potential_trivial_const_arg() {
if !arg.is_potential_trivial_const_arg(true) {
// Add a definition for the in-band const def.
self.create_def(parent_def_id, node_id, kw::Empty, DefKind::AnonConst, f.span);
}
@ -725,18 +725,15 @@ pub(super) fn maybe_forward_track_caller(
span,
Some(self.allow_gen_future.clone()),
);
self.lower_attrs(
inner_hir_id,
&[Attribute {
kind: AttrKind::Normal(ptr::P(NormalAttr::from_ident(Ident::new(
sym::track_caller,
span,
)))),
id: self.tcx.sess.psess.attr_id_generator.mk_attr_id(),
style: AttrStyle::Outer,
span: unstable_span,
}],
);
self.lower_attrs(inner_hir_id, &[Attribute {
kind: AttrKind::Normal(ptr::P(NormalAttr::from_ident(Ident::new(
sym::track_caller,
span,
)))),
id: self.tcx.sess.psess.attr_id_generator.mk_attr_id(),
style: AttrStyle::Outer,
span: unstable_span,
}]);
}
}

View File

@ -6,8 +6,8 @@
use rustc_data_structures::fx::FxIndexMap;
use rustc_hir as hir;
use rustc_session::config::FmtDebug;
use rustc_span::symbol::{kw, Ident};
use rustc_span::{sym, Span, Symbol};
use rustc_span::symbol::{Ident, kw};
use rustc_span::{Span, Symbol, sym};
use super::LoweringContext;
@ -363,16 +363,13 @@ fn make_format_spec<'hir>(
debug_hex,
} = &placeholder.format_options;
let fill = ctx.expr_char(sp, fill.unwrap_or(' '));
let align = ctx.expr_lang_item_type_relative(
sp,
hir::LangItem::FormatAlignment,
match alignment {
let align =
ctx.expr_lang_item_type_relative(sp, hir::LangItem::FormatAlignment, match alignment {
Some(FormatAlignment::Left) => sym::Left,
Some(FormatAlignment::Right) => sym::Right,
Some(FormatAlignment::Center) => sym::Center,
None => sym::Unknown,
},
);
});
// This needs to match `Flag` in library/core/src/fmt/rt.rs.
let flags: u32 = ((sign == Some(FormatSign::Plus)) as u32)
| ((sign == Some(FormatSign::Minus)) as u32) << 1

View File

@ -6,7 +6,7 @@
use rustc_index::IndexVec;
use rustc_middle::span_bug;
use rustc_middle::ty::TyCtxt;
use rustc_span::{Span, DUMMY_SP};
use rustc_span::{DUMMY_SP, Span};
use tracing::{debug, instrument};
/// A visitor that walks over the HIR and collects `Node`s into a HIR map.

View File

@ -3,17 +3,17 @@
use rustc_ast::*;
use rustc_errors::ErrorGuaranteed;
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
use rustc_hir::PredicateOrigin;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId};
use rustc_index::{IndexSlice, IndexVec};
use rustc_middle::span_bug;
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
use rustc_span::edit_distance::find_best_match_for_name;
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{DesugaringKind, Span, Symbol};
use rustc_target::spec::abi;
use smallvec::{smallvec, SmallVec};
use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec;
use tracing::instrument;
@ -281,16 +281,13 @@ fn lower_item_kind(
);
this.arena.alloc(this.ty(span, hir::TyKind::Err(guar)))
}
Some(ty) => this.lower_ty(
ty,
ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias {
parent: this.local_def_id(id),
in_assoc_ty: false,
},
fn_kind: None,
Some(ty) => this.lower_ty(ty, ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias {
parent: this.local_def_id(id),
in_assoc_ty: false,
},
),
fn_kind: None,
}),
},
);
hir::ItemKind::TyAlias(ty, generics)
@ -981,16 +978,13 @@ fn lower_impl_item(
hir::ImplItemKind::Type(ty)
}
Some(ty) => {
let ty = this.lower_ty(
ty,
ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias {
parent: this.local_def_id(i.id),
in_assoc_ty: true,
},
fn_kind: None,
let ty = this.lower_ty(ty, ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::TyAlias {
parent: this.local_def_id(i.id),
in_assoc_ty: true,
},
);
fn_kind: None,
});
hir::ImplItemKind::Type(ty)
}
},
@ -1129,13 +1123,10 @@ fn lower_block_expr_opt(&mut self, span: Span, block: Option<&Block>) -> hir::Ex
pub(super) fn lower_const_body(&mut self, span: Span, expr: Option<&Expr>) -> hir::BodyId {
self.lower_body(|this| {
(
&[],
match expr {
Some(expr) => this.lower_expr_mut(expr),
None => this.expr_err(span, this.dcx().span_delayed_bug(span, "no block")),
},
)
(&[], match expr {
Some(expr) => this.lower_expr_mut(expr),
None => this.expr_err(span, this.dcx().span_delayed_bug(span, "no block")),
})
})
}
@ -1515,10 +1506,10 @@ fn lower_generics<T>(
for bound in &bound_pred.bounds {
if !matches!(
*bound,
GenericBound::Trait(
_,
TraitBoundModifiers { polarity: BoundPolarity::Maybe(_), .. }
)
GenericBound::Trait(_, TraitBoundModifiers {
polarity: BoundPolarity::Maybe(_),
..
})
) {
continue;
}
@ -1619,16 +1610,13 @@ fn lower_generics<T>(
self.children.push((anon_const_did, hir::MaybeOwner::NonOwner(const_id)));
let const_body = self.lower_body(|this| {
(
&[],
hir::Expr {
hir_id: const_expr_id,
kind: hir::ExprKind::Lit(
this.arena.alloc(hir::Lit { node: LitKind::Bool(true), span }),
),
span,
},
)
(&[], hir::Expr {
hir_id: const_expr_id,
kind: hir::ExprKind::Lit(
this.arena.alloc(hir::Lit { node: LitKind::Bool(true), span }),
),
span,
})
});
let default_ac = self.arena.alloc(hir::AnonConst {

View File

@ -53,7 +53,7 @@
use rustc_data_structures::sync::Lrc;
use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, StashKey};
use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
use rustc_hir::def_id::{LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE};
use rustc_hir::def_id::{CRATE_DEF_ID, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
use rustc_hir::{
self as hir, ConstArg, GenericArg, HirId, ItemLocalMap, MissingLifetimeKind, ParamName,
TraitCandidate,
@ -63,9 +63,9 @@
use rustc_middle::span_bug;
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
use rustc_session::parse::{add_feature_diagnostics, feature_err};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{DesugaringKind, Span, DUMMY_SP};
use smallvec::{smallvec, SmallVec};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, DesugaringKind, Span};
use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec;
use tracing::{debug, instrument, trace};
@ -2466,7 +2466,7 @@ fn lower_anon_const_to_const_arg_direct(&mut self, anon: &AnonConst) -> hir::Con
/// See [`hir::ConstArg`] for when to use this function vs
/// [`Self::lower_anon_const_to_const_arg`].
fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst {
if c.value.is_potential_trivial_const_arg() {
if c.value.is_potential_trivial_const_arg(true) {
// HACK(min_generic_const_args): see DefCollector::visit_anon_const
// Over there, we guess if this is a bare param and only create a def if
// we think it's not. However we may can guess wrong (see there for example)

View File

@ -4,8 +4,8 @@
use rustc_hir::def::{DefKind, LifetimeRes, Res};
use rustc_middle::span_bug;
use rustc_middle::ty::ResolverAstLowering;
use rustc_span::symbol::{kw, Ident};
use rustc_span::Span;
use rustc_span::symbol::{Ident, kw};
use super::ResolverAstLoweringExt;

View File

@ -3,9 +3,9 @@
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir as hir;
use rustc_hir::def::Res;
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::Ident;
use rustc_span::Span;
use super::errors::{
ArbitraryExpressionInPattern, ExtraDoubleDot, MisplacedDoubleDot, SubTupleBinding,

View File

@ -1,14 +1,14 @@
use rustc_ast::{self as ast, *};
use rustc_data_structures::sync::Lrc;
use rustc_hir as hir;
use rustc_hir::GenericArg;
use rustc_hir::def::{DefKind, PartialRes, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::GenericArg;
use rustc_middle::span_bug;
use rustc_session::parse::add_feature_diagnostics;
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::{BytePos, DesugaringKind, Span, Symbol, DUMMY_SP};
use smallvec::{smallvec, SmallVec};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Span, Symbol};
use smallvec::{SmallVec, smallvec};
use tracing::{debug, instrument};
use super::errors::{

View File

@ -21,21 +21,21 @@
use itertools::{Either, Itertools};
use rustc_ast::ptr::P;
use rustc_ast::visit::{walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor};
use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor, walk_list};
use rustc_ast::*;
use rustc_ast_pretty::pprust::{self, State};
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::DiagCtxtHandle;
use rustc_feature::Features;
use rustc_parse::validate_attr;
use rustc_session::Session;
use rustc_session::lint::builtin::{
DEPRECATED_WHERE_CLAUSE_LOCATION, MISSING_ABI, MISSING_UNSAFE_ON_EXTERN,
PATTERNS_IN_FNS_WITHOUT_BODY,
};
use rustc_session::lint::{BuiltinLintDiag, LintBuffer};
use rustc_session::Session;
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
use rustc_span::symbol::{Ident, kw, sym};
use rustc_target::spec::abi;
use thin_vec::thin_vec;

View File

@ -1,12 +1,12 @@
use rustc_ast as ast;
use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
use rustc_ast::{attr, token, NodeId, PatKind};
use rustc_feature::{AttributeGate, BuiltinAttribute, Features, GateIssue, BUILTIN_ATTRIBUTE_MAP};
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
use rustc_ast::{NodeId, PatKind, attr, token};
use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features, GateIssue};
use rustc_session::Session;
use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
use rustc_span::Span;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym;
use rustc_span::Span;
use rustc_target::spec::abi;
use thin_vec::ThinVec;

View File

@ -2,8 +2,8 @@
use rustc_ast::visit::*;
use rustc_ast::*;
use rustc_span::symbol::Ident;
use rustc_span::Span;
use rustc_span::symbol::Ident;
pub struct NodeCounter {
pub count: usize,

View File

@ -1,6 +1,6 @@
use std::borrow::Cow;
use crate::pp::{BeginToken, BreakToken, Breaks, IndentStyle, Printer, Token, SIZE_INFINITY};
use crate::pp::{BeginToken, BreakToken, Breaks, IndentStyle, Printer, SIZE_INFINITY, Token};
impl Printer {
/// "raw box"

View File

@ -7,7 +7,7 @@
use rustc_ast as ast;
use rustc_ast::token::{Nonterminal, Token, TokenKind};
use rustc_ast::tokenstream::{TokenStream, TokenTree};
pub use state::{print_crate, AnnNode, Comments, PpAnn, PrintState, State};
pub use state::{AnnNode, Comments, PpAnn, PrintState, State, print_crate};
pub fn nonterminal_to_string(nt: &Nonterminal) -> String {
State::new().nonterminal_to_string(nt)

View File

@ -18,14 +18,14 @@
use rustc_ast::util::classify;
use rustc_ast::util::comments::{Comment, CommentStyle};
use rustc_ast::{
self as ast, attr, AttrArgs, AttrArgsEq, BindingMode, BlockCheckMode, ByRef, DelimArgs,
GenericArg, GenericBound, InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass,
InlineAsmTemplatePiece, PatKind, RangeEnd, RangeSyntax, Safety, SelfKind, Term,
self as ast, AttrArgs, AttrArgsEq, BindingMode, BlockCheckMode, ByRef, DelimArgs, GenericArg,
GenericBound, InlineAsmOperand, InlineAsmOptions, InlineAsmRegOrRegClass,
InlineAsmTemplatePiece, PatKind, RangeEnd, RangeSyntax, Safety, SelfKind, Term, attr,
};
use rustc_span::edition::Edition;
use rustc_span::source_map::{SourceMap, Spanned};
use rustc_span::symbol::{kw, sym, Ident, IdentPrinter, Symbol};
use rustc_span::{BytePos, CharPos, FileName, Pos, Span, DUMMY_SP};
use rustc_span::symbol::{Ident, IdentPrinter, Symbol, kw, sym};
use rustc_span::{BytePos, CharPos, DUMMY_SP, FileName, Pos, Span};
use thin_vec::ThinVec;
use crate::pp::Breaks::{Consistent, Inconsistent};
@ -292,9 +292,9 @@ pub fn print_crate<'a>(
/// - #73345: `#[allow(unused)]` must be printed rather than `# [allow(unused)]`
///
fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
use token::*;
use Delimiter::*;
use TokenTree::{Delimited as Del, Token as Tok};
use token::*;
fn is_punct(tt: &TokenTree) -> bool {
matches!(tt, TokenTree::Token(tok, _) if tok.is_punct())

View File

@ -7,13 +7,13 @@
use rustc_ast::util::literal::escape_byte_str_symbol;
use rustc_ast::util::parser::{self, AssocOp, Fixity};
use rustc_ast::{
self as ast, token, BlockCheckMode, FormatAlignment, FormatArgPosition, FormatArgsPiece,
FormatCount, FormatDebugHex, FormatSign, FormatTrait,
self as ast, BlockCheckMode, FormatAlignment, FormatArgPosition, FormatArgsPiece, FormatCount,
FormatDebugHex, FormatSign, FormatTrait, token,
};
use crate::pp::Breaks::Inconsistent;
use crate::pprust::state::fixup::FixupContext;
use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
use crate::pprust::state::{AnnNode, INDENT_UNIT, PrintState, State};
impl<'a> State<'a> {
fn print_else(&mut self, els: Option<&ast::Expr>) {

View File

@ -1,5 +1,5 @@
use rustc_ast::util::{classify, parser};
use rustc_ast::Expr;
use rustc_ast::util::{classify, parser};
#[derive(Copy, Clone, Debug)]
pub(crate) struct FixupContext {

View File

@ -1,13 +1,13 @@
use ast::StaticItem;
use itertools::{Itertools, Position};
use rustc_ast as ast;
use rustc_ast::ptr::P;
use rustc_ast::ModKind;
use rustc_ast::ptr::P;
use rustc_span::symbol::Ident;
use crate::pp::Breaks::Inconsistent;
use crate::pprust::state::fixup::FixupContext;
use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
use crate::pprust::state::{AnnNode, INDENT_UNIT, PrintState, State};
enum DelegationKind<'a> {
Single,

View File

@ -1,6 +1,6 @@
use rustc_ast as ast;
use rustc_span::symbol::Ident;
use rustc_span::{create_default_session_globals_then, DUMMY_SP};
use rustc_span::{DUMMY_SP, create_default_session_globals_then};
use thin_vec::ThinVec;
use super::*;

View File

@ -4,21 +4,21 @@
use rustc_abi::Align;
use rustc_ast::{
self as ast, attr, Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem,
NodeId,
self as ast, Attribute, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NodeId,
attr,
};
use rustc_ast_pretty::pprust;
use rustc_errors::ErrorGuaranteed;
use rustc_feature::{find_gated_cfg, is_builtin_attr_name, Features, GatedCfg};
use rustc_feature::{Features, GatedCfg, find_gated_cfg, is_builtin_attr_name};
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
use rustc_session::config::ExpectedValues;
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
use rustc_session::lint::BuiltinLintDiag;
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
use rustc_session::parse::feature_err;
use rustc_session::{RustcVersion, Session};
use rustc_span::hygiene::Transparency;
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;
use rustc_span::hygiene::Transparency;
use rustc_span::symbol::{Symbol, sym};
use crate::fluent_generated;
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};

View File

@ -15,11 +15,11 @@
mod builtin;
mod session_diagnostics;
pub use builtin::*;
pub use rustc_ast::attr::*;
pub(crate) use rustc_session::HashStableContext;
pub use IntType::*;
pub use ReprAttr::*;
pub use StabilityLevel::*;
pub use builtin::*;
pub use rustc_ast::attr::*;
pub(crate) use rustc_session::HashStableContext;
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

View File

@ -6,7 +6,7 @@
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{Span, Symbol};
use crate::{fluent_generated as fluent, UnsupportedLiteralReason};
use crate::{UnsupportedLiteralReason, fluent_generated as fluent};
#[derive(Diagnostic)]
#[diag(attr_expected_one_cfg_pattern, code = E0536)]
@ -203,20 +203,16 @@ pub(crate) struct UnsupportedLiteral {
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UnsupportedLiteral {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
let mut diag = Diag::new(
dcx,
level,
match self.reason {
UnsupportedLiteralReason::Generic => fluent::attr_unsupported_literal_generic,
UnsupportedLiteralReason::CfgString => fluent::attr_unsupported_literal_cfg_string,
UnsupportedLiteralReason::DeprecatedString => {
fluent::attr_unsupported_literal_deprecated_string
}
UnsupportedLiteralReason::DeprecatedKvPair => {
fluent::attr_unsupported_literal_deprecated_kv_pair
}
},
);
let mut diag = Diag::new(dcx, level, match self.reason {
UnsupportedLiteralReason::Generic => fluent::attr_unsupported_literal_generic,
UnsupportedLiteralReason::CfgString => fluent::attr_unsupported_literal_cfg_string,
UnsupportedLiteralReason::DeprecatedString => {
fluent::attr_unsupported_literal_deprecated_string
}
UnsupportedLiteralReason::DeprecatedKvPair => {
fluent::attr_unsupported_literal_deprecated_kv_pair
}
});
diag.span(self.span);
diag.code(E0565);
if self.is_bytestr {

View File

@ -4,15 +4,15 @@
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_index::bit_set::BitSet;
use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor};
use rustc_middle::mir::{self, traversal, Body, Local, Location};
use rustc_middle::mir::{self, Body, Local, Location, traversal};
use rustc_middle::span_bug;
use rustc_middle::ty::{RegionVid, TyCtxt};
use rustc_mir_dataflow::move_paths::MoveData;
use tracing::debug;
use crate::BorrowIndex;
use crate::path_utils::allow_two_phase_borrow;
use crate::place_ext::PlaceExt;
use crate::BorrowIndex;
pub struct BorrowSet<'tcx> {
/// The fundamental map relating bitvector indexes to the borrows

View File

@ -2,7 +2,7 @@
#![allow(rustc::untranslatable_diagnostic)]
use rustc_errors::codes::*;
use rustc_errors::{struct_span_code_err, Applicability, Diag, DiagCtxtHandle};
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, struct_span_code_err};
use rustc_hir as hir;
use rustc_middle::span_bug;
use rustc_middle::ty::{self, Ty, TyCtxt};

View File

@ -8,12 +8,12 @@
use rustc_middle::ty::TyCtxt;
pub use super::constraints::OutlivesConstraint;
pub use super::dataflow::{calculate_borrows_out_of_scope_at_location, BorrowIndex, Borrows};
pub use super::dataflow::{BorrowIndex, Borrows, calculate_borrows_out_of_scope_at_location};
pub use super::facts::{AllFacts as PoloniusInput, RustcFacts};
pub use super::location::{LocationTable, RichLocation};
pub use super::nll::PoloniusOutput;
pub use super::place_ext::PlaceExt;
pub use super::places_conflict::{places_conflict, PlaceConflictBias};
pub use super::places_conflict::{PlaceConflictBias, places_conflict};
pub use super::region_infer::RegionInferenceContext;
use crate::borrow_set::BorrowSet;

View File

@ -12,7 +12,7 @@
use rustc_mir_dataflow::{Analysis, AnalysisDomain, Forward, GenKill, Results, ResultsVisitable};
use tracing::debug;
use crate::{places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext};
use crate::{BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext, places_conflict};
/// The results of the dataflow analyses used by the borrow checker.
pub(crate) struct BorrowckResults<'a, 'tcx> {

View File

@ -14,18 +14,18 @@
self, RePlaceholder, Region, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex,
};
use rustc_span::Span;
use rustc_trait_selection::error_reporting::infer::nice_region_error::NiceRegionError;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::traits::query::type_op;
use rustc_trait_selection::error_reporting::infer::nice_region_error::NiceRegionError;
use rustc_trait_selection::traits::ObligationCtxt;
use rustc_trait_selection::traits::query::type_op;
use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_cause};
use tracing::{debug, instrument};
use crate::MirBorrowckCtxt;
use crate::region_infer::values::RegionElement;
use crate::session_diagnostics::{
HigherRankedErrorCause, HigherRankedLifetimeError, HigherRankedSubtypeError,
};
use crate::MirBorrowckCtxt;
#[derive(Clone)]
pub(crate) struct UniverseInfo<'tcx>(UniverseInfoInner<'tcx>);
@ -176,25 +176,24 @@ fn report_error(
return;
};
let placeholder_region = ty::Region::new_placeholder(
tcx,
ty::Placeholder { universe: adjusted_universe.into(), bound: placeholder.bound },
);
let placeholder_region = ty::Region::new_placeholder(tcx, ty::Placeholder {
universe: adjusted_universe.into(),
bound: placeholder.bound,
});
let error_region = if let RegionElement::PlaceholderRegion(error_placeholder) =
error_element
{
let adjusted_universe =
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
adjusted_universe.map(|adjusted| {
ty::Region::new_placeholder(
tcx,
ty::Placeholder { universe: adjusted.into(), bound: error_placeholder.bound },
)
})
} else {
None
};
let error_region =
if let RegionElement::PlaceholderRegion(error_placeholder) = error_element {
let adjusted_universe =
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
adjusted_universe.map(|adjusted| {
ty::Region::new_placeholder(tcx, ty::Placeholder {
universe: adjusted.into(),
bound: error_placeholder.bound,
})
})
} else {
None
};
debug!(?placeholder_region);

View File

@ -11,10 +11,10 @@
use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::codes::*;
use rustc_errors::{struct_span_code_err, Applicability, Diag, MultiSpan};
use rustc_errors::{Applicability, Diag, MultiSpan, struct_span_code_err};
use rustc_hir as hir;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::intravisit::{walk_block, walk_expr, Map, Visitor};
use rustc_hir::intravisit::{Map, Visitor, walk_block, walk_expr};
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField};
use rustc_middle::bug;
use rustc_middle::hir::nested_filter::OnlyBodies;
@ -27,17 +27,17 @@
};
use rustc_middle::ty::print::PrintTraitRefExt as _;
use rustc_middle::ty::{
self, suggest_constraining_type_params, PredicateKind, Ty, TyCtxt, TypeSuperVisitable,
TypeVisitor, Upcast,
self, PredicateKind, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor, Upcast,
suggest_constraining_type_params,
};
use rustc_middle::util::CallKind;
use rustc_mir_dataflow::move_paths::{InitKind, MoveOutIndex, MovePathIndex};
use rustc_span::def_id::{DefId, LocalDefId};
use rustc_span::hygiene::DesugaringKind;
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{BytePos, Span, Symbol};
use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
use tracing::{debug, instrument};
@ -46,9 +46,9 @@
use super::{DescribePlaceOpt, RegionName, RegionNameSource, UseSpans};
use crate::borrow_set::{BorrowData, TwoPhaseActivation};
use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead;
use crate::diagnostics::{find_all_local_uses, CapturedMessageOpt, Instance};
use crate::diagnostics::{CapturedMessageOpt, Instance, find_all_local_uses};
use crate::prefixes::IsPrefixOf;
use crate::{borrowck_errors, InitializationRequiringAction, MirBorrowckCtxt, WriteKind};
use crate::{InitializationRequiringAction, MirBorrowckCtxt, WriteKind, borrowck_errors};
#[derive(Debug)]
struct MoveSite {
@ -145,10 +145,10 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
span,
desired_action.as_noun(),
partially_str,
self.describe_place_with_options(
moved_place,
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
),
self.describe_place_with_options(moved_place, DescribePlaceOpt {
including_downcast: true,
including_tuple_field: true,
}),
);
let reinit_spans = maybe_reinitialized_locations
@ -266,10 +266,10 @@ pub(crate) fn report_use_of_moved_or_uninitialized(
}
}
let opt_name = self.describe_place_with_options(
place.as_ref(),
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
);
let opt_name = self.describe_place_with_options(place.as_ref(), DescribePlaceOpt {
including_downcast: true,
including_tuple_field: true,
});
let note_msg = match opt_name {
Some(name) => format!("`{name}`"),
None => "value".to_owned(),
@ -689,17 +689,17 @@ fn report_use_of_uninitialized(
}
let spans: Vec<_> = spans_set.into_iter().collect();
let (name, desc) = match self.describe_place_with_options(
moved_place,
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
) {
let (name, desc) = match self.describe_place_with_options(moved_place, DescribePlaceOpt {
including_downcast: true,
including_tuple_field: true,
}) {
Some(name) => (format!("`{name}`"), format!("`{name}` ")),
None => ("the variable".to_string(), String::new()),
};
let path = match self.describe_place_with_options(
used_place,
DescribePlaceOpt { including_downcast: true, including_tuple_field: true },
) {
let path = match self.describe_place_with_options(used_place, DescribePlaceOpt {
including_downcast: true,
including_tuple_field: true,
}) {
Some(name) => format!("`{name}`"),
None => "value".to_string(),
};

View File

@ -17,12 +17,12 @@
};
use rustc_middle::ty::adjustment::PointerCoercion;
use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt};
use rustc_span::symbol::{kw, Symbol};
use rustc_span::{sym, DesugaringKind, Span};
use rustc_span::symbol::{Symbol, kw};
use rustc_span::{DesugaringKind, Span, sym};
use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
use tracing::{debug, instrument};
use super::{find_use, RegionName, UseSpans};
use super::{RegionName, UseSpans, find_use};
use crate::borrow_set::BorrowData;
use crate::nll::ConstraintDescription;
use crate::region_infer::{BlameConstraint, Cause, ExtraConstraintInfo};

View File

@ -15,22 +15,22 @@
};
use rustc_middle::ty::print::Print;
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
use rustc_middle::util::{call_kind, CallDesugaringKind};
use rustc_middle::util::{CallDesugaringKind, call_kind};
use rustc_mir_dataflow::move_paths::{InitLocation, LookupResult};
use rustc_span::def_id::LocalDefId;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym;
use rustc_span::{Span, Symbol, DUMMY_SP};
use rustc_span::{DUMMY_SP, Span, Symbol};
use rustc_target::abi::{FieldIdx, VariantIdx};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{
type_known_to_meet_bound_modulo_regions, FulfillmentErrorCode,
FulfillmentErrorCode, type_known_to_meet_bound_modulo_regions,
};
use tracing::debug;
use super::borrow_set::BorrowData;
use super::MirBorrowckCtxt;
use super::borrow_set::BorrowData;
use crate::fluent_generated as fluent;
use crate::session_diagnostics::{
CaptureArgLabel, CaptureReasonLabel, CaptureReasonNote, CaptureReasonSuggest, CaptureVarCause,
@ -177,10 +177,10 @@ pub(super) fn describe_any_place(&self, place_ref: PlaceRef<'tcx>) -> String {
/// End-user visible description of `place` if one can be found.
/// If the place is a temporary for instance, `None` will be returned.
pub(super) fn describe_place(&self, place_ref: PlaceRef<'tcx>) -> Option<String> {
self.describe_place_with_options(
place_ref,
DescribePlaceOpt { including_downcast: false, including_tuple_field: true },
)
self.describe_place_with_options(place_ref, DescribePlaceOpt {
including_downcast: false,
including_tuple_field: true,
})
}
/// End-user visible description of `place` if one can be found. If the place is a temporary

View File

@ -12,9 +12,9 @@
use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
use tracing::debug;
use crate::MirBorrowckCtxt;
use crate::diagnostics::{CapturedMessageOpt, DescribePlaceOpt, UseSpans};
use crate::prefixes::PrefixSet;
use crate::MirBorrowckCtxt;
#[derive(Debug)]
pub(crate) enum IllegalMoveOriginKind<'tcx> {

View File

@ -14,8 +14,8 @@
PlaceRef, ProjectionElem,
};
use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt, Upcast};
use rustc_span::symbol::{kw, Symbol};
use rustc_span::{sym, BytePos, DesugaringKind, Span};
use rustc_span::symbol::{Symbol, kw};
use rustc_span::{BytePos, DesugaringKind, Span, sym};
use rustc_target::abi::FieldIdx;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
@ -24,7 +24,7 @@
use crate::diagnostics::BorrowedContentSource;
use crate::util::FindAssignments;
use crate::{session_diagnostics, MirBorrowckCtxt};
use crate::{MirBorrowckCtxt, session_diagnostics};
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub(crate) enum AccessKind {

View File

@ -3,26 +3,26 @@
use rustc_data_structures::fx::FxIndexSet;
use rustc_errors::{Applicability, Diag, ErrorGuaranteed, MultiSpan};
use rustc_hir as hir;
use rustc_hir::def::Res::Def;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
use rustc_hir::GenericBound::Trait;
use rustc_hir::QPath::Resolved;
use rustc_hir::WherePredicate::BoundPredicate;
use rustc_hir::def::Res::Def;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::Visitor;
use rustc_hir::{PolyTraitRef, TyKind, WhereBoundPredicate};
use rustc_infer::infer::{NllRegionVariableOrigin, RelateParamBound};
use rustc_middle::bug;
use rustc_middle::hir::place::PlaceBase;
use rustc_middle::mir::{ConstraintCategory, ReturnConstraint};
use rustc_middle::ty::{self, GenericArgs, Region, RegionVid, Ty, TyCtxt, TypeVisitor};
use rustc_span::symbol::{kw, Ident};
use rustc_span::Span;
use rustc_span::symbol::{Ident, kw};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::error_reporting::infer::nice_region_error::{
self, find_anon_type, find_param_with_region, suggest_adding_lifetime_params,
HirTraitObjectVisitor, NiceRegionError, TraitObjectVisitor,
self, HirTraitObjectVisitor, NiceRegionError, TraitObjectVisitor, find_anon_type,
find_param_with_region, suggest_adding_lifetime_params,
};
use rustc_trait_selection::error_reporting::infer::region::unexpected_hidden_region_diagnostic;
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{Obligation, ObligationCtxt};
use tracing::{debug, instrument, trace};
@ -36,7 +36,7 @@
LifetimeReturnCategoryErr, RequireStaticErr, VarHereDenote,
};
use crate::universal_regions::DefiningTy;
use crate::{borrowck_errors, fluent_generated as fluent, MirBorrowckCtxt};
use crate::{MirBorrowckCtxt, borrowck_errors, fluent_generated as fluent};
impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
fn description(&self) -> &'static str {
@ -1108,15 +1108,12 @@ fn suggest_deref_closure_return(&self, diag: &mut Diag<'_>) {
let closure_ty = Ty::new_closure(
tcx,
closure_def_id.to_def_id(),
ty::ClosureArgs::new(
tcx,
ty::ClosureArgsParts {
parent_args: args.parent_args(),
closure_kind_ty: args.kind_ty(),
tupled_upvars_ty: args.tupled_upvars_ty(),
closure_sig_as_fn_ptr_ty,
},
)
ty::ClosureArgs::new(tcx, ty::ClosureArgsParts {
parent_args: args.parent_args(),
closure_kind_ty: args.kind_ty(),
tupled_upvars_ty: args.tupled_upvars_ty(),
closure_sig_as_fn_ptr_ty,
})
.args,
);

View File

@ -11,13 +11,13 @@
use rustc_middle::ty::print::RegionHighlightMode;
use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, RegionVid, Ty};
use rustc_middle::{bug, span_bug};
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_span::symbol::{Symbol, kw, sym};
use rustc_span::{DUMMY_SP, Span};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use tracing::{debug, instrument};
use crate::universal_regions::DefiningTy;
use crate::MirBorrowckCtxt;
use crate::universal_regions::DefiningTy;
/// A name for a particular region used in emitting diagnostics. This name could be a generated
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.

View File

@ -1,8 +1,8 @@
use rustc_index::IndexSlice;
use rustc_middle::mir::{Body, Local};
use rustc_middle::ty::{self, RegionVid, TyCtxt};
use rustc_span::symbol::Symbol;
use rustc_span::Span;
use rustc_span::symbol::Symbol;
use tracing::debug;
use crate::region_infer::RegionInferenceContext;

View File

@ -10,8 +10,8 @@
use rustc_middle::ty::{RegionVid, TyCtxt};
use rustc_mir_dataflow::move_paths::MovePathIndex;
use crate::location::{LocationIndex, LocationTable};
use crate::BorrowIndex;
use crate::location::{LocationIndex, LocationTable};
#[derive(Copy, Clone, Debug)]
pub struct RustcFacts;

View File

@ -37,13 +37,13 @@
use rustc_middle::query::Providers;
use rustc_middle::ty::{self, ParamEnv, RegionVid, TyCtxt};
use rustc_middle::{bug, span_bug};
use rustc_mir_dataflow::Analysis;
use rustc_mir_dataflow::impls::{
EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces,
};
use rustc_mir_dataflow::move_paths::{
InitIndex, InitLocation, LookupResult, MoveData, MoveOutIndex, MovePathIndex,
};
use rustc_mir_dataflow::Analysis;
use rustc_session::lint::builtin::UNUSED_MUT;
use rustc_span::{Span, Symbol};
use rustc_target::abi::FieldIdx;
@ -86,7 +86,7 @@
use dataflow::{BorrowIndex, BorrowckDomain, BorrowckResults, Borrows};
use nll::PoloniusOutput;
use place_ext::PlaceExt;
use places_conflict::{places_conflict, PlaceConflictBias};
use places_conflict::{PlaceConflictBias, places_conflict};
use region_infer::RegionInferenceContext;
use renumber::RegionCtxt;
@ -1612,13 +1612,9 @@ fn check_movable_place(&mut self, location: Location, place: Place<'tcx>) {
match elem {
ProjectionElem::Deref => match place_ty.ty.kind() {
ty::Ref(..) | ty::RawPtr(..) => {
self.move_errors.push(MoveError::new(
place,
location,
BorrowedContent {
target_place: place_ref.project_deeper(&[elem], tcx),
},
));
self.move_errors.push(MoveError::new(place, location, BorrowedContent {
target_place: place_ref.project_deeper(&[elem], tcx),
}));
return;
}
ty::Adt(adt, _) => {

View File

@ -9,17 +9,17 @@
use rustc_data_structures::fx::FxIndexMap;
use rustc_hir::def_id::LocalDefId;
use rustc_index::IndexSlice;
use rustc_middle::mir::pretty::{dump_mir_with_options, PrettyPrintMirOptions};
use rustc_middle::mir::pretty::{PrettyPrintMirOptions, dump_mir_with_options};
use rustc_middle::mir::{
create_dump_file, dump_enabled, dump_mir, Body, ClosureOutlivesSubject,
ClosureRegionRequirements, PassWhere, Promoted,
Body, ClosureOutlivesSubject, ClosureRegionRequirements, PassWhere, Promoted, create_dump_file,
dump_enabled, dump_mir,
};
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{self, OpaqueHiddenType, TyCtxt};
use rustc_mir_dataflow::ResultsCursor;
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_mir_dataflow::ResultsCursor;
use rustc_session::config::MirIncludeSpans;
use rustc_span::symbol::sym;
use tracing::{debug, instrument};
@ -32,7 +32,7 @@
use crate::region_infer::RegionInferenceContext;
use crate::type_check::{self, MirTypeckRegionConstraints, MirTypeckResults};
use crate::universal_regions::UniversalRegions;
use crate::{polonius, renumber, BorrowckInferCtxt};
use crate::{BorrowckInferCtxt, polonius, renumber};
pub type PoloniusOutput = Output<RustcFacts>;

View File

@ -5,7 +5,7 @@
use tracing::debug;
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
use crate::{places_conflict, AccessDepth, BorrowIndex};
use crate::{AccessDepth, BorrowIndex, places_conflict};
/// Returns `true` if the borrow represented by `kind` is
/// allowed to be split into separate Reservation and

View File

@ -23,6 +23,7 @@
use rustc_span::Span;
use tracing::{debug, instrument, trace};
use crate::BorrowckInferCtxt;
use crate::constraints::graph::{self, NormalConstraintGraph, RegionGraph};
use crate::constraints::{ConstraintSccIndex, OutlivesConstraint, OutlivesConstraintSet};
use crate::dataflow::BorrowIndex;
@ -33,10 +34,9 @@
use crate::region_infer::values::{
LivenessValues, PlaceholderIndices, RegionElement, RegionValues, ToElementIndex,
};
use crate::type_check::free_region_relations::UniversalRegionRelations;
use crate::type_check::Locations;
use crate::type_check::free_region_relations::UniversalRegionRelations;
use crate::universal_regions::UniversalRegions;
use crate::BorrowckInferCtxt;
mod dump_mir;
mod graphviz;

View File

@ -1,8 +1,8 @@
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::ErrorGuaranteed;
use rustc_hir::OpaqueTyOrigin;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::OpaqueTyOrigin;
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin, TyCtxtInferExt as _};
use rustc_infer::traits::{Obligation, ObligationCause};
use rustc_macros::extension;
@ -165,10 +165,10 @@ pub(crate) fn infer_opaque_types(
// FIXME(oli-obk): collect multiple spans for better diagnostics down the road.
prev.span = prev.span.substitute_dummy(concrete_type.span);
} else {
result.insert(
opaque_type_key.def_id,
OpaqueHiddenType { ty, span: concrete_type.span },
);
result.insert(opaque_type_key.def_id, OpaqueHiddenType {
ty,
span: concrete_type.span,
});
}
// Check that all opaque types have the same region parameters if they have the same

View File

@ -5,8 +5,8 @@
use rustc_data_structures::graph::vec_graph::VecGraph;
use rustc_middle::ty::RegionVid;
use crate::constraints::ConstraintSccIndex;
use crate::RegionInferenceContext;
use crate::constraints::ConstraintSccIndex;
pub(crate) struct ReverseSccGraph {
graph: VecGraph<ConstraintSccIndex>,

View File

@ -2,9 +2,9 @@
use std::rc::Rc;
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
use rustc_index::Idx;
use rustc_index::bit_set::SparseBitMatrix;
use rustc_index::interval::{IntervalSet, SparseIntervalMatrix};
use rustc_index::Idx;
use rustc_middle::mir::{BasicBlock, Location};
use rustc_middle::ty::{self, RegionVid};
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};

View File

@ -1,5 +1,5 @@
use rustc_errors::codes::*;
use rustc_errors::MultiSpan;
use rustc_errors::codes::*;
use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
use rustc_middle::ty::{GenericArg, Ty};
use rustc_span::Span;

View File

@ -5,11 +5,11 @@
use rustc_middle::bug;
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Upcast};
use rustc_span::def_id::DefId;
use rustc_span::Span;
use rustc_span::def_id::DefId;
use rustc_trait_selection::traits::ObligationCause;
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput};
use rustc_trait_selection::traits::ObligationCause;
use tracing::{debug, instrument};
use super::{Locations, NormalizeLocation, TypeChecker};

View File

@ -6,13 +6,13 @@
use rustc_infer::infer::{self, InferCtxt, SubregionOrigin};
use rustc_middle::bug;
use rustc_middle::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, ConstraintCategory};
use rustc_middle::traits::query::NoSolution;
use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::{self, GenericArgKind, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
use rustc_span::Span;
use rustc_trait_selection::traits::ScrubbedTraitError;
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
use rustc_trait_selection::traits::ScrubbedTraitError;
use tracing::{debug, instrument};
use crate::constraints::OutlivesConstraint;

View File

@ -6,10 +6,10 @@
use rustc_infer::infer::canonical::QueryRegionConstraints;
use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::infer::region_constraints::GenericKind;
use rustc_infer::infer::{outlives, InferCtxt};
use rustc_infer::infer::{InferCtxt, outlives};
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::traits::query::OutlivesBound;
use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::query::OutlivesBound;
use rustc_middle::ty::{self, RegionVid, Ty, TypeVisitableExt};
use rustc_span::{ErrorGuaranteed, Span};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
@ -18,7 +18,7 @@
use tracing::{debug, instrument};
use type_op::TypeOpOutput;
use crate::type_check::{constraint_conversion, Locations, MirTypeckRegionConstraints};
use crate::type_check::{Locations, MirTypeckRegionConstraints, constraint_conversion};
use crate::universal_regions::UniversalRegions;
#[derive(Debug)]

View File

@ -77,20 +77,17 @@ pub(super) fn check_signature_annotation(&mut self, body: &Body<'tcx>) {
let output_ty = Ty::new_coroutine(
self.tcx(),
self.tcx().coroutine_for_closure(mir_def_id),
ty::CoroutineArgs::new(
self.tcx(),
ty::CoroutineArgsParts {
parent_args: args.parent_args(),
kind_ty: Ty::from_coroutine_closure_kind(self.tcx(), args.kind()),
return_ty: user_provided_sig.output(),
tupled_upvars_ty,
// For async closures, none of these can be annotated, so just fill
// them with fresh ty vars.
resume_ty: next_ty_var(),
yield_ty: next_ty_var(),
witness: next_ty_var(),
},
)
ty::CoroutineArgs::new(self.tcx(), ty::CoroutineArgsParts {
parent_args: args.parent_args(),
kind_ty: Ty::from_coroutine_closure_kind(self.tcx(), args.kind()),
return_ty: user_provided_sig.output(),
tupled_upvars_ty,
// For async closures, none of these can be annotated, so just fill
// them with fresh ty vars.
resume_ty: next_ty_var(),
yield_ty: next_ty_var(),
witness: next_ty_var(),
})
.args,
);

View File

@ -7,10 +7,10 @@
use rustc_middle::span_bug;
use rustc_middle::ty::visit::TypeVisitable;
use rustc_middle::ty::{GenericArgsRef, Region, RegionVid, Ty, TyCtxt};
use rustc_mir_dataflow::ResultsCursor;
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_mir_dataflow::ResultsCursor;
use tracing::debug;
use super::TypeChecker;

View File

@ -8,10 +8,10 @@
use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location};
use rustc_middle::traits::query::DropckOutlivesResult;
use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt};
use rustc_mir_dataflow::ResultsCursor;
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
use rustc_mir_dataflow::ResultsCursor;
use rustc_span::DUMMY_SP;
use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};

View File

@ -31,20 +31,20 @@
UserType, UserTypeAnnotationIndex,
};
use rustc_middle::{bug, span_bug};
use rustc_mir_dataflow::ResultsCursor;
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
use rustc_mir_dataflow::move_paths::MoveData;
use rustc_mir_dataflow::points::DenseLocationMap;
use rustc_mir_dataflow::ResultsCursor;
use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::sym;
use rustc_span::{Span, DUMMY_SP};
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
use rustc_span::{DUMMY_SP, Span};
use rustc_target::abi::{FIRST_VARIANT, FieldIdx};
use rustc_trait_selection::traits::PredicateObligation;
use rustc_trait_selection::traits::query::type_op::custom::{
scrape_region_constraints, CustomTypeOp,
CustomTypeOp, scrape_region_constraints,
};
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
use rustc_trait_selection::traits::PredicateObligation;
use tracing::{debug, instrument, trace};
use crate::borrow_set::BorrowSet;
@ -53,13 +53,13 @@
use crate::facts::AllFacts;
use crate::location::LocationTable;
use crate::member_constraints::MemberConstraintSet;
use crate::region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderIndices};
use crate::region_infer::TypeTest;
use crate::region_infer::values::{LivenessValues, PlaceholderIndex, PlaceholderIndices};
use crate::renumber::RegionCtxt;
use crate::session_diagnostics::{MoveUnsized, SimdIntrinsicArgConst};
use crate::type_check::free_region_relations::{CreateResult, UniversalRegionRelations};
use crate::universal_regions::{DefiningTy, UniversalRegions};
use crate::{path_utils, BorrowckInferCtxt};
use crate::{BorrowckInferCtxt, path_utils};
macro_rules! span_mirbug {
($context:expr, $elem:expr, $($message:tt)*) => ({
@ -1944,11 +1944,10 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
}
&Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, ty) => {
let trait_ref = ty::TraitRef::new(
tcx,
tcx.require_lang_item(LangItem::Sized, Some(span)),
[ty],
);
let trait_ref =
ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Sized, Some(span)), [
ty,
]);
self.prove_trait_ref(
trait_ref,
@ -1961,11 +1960,10 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
Rvalue::ShallowInitBox(operand, ty) => {
self.check_operand(operand, location);
let trait_ref = ty::TraitRef::new(
tcx,
tcx.require_lang_item(LangItem::Sized, Some(span)),
[*ty],
);
let trait_ref =
ty::TraitRef::new(tcx, tcx.require_lang_item(LangItem::Sized, Some(span)), [
*ty,
]);
self.prove_trait_ref(
trait_ref,

View File

@ -4,12 +4,12 @@
PredicateEmittingRelation, Relate, RelateResult, StructurallyRelateAliases, TypeRelation,
};
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
use rustc_infer::traits::solve::Goal;
use rustc_infer::traits::Obligation;
use rustc_infer::traits::solve::Goal;
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::span_bug;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::query::NoSolution;
use rustc_middle::ty::fold::FnMutDelegate;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::symbol::sym;

View File

@ -20,9 +20,9 @@
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::Diag;
use rustc_hir::BodyOwnerKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::lang_items::LangItem;
use rustc_hir::BodyOwnerKind;
use rustc_index::IndexVec;
use rustc_infer::infer::NllRegionVariableOrigin;
use rustc_macros::extension;
@ -37,8 +37,8 @@
use rustc_span::{ErrorGuaranteed, Symbol};
use tracing::{debug, instrument};
use crate::renumber::RegionCtxt;
use crate::BorrowckInferCtxt;
use crate::renumber::RegionCtxt;
#[derive(Debug)]
pub(crate) struct UniversalRegions<'tcx> {
@ -629,10 +629,10 @@ fn defining_ty(&self) -> DefiningTy<'tcx> {
let ty = tcx
.typeck(self.mir_def)
.node_type(tcx.local_def_id_to_hir_id(self.mir_def));
let args = InlineConstArgs::new(
tcx,
InlineConstArgsParts { parent_args: identity_args, ty },
)
let args = InlineConstArgs::new(tcx, InlineConstArgsParts {
parent_args: identity_args,
ty,
})
.args;
let args = self.infcx.replace_free_regions_with_nll_infer_vars(FR, args);
DefiningTy::InlineConst(self.mir_def.to_def_id(), args)

View File

@ -3,9 +3,9 @@
self as ast, Fn, FnHeader, FnSig, Generics, ItemKind, Safety, Stmt, StmtKind, TyKind,
};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Ident, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::errors;
use crate::util::check_builtin_macro_attribute;
@ -68,11 +68,10 @@ fn generate_handler(cx: &ExtCtxt<'_>, handler: Ident, span: Span, sig_span: Span
let layout_new = cx.std_path(&[sym::alloc, sym::Layout, sym::from_size_align_unchecked]);
let layout_new = cx.expr_path(cx.path(span, layout_new));
let layout = cx.expr_call(
span,
layout_new,
thin_vec![cx.expr_ident(span, size), cx.expr_ident(span, align)],
);
let layout = cx.expr_call(span, layout_new, thin_vec![
cx.expr_ident(span, size),
cx.expr_ident(span, align)
]);
let call = cx.expr_call_ident(sig_span, handler, thin_vec![layout]);

View File

@ -1,16 +1,16 @@
use ast::token::IdentIsRaw;
use lint::BuiltinLintDiag;
use rustc_ast::AsmMacro;
use rustc_ast::ptr::P;
use rustc_ast::token::{self, Delimiter};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::AsmMacro;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_errors::PResult;
use rustc_expand::base::*;
use rustc_index::bit_set::GrowableBitSet;
use rustc_parse::parser::Parser;
use rustc_session::lint;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{ErrorGuaranteed, InnerSpan, Span};
use rustc_target::asm::InlineAsmArch;
use smallvec::smallvec;

View File

@ -3,13 +3,13 @@
use rustc_ast::ptr::P;
use rustc_ast::token::Delimiter;
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
use rustc_ast::{token, DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp};
use rustc_ast::{DelimArgs, Expr, ExprKind, MacCall, Path, PathSegment, UnOp, token};
use rustc_ast_pretty::pprust;
use rustc_errors::PResult;
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_parse::parser::Parser;
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_span::symbol::{Ident, Symbol, sym};
use rustc_span::{DUMMY_SP, Span};
use thin_vec::thin_vec;
use crate::edition_panic::use_panic_2021;

View File

@ -2,15 +2,15 @@
use rustc_ast::token::{self, Delimiter, IdentIsRaw};
use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree};
use rustc_ast::{
BinOpKind, BorrowKind, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall, Mutability,
Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind, DUMMY_NODE_ID,
BinOpKind, BorrowKind, DUMMY_NODE_ID, DelimArgs, Expr, ExprKind, ItemKind, MacCall, MethodCall,
Mutability, Path, PathSegment, Stmt, StructRest, UnOp, UseTree, UseTreeKind,
};
use rustc_ast_pretty::pprust;
use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::ExtCtxt;
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Ident, Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
pub(super) struct Context<'cx, 'a> {
// An optimization.

View File

@ -4,8 +4,8 @@
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier};
use rustc_feature::AttributeTemplate;
use rustc_parse::validate_attr;
use rustc_span::symbol::sym;
use rustc_span::Span;
use rustc_span::symbol::sym;
use crate::errors;

View File

@ -4,7 +4,7 @@
use rustc_ast::mut_visit::MutVisitor;
use rustc_ast::ptr::P;
use rustc_ast::visit::{AssocCtxt, Visitor};
use rustc_ast::{mut_visit, visit, Attribute, HasAttrs, HasTokens, NodeId};
use rustc_ast::{Attribute, HasAttrs, HasTokens, NodeId, mut_visit, visit};
use rustc_errors::PResult;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_expand::config::StripUnconfigured;
@ -12,8 +12,8 @@
use rustc_feature::Features;
use rustc_parse::parser::{ForceCollect, Parser};
use rustc_session::Session;
use rustc_span::symbol::sym;
use rustc_span::Span;
use rustc_span::symbol::sym;
use smallvec::SmallVec;
use tracing::instrument;

View File

@ -1,7 +1,7 @@
//! Attributes injected into the crate root from command line using `-Z crate-attr`.
use rustc_ast::attr::mk_attr;
use rustc_ast::{self as ast, token, AttrItem, AttrStyle};
use rustc_ast::{self as ast, AttrItem, AttrStyle, token};
use rustc_parse::parser::ForceCollect;
use rustc_parse::{new_parser_from_source_str, unwrap_or_emit_fatal};
use rustc_session::parse::ParseSess;

View File

@ -1,6 +1,6 @@
use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{token, ExprKind, LitIntType, LitKind, UintTy};
use rustc_ast::{ExprKind, LitIntType, LitKind, UintTy, token};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_session::errors::report_lit_error;
use rustc_span::{ErrorGuaranteed, Span};

View File

@ -1,10 +1,10 @@
use rustc_ast::ptr::P;
use rustc_ast::token::{self, Token};
use rustc_ast::tokenstream::{TokenStream, TokenTree};
use rustc_ast::{AttrVec, Expr, ExprKind, Path, Ty, TyKind, DUMMY_NODE_ID};
use rustc_ast::{AttrVec, DUMMY_NODE_ID, Expr, ExprKind, Path, Ty, TyKind};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacResult, MacroExpanderResult};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::Span;
use rustc_span::symbol::{Ident, Symbol};
use crate::errors;

View File

@ -6,7 +6,7 @@
use rustc_feature::AttributeTemplate;
use rustc_parse::validate_attr;
use rustc_session::Session;
use rustc_span::symbol::{sym, Ident};
use rustc_span::symbol::{Ident, sym};
use rustc_span::{ErrorGuaranteed, Span};
use crate::cfg_eval::cfg_eval;

View File

@ -1,9 +1,9 @@
use rustc_ast::{self as ast, Generics, ItemKind, MetaItem, VariantData};
use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Ident, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
@ -115,13 +115,10 @@ fn cs_clone_simple(
// type parameters.
} else if !field.ty.kind.is_anon_adt() {
// let _: AssertParamIsClone<FieldTy>;
super::assert_ty_bounds(
cx,
&mut stmts,
field.ty.clone(),
field.span,
&[sym::clone, sym::AssertParamIsClone],
);
super::assert_ty_bounds(cx, &mut stmts, field.ty.clone(), field.span, &[
sym::clone,
sym::AssertParamIsClone,
]);
}
}
};
@ -130,13 +127,10 @@ fn cs_clone_simple(
// Just a single assertion for unions, that the union impls `Copy`.
// let _: AssertParamIsCopy<Self>;
let self_ty = cx.ty_path(cx.path_ident(trait_span, Ident::with_dummy_span(kw::SelfUpper)));
super::assert_ty_bounds(
cx,
&mut stmts,
self_ty,
trait_span,
&[sym::clone, sym::AssertParamIsCopy],
);
super::assert_ty_bounds(cx, &mut stmts, self_ty, trait_span, &[
sym::clone,
sym::AssertParamIsCopy,
]);
} else {
match *substr.fields {
StaticStruct(vdata, ..) => {

View File

@ -1,9 +1,9 @@
use rustc_ast::{self as ast, MetaItem};
use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::sym;
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::sym;
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
@ -66,13 +66,10 @@ fn cs_total_eq_assert(
// Already produced an assertion for this type.
} else {
// let _: AssertParamIsEq<FieldTy>;
super::assert_ty_bounds(
cx,
&mut stmts,
field.ty.clone(),
field.span,
&[sym::cmp, sym::AssertParamIsEq],
);
super::assert_ty_bounds(cx, &mut stmts, field.ty.clone(), field.span, &[
sym::cmp,
sym::AssertParamIsEq,
]);
}
}
};

View File

@ -1,7 +1,7 @@
use rustc_ast::MetaItem;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
use rustc_span::symbol::{Ident, sym};
use thin_vec::thin_vec;
use crate::deriving::generic::ty::*;

View File

@ -1,8 +1,8 @@
use rustc_ast::ptr::P;
use rustc_ast::{BinOpKind, BorrowKind, Expr, ExprKind, MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::sym;
use rustc_span::Span;
use rustc_span::symbol::sym;
use thin_vec::thin_vec;
use crate::deriving::generic::ty::*;

View File

@ -1,7 +1,7 @@
use rustc_ast::{ExprKind, ItemKind, MetaItem, PatKind};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
use rustc_span::symbol::{Ident, sym};
use thin_vec::thin_vec;
use crate::deriving::generic::ty::*;

View File

@ -1,9 +1,9 @@
use rustc_ast::{self as ast, EnumDef, MetaItem};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_session::config::FmtDebug;
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Ident, Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;

View File

@ -3,9 +3,9 @@
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, Expr, MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Ident, Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
@ -32,10 +32,11 @@ pub(crate) fn expand_deriving_rustc_decodable(
methods: vec![MethodDef {
name: sym::decode,
generics: Bounds {
bounds: vec![(
typaram,
vec![Path::new_(vec![krate, sym::Decoder], vec![], PathKind::Global)],
)],
bounds: vec![(typaram, vec![Path::new_(
vec![krate, sym::Decoder],
vec![],
PathKind::Global,
)])],
},
explicit_self: false,
nonself_args: vec![(
@ -94,32 +95,24 @@ fn decodable_substructure(
decode_static_fields(cx, trait_span, path, summary, |cx, span, name, field| {
cx.expr_try(
span,
cx.expr_call_global(
span,
fn_read_struct_field_path.clone(),
thin_vec![
blkdecoder.clone(),
cx.expr_str(span, name),
cx.expr_usize(span, field),
exprdecode.clone(),
],
),
cx.expr_call_global(span, fn_read_struct_field_path.clone(), thin_vec![
blkdecoder.clone(),
cx.expr_str(span, name),
cx.expr_usize(span, field),
exprdecode.clone(),
]),
)
});
let result = cx.expr_ok(trait_span, result);
let fn_read_struct_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_struct]);
cx.expr_call_global(
trait_span,
fn_read_struct_path,
thin_vec![
decoder,
cx.expr_str(trait_span, substr.type_ident.name),
cx.expr_usize(trait_span, nfields),
cx.lambda1(trait_span, result, blkarg),
],
)
cx.expr_call_global(trait_span, fn_read_struct_path, thin_vec![
decoder,
cx.expr_str(trait_span, substr.type_ident.name),
cx.expr_usize(trait_span, nfields),
cx.lambda1(trait_span, result, blkarg),
])
}
StaticEnum(_, fields) => {
let variant = Ident::new(sym::i, trait_span);
@ -160,23 +153,19 @@ fn decodable_substructure(
let variant_array_ref = cx.expr_array_ref(trait_span, variants);
let fn_read_enum_variant_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_enum_variant]);
let result = cx.expr_call_global(
trait_span,
fn_read_enum_variant_path,
thin_vec![blkdecoder, variant_array_ref, lambda],
);
let result = cx.expr_call_global(trait_span, fn_read_enum_variant_path, thin_vec![
blkdecoder,
variant_array_ref,
lambda
]);
let fn_read_enum_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Decoder, sym::read_enum]);
cx.expr_call_global(
trait_span,
fn_read_enum_path,
thin_vec![
decoder,
cx.expr_str(trait_span, substr.type_ident.name),
cx.lambda1(trait_span, result, blkarg),
],
)
cx.expr_call_global(trait_span, fn_read_enum_path, thin_vec![
decoder,
cx.expr_str(trait_span, substr.type_ident.name),
cx.lambda1(trait_span, result, blkarg),
])
}
_ => cx.dcx().bug("expected StaticEnum or StaticStruct in derive(Decodable)"),
};

View File

@ -2,12 +2,12 @@
use rustc_ast as ast;
use rustc_ast::visit::visit_opt;
use rustc_ast::{attr, EnumDef, VariantData};
use rustc_ast::{EnumDef, VariantData, attr};
use rustc_expand::base::{Annotatable, DummyResult, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{ErrorGuaranteed, Span};
use smallvec::SmallVec;
use thin_vec::{thin_vec, ThinVec};
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
@ -93,10 +93,10 @@ fn default_enum_substructure(
} {
Ok(default_variant) => {
// We now know there is exactly one unit variant with exactly one `#[default]` attribute.
cx.expr_path(cx.path(
default_variant.span,
vec![Ident::new(kw::SelfUpper, default_variant.span), default_variant.ident],
))
cx.expr_path(cx.path(default_variant.span, vec![
Ident::new(kw::SelfUpper, default_variant.span),
default_variant.ident,
]))
}
Err(guar) => DummyResult::raw_expr(trait_span, Some(guar)),
};

View File

@ -87,9 +87,9 @@
use rustc_ast::{AttrVec, ExprKind, MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Ident, Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::ty::*;
use crate::deriving::generic::*;
@ -116,10 +116,11 @@ pub(crate) fn expand_deriving_rustc_encodable(
methods: vec![MethodDef {
name: sym::encode,
generics: Bounds {
bounds: vec![(
typaram,
vec![Path::new_(vec![krate, sym::Encoder], vec![], PathKind::Global)],
)],
bounds: vec![(typaram, vec![Path::new_(
vec![krate, sym::Encoder],
vec![],
PathKind::Global,
)])],
},
explicit_self: true,
nonself_args: vec![(
@ -157,14 +158,11 @@ fn encodable_substructure(
// throw an underscore in front to suppress unused variable warnings
let blkarg = Ident::new(sym::_e, trait_span);
let blkencoder = cx.expr_ident(trait_span, blkarg);
let fn_path = cx.expr_path(cx.path_global(
trait_span,
vec![
Ident::new(krate, trait_span),
Ident::new(sym::Encodable, trait_span),
Ident::new(sym::encode, trait_span),
],
));
let fn_path = cx.expr_path(cx.path_global(trait_span, vec![
Ident::new(krate, trait_span),
Ident::new(sym::Encodable, trait_span),
Ident::new(sym::encode, trait_span),
]));
match substr.fields {
Struct(_, fields) => {
@ -180,16 +178,12 @@ fn encodable_substructure(
let enc =
cx.expr_call(span, fn_path.clone(), thin_vec![self_ref, blkencoder.clone()]);
let lambda = cx.lambda1(span, enc, blkarg);
let call = cx.expr_call_global(
span,
fn_emit_struct_field_path.clone(),
thin_vec![
blkencoder.clone(),
cx.expr_str(span, name),
cx.expr_usize(span, i),
lambda,
],
);
let call = cx.expr_call_global(span, fn_emit_struct_field_path.clone(), thin_vec![
blkencoder.clone(),
cx.expr_str(span, name),
cx.expr_usize(span, i),
lambda,
]);
// last call doesn't need a try!
let last = fields.len() - 1;
@ -214,16 +208,12 @@ fn encodable_substructure(
let fn_emit_struct_path =
cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_struct]);
let expr = cx.expr_call_global(
trait_span,
fn_emit_struct_path,
thin_vec![
encoder,
cx.expr_str(trait_span, substr.type_ident.name),
cx.expr_usize(trait_span, fields.len()),
blk,
],
);
let expr = cx.expr_call_global(trait_span, fn_emit_struct_path, thin_vec![
encoder,
cx.expr_str(trait_span, substr.type_ident.name),
cx.expr_usize(trait_span, fields.len()),
blk,
]);
BlockOrExpr::new_expr(expr)
}
@ -243,11 +233,8 @@ fn encodable_substructure(
let last = fields.len() - 1;
for (i, &FieldInfo { ref self_expr, span, .. }) in fields.iter().enumerate() {
let self_ref = cx.expr_addr_of(span, self_expr.clone());
let enc = cx.expr_call(
span,
fn_path.clone(),
thin_vec![self_ref, blkencoder.clone()],
);
let enc = cx
.expr_call(span, fn_path.clone(), thin_vec![self_ref, blkencoder.clone()]);
let lambda = cx.lambda1(span, enc, blkarg);
let call = cx.expr_call_global(
@ -274,26 +261,22 @@ fn encodable_substructure(
let fn_emit_enum_variant_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_enum_variant]);
let call = cx.expr_call_global(
trait_span,
fn_emit_enum_variant_path,
thin_vec![
blkencoder,
name,
cx.expr_usize(trait_span, *idx),
cx.expr_usize(trait_span, fields.len()),
blk,
],
);
let call = cx.expr_call_global(trait_span, fn_emit_enum_variant_path, thin_vec![
blkencoder,
name,
cx.expr_usize(trait_span, *idx),
cx.expr_usize(trait_span, fields.len()),
blk,
]);
let blk = cx.lambda1(trait_span, call, blkarg);
let fn_emit_enum_path: Vec<_> =
cx.def_site_path(&[sym::rustc_serialize, sym::Encoder, sym::emit_enum]);
let expr = cx.expr_call_global(
trait_span,
fn_emit_enum_path,
thin_vec![encoder, cx.expr_str(trait_span, substr.type_ident.name), blk],
);
let expr = cx.expr_call_global(trait_span, fn_emit_enum_path, thin_vec![
encoder,
cx.expr_str(trait_span, substr.type_ident.name),
blk
]);
BlockOrExpr::new_mixed(thin_vec![me], Some(expr))
}

View File

@ -178,6 +178,8 @@
use std::ops::Not;
use std::{iter, vec};
pub(crate) use StaticFields::*;
pub(crate) use SubstructureFields::*;
use rustc_ast::ptr::P;
use rustc_ast::{
self as ast, BindingMode, ByRef, EnumDef, Expr, GenericArg, GenericParamKind, Generics,
@ -185,12 +187,10 @@
};
use rustc_attr as attr;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, Span};
use thin_vec::{ThinVec, thin_vec};
use ty::{Bounds, Path, Ref, Self_, Ty};
pub(crate) use StaticFields::*;
pub(crate) use SubstructureFields::*;
use crate::{deriving, errors};
@ -1228,12 +1228,10 @@ fn expand_enum_method_body<'b>(
let discr_let_stmts: ThinVec<_> = iter::zip(&discr_idents, &selflike_args)
.map(|(&ident, selflike_arg)| {
let variant_value = deriving::call_intrinsic(
cx,
span,
sym::discriminant_value,
thin_vec![selflike_arg.clone()],
);
let variant_value =
deriving::call_intrinsic(cx, span, sym::discriminant_value, thin_vec![
selflike_arg.clone()
]);
cx.stmt_let(span, false, ident, variant_value)
})
.collect();

View File

@ -1,14 +1,14 @@
//! A mini version of ast::Ty, which is easier to use, and features an explicit `Self` type to use
//! when specifying impls to be derived.
pub(crate) use Ty::*;
use rustc_ast::ptr::P;
use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind};
use rustc_expand::base::ExtCtxt;
use rustc_span::source_map::respan;
use rustc_span::symbol::{kw, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
use rustc_span::symbol::{Ident, Symbol, kw};
use rustc_span::{DUMMY_SP, Span};
use thin_vec::ThinVec;
pub(crate) use Ty::*;
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
/// for type parameters.

View File

@ -1,7 +1,7 @@
use rustc_ast::{MetaItem, Mutability};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::sym;
use rustc_span::Span;
use rustc_span::symbol::sym;
use thin_vec::thin_vec;
use crate::deriving::generic::ty::*;

View File

@ -4,9 +4,9 @@
use rustc_ast::ptr::P;
use rustc_ast::{GenericArg, MetaItem};
use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, MultiItemModifier};
use rustc_span::symbol::{sym, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Symbol, sym};
use thin_vec::{ThinVec, thin_vec};
macro path_local($x:ident) {
generic::ty::Path::new_local(sym::$x)

View File

@ -1,5 +1,5 @@
use ast::ptr::P;
use ast::HasAttrs;
use ast::ptr::P;
use rustc_ast::mut_visit::MutVisitor;
use rustc_ast::visit::BoundKind;
use rustc_ast::{
@ -9,9 +9,9 @@
use rustc_attr as attr;
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident};
use rustc_span::symbol::{Ident, sym};
use rustc_span::{Span, Symbol};
use thin_vec::{thin_vec, ThinVec};
use thin_vec::{ThinVec, thin_vec};
macro_rules! path {
($span:expr, $($part:ident)::*) => { vec![$(Ident::new(sym::$part, $span),)*] }

View File

@ -3,9 +3,9 @@
use rustc_ast::tokenstream::{DelimSpan, TokenStream};
use rustc_ast::*;
use rustc_expand::base::*;
use rustc_span::Span;
use rustc_span::edition::Edition;
use rustc_span::symbol::sym;
use rustc_span::Span;
/// This expands to either
/// - `$crate::panic::panic_2015!(...)` or

View File

@ -10,8 +10,8 @@
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{AstDeref, ExprKind, GenericArg, Mutability};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacEager, MacroExpanderResult};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span;
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use thin_vec::thin_vec;
use crate::errors;
@ -58,11 +58,11 @@ pub(crate) fn expand_option_env<'cx>(
))],
))
}
Some(value) => cx.expr_call_global(
sp,
cx.std_path(&[sym::option, sym::Option, sym::Some]),
thin_vec![cx.expr_str(sp, value)],
),
Some(value) => {
cx.expr_call_global(sp, cx.std_path(&[sym::option, sym::Option, sym::Some]), thin_vec![
cx.expr_str(sp, value)
])
}
};
ExpandResult::Ready(MacEager::expr(e))
}

View File

@ -2,9 +2,10 @@
use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{
token, Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs,
Expr, ExprKind, FormatAlignment, FormatArgPosition, FormatArgPositionKind, FormatArgs,
FormatArgsPiece, FormatArgument, FormatArgumentKind, FormatArguments, FormatCount,
FormatDebugHex, FormatOptions, FormatPlaceholder, FormatSign, FormatTrait, Recovered, StmtKind,
token,
};
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{Applicability, Diag, MultiSpan, PResult, SingleLabelManySpans};

View File

@ -183,14 +183,10 @@ pub(crate) fn translate(&self) -> Result<String, Option<String>> {
s.push('{');
if let Some(arg) = self.parameter {
match write!(
s,
"{}",
match arg.checked_sub(1) {
Some(a) => a,
None => return Err(None),
}
) {
match write!(s, "{}", match arg.checked_sub(1) {
Some(a) => a,
None => return Err(None),
}) {
Err(_) => return Err(None),
_ => {}
}

View File

@ -1,4 +1,4 @@
use super::{iter_subs, parse_next_substitution as pns, Format as F, Num as N, Substitution as S};
use super::{Format as F, Num as N, Substitution as S, iter_subs, parse_next_substitution as pns};
macro_rules! assert_eq_pnsat {
($lhs:expr, $rhs:expr) => {
@ -99,10 +99,12 @@ macro_rules! assert_pns_eq_sub {
fn test_iter() {
let s = "The %d'th word %% is: `%.*s` %!\n";
let subs: Vec<_> = iter_subs(s, 0).map(|sub| sub.translate().ok()).collect();
assert_eq!(
subs.iter().map(Option::as_deref).collect::<Vec<_>>(),
vec![Some("{}"), None, Some("{:.*}"), None]
);
assert_eq!(subs.iter().map(Option::as_deref).collect::<Vec<_>>(), vec![
Some("{}"),
None,
Some("{:.*}"),
None
]);
}
/// Checks that the translations are what we expect.

View File

@ -1,4 +1,4 @@
use super::{parse_next_substitution as pns, Substitution as S};
use super::{Substitution as S, parse_next_substitution as pns};
macro_rules! assert_eq_pnsat {
($lhs:expr, $rhs:expr) => {
@ -38,10 +38,11 @@ fn test_iter() {
use super::iter_subs;
let s = "The $0'th word $$ is: `$WORD` $!\n";
let subs: Vec<_> = iter_subs(s, 0).map(|sub| sub.translate().ok()).collect();
assert_eq!(
subs.iter().map(Option::as_deref).collect::<Vec<_>>(),
vec![Some("{0}"), None, Some("{WORD}")]
);
assert_eq!(subs.iter().map(Option::as_deref).collect::<Vec<_>>(), vec![
Some("{0}"),
None,
Some("{WORD}")
]);
}
#[test]

View File

@ -1,5 +1,5 @@
use rustc_ast::expand::allocator::{
global_fn_name, AllocatorMethod, AllocatorMethodInput, AllocatorTy, ALLOCATOR_METHODS,
ALLOCATOR_METHODS, AllocatorMethod, AllocatorMethodInput, AllocatorTy, global_fn_name,
};
use rustc_ast::ptr::P;
use rustc_ast::{
@ -7,9 +7,9 @@
Stmt, StmtKind, Ty, TyKind,
};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::Span;
use thin_vec::{thin_vec, ThinVec};
use rustc_span::symbol::{Ident, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};
use crate::errors;
use crate::util::check_builtin_macro_attribute;

View File

@ -1,9 +1,9 @@
use rustc_ast::ptr::P;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{ast, Pat, Ty};
use rustc_ast::{Pat, Ty, ast};
use rustc_errors::PResult;
use rustc_expand::base::{self, DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
use rustc_span::{sym, Span};
use rustc_span::{Span, sym};
pub(crate) fn expand<'cx>(
cx: &'cx mut ExtCtxt<'_>,

Some files were not shown because too many files have changed in this diff Show More