]> git.lizzy.rs Git - rust.git/log
rust.git
23 months agouse `pluralize!`
Takayuki Maeda [Wed, 27 Jul 2022 01:09:06 +0000 (10:09 +0900)]
use `pluralize!`

23 months agoAuto merge of #99603 - fasterthanlime:ra-subtree-2, r=jyn514
bors [Sun, 24 Jul 2022 21:36:31 +0000 (21:36 +0000)]
Auto merge of #99603 - fasterthanlime:ra-subtree-2, r=jyn514

Convert rust-analyzer to an in-tree tool

This re-adds `rust-lang/rust-analyzer` as a git subtree rather than a submodule.

Closes https://github.com/rust-lang/rust-analyzer/issues/12815.

Prior attempt (research PR): https://github.com/rust-lang/rust/pull/99465

  * [x] Remove submodule: `git rm -f src/tools/rust-analyzer`
  * [x] Add subtree: `git subtree add -P src/tools/rust-analyzer https://github.com/rust-lang/rust-analyzer.git master`
  * [x] Move to `SourceType::InTree`,
  * [x] Enable `rust-analyzer/in-rust-tree` feature when built through `x.py`
  * [x] Add 'check' step
  * [x] Add 'test' step

With this PR, rust-analyzer becomes an "in-tree" tool. Syncs can happen in both directions, see [clippy's relevant book section](https://doc.rust-lang.org/nightly/clippy/development/infrastructure/sync.html).

Making sure `proc-macro-srv` doesn't break when the proc_macro bridge changes effectively becomes the responsibility of `rust-lang/rust` contributors. These days, that's mostly `@mystor,` who has been consulted throughout the process. I'm also making myself available in case there's questions / work needed that nobody else signed up for.

This doesn't change rust-analyzer's release cycle. After this PR is merged and the next nightly goes out, one can point `rust-analyzer.procMacro.server` to the rustup-provided `rust-analyzer` binary. Changes to improve the situation further (auto-discovery/install of the rust-analyzer component) will happen in `rust-lang/rust-analyzer` and be synced here eventually.

23 months agoOnly run proc-macro-srv tests for now (after discussion with @Veykril, @jyn514, and...
Amos Wenger [Sun, 24 Jul 2022 19:04:56 +0000 (21:04 +0200)]
Only run proc-macro-srv tests for now (after discussion with @Veykril, @jyn514, and @lnicola)

23 months agoAuto merge of #99687 - RalfJung:rollup-bojacrc, r=RalfJung
bors [Sun, 24 Jul 2022 18:55:31 +0000 (18:55 +0000)]
Auto merge of #99687 - RalfJung:rollup-bojacrc, r=RalfJung

Rollup of 4 pull requests

Successful merges:

 - #99644 (remove some provenance-related machine hooks that Miri no longer needs)
 - #99657 (Docs - remove unnecessary `mut` that gives a warning)
 - #99672 (Remove Clean trait implementation for more items)
 - #99678 (Update doc comments that refer to config parameter)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoRollup merge of #99678 - danbev:rustc_parse-config-doc-comments, r=cjgillot
Ralf Jung [Sun, 24 Jul 2022 18:04:29 +0000 (14:04 -0400)]
Rollup merge of #99678 - danbev:rustc_parse-config-doc-comments, r=cjgillot

Update doc comments that refer to config parameter

This commit updates the `source_file_to_parser` and the
`maybe_source_file_to_parse` function's doc comments which currently
refer to a `config` parameter. The doc comments have been updated to
refer to the `session` parameter similar to the doc comment for
`try_file_to_source_file`, which also takes a `&Session` parameter.

23 months agoRollup merge of #99672 - GuillaumeGomez:clean-trait-removal, r=Dylan-DPC
Ralf Jung [Sun, 24 Jul 2022 18:04:28 +0000 (14:04 -0400)]
Rollup merge of #99672 - GuillaumeGomez:clean-trait-removal, r=Dylan-DPC

Remove Clean trait implementation for more items

Follow up of #99638.

cc `@camelid`
r? `@notriddle`

23 months agoRollup merge of #99657 - Phosra:patch-1, r=Dylan-DPC
Ralf Jung [Sun, 24 Jul 2022 18:04:27 +0000 (14:04 -0400)]
Rollup merge of #99657 - Phosra:patch-1, r=Dylan-DPC

Docs - remove unnecessary `mut` that gives a warning

Fixes #99654.

A trivial linting fix for a Stdio example.

`@rustbot` label +T-lib

23 months agoRollup merge of #99644 - RalfJung:interpret-int-ptr-transmute, r=oli-obk
Ralf Jung [Sun, 24 Jul 2022 18:04:26 +0000 (14:04 -0400)]
Rollup merge of #99644 - RalfJung:interpret-int-ptr-transmute, r=oli-obk

remove some provenance-related machine hooks that Miri no longer needs

Then we can make `scalar_to_ptr` a method on `Scalar`. :)

Fixes https://github.com/rust-lang/miri/issues/2188
r? `@oli-obk`

23 months agoAuto merge of #99409 - tmiasko:atomic-tests, r=m-ou-se
bors [Sun, 24 Jul 2022 16:26:56 +0000 (16:26 +0000)]
Auto merge of #99409 - tmiasko:atomic-tests, r=m-ou-se

Test codegen of atomic compare-exchange with additional memory orderings

* Add a test for atomic operations introduced in #97423 & #98383.
* Add a test for fallback code generation strategy used on LLVM 12 introduced in #98385. Use a separate test case instead of a revision system since test will be gone once LLVM 12 is no longer supported.

23 months agoMake macros test order-resistant
Amos Wenger [Sun, 24 Jul 2022 14:48:06 +0000 (16:48 +0200)]
Make macros test order-resistant

23 months agoUpdate doc comments that refer to config parameter
Daniel Bevenius [Sun, 24 Jul 2022 14:09:04 +0000 (16:09 +0200)]
Update doc comments that refer to config parameter

This commit updates the source_file_to_parser and the
maybe_source_file_to_parse function's doc comments which currently
refer to a config parameter. The doc comments have been updated to
refer to the 'session' parameter similar to the doc comment for
try_file_to_source_file, which also takes a &Session parameter.

23 months agoSort when iterating through CrateGraph
Amos Wenger [Sun, 24 Jul 2022 14:11:05 +0000 (16:11 +0200)]
Sort when iterating through CrateGraph

23 months agoSort in DefMap::dump, since HashMap iteration order isn't defined
Amos Wenger [Sun, 24 Jul 2022 14:04:20 +0000 (16:04 +0200)]
Sort in DefMap::dump, since HashMap iteration order isn't defined

23 months agohir-def tests: sort results before comparing, since FxHashSet iteration order isn...
Amos Wenger [Sun, 24 Jul 2022 13:55:20 +0000 (15:55 +0200)]
hir-def tests: sort results before comparing, since FxHashSet iteration order isn't guaranteed

(And, in fact, it failed on i686)

23 months agoAuto merge of #99670 - Amanieu:revert-99595, r=nikic
bors [Sun, 24 Jul 2022 13:46:15 +0000 (13:46 +0000)]
Auto merge of #99670 - Amanieu:revert-99595, r=nikic

Revert "Mark atomics as unsupported on thumbv6m"

This is a breaking change for the `thumbv6m` target. See #99668 for discussion on how we can proceed forward from here.

This reverts commit 75146102197c7f35e6c38cb402b2bc1065858c54.

cc `@nikic`

23 months agoRemove Clean trait implementation for Constant
Guillaume Gomez [Sun, 24 Jul 2022 13:08:24 +0000 (15:08 +0200)]
Remove Clean trait implementation for Constant

23 months agoRemove Clean trait implementation for FieldDef
Guillaume Gomez [Sun, 24 Jul 2022 12:58:10 +0000 (14:58 +0200)]
Remove Clean trait implementation for FieldDef

23 months agoRevert "Mark atomics as unsupported on thumbv6m"
Amanieu d'Antras [Sun, 24 Jul 2022 12:12:08 +0000 (13:12 +0100)]
Revert "Mark atomics as unsupported on thumbv6m"

This reverts commit 75146102197c7f35e6c38cb402b2bc1065858c54.

23 months agoFix .gitattributes for test_data
Amos Wenger [Sun, 24 Jul 2022 12:05:35 +0000 (14:05 +0200)]
Fix .gitattributes for test_data

23 months agoAuto merge of #93429 - fee1-dead-contrib:allow-super-trait-tilde-const, r=oli-obk
bors [Sun, 24 Jul 2022 09:16:02 +0000 (09:16 +0000)]
Auto merge of #93429 - fee1-dead-contrib:allow-super-trait-tilde-const, r=oli-obk

Allow `trait A: ~const B`

What's included: a minimal working change set for `~const` supertraits to work.

r? `@oli-obk`

23 months agoSmall fixups
Joshua Nelson [Sat, 23 Jul 2022 20:37:46 +0000 (15:37 -0500)]
Small fixups

- use `path` instead of `paths`
- don't mark rust-analyzer as an optional tool
- print the cargo command that's run in the proc-macro-test build script

  this originally was part of a change to fix `test --stage 0 rust-analyzer`,
  but I'm going to leave that for a separate PR so it's easier to review.

23 months agoMove cfg attrs up to the mod definitions to disable sourcegen
Amos Wenger [Sat, 23 Jul 2022 15:23:13 +0000 (17:23 +0200)]
Move cfg attrs up to the mod definitions to disable sourcegen

23 months agoDisable all source-gen tests at compile time
Amos Wenger [Sat, 23 Jul 2022 00:06:11 +0000 (02:06 +0200)]
Disable all source-gen tests at compile time

23 months agoDon't run slow tests in Rust CI, only RA CI
Amos Wenger [Fri, 22 Jul 2022 16:16:46 +0000 (18:16 +0200)]
Don't run slow tests in Rust CI, only RA CI

23 months agoAdd comment about CARGO_WORKSPACE_DIR
Amos Wenger [Fri, 22 Jul 2022 16:06:38 +0000 (18:06 +0200)]
Add comment about CARGO_WORKSPACE_DIR

23 months agoUse top-level path in tool Step
Amos Wenger [Fri, 22 Jul 2022 16:03:04 +0000 (18:03 +0200)]
Use top-level path in tool Step

23 months agoAllow cross-compiling, build all crates
Amos Wenger [Fri, 22 Jul 2022 16:01:49 +0000 (18:01 +0200)]
Allow cross-compiling, build all crates

23 months agoUse compiler.stage
Amos Wenger [Fri, 22 Jul 2022 15:59:15 +0000 (17:59 +0200)]
Use compiler.stage

Co-authored-by: Joshua Nelson <github@jyn.dev>
23 months agoAdd test step for rust-analyzer, run it by default
Amos Wenger [Fri, 22 Jul 2022 15:21:33 +0000 (17:21 +0200)]
Add test step for rust-analyzer, run it by default

23 months agoCheck only tests and benches, not examples
Amos Wenger [Fri, 22 Jul 2022 14:38:05 +0000 (16:38 +0200)]
Check only tests and benches, not examples

23 months agoAdd check step, stuck on 'no output generated for libgoto_def-hash rmeta'
Amos Wenger [Fri, 22 Jul 2022 14:23:40 +0000 (16:23 +0200)]
Add check step, stuck on 'no output generated for libgoto_def-hash rmeta'

23 months agoConvert rust-analyzer to 'in-tree' tool, pass 'in-rust-tree' feature by default
Amos Wenger [Fri, 22 Jul 2022 13:38:45 +0000 (15:38 +0200)]
Convert rust-analyzer to 'in-tree' tool, pass 'in-rust-tree' feature by default

23 months agoAdd 'src/tools/rust-analyzer/' from commit '977e12a0bdc3e329af179ef3a9d466af9eb613bb'
Amos Wenger [Sun, 24 Jul 2022 08:37:08 +0000 (10:37 +0200)]
Add 'src/tools/rust-analyzer/' from commit '977e12a0bdc3e329af179ef3a9d466af9eb613bb'

git-subtree-dir: src/tools/rust-analyzer
git-subtree-mainline: 3c98486a0cdb6d92f0fca34ffb1fd46c0e498653
git-subtree-split: 977e12a0bdc3e329af179ef3a9d466af9eb613bb

23 months agoRemove rust-analyzer submodule
Amos Wenger [Sun, 24 Jul 2022 08:36:44 +0000 (10:36 +0200)]
Remove rust-analyzer submodule

23 months agoInstantiate constness in wfcheck
Deadbeef [Sat, 23 Jul 2022 14:25:32 +0000 (14:25 +0000)]
Instantiate constness in wfcheck

23 months agoAuto merge of #98674 - RalfJung:miri-stacktrace-pruning, r=Mark-Simulacrum
bors [Sun, 24 Jul 2022 06:46:46 +0000 (06:46 +0000)]
Auto merge of #98674 - RalfJung:miri-stacktrace-pruning, r=Mark-Simulacrum

miri: prune some atomic operation and raw pointer details from stacktrace

Since Miri removes `track_caller` frames from the stacktrace, adding that attribute can help make backtraces more readable (similar to how it makes panic locations better). I made them only show up with `cfg(miri)` to make sure the extra arguments induced by `track_caller` do not cause any runtime performance trouble.

This is also testing the waters for whether the libs team is okay with having these attributes in their code, or whether you'd prefer if we find some other way to do this. If you are fine with this, we will probably want to add it to a lot more functions (all the other atomic operations, to start).

Before:
```
error: Undefined Behavior: Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1) at alloc1727 (current vector clock = VClock([9, 0, 6]), conflicting timestamp = VClock([0, 6]))
    --> /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2594:23
     |
2594 |             SeqCst => intrinsics::atomic_load_seqcst(dst),
     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1) at alloc1727 (current vector clock = VClock([9, 0, 6]), conflicting timestamp = VClock([0, 6]))
     |
     = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
     = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

     = note: inside `std::sync::atomic::atomic_load::<usize>` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2594:23
     = note: inside `std::sync::atomic::AtomicUsize::load` at /home/r/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:1719:26
note: inside closure at ../miri/tests/fail/data_race/atomic_read_na_write_race1.rs:22:13
    --> ../miri/tests/fail/data_race/atomic_read_na_write_race1.rs:22:13
     |
22   |             (&*c.0).load(Ordering::SeqCst)
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

After:
```
error: Undefined Behavior: Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1) at alloc1727 (current vector clock = VClock([9, 0, 6]), conflicting timestamp = VClock([0, 6]))
  --> tests/fail/data_race/atomic_read_na_write_race1.rs:22:13
   |
22 |             (&*c.0).load(Ordering::SeqCst)
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on Thread(id = 2) and Write on Thread(id = 1) at alloc1727 (current vector clock = VClock([9, 0, 6]), conflicting timestamp = VClock([0, 6]))
   |
   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

   = note: inside closure at tests/fail/data_race/atomic_read_na_write_race1.rs:22:13
```

23 months agoRemove `mut`
Phosra [Sun, 24 Jul 2022 04:22:43 +0000 (21:22 -0700)]
Remove `mut`

23 months agoAuto merge of #99251 - cuviper:hashbrown-0.12, r=Mark-Simulacrum
bors [Sun, 24 Jul 2022 04:03:29 +0000 (04:03 +0000)]
Auto merge of #99251 - cuviper:hashbrown-0.12, r=Mark-Simulacrum

Upgrade indexmap and thorin-dwp to use hashbrown 0.12

This removes the last dependencies on hashbrown 0.11.

This also upgrades to hashbrown 0.12.3 to fix a double-free (#99372).

23 months agoAuto merge of #95548 - rcvalle:rust-cfi-2, r=nagisa
bors [Sun, 24 Jul 2022 01:22:36 +0000 (01:22 +0000)]
Auto merge of #95548 - rcvalle:rust-cfi-2, r=nagisa

Add fine-grained LLVM CFI support to the Rust compiler

This PR improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types.

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue https://github.com/rust-lang/rust/issues/89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).

Thank you again, `@eddyb,` `@nagisa,` `@pcc,` and `@tmiasko` for all the help!

23 months agoAuto merge of #99652 - GuillaumeGomez:rollup-38v0x7y, r=GuillaumeGomez
bors [Sat, 23 Jul 2022 22:41:48 +0000 (22:41 +0000)]
Auto merge of #99652 - GuillaumeGomez:rollup-38v0x7y, r=GuillaumeGomez

Rollup of 6 pull requests

Successful merges:

 - #99298 (Make `ui-fulldeps/gated-plugins` and `ui-fulldeps/multiple-plugins` tests stage 2 only)
 - #99396 (Add some additional double-adjustment regression tests)
 - #99449 (Do not resolve associated const when there is no provided value)
 - #99595 (Mark atomics as unsupported on thumbv6m)
 - #99627 (Lock stdout once when listing tests)
 - #99638 (Remove Clean trait implementation for hir::Ty and middle::Ty)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoAuto merge of #12859 - matklad:dont-color-the-whole-block-red-all-the-time-please...
bors [Sat, 23 Jul 2022 21:37:32 +0000 (21:37 +0000)]
Auto merge of #12859 - matklad:dont-color-the-whole-block-red-all-the-time-please, r=Veykril

feat: don't highlight the whole fn on return-type mismatch

23 months agoRollup merge of #99638 - GuillaumeGomez:rm-clean-trait, r=notriddle
Guillaume Gomez [Sat, 23 Jul 2022 21:34:32 +0000 (23:34 +0200)]
Rollup merge of #99638 - GuillaumeGomez:rm-clean-trait, r=notriddle

Remove Clean trait implementation for hir::Ty and middle::Ty

While going through the code, I realized that the "remove the Clean trait" effort which was started a while ago was never finished.

The idea behind it was to make it much simpler to go through the different clean steps (which is definitely not easy when you just have `something.clean(cx)`).

I'm planning to finish this effort.

cc ``@camelid``
r? ``@notriddle``

23 months agoRollup merge of #99627 - saethlin:lock-once, r=eddyb
Guillaume Gomez [Sat, 23 Jul 2022 21:34:31 +0000 (23:34 +0200)]
Rollup merge of #99627 - saethlin:lock-once, r=eddyb

Lock stdout once when listing tests

This is a marginal optimization for normal operation, but for `cargo miri nextest list` (which is invoked by `cargo miri nextest run`) this knocks the startup time on `regex` down from 87 seconds to 17 seconds. Still slow, but a nice 5x improvement.

23 months agoRollup merge of #99595 - nikic:thumbv6m-atomics, r=nagisa
Guillaume Gomez [Sat, 23 Jul 2022 21:34:31 +0000 (23:34 +0200)]
Rollup merge of #99595 - nikic:thumbv6m-atomics, r=nagisa

Mark atomics as unsupported on thumbv6m

The thumbv6m target does not support atomics. Historically, LLVM
had a bug where atomic load/stores for this target were emitted
as plain load/stores rather than as libatomic calls. This was
fixed in https://reviews.llvm.org/D120026, which will be part of
LLVM 15. As we require that "atomic support" does not use libatomic,
we need to indicate that this target does not have native atomics.

23 months agoRollup merge of #99449 - compiler-errors:assoc-const-missing-item, r=lcnr
Guillaume Gomez [Sat, 23 Jul 2022 21:34:30 +0000 (23:34 +0200)]
Rollup merge of #99449 - compiler-errors:assoc-const-missing-item, r=lcnr

Do not resolve associated const when there is no provided value

Fixes #98629, since now we just delay a bug when we're not able to evaluate a const item due to the value not actually being provided by anything. This means compilation proceeds forward to where the "missing item in impl" error is emitted.

----

The root issue here is that when we're looking for the defining `LeafDef` in `resolve_associated_item`, we end up getting the trait's AssocItem instead of the impl's AssocItem (which does not exist). This resolution "succeeds" even if the trait's item has no default value, and then since this item has no value to evaluate, it turns into a const eval error.

This root issue becomes problematic (as in #98629) when this const eval error happens in wfcheck (for example, due to normalizing the param-env of something that references this const). Since this happens sooner than the check that an impl actually provides all of the items that a trait requires (which happens during later typecheck), we end up aborting compilation early with only this un-informative message.

I'm not exactly sure _why_ this bug arises due to #96591 -- perhaps valtrees are evaluated more eagerly than in the old system?

r? ``@oli-obk`` or ``@lcnr`` since y'all are familiar with const eval and reviewed #96591, though feel free to reassign.

This is a regression from stable to beta, so I would be open to considering this for beta backport. It seems correct to me, especially given the improvements in the other UI tests this PR touches, but may have some side-effects that I'm unaware of...?

23 months agoRollup merge of #99396 - compiler-errors:missing-tests, r=Mark-Simulacrum
Guillaume Gomez [Sat, 23 Jul 2022 21:34:29 +0000 (23:34 +0200)]
Rollup merge of #99396 - compiler-errors:missing-tests, r=Mark-Simulacrum

Add some additional double-adjustment regression tests

I accidentally missed these when I rebased #98785

cc #98894 and #98897

23 months agoRollup merge of #99298 - ChrisDenton:ignore-plugins-stage1, r=Mark-Simulacrum
Guillaume Gomez [Sat, 23 Jul 2022 21:34:28 +0000 (23:34 +0200)]
Rollup merge of #99298 - ChrisDenton:ignore-plugins-stage1, r=Mark-Simulacrum

Make `ui-fulldeps/gated-plugins` and `ui-fulldeps/multiple-plugins` tests stage 2 only

These test can fail on stage 1.

Fixes #99295

23 months agointernal: extract common code for adjusting diagnostic range
Aleksey Kladov [Sat, 23 Jul 2022 21:16:36 +0000 (22:16 +0100)]
internal: extract common code for adjusting diagnostic range

23 months agofeat: don't highlight the whole fn on return-type mismatch
Aleksey Kladov [Sat, 23 Jul 2022 20:16:59 +0000 (21:16 +0100)]
feat: don't highlight the whole fn on return-type mismatch

23 months agoAuto merge of #98208 - ivanloz:master, r=nagisa
bors [Sat, 23 Jul 2022 20:01:07 +0000 (20:01 +0000)]
Auto merge of #98208 - ivanloz:master, r=nagisa

Add support for LLVM ShadowCallStack.

LLVMs ShadowCallStack provides backward edge control flow integrity protection by using a separate shadow stack to store and retrieve a function's return address.

LLVM currently only supports this for AArch64 targets. The x18 register is used to hold the pointer to the shadow stack, and therefore this only works on ABIs which reserve x18. Further details are available in the [LLVM ShadowCallStack](https://clang.llvm.org/docs/ShadowCallStack.html) docs.

# Usage
`-Zsanitizer=shadow-call-stack`

# Comments/Caveats
* Currently only enabled for the aarch64-linux-android target
* Requires the platform to define a runtime to initialize the shadow stack, see the [LLVM docs](https://clang.llvm.org/docs/ShadowCallStack.html) for more detail.

23 months agoUpdate documentation for LLVM CFI support
Ramon de C Valle [Fri, 1 Apr 2022 05:51:37 +0000 (22:51 -0700)]
Update documentation for LLVM CFI support

This commit updates the documentation for the LLVM Control Flow
Integrity (CFI) support in the Rust compiler (see #95548 and #89653).

23 months agoAdd fine-grained LLVM CFI support to the Rust compiler
Ramon de C Valle [Fri, 1 Apr 2022 05:50:41 +0000 (22:50 -0700)]
Add fine-grained LLVM CFI support to the Rust compiler

This commit improves the LLVM Control Flow Integrity (CFI) support in
the Rust compiler by providing forward-edge control flow protection for
Rust-compiled code only by aggregating function pointers in groups
identified by their return and parameter types.

Forward-edge control flow protection for C or C++ and Rust -compiled
code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code
share the same virtual address space) will be provided in later work as
part of this project by identifying C char and integer type uses at the
time types are encoded (see Type metadata in the design document in the
tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e.,
-Clto).

23 months agoAuto merge of #12851 - DorianListens:dscheidt/if-completion-match-guard, r=Veykril
bors [Sat, 23 Jul 2022 17:42:59 +0000 (17:42 +0000)]
Auto merge of #12851 - DorianListens:dscheidt/if-completion-match-guard, r=Veykril

fix: Don't add braces to 'if' completion in match guard position

fixes #12823

Is this what you were thinking of here, `@Veykril` ? I haven't done any work on completions before, so I could definitely be misunderstanding the issue.

23 months agofix: Don't add braces to 'if' completion in match guard position
Dorian Scheidt [Sat, 23 Jul 2022 00:06:14 +0000 (19:06 -0500)]
fix: Don't add braces to 'if' completion in match guard position

When the cursor is in a match arm, but before the fat arrow (=>) token, don't
add braces when autocompleting "if".

fixes #12823

23 months agoAuto merge of #98471 - wesleywiser:update_measureme, r=Mark-Simulacrum
bors [Sat, 23 Jul 2022 16:14:40 +0000 (16:14 +0000)]
Auto merge of #98471 - wesleywiser:update_measureme, r=Mark-Simulacrum

Update measureme to the latest version

23 months agoAuto merge of #12854 - RalfJung:generate_new, r=Veykril
bors [Sat, 23 Jul 2022 15:18:48 +0000 (15:18 +0000)]
Auto merge of #12854 - RalfJung:generate_new, r=Veykril

fix generate_new doc

Looks like this got copied from `generate_impl` without adjusting the description.

23 months agofix generate_new doc
Ralf Jung [Sat, 23 Jul 2022 15:09:01 +0000 (11:09 -0400)]
fix generate_new doc

23 months agonow we can make scalar_to_ptr a method on Scalar
Ralf Jung [Sat, 23 Jul 2022 14:36:57 +0000 (10:36 -0400)]
now we can make scalar_to_ptr a method on Scalar

23 months agoAdd tests
Deadbeef [Fri, 28 Jan 2022 14:49:15 +0000 (01:49 +1100)]
Add tests

23 months agoRemap elaborated obligation constness
Deadbeef [Fri, 28 Jan 2022 14:47:58 +0000 (01:47 +1100)]
Remap elaborated obligation constness

23 months agoAllow `~const` on super traits
Deadbeef [Fri, 28 Jan 2022 14:47:20 +0000 (01:47 +1100)]
Allow `~const` on super traits

23 months agoremove some provenance-related machine hooks that Miri no longer needs
Ralf Jung [Sat, 23 Jul 2022 14:15:37 +0000 (10:15 -0400)]
remove some provenance-related machine hooks that Miri no longer needs

23 months agoAuto merge of #97925 - the8472:cgroupv1, r=joshtriplett
bors [Sat, 23 Jul 2022 13:33:56 +0000 (13:33 +0000)]
Auto merge of #97925 - the8472:cgroupv1, r=joshtriplett

Add cgroupv1 support to available_parallelism

Fixes #97549

My dev machine uses cgroup v2 so I was only able to test that code path. So the v1 code path is written only based on documentation. I could use some help testing that it works on a machine with cgroups v1:

```
$ x.py build --stage 1

# quota.rs
fn main() {
    println!("{:?}", std::thread::available_parallelism());
}

# assuming stage1 is linked in rustup
$ rust +stage1 quota.rs

# spawn a new cgroup scope for the current user
$ sudo systemd-run -p CPUQuota="300%" --uid=$(id -u) -tdS

# should print Ok(3)
$ ./quota
```

If it doesn't work as expected an strace, the contents of `/proc/self/cgroups` and the structure of `/sys/fs/cgroups` would help.

23 months agoRemove Clean trait implementation for hir::Ty and middle::Ty
Guillaume Gomez [Sat, 23 Jul 2022 12:56:58 +0000 (14:56 +0200)]
Remove Clean trait implementation for hir::Ty and middle::Ty

23 months agoAuto merge of #99636 - matthiaskrgr:rollup-yg0xxkx, r=matthiaskrgr
bors [Sat, 23 Jul 2022 10:40:41 +0000 (10:40 +0000)]
Auto merge of #99636 - matthiaskrgr:rollup-yg0xxkx, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - #99580 (Don't suggest unnameable generic arguments)
 - #99617 (Update mdbook)
 - #99631 (Use span_bug in case of unexpected rib kind)
 - #99632 (Fix typo/grammar in locator.rs doc comment)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoRollup merge of #99632 - danbev:locator.rs-typo, r=Dylan-DPC
Matthias Krüger [Sat, 23 Jul 2022 10:08:14 +0000 (12:08 +0200)]
Rollup merge of #99632 - danbev:locator.rs-typo, r=Dylan-DPC

Fix typo/grammar in locator.rs doc comment

23 months agoRollup merge of #99631 - jmqd:master, r=oli-obk
Matthias Krüger [Sat, 23 Jul 2022 10:08:13 +0000 (12:08 +0200)]
Rollup merge of #99631 - jmqd:master, r=oli-obk

Use span_bug in case of unexpected rib kind

Extremely minor QOL change to improve the ICE compiler output in case
this default match case is encountered (an unexpected rib kind).

I have limited experience in this area of the compiler; please let me know
if a span more precise than `param.ident.span` is more applicable.

23 months agoRollup merge of #99617 - ehuss:update-mdbook, r=Dylan-DPC
Matthias Krüger [Sat, 23 Jul 2022 10:08:12 +0000 (12:08 +0200)]
Rollup merge of #99617 - ehuss:update-mdbook, r=Dylan-DPC

Update mdbook

This updates mdbook from 0.4.20 to 0.4.21
Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0421

This contains a single fix that prevents mdbook from compiling on nightly (due to #99413). This will be necessary to keep everything working after the next master bootstrap switch.

23 months agoRollup merge of #99580 - fmease:fix-issue-99565, r=estebank
Matthias Krüger [Sat, 23 Jul 2022 10:08:11 +0000 (12:08 +0200)]
Rollup merge of #99580 - fmease:fix-issue-99565, r=estebank

Don't suggest unnameable generic arguments

Fixes #99565.

`@rustbot` label T-compiler A-diagnostics
r? `@rust-lang/wg-diagnostics`

23 months agoAuto merge of #99320 - NiklasJonsson:84447/rustc_expand, r=compiler-errors
bors [Sat, 23 Jul 2022 07:59:54 +0000 (07:59 +0000)]
Auto merge of #99320 - NiklasJonsson:84447/rustc_expand, r=compiler-errors

rustc_expand: Switch FxHashMap to FxIndexMap where iteration is used

Relates #84447

23 months agoFix typo/grammar in locator.rs doc comment
Daniel Bevenius [Sat, 23 Jul 2022 05:31:20 +0000 (07:31 +0200)]
Fix typo/grammar in locator.rs doc comment

23 months agoAuto merge of #99599 - RalfJung:miri-stage-0, r=RalfJung
bors [Sat, 23 Jul 2022 05:28:35 +0000 (05:28 +0000)]
Auto merge of #99599 - RalfJung:miri-stage-0, r=RalfJung

miri: make --stage 0 testing work

This needs https://github.com/rust-lang/miri/pull/2415 or it'll break Miri entirely.

also fixes https://github.com/rust-lang/rust/issues/99589

23 months agoUse span_bug in case of unexpected rib kind
Jordan McQueen [Sat, 23 Jul 2022 04:26:45 +0000 (13:26 +0900)]
Use span_bug in case of unexpected rib kind

Extremely minor QOL change to improve the ICE output in case this
default match case is encountered (an unexpected rib kind).

23 months agoAuto merge of #93397 - joshtriplett:sort-floats, r=Amanieu
bors [Sat, 23 Jul 2022 02:47:54 +0000 (02:47 +0000)]
Auto merge of #93397 - joshtriplett:sort-floats, r=Amanieu

Add `[f32]::sort_floats` and `[f64]::sort_floats`

It's inconvenient to sort a slice or Vec of floats, compared to sorting integers. To simplify numeric code, add a convenience method to `[f32]` and `[f64]` to sort them using `sort_unstable_by` with `total_cmp`.

23 months agoAuto merge of #99623 - RalfJung:rollup-0h066kc, r=RalfJung
bors [Sat, 23 Jul 2022 00:01:19 +0000 (00:01 +0000)]
Auto merge of #99623 - RalfJung:rollup-0h066kc, r=RalfJung

Rollup of 3 pull requests

Successful merges:

 - #99588 (Update books)
 - #99602 (cargotest: do not run quickcheck tests in xsv)
 - #99607 (interpret: fix vtable check debug assertion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

23 months agoAuto merge of #12849 - Veykril:no-parse, r=Veykril
bors [Fri, 22 Jul 2022 23:00:35 +0000 (23:00 +0000)]
Auto merge of #12849 - Veykril:no-parse, r=Veykril

internal: Don't parse files unnecessarily in scope_for_offset

23 months agoAuto merge of #12850 - Veykril:display-fix, r=Veykril
bors [Fri, 22 Jul 2022 22:52:53 +0000 (22:52 +0000)]
Auto merge of #12850 - Veykril:display-fix, r=Veykril

fix: Fix error tooltip message for VSCode status bar item

23 months agofix: Fix error tooltip message for VSCode status bar item
Lukas Wirth [Fri, 22 Jul 2022 22:52:12 +0000 (00:52 +0200)]
fix: Fix error tooltip message for VSCode status bar item

23 months agointernal: Don't parse files unnecessarily in scope_for_offset
Lukas Wirth [Fri, 22 Jul 2022 22:50:59 +0000 (00:50 +0200)]
internal: Don't parse files unnecessarily in scope_for_offset

23 months agoLock stdout once when listing tests
Ben Kimock [Fri, 22 Jul 2022 22:39:26 +0000 (18:39 -0400)]
Lock stdout once when listing tests

23 months agoAuto merge of #12847 - Veykril:vscode-downgrade, r=Veykril
bors [Fri, 22 Jul 2022 22:18:05 +0000 (22:18 +0000)]
Auto merge of #12847 - Veykril:vscode-downgrade, r=Veykril

fix: Fix restart server duplicating language clients

Reverts 03a62c180e6a7300d0d7b8c4d680b749c101bcbb
vscode-languageclient@8.0.0-next.15 and beyond changed the behaviour of language clients to be automatically started if a request comes in while they are not running. Currently when we restart the server via the restart command we recreate the language client, which causes VSCode to restart the stopped server, effectively duplicating our language clients...

Reverting the commit is simpler right now, the proper fix would be to only create a language client once and then use the `restart` functionality on it instead.

Fixes https://github.com/rust-lang/rust-analyzer/issues/12836

23 months agoRevert 03a62c180e6a7300d0d7b8c4d680b749c101bcbb
Lukas Wirth [Fri, 22 Jul 2022 22:14:34 +0000 (00:14 +0200)]
Revert 03a62c180e6a7300d0d7b8c4d680b749c101bcbb

23 months agoRollup merge of #99607 - RalfJung:vtable-check, r=eddyb
Ralf Jung [Fri, 22 Jul 2022 21:26:10 +0000 (17:26 -0400)]
Rollup merge of #99607 - RalfJung:vtable-check, r=eddyb

interpret: fix vtable check debug assertion

Fixes https://github.com/rust-lang/rust/issues/99605
Thanks to `@eddyb` for suggesting the fix!

23 months agoRollup merge of #99602 - RalfJung:xsv, r=Mark-Simulacrum
Ralf Jung [Fri, 22 Jul 2022 21:26:09 +0000 (17:26 -0400)]
Rollup merge of #99602 - RalfJung:xsv, r=Mark-Simulacrum

cargotest: do not run quickcheck tests in xsv

Fixes https://github.com/rust-lang/rust/issues/73514
I know https://github.com/rust-lang/rust/issues/70659 discusses a larger overhaul of cargotest, but that seems to have stalled and I'd like to fix the immediate issue of PRs failing due to random test failures in xsv.

This still runs the vast majority of tests by numbers:
```
test result: ok. 394 passed; 0 failed; 0 ignored; 0 measured; 32 filtered out; finished in 1.84s
```
So the loss in test coverage is hopefully not too big.

23 months agoRollup merge of #99588 - ehuss:update-books, r=ehuss
Ralf Jung [Fri, 22 Jul 2022 21:26:08 +0000 (17:26 -0400)]
Rollup merge of #99588 - ehuss:update-books, r=ehuss

Update books

## nomicon

1 commits in 70db9e4189f64d1d8e2451b1046111fb356b6dc2..8d1e4dccf71114ff56f328f671f2026d8e6b62a2
2022-06-27 20:47:21 +0900 to 2022-07-18 18:12:35 -0400
- Should be `align_of` instead of `size_of`

## reference

11 commits in 9fce337a55ee4a4629205f6094656195cecad231..a92be0fef439b3d8e0468d82cb24812d303520a0
2022-06-22 13:59:28 -0700 to 2022-07-21 19:01:23 -0700
- Add `IntoFuture::into_future` desugaring (rust-lang/reference#1233)
- Remove uses of the phrase "in Rust" (rust-lang/reference#1241)
- Revert "Add stable references of `macro_metavar_expr`" (rust-lang/reference#1242)
- tweaks
- further tweak addr_of exposition
- edits
- Apply suggestions from code review
- document raw-addr-of operators
- update union field type rules (rust-lang/reference#1238)
- clarify that references size_of_val can never exceed isize::MAX (rust-lang/reference#1186)
- Describe what `windows_subsystem` does (rust-lang/reference#1232)

## book

9 commits in cf2653a5ca553cbbb4a17f1a7db1947820f6a775..36383b4da21dbd0a0781473bc8ad7ef0ed1b6751
2022-07-05 12:07:58 -0400 to 2022-07-19 21:03:20 -0400
- Update ch16-02-message-passing.md
- Update snapshots with edits made to src that need to be checked
- Remove inconsistent newline. Fixes rust-lang/book#3240.
- add missing `b` in chapter 15.6
- Grammar: corrected 'as much' to 'as such'
- grammar: add missing 'of'
- Fix incorrect link for listing 13-06
- Correct method name
- Remove unused theme directories.

## rust-by-example

2 commits in 83724ca387a2a1cd3e8d848f62820020760e358b..3155db49b0d57cd82c65456ac210b69ecec5ccb1
2022-07-05 10:38:07 -0300 to 2022-07-05 20:35:53 -0300
- fix-type (rust-lang/rust-by-example#1565)
- add-examples-to-destructure-tuples (rust-lang/rust-by-example#1566)

## rustc-dev-guide

27 commits in eb83839e903a0a8f1406f7e941886273f189b26b..d5201cddace979b299ec1bf9fd8997338151aa9d
2022-07-03 15:17:39 +0900 to 2022-07-21 04:48:49 +0200
- Debuginfo tests now also support revisions.
- Link to rendered book directly
- Fix link to clippy sync docs
- remove stray markup
- renamed
- sync with hackmd version
- replace misleading name (rust-lang/rustc-dev-guide#1401)
- Remove a mention to Steve on r? example
- obey line length limit (part 3)
- obey line length limit (part 2)
- obey line length limit
- sync with hackmd
- add draft chapter
- add mdbook-mermaid
- use relative links
- fix some typos (rust-lang/rustc-dev-guide#1398)
- typo: monomorph docs
- Rename debugging_opts to unstable_opts, use link
- address review comment
- update date reference on MIR inliner
- remove outdated info on debugging
- small fixes to ty chapter (rust-lang/rustc-dev-guide#1390)
- Update the build instructions for the standard library
- overview.md: Link to existing Macro Expansion and Name Resolution docs (rust-lang/rustc-dev-guide#1388)
- Git-ignore `pulls.json` (rust-lang/rustc-dev-guide#1386)
- Revert "Add the config needed to get rust-analyzer working on src/bootstrap (rust-lang/rustc-dev-guide#1381)"
- Use `x.py check` instead of `cargo check` for build scripts (rust-lang/rustc-dev-guide#1384)

23 months agoAuto merge of #98017 - RalfJung:dereferenceable, r=nikic
bors [Fri, 22 Jul 2022 21:20:35 +0000 (21:20 +0000)]
Auto merge of #98017 - RalfJung:dereferenceable, r=nikic

do not mark interior mutable shared refs as dereferenceable

My proposed solution to https://github.com/rust-lang/rust/issues/55005.

23 months agoAuto merge of #12840 - Veykril:be-lazy, r=Veykril
bors [Fri, 22 Jul 2022 20:35:31 +0000 (20:35 +0000)]
Auto merge of #12840 - Veykril:be-lazy, r=Veykril

internal: Use ItemTree for variant, field and module attribute collection in attrs_query

Less parsing = very good, should speed up lang item collection as that basically probes attributes of all enum variants which currently triggers parsing

Not fond of how this is searching for the correct index, ideally we'd map between HIR and item tree Id here but I am not sure how, storing the item tree ids in the HIR version doesn't work due to the usage of `Trace`...

23 months ago[review] mention that runtime may scale with # of mountpoints
the8472 [Fri, 22 Jul 2022 20:18:07 +0000 (22:18 +0200)]
[review] mention that runtime may scale with # of mountpoints

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
23 months agoUse ItemTree for modules in attrs_query
Lukas Wirth [Thu, 21 Jul 2022 14:05:52 +0000 (16:05 +0200)]
Use ItemTree for modules in attrs_query

23 months agoUpdate mdbook
Eric Huss [Fri, 22 Jul 2022 18:59:20 +0000 (11:59 -0700)]
Update mdbook

23 months agoDo not resolve associated const when there is no provided value
Michael Goulet [Fri, 15 Jul 2022 05:37:32 +0000 (05:37 +0000)]
Do not resolve associated const when there is no provided value

23 months agoadjust UnsafeCell documentation
Ralf Jung [Wed, 22 Jun 2022 21:36:30 +0000 (14:36 -0700)]
adjust UnsafeCell documentation

23 months agodo not mark interior mutable shared refs as dereferenceable
Ralf Jung [Tue, 21 Jun 2022 03:51:15 +0000 (20:51 -0700)]
do not mark interior mutable shared refs as dereferenceable

23 months agorename PointerKind::Shared → SharedMutable to indicate this is NOT the usual shared...
Ralf Jung [Sun, 12 Jun 2022 06:20:00 +0000 (23:20 -0700)]
rename PointerKind::Shared → SharedMutable to indicate this is NOT the usual shared reference

23 months agoAuto merge of #99598 - GuillaumeGomez:clean-trait-fields-on-demand, r=notriddle
bors [Fri, 22 Jul 2022 16:52:10 +0000 (16:52 +0000)]
Auto merge of #99598 - GuillaumeGomez:clean-trait-fields-on-demand, r=notriddle

Make some clean::Trait fields computation on demand

r? `@notriddle`

23 months agoupdate Miri
Ralf Jung [Fri, 22 Jul 2022 16:18:52 +0000 (12:18 -0400)]
update Miri

23 months agocargotest: do not run quickcheck tests in xsv
Ralf Jung [Fri, 22 Jul 2022 13:23:21 +0000 (09:23 -0400)]
cargotest: do not run quickcheck tests in xsv

23 months agoAuto merge of #12844 - Veykril:highlight-attr, r=Veykril
bors [Fri, 22 Jul 2022 15:31:32 +0000 (15:31 +0000)]
Auto merge of #12844 - Veykril:highlight-attr, r=Veykril

fix: Improve syntax highlighting in attributes

Fixes https://github.com/rust-lang/rust-analyzer/issues/12842

23 months agofix: Improve syntax highlighting in attributes
Lukas Wirth [Fri, 22 Jul 2022 15:29:03 +0000 (17:29 +0200)]
fix: Improve syntax highlighting in attributes

23 months agointerpret: fix vtable check debug assertion
Ralf Jung [Fri, 22 Jul 2022 14:37:03 +0000 (10:37 -0400)]
interpret: fix vtable check debug assertion