]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoWindows: No panic if function not (yet) available
Chris Denton [Tue, 7 Jun 2022 20:22:53 +0000 (21:22 +0100)]
Windows: No panic if function not (yet) available

In some situations it is possible for required functions to be called before they've had a chance to be loaded. Therefore, we make it possible to recover from this situation simply by looking at error codes.

2 years agoAuto merge of #97825 - Dylan-DPC:rollup-ya51k1k, r=Dylan-DPC
bors [Tue, 7 Jun 2022 11:08:58 +0000 (11:08 +0000)]
Auto merge of #97825 - Dylan-DPC:rollup-ya51k1k, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #97058 (Various refactors to the incr comp workproduct handling)
 - #97301 (Allow unstable items to be re-exported unstably without requiring the feature be enabled)
 - #97738 (Fix ICEs from zsts within unsized types with non-zero offsets)
 - #97771 (Remove SIGIO reference on Haiku)
 - #97808 (Add some unstable target features for the wasm target codegen)

Failed merges:

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

2 years agoRollup merge of #97808 - alexcrichton:wasm-features, r=petrochenkov
Dylan DPC [Tue, 7 Jun 2022 09:41:09 +0000 (11:41 +0200)]
Rollup merge of #97808 - alexcrichton:wasm-features, r=petrochenkov

Add some unstable target features for the wasm target codegen

I was experimenting with cross-language LTO for the wasm target recently
between Rust and C and found that C was injecting the `+mutable-globals`
flag on all functions. When specifying the corresponding
`-Ctarget-feature=+mutable-globals` feature to Rust it prints a warning
about an unknown feature. I've added the `mutable-globals` feature plus
another few I know of to the list of known features for wasm targets.
These features all continue to be unstable to source code as they were
before.

2 years agoRollup merge of #97771 - rtzoeller:haiku_no_sigio, r=kennytm
Dylan DPC [Tue, 7 Jun 2022 09:41:09 +0000 (11:41 +0200)]
Rollup merge of #97771 - rtzoeller:haiku_no_sigio, r=kennytm

Remove SIGIO reference on Haiku

Haiku doesn't define SIGIO. The nix crate already employs this workaround:
https://github.com/nix-rust/nix/blob/5dedbc7850448ae3922ab0a833f3eb971bf7e25f/src/sys/signal.rs#L92-L94

2 years agoRollup merge of #97738 - Kixiron:zst-panic, r=eddyb
Dylan DPC [Tue, 7 Jun 2022 09:41:08 +0000 (11:41 +0200)]
Rollup merge of #97738 - Kixiron:zst-panic, r=eddyb

Fix ICEs from zsts within unsized types with non-zero offsets

- Fixes #97732
- Fixes ICEs while compiling `alloc` with `-Z randomize-layout`

r? ``@eddyb``

2 years agoRollup merge of #97301 - semicoleon:unstable-reexport, r=petrochenkov
Dylan DPC [Tue, 7 Jun 2022 09:41:07 +0000 (11:41 +0200)]
Rollup merge of #97301 - semicoleon:unstable-reexport, r=petrochenkov

Allow unstable items to be re-exported unstably without requiring the feature be enabled

Closes #94972

The diagnostic may need some work still, and I haven't added a test yet

2 years agoRollup merge of #97058 - bjorn3:multi_artifact_work_products, r=nagisa
Dylan DPC [Tue, 7 Jun 2022 09:41:06 +0000 (11:41 +0200)]
Rollup merge of #97058 - bjorn3:multi_artifact_work_products, r=nagisa

Various refactors to the incr comp workproduct handling

This is the result of me looking into adding support for having multiple object files for a single codegen unit to incr comp. This is necessary to support inline assembly in cg_clif without requiring partial linking which is not supported on Windows and seems to fail on macOS for some reason. Cg_clif uses an external assembler to handle inline asm and thus produces one object file with regular functions and one object file containing compiled inline asm for each codegen unit which uses inline asm. Current incr comp can't handle this. This PR doesn't yet add support for this, but it makes it easier to do so.

2 years agoAuto merge of #97512 - scottmcm:add-coldcc, r=nagisa,lcnr
bors [Tue, 7 Jun 2022 08:12:45 +0000 (08:12 +0000)]
Auto merge of #97512 - scottmcm:add-coldcc, r=nagisa,lcnr

Add support for emitting functions with `coldcc` to LLVM

The eventual goal is to try using this for things like the internal panicking stuff, to see whether it helps.

2 years agoAuto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakis
bors [Tue, 7 Jun 2022 05:04:14 +0000 (05:04 +0000)]
Auto merge of #95565 - jackh726:remove-borrowck-mode, r=nikomatsakis

Remove migrate borrowck mode

Closes #58781
Closes #43234

# Stabilization proposal

This PR proposes the stabilization of `#![feature(nll)]` and the removal of `-Z borrowck`. Current borrow checking behavior of item bodies is currently done by first infering regions *lexically* and reporting any errors during HIR type checking. If there *are* any errors, then MIR borrowck (NLL) never occurs. If there *aren't* any errors, then MIR borrowck happens and any errors there would be reported. This PR removes the lexical region check of item bodies entirely and only uses MIR borrowck. Because MIR borrowck could never *not* be run for a compiled program, this should not break any programs. It does, however, change diagnostics significantly and allows a slightly larger set of programs to compile.

Tracking issue: #43234
RFC: https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md
Version: 1.63 (2022-06-30 => beta, 2022-08-11 => stable).

## Motivation

Over time, the Rust borrow checker has become "smarter" and thus allowed more programs to compile. There have been three different implementations: AST borrowck, MIR borrowck, and polonius (well, in progress). Additionally, there is the "lexical region resolver", which (roughly) solves the constraints generated through HIR typeck. It is not a full borrow checker, but does emit some errors.

The AST borrowck was the original implementation of the borrow checker and was part of the initially stabilized Rust 1.0. In mid 2017, work began to implement the current MIR borrow checker and that effort ompleted by the end of 2017, for the most part. During 2018, efforts were made to migrate away from the AST borrow checker to the MIR borrow checker - eventually culminating into "migrate" mode - where HIR typeck with lexical region resolving following by MIR borrow checking - being active by default in the 2018 edition.

In early 2019, migrate mode was turned on by default in the 2015 edition as well, but with MIR borrowck errors emitted as warnings. By late 2019, these warnings were upgraded to full errors. This was followed by the complete removal of the AST borrow checker.

In the period since, various errors emitted by the MIR borrow checker have been improved to the point that they are mostly the same or better than those emitted by the lexical region resolver.

While there do remain some degradations in errors (tracked under the [NLL-diagnostics tag](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-diagnostics), those are sufficiently small and rare enough that increased flexibility of MIR borrow check-only is now a worthwhile tradeoff.

## What is stabilized

As said previously, this does not fundamentally change the landscape of accepted programs. However, there are a [few](https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3ANLL-fixed-by-NLL) cases where programs can compile under `feature(nll)`, but not otherwise.

There are two notable patterns that are "fixed" by this stabilization. First, the `scoped_threads` feature, which is a continutation of a pre-1.0 API, can sometimes emit a [weird lifetime error](https://github.com/rust-lang/rust/issues/95527) without NLL. Second, actually seen in the standard library. In the `Extend` impl for `HashMap`, there is an implied bound of `K: 'a` that is available with NLL on but not without - this is utilized in the impl.

As mentioned before, there are a large number of diagnostic differences. Most of them are better, but some are worse. None are serious or happen often enough to need to block this PR. The biggest change is the loss of error code for a number of lifetime errors in favor of more general "lifetime may not live long enough" error. While this may *seem* bad, the former error codes were just attempts to somewhat-arbitrarily bin together lifetime errors of the same type; however, on paper, they end up being roughly the same with roughly the same kinds of solutions.

## What isn't stabilized

This PR does not completely remove the lexical region resolver. In the future, it may be possible to remove that (while still keeping HIR typeck) or to remove it together with HIR typeck.

## Tests

Many test outputs get updated by this PR. However, there are number of tests specifically geared towards NLL under `src/test/ui/nll`

## History

* On 2017-07-14, [tracking issue opened](https://github.com/rust-lang/rust/issues/43234)
* On 2017-07-20, [initial empty MIR pass added](https://github.com/rust-lang/rust/pull/43271)
* On 2017-08-29, [RFC opened](https://github.com/rust-lang/rfcs/pull/2094)
* On 2017-11-16, [Integrate MIR type-checker with NLL](https://github.com/rust-lang/rust/pull/45825)
* On 2017-12-20, [NLL feature complete](https://github.com/rust-lang/rust/pull/46862)
* On 2018-07-07, [Don't run AST borrowck on mir mode](https://github.com/rust-lang/rust/pull/52083)
* On 2018-07-27, [Add migrate mode](https://github.com/rust-lang/rust/pull/52681)
* On 2019-04-22, [Enable migrate mode on 2015 edition](https://github.com/rust-lang/rust/pull/59114)
* On 2019-08-26, [Don't downgrade errors on 2015 edition](https://github.com/rust-lang/rust/pull/64221)
* On 2019-08-27, [Remove AST borrowck](https://github.com/rust-lang/rust/pull/64790)

2 years agoAuto merge of #97801 - RalfJung:miri, r=RalfJung
bors [Tue, 7 Jun 2022 02:35:19 +0000 (02:35 +0000)]
Auto merge of #97801 - RalfJung:miri, r=RalfJung

update Miri

Fixes https://github.com/rust-lang/rust/issues/97745
r? `@ghost` Cc `@rust-lang/miri`
Cc `@InfRandomness`

2 years agoAuto merge of #97809 - matthiaskrgr:rollup-ajyvjd3, r=matthiaskrgr
bors [Mon, 6 Jun 2022 23:53:07 +0000 (23:53 +0000)]
Auto merge of #97809 - matthiaskrgr:rollup-ajyvjd3, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #97700 (Add note to documentation of HashSet::intersection)
 - #97792 (More eslint checks)
 - #97794 (Fix typo in redundant_pattern_match.rs)

Failed merges:

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

2 years agoRollup merge of #97794 - eltociear:patch-13, r=matthiaskrgr
Matthias Krüger [Mon, 6 Jun 2022 23:13:48 +0000 (01:13 +0200)]
Rollup merge of #97794 - eltociear:patch-13, r=matthiaskrgr

Fix typo in redundant_pattern_match.rs

alway -> always

2 years agoRollup merge of #97792 - GuillaumeGomez:eslint-checks, r=Dylan-DPC
Matthias Krüger [Mon, 6 Jun 2022 23:13:47 +0000 (01:13 +0200)]
Rollup merge of #97792 - GuillaumeGomez:eslint-checks, r=Dylan-DPC

More eslint checks

Here is the list of newly added eslint checks:

 * [no-confusing-arrow](https://eslint.org/docs/rules/no-confusing-arrow)
 * [no-div-regex](https://eslint.org/docs/rules/no-div-regex)
 * [no-floating-decimal](https://eslint.org/docs/rules/no-floating-decimal)
 * [no-implicit-globals](https://eslint.org/docs/rules/no-implicit-globals)
 * [no-implied-eval](https://eslint.org/docs/rules/no-implied-eval)
 * [no-label-var](https://eslint.org/docs/rules/no-label-var)

Since you already reviewed the previous ones:

r? `@Dylan-DPC`

2 years agoRollup merge of #97700 - nzrq:patch-1, r=dtolnay
Matthias Krüger [Mon, 6 Jun 2022 23:13:46 +0000 (01:13 +0200)]
Rollup merge of #97700 - nzrq:patch-1, r=dtolnay

Add note to documentation of HashSet::intersection

The functionality of the `std::collections::HashSet::intersection(...)` method was slightly surprising to me so I wanted to take a sec to contribute to the documentation for this method.

I've added a `Note:` section if that is appropriate.

2 years agoAdd some unstable target features for the wasm target codegen
Alex Crichton [Mon, 6 Jun 2022 22:01:17 +0000 (15:01 -0700)]
Add some unstable target features for the wasm target codegen

I was experimenting with cross-language LTO for the wasm target recently
between Rust and C and found that C was injecting the `+mutable-globals`
flag on all functions. When specifying the corresponding
`-Ctarget-feature=+mutable-globals` feature to Rust it prints a warning
about an unknown feature. I've added the `mutable-globals` feature plus
another few I know of to the list of known features for wasm targets.
These features all continue to be unstable to source code as they were
before.

2 years agoApply suggestions from code review
nzrq [Mon, 6 Jun 2022 21:14:58 +0000 (17:14 -0400)]
Apply suggestions from code review

Co-authored-by: David Tolnay <dtolnay@gmail.com>
2 years agoAuto merge of #97730 - flip1995:clippyup, r=Manishearth
bors [Mon, 6 Jun 2022 19:40:54 +0000 (19:40 +0000)]
Auto merge of #97730 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

This includes a bit bigger `Cargo.lock` update.

2 years agoupdate Miri
Ralf Jung [Mon, 6 Jun 2022 17:36:21 +0000 (13:36 -0400)]
update Miri

2 years agoAuto merge of #97795 - Dylan-DPC:rollup-dxilagr, r=Dylan-DPC
bors [Mon, 6 Jun 2022 16:09:54 +0000 (16:09 +0000)]
Auto merge of #97795 - Dylan-DPC:rollup-dxilagr, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #97312 (Compute lifetimes in scope at diagnostic time)
 - #97495 (Add E0788 for improper #[no_coverage] usage)
 - #97579 (Avoid creating `SmallVec`s in `global_llvm_features`)
 - #97767 (interpret: do not claim UB until we looked more into variadic functions)
 - #97787 (E0432: rust 2018 -> rust 2018 or later    in --explain message)

Failed merges:

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

2 years agoUpdate src/test/ui/unsized/issue-97732.rs
Chase Wilson [Mon, 6 Jun 2022 15:19:33 +0000 (10:19 -0500)]
Update src/test/ui/unsized/issue-97732.rs

Co-authored-by: Eduard-Mihai Burtescu <edy.burt@gmail.com>
2 years agoAuto merge of #97684 - RalfJung:better-provenance-control, r=oli-obk
bors [Mon, 6 Jun 2022 13:28:58 +0000 (13:28 +0000)]
Auto merge of #97684 - RalfJung:better-provenance-control, r=oli-obk

interpret: better control over whether we read data with provenance

The resolution in https://github.com/rust-lang/unsafe-code-guidelines/issues/286 seems to be that when we load data at integer type, we implicitly strip provenance. So let's implement that in Miri at least for scalar loads. This makes use of the fact that `Scalar` layouts distinguish pointer-sized integers and pointers -- so I was expecting some wild bugs where layouts set this incorrectly, but so far that does not seem to happen.

This does not entirely implement the solution to https://github.com/rust-lang/unsafe-code-guidelines/issues/286; we still do the wrong thing for integers in larger types: we will `copy_op` them and then do validation, and validation will complain about the provenance. To fix that we need mutating validation; validation needs to strip the provenance rather than complaining about it. This is a larger undertaking (but will also help resolve https://github.com/rust-lang/miri/issues/845 since we can reset padding to `Uninit`).

The reason this is useful is that we can now implement `addr` as a `transmute` from a pointer to an integer, and actually get the desired behavior of stripping provenance without exposing it!

2 years agoMake saved_file field of WorkProduct non-optional
bjorn3 [Sun, 15 May 2022 11:31:28 +0000 (11:31 +0000)]
Make saved_file field of WorkProduct non-optional

A WorkProduct without a saved file is useless

2 years agoFactor Option out of copy_cgu_workproduct_to_incr_comp_cache_dir call
bjorn3 [Fri, 13 May 2022 12:20:32 +0000 (12:20 +0000)]
Factor Option out of copy_cgu_workproduct_to_incr_comp_cache_dir call

This improves clarity of the code a bit

2 years agoRollup merge of #97787 - matthiaskrgr:e0432_explain, r=Dylan-DPC
Dylan DPC [Mon, 6 Jun 2022 12:34:59 +0000 (14:34 +0200)]
Rollup merge of #97787 - matthiaskrgr:e0432_explain, r=Dylan-DPC

E0432: rust 2018 -> rust 2018 or later    in --explain message

2 years agoRollup merge of #97767 - RalfJung:variadic, r=davidtwco
Dylan DPC [Mon, 6 Jun 2022 12:34:58 +0000 (14:34 +0200)]
Rollup merge of #97767 - RalfJung:variadic, r=davidtwco

interpret: do not claim UB until we looked more into variadic functions

I am not actually sure if this is UB, and anyway for FFI shims, Miri currently does not attempt to distinguish between arguments passed via variadics vs directly. So let's be consistent.
(Programs that ran into this error will anyway immediately fall through to the "unsupported" message on the next line.)

2 years agoRollup merge of #97579 - SparrowLii:target_features, r=nagisa
Dylan DPC [Mon, 6 Jun 2022 12:34:57 +0000 (14:34 +0200)]
Rollup merge of #97579 - SparrowLii:target_features, r=nagisa

Avoid creating `SmallVec`s in `global_llvm_features`

This PR made a simple optimization to avoid creating extra `SmallVec`s by adjusting the use of iterator statements.
Also, given the very small size of `tied_target_features`, there is no need to insert each feature into the FxHashMap.

2 years agoRollup merge of #97495 - clarfonthey:e0788-no-coverage, r=nagisa
Dylan DPC [Mon, 6 Jun 2022 12:34:56 +0000 (14:34 +0200)]
Rollup merge of #97495 - clarfonthey:e0788-no-coverage, r=nagisa

Add E0788 for improper #[no_coverage] usage

Essentially, this adds proper checking for the attribute (tracking issue #84605) and throws errors when it's put in obviously-wrong places, like on struct or const definitions. Most of the code is taken directly from the checks for the `#[inline]` attribute, since it's very similar.

Right now, the code only checks at the function level, but it seems reasonable to allow adding `#[no_coverage]` to individual blocks or expressions, so, for now those just throw `unused_attributes` warnings. Similarly, since there was a lot of desire to eventually allow recursive definitions as well on modules and impl blocks, these also throw `unused_attributes` instead of an error.

I'm not sure if anything has to be done since this error is technically for an unstable feature, but since an error for using unstable features will show up anyway, I think it's okay.

This is the first big piece needed for stabilising this attribute, although I personally would like to explore renaming it to `#[coverage(never)]` on a separate PR, which I will offer soon. There's a lot of discussion still to be had about that, which is why it will be kept separate.

I don't think much is needed besides adding this simple check and a UI test, but let me know if there's something else that should be added to make this happen.

2 years agoRollup merge of #97312 - cjgillot:no-path-in-scope, r=compiler-errors
Dylan DPC [Mon, 6 Jun 2022 12:34:55 +0000 (14:34 +0200)]
Rollup merge of #97312 - cjgillot:no-path-in-scope, r=compiler-errors

Compute lifetimes in scope at diagnostic time

The set of available lifetimes is currently computed during lifetime resolution on HIR.  It is only used for one diagnostic.

In this PR, HIR lifetime resolution just reports whether elided lifetimes are well-defined at the place of use.  The diagnostic code is responsible for building a list of lifetime names if elision is not allowed.

This will allow to remove lifetime resolution on HIR eventually.

2 years agoAvoid an unnecessary clone for copy_cgu_workproduct_to_incr_comp_cache_dir calls
bjorn3 [Fri, 13 May 2022 12:18:13 +0000 (12:18 +0000)]
Avoid an unnecessary clone for copy_cgu_workproduct_to_incr_comp_cache_dir calls

2 years agoRename CodegenUnit::work_product to previous_work_product
bjorn3 [Fri, 13 May 2022 10:32:03 +0000 (10:32 +0000)]
Rename CodegenUnit::work_product to previous_work_product

It returns the previous work product or panics if there is none. This rename
makes the purpose of this method clearer.

2 years agoRemove unnecessary cgu name length hash
bjorn3 [Fri, 13 May 2022 10:29:35 +0000 (10:29 +0000)]
Remove unnecessary cgu name length hash

This is a tiny optimization

2 years agoFix typo in redundant_pattern_match.rs
Ikko Ashimine [Mon, 6 Jun 2022 12:16:31 +0000 (21:16 +0900)]
Fix typo in redundant_pattern_match.rs

alway -> always

2 years agoAdd "no-label-var" eslint check
Guillaume Gomez [Mon, 6 Jun 2022 12:03:26 +0000 (14:03 +0200)]
Add "no-label-var" eslint check

2 years agoAdd "no-implied-eval" eslint check
Guillaume Gomez [Mon, 6 Jun 2022 12:02:37 +0000 (14:02 +0200)]
Add "no-implied-eval" eslint check

2 years agoAdd "no-implicit-globals" eslint check
Guillaume Gomez [Mon, 6 Jun 2022 12:01:52 +0000 (14:01 +0200)]
Add "no-implicit-globals" eslint check

2 years agoAdd "no-floating-decimal" eslint check
Guillaume Gomez [Mon, 6 Jun 2022 12:00:43 +0000 (14:00 +0200)]
Add "no-floating-decimal" eslint check

2 years agoAdd "no-div-regex" eslint check
Guillaume Gomez [Mon, 6 Jun 2022 11:58:53 +0000 (13:58 +0200)]
Add "no-div-regex" eslint check

2 years agoAdd "no-confusing-arrow" eslint check
Guillaume Gomez [Mon, 6 Jun 2022 11:57:54 +0000 (13:57 +0200)]
Add "no-confusing-arrow" eslint check

2 years agoAuto merge of #97086 - 5225225:link-section-is-unsafe, r=davidtwco
bors [Mon, 6 Jun 2022 10:43:27 +0000 (10:43 +0000)]
Auto merge of #97086 - 5225225:link-section-is-unsafe, r=davidtwco

Report unsafe for overriding link sections

I'm not too sure about the lint wording here, but I couldn't think of anything better.

2 years agoAvoid creating `SmallVec`s in `global_llvm_features`
SparrowLii [Mon, 6 Jun 2022 10:05:07 +0000 (18:05 +0800)]
Avoid creating `SmallVec`s in `global_llvm_features`

2 years agoE0432: rust 2018 -> rust 2018 or later in --explain message
Matthias Krüger [Mon, 6 Jun 2022 09:39:54 +0000 (11:39 +0200)]
E0432: rust 2018 -> rust 2018 or later    in --explain message

2 years agoAdd winnt feature to winapi in rustc-workspace-hack
Philipp Krones [Mon, 6 Jun 2022 09:14:59 +0000 (11:14 +0200)]
Add winnt feature to winapi in rustc-workspace-hack

2 years agoAuto merge of #97783 - matthiaskrgr:rollup-14t9htt, r=matthiaskrgr
bors [Mon, 6 Jun 2022 08:02:38 +0000 (08:02 +0000)]
Auto merge of #97783 - matthiaskrgr:rollup-14t9htt, r=matthiaskrgr

Rollup of 7 pull requests

Successful merges:

 - #90905 (Add empty impl blocks if they have documentation)
 - #97683 (Fail gracefully when encountering an HRTB in APIT. )
 - #97721 (Do `suggest_await_before_try` with infer variables in self, and clean up binders)
 - #97752 (typo: `-Zcodegen-backend=llvm -Cpasses=list` should work now)
 - #97759 (Suggest adding `{}` for `'label: non_block_expr`)
 - #97764 (use strict provenance APIs)
 - #97765 (Restore a test that was intended to test `as` cast to ptr)

Failed merges:

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

2 years agoRollup merge of #97765 - RalfJung:restoration, r=Mark-Simulacrum
Matthias Krüger [Mon, 6 Jun 2022 06:37:05 +0000 (08:37 +0200)]
Rollup merge of #97765 - RalfJung:restoration, r=Mark-Simulacrum

Restore a test that was intended to test `as` cast to ptr

This test was changed in https://github.com/rust-lang/rust/pull/61864, but the original bug https://github.com/rust-lang/rust/issues/46365 was about casts so I doubt the changed test still even tests what this was intended to test. Let's restore the original test.

2 years agoRollup merge of #97764 - RalfJung:strict, r=dtolnay
Matthias Krüger [Mon, 6 Jun 2022 06:37:04 +0000 (08:37 +0200)]
Rollup merge of #97764 - RalfJung:strict, r=dtolnay

use strict provenance APIs

The stdlib was adjusted to avoid bare int2ptr casts, but recently some casts of that sort have sneaked back in. Let's fix that. :)

2 years agoRollup merge of #97759 - WaffleLapkin:recover_label_expr, r=compiler-errors
Matthias Krüger [Mon, 6 Jun 2022 06:37:03 +0000 (08:37 +0200)]
Rollup merge of #97759 - WaffleLapkin:recover_label_expr, r=compiler-errors

Suggest adding `{}` for `'label: non_block_expr`

Adds suggestions like this:
```text
help: consider enclosing expression in a block
  |
3 |     'l {0};
  |        + +
```

inspired by https://github.com/rust-lang/rust/issues/48594#issuecomment-1146744400

r? ``@compiler-errors``

2 years agoRollup merge of #97752 - klensy:cg-typo, r=bjorn3
Matthias Krüger [Mon, 6 Jun 2022 06:37:02 +0000 (08:37 +0200)]
Rollup merge of #97752 - klensy:cg-typo, r=bjorn3

typo: `-Zcodegen-backend=llvm -Cpasses=list` should work now

r? ```@bjorn3```

2 years agoRollup merge of #97721 - compiler-errors:issue-97704, r=jackh726
Matthias Krüger [Mon, 6 Jun 2022 06:37:01 +0000 (08:37 +0200)]
Rollup merge of #97721 - compiler-errors:issue-97704, r=jackh726

Do `suggest_await_before_try` with infer variables in self, and clean up binders

Fixes #97704

Also cleans up binders in this fn, since everything is a `Poly*` and we really shouldn't have stray escaping late-bound regions everywhere. That's why the function changed so much. This isn't necessary, so I can revert if necessary.

2 years agoRollup merge of #97683 - cjgillot:no-apit-hrtb, r=nagisa
Matthias Krüger [Mon, 6 Jun 2022 06:37:00 +0000 (08:37 +0200)]
Rollup merge of #97683 - cjgillot:no-apit-hrtb, r=nagisa

Fail gracefully when encountering an HRTB in APIT.

Fixes https://github.com/rust-lang/rust/issues/96954

~The first commit will be merged as part of https://github.com/rust-lang/rust/pull/97415~

2 years agoRollup merge of #90905 - GuillaumeGomez:empty-impl-blocks, r=jsha
Matthias Krüger [Mon, 6 Jun 2022 06:36:59 +0000 (08:36 +0200)]
Rollup merge of #90905 - GuillaumeGomez:empty-impl-blocks, r=jsha

Add empty impl blocks if they have documentation

Fixes https://github.com/rust-lang/rust/issues/90866.

The update for the test script is needed to count the number of impl blocks we have with only the struct. To be noted that with https://github.com/rust-lang/rust/pull/89676 merged, it wouldn't be needed (I don't know what is the status of it btw. cc ```@Mark-Simulacrum).```

It looks like this:

![Screenshot from 2021-11-14 16-51-28](https://user-images.githubusercontent.com/3050060/141689100-e57123c0-bf50-4c42-adf5-d991e169a0e4.png)

cc ```@jyn514```
r? ```@camelid```

2 years agoAuto merge of #96551 - ferrocene:pa-ignore-paths-when-abbreviating, r=Mark-Simulacrum
bors [Mon, 6 Jun 2022 05:21:49 +0000 (05:21 +0000)]
Auto merge of #96551 - ferrocene:pa-ignore-paths-when-abbreviating, r=Mark-Simulacrum

[compiletest] Ignore known paths when abbreviating output

To prevent out of memory conditions, compiletest limits the amount of output a test can generate, abbreviating it if the test emits more than a threshold. While the behavior is desirable, it also causes some issues (like #96229, #94322 and #92211).

The latest one happened recently, when the `src/test/ui/numeric/numeric-cast.rs` test started to fail on systems where the path of the rust-lang/rust checkout is too long. This includes my own development machine and [LLVM's CI](https://github.com/rust-lang/rust/issues/96362#issuecomment-1108609893). Rust's CI uses a pretty short directory name for the checkout, which hides these sort of problems until someone runs the test suite on their own computer.

When developing the fix I tried to find the most targeted fix that would prevent this class of failures from happening in the future, deferring the decision on if/how to redesign abbreviation to a later date. The solution I came up with was to ignore known base paths when calculating whether the output exceeds the abbreviation threshold, which removes this kind of nondeterminism.

This PR is best reviewed commit-by-commit.

2 years agoChanges from code review
ltdk [Mon, 6 Jun 2022 02:24:14 +0000 (22:24 -0400)]
Changes from code review

2 years agoDo suggest_await_before_try with infer in self, clean up binders
Michael Goulet [Sat, 4 Jun 2022 01:40:39 +0000 (18:40 -0700)]
Do suggest_await_before_try with infer in self, clean up binders

2 years agoAuto merge of #97710 - RalfJung:ptr-addr, r=thomcc
bors [Mon, 6 Jun 2022 01:03:26 +0000 (01:03 +0000)]
Auto merge of #97710 - RalfJung:ptr-addr, r=thomcc

implement ptr.addr() via transmute

As per the discussion in https://github.com/rust-lang/unsafe-code-guidelines/issues/286, the semantics for ptr-to-int transmutes that we are going with for now is to make them strip provenance without exposing it. That's exactly what `ptr.addr()` does! So we can implement `ptr.addr()` via `transmute`. This also means that once https://github.com/rust-lang/rust/pull/97684 lands, Miri can distinguish `ptr.addr()` from `ptr.expose_addr()`, and the following code will correctly be called out as having UB (if permissive provenance mode is enabled, which will become the default once the [implementation is complete](https://github.com/rust-lang/miri/issues/2133)):

```rust
fn main() {
    let x: i32 = 3;
    let x_ptr = &x as *const i32;

    let x_usize: usize = x_ptr.addr();
    // Cast back an address that did *not* get exposed.
    let ptr = std::ptr::from_exposed_addr::<i32>(x_usize);
    assert_eq!(unsafe { *ptr }, 3); //~ ERROR Undefined Behavior: dereferencing pointer failed
}
```

This completes the Miri implementation of the new distinctions introduced by strict provenance. :)

Cc `@Gankra` -- for now I left in your `FIXME(strict_provenance_magic)` saying these should be intrinsics, but I do not necessarily agree that they should be. Or if we have an intrinsic, I think it should behave exactly like the `transmute` does, which makes one wonder why the intrinsic should be needed.

2 years agoFix the coldcc codegen test on wasm32
Scott McMurray [Sun, 5 Jun 2022 23:02:10 +0000 (16:02 -0700)]
Fix the coldcc codegen test on wasm32

2 years agoAdd spaces before and after expr in add {} suggestion
Waffle Maybe [Sun, 5 Jun 2022 21:35:37 +0000 (01:35 +0400)]
Add spaces before and after expr in add {} suggestion

Co-authored-by: Michael Goulet <michael@errs.io>
2 years agoRemove SIGIO reference on Haiku
Ryan Zoeller [Sun, 5 Jun 2022 20:14:18 +0000 (15:14 -0500)]
Remove SIGIO reference on Haiku

Haiku doesn't define SIGIO. The nix crate already employs this workaround:
https://github.com/nix-rust/nix/blob/5dedbc7850448ae3922ab0a833f3eb971bf7e25f/src/sys/signal.rs#L92-L94

2 years agoSuggest removing label in `'label: non_block_expr`
Maybe Waffle [Sun, 5 Jun 2022 19:34:11 +0000 (23:34 +0400)]
Suggest removing label in `'label: non_block_expr`

2 years agoDo not suggest adding labeled block if there are no labeled breaks
Maybe Waffle [Sun, 5 Jun 2022 19:12:51 +0000 (23:12 +0400)]
Do not suggest adding labeled block if there are no labeled breaks

2 years agointerpret: do not claim UB until we looked more into variadic functions
Ralf Jung [Sun, 5 Jun 2022 17:24:10 +0000 (13:24 -0400)]
interpret: do not claim UB until we looked more into variadic functions

2 years agorestore a test
Ralf Jung [Sun, 5 Jun 2022 16:00:43 +0000 (12:00 -0400)]
restore a test

2 years agouse strict provenance APIs
Ralf Jung [Sun, 5 Jun 2022 15:44:12 +0000 (11:44 -0400)]
use strict provenance APIs

2 years agoreduce code duplication
Ralf Jung [Fri, 3 Jun 2022 14:25:35 +0000 (10:25 -0400)]
reduce code duplication

2 years agointerpret: better control over whether we read data with provenance, and implicit...
Ralf Jung [Fri, 3 Jun 2022 00:30:29 +0000 (20:30 -0400)]
interpret: better control over whether we read data with provenance, and implicit provenance stripping where possible

2 years agoSuggest adding `{}` for `'label: non_block_expr`
Maybe Waffle [Sun, 5 Jun 2022 12:45:29 +0000 (16:45 +0400)]
Suggest adding `{}` for `'label: non_block_expr`

2 years agoAuto merge of #97756 - pietroalbini:pa-remove-azure-pipelines, r=Mark-Simulacrum
bors [Sun, 5 Jun 2022 12:31:26 +0000 (12:31 +0000)]
Auto merge of #97756 - pietroalbini:pa-remove-azure-pipelines, r=Mark-Simulacrum

Remove Azure Pipelines configuration

This PR removes the remaining Azure Pipelines configuration, now that we fully removed all the resources on the Azure side of things.

2 years agoupdate comment
Pietro Albini [Sun, 5 Jun 2022 10:32:46 +0000 (12:32 +0200)]
update comment

2 years agoremove azure pipelines-specific debug statement
Pietro Albini [Sun, 5 Jun 2022 10:30:55 +0000 (12:30 +0200)]
remove azure pipelines-specific debug statement

2 years agoremove clean-disk script
Pietro Albini [Sun, 5 Jun 2022 10:30:01 +0000 (12:30 +0200)]
remove clean-disk script

The script wasn't referenced anywhere, and it's not useful anymore:
/opt/ghc is not present in new images, while /usr/share/dotnet is only
2.3 GB rather than 16 GB.

2 years agoremove azure pipelines configuration
Pietro Albini [Sun, 5 Jun 2022 10:29:20 +0000 (12:29 +0200)]
remove azure pipelines configuration

2 years agoAuto merge of #97697 - WaffleLapkin:no_ref_vec, r=WaffleLapkin
bors [Sun, 5 Jun 2022 09:30:53 +0000 (09:30 +0000)]
Auto merge of #97697 - WaffleLapkin:no_ref_vec, r=WaffleLapkin

Replace `&Vec<_>`s with `&[_]`s

It's generally preferable to use `&[_]` since it's one less indirection and it can be created from types other that `Vec`.

I've left `&Vec` in some locals where it doesn't really matter, in cases where `TypeFoldable` is expected (`TypeFoldable: Clone` so slice can't implement it) and in cases where it's `&TypeAliasThatIsActiallyVec`. Nothing important, really, I was just a little annoyed by `visit_generic_param_vec` :D

r? `@compiler-errors`

2 years agoRename `visit_generic_param{_slice => s}`
Maybe Waffle [Sun, 5 Jun 2022 09:12:31 +0000 (13:12 +0400)]
Rename `visit_generic_param{_slice => s}`

2 years agoSuggest 'static when in static/const items.
Camille GILLOT [Sun, 5 Jun 2022 07:59:26 +0000 (09:59 +0200)]
Suggest 'static when in static/const items.

2 years agoAuto merge of #97577 - betrusted-io:add-xous-target, r=nagisa
bors [Sun, 5 Jun 2022 07:03:50 +0000 (07:03 +0000)]
Auto merge of #97577 - betrusted-io:add-xous-target, r=nagisa

riscv32imac-unknown-xous-elf: add target

This PR starts the process of upstreaming support for our operating system, thanks to a suggestion from `@yaahc` [on Twitter](https://twitter.com/yaahc_/status/1530558574706839567?s=20&t=Mgkn1LEYvGU6FEi5SpZRsA). We have maintained a fork of Rust and have made changes to improve support for our platform since Rust 1.51. Now we would like to upstream these changes.

Xous is a microkernel operating system designed to run on small systems. The kernel contains a wide range of userspace processes that provide common services such as console output, networking, and time access.

The kernel and its services are completely written in Rust using a custom build of libstd. This adds support for this target to upstream Rust so that we can drop support for our out-of-tree `target.json` file.

This first patch adds a Tier 3 target for Xous running on RISC-V. Future patches will add libstd support, but those patches require changes to `dlmalloc` and `compiler_builtins`.

> Tier 3 policy:
>
> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

I will be the target maintainer for this target on matters that pertain to the `xous` part of the triple. For matters pertaining to the `riscv32imac` part of the triple, there should be no difference from all other `riscv` targets. If there are issues, I will address issues regarding the target.

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

This is a new OS, so I have taken the `riscv32imac-unknown-none-elf` target and changed the `os` section of the triple. This follows convention on targets such as `riscv32gc-unknown-linux-gnu` and `mipsel-unknown-linux-uclibc`. An argument could be made for omitting the `-elf` section of the triple, such as `riscv32imc-esp-espidf`, however I'm not certain what benefit that has.

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

I feel that the target name does not introduce any ambiguity.

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

The only unusual requirement for building the `compiler-builtins` crate is a standard RISC-V C compiler supported by `cc-rs`, and using this target does not require any additional software beyond what is shipped by `rustup`.

> The target must not introduce license incompatibilities.

All of the additional code will use Apache-2.0.

> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

Agreed, and there is no problem here.

> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.

The only new dependency will be the `xous` crate, which is licensed `MIT OR Apache-2.0`

> Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.

Linking is performed by `rust-lld`

> "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

There are no terms. Xous is completely open. It runs on open hardware. We even provide the source to the CPU.

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

This paragraph makes sense, but I don't think it's directed at me.

> This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

This paragraph also does not appear to be directed at me.

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

So far we have:

 * Thread
 * Mutexex
 * Condvar
 * TcpStream
 * TcpListener
 * UdpSocket
 * DateTime
 * alloc

These will be merged as part of libstd in a future patch once I submit support for Xous in `dlmalloc` and `compiler-builtins`.

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Testing is currently done on real hardware or in a Renode emulator. I can add documentation on how to do this in a future patch, and I would need instructions on where to add said documentation.

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Alright.

> Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

Sounds good.

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

This shouldn't affect any other targets, so this is understood.

> In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

This shouldn't come up right away. `xous` is a new operating system, and most features are keyed off of `target(os = "xous")` rather than a given architecture.

2 years agoAuto merge of #97391 - Urgau:cfg_accessible, r=petrochenkov
bors [Sun, 5 Jun 2022 04:16:03 +0000 (04:16 +0000)]
Auto merge of #97391 - Urgau:cfg_accessible, r=petrochenkov

Handle more cases in cfg_accessible

This PR tries to handle more cases in the cfg_accessible implementation by only emitting a "not sure" error only if we have partially resolved a path.

This PR also adds many tests for the "not sure" cases and for private items.

r? `@petrochenkov`

2 years agotypo: `-Zcodegen-backend=llvm -Cpasses=list` should work now
klensy [Sun, 5 Jun 2022 04:02:32 +0000 (07:02 +0300)]
typo: `-Zcodegen-backend=llvm -Cpasses=list` should work now

2 years agoAuto merge of #93717 - pietroalbini:pa-ci-profiler, r=Mark-Simulacrum
bors [Sun, 5 Jun 2022 01:35:03 +0000 (01:35 +0000)]
Auto merge of #93717 - pietroalbini:pa-ci-profiler, r=Mark-Simulacrum

Add build metrics to rustbuild

This PR adds a new module of rustbuild, `ci_profiler`, whose job is to gather as much information as possible about the CI build as possible and store it in a JSON file uploaded to `ci-artifacts`. Right now for each step it collects:

* Type name and debug representation of the `Step` object.
* Duration of the step (excluding child steps).
* Systemwide CPU stats for the duration of the step (both single core and all cores).
* Which child steps were executed.

This is capable of replacing both the scripts to collect CPU stats and the `[TIMING]` lines in build logs (not yet removed, until we port our tooling to use the CI profiler). The format is also extensible to be able in the future to collect more information.

r? `@Mark-Simulacrum`

2 years agoUpdate library/std/src/collections/hash/set.rs
nzrq [Sun, 5 Jun 2022 00:03:55 +0000 (20:03 -0400)]
Update library/std/src/collections/hash/set.rs

Co-authored-by: David Tolnay <dtolnay@gmail.com>
2 years agoAuto merge of #97742 - matthiaskrgr:rollup-fr3j0t8, r=matthiaskrgr
bors [Sat, 4 Jun 2022 23:14:09 +0000 (23:14 +0000)]
Auto merge of #97742 - matthiaskrgr:rollup-fr3j0t8, r=matthiaskrgr

Rollup of 6 pull requests

Successful merges:

 - #97609 (Iterate over `maybe_unused_trait_imports` when checking dead trait imports)
 - #97688 (test const_copy to make sure bytewise pointer copies are working)
 - #97707 (Improve soundness of rustc_data_structures)
 - #97731 (Add regresion test for #87142)
 - #97735 (Don't generate "Impls on Foreign Types" for std)
 - #97737 (Fix pretty printing named bound regions under -Zverbose)

Failed merges:

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

2 years agoAllow unstable items to be re-exported unstably without requiring the feature be...
cole [Sat, 4 Jun 2022 22:05:33 +0000 (17:05 -0500)]
Allow unstable items to be re-exported unstably without requiring the feature be enabled

2 years agoRollup merge of #97737 - jackh726:verbose-pretty-printing-fix, r=compiler-errors
Matthias Krüger [Sat, 4 Jun 2022 21:42:04 +0000 (23:42 +0200)]
Rollup merge of #97737 - jackh726:verbose-pretty-printing-fix, r=compiler-errors

Fix pretty printing named bound regions under -Zverbose

Fixed regression introduced in #97023

r? `@compiler-errors`

cc `@cjgillot`

2 years agoRollup merge of #97735 - jsha:no-foreign-std, r=GuillaumeGomez
Matthias Krüger [Sat, 4 Jun 2022 21:42:03 +0000 (23:42 +0200)]
Rollup merge of #97735 - jsha:no-foreign-std, r=GuillaumeGomez

Don't generate "Impls on Foreign Types" for std

Hack: many traits and types in std are re-exported from core or alloc. In general, rustdoc is capable of recognizing these implementations as being on local types. However, in at least one case, rustdoc gets confused and labels an implementation as being on a foreign type. To make sure that confusion doesn't pass on to the reader, consider all implementations in std, core, and alloc to be on local types.

Demo: https://rustdoc.crud.net/jsha/no-foreign-std/std/clone/trait.Clone.html

2 years agoRollup merge of #97731 - JohnTitor:issue-87142, r=compiler-errors
Matthias Krüger [Sat, 4 Jun 2022 21:42:03 +0000 (23:42 +0200)]
Rollup merge of #97731 - JohnTitor:issue-87142, r=compiler-errors

Add regresion test for #87142

Closes #87142
r? `@compiler-errors`

2 years agoRollup merge of #97707 - Nilstrieb:data-structures-ub, r=cjgillot
Matthias Krüger [Sat, 4 Jun 2022 21:42:02 +0000 (23:42 +0200)]
Rollup merge of #97707 - Nilstrieb:data-structures-ub, r=cjgillot

Improve soundness of rustc_data_structures

Make it runnable in miri by adding some ignores and changing N in miri. Also fix a stacked borrows issue in sip128.

2 years agoRollup merge of #97688 - RalfJung:test-const-cpy, r=Mark-Simulacrum
Matthias Krüger [Sat, 4 Jun 2022 21:42:01 +0000 (23:42 +0200)]
Rollup merge of #97688 - RalfJung:test-const-cpy, r=Mark-Simulacrum

test const_copy to make sure bytewise pointer copies are working

This is non-trivial; for `swap_nonoverlapping`, this is [not working](https://github.com/rust-lang/rust/issues/83163#issuecomment-1145917372).

2 years agoRollup merge of #97609 - Elliot-Roberts:unused-trait-refactor, r=cjgillot
Matthias Krüger [Sat, 4 Jun 2022 21:42:00 +0000 (23:42 +0200)]
Rollup merge of #97609 - Elliot-Roberts:unused-trait-refactor, r=cjgillot

Iterate over `maybe_unused_trait_imports` when checking dead trait imports

Closes #96873
r? `@cjgillot`

Some questions, if you have time:

- Is there a way to shorten the `rustc_data_structures::fx::FxIndexSet` path in the query declaration? I wasn't sure where to put a `use`.
- Was returning by reference from the query the right choice here?
- How would I go about evaluating the importance of the `is_dummy()` call in `check_crate`? I don't see failing tests when I comment it out. Should I just try to determine whether dummy spans can ever be put into `maybe_unused_trait_imports`?
- Am I doing anything silly with the various ID types?
- Is that `let-else` with `unreachable!()` bad? (i.e is there a better idiom? Would `panic!("<explanation>")` be better?)
- If I want to evaluate the perf of using a `Vec` as mentioned in #96873, is the best way to use the CI or is it feasible locally?

Thanks :)

2 years agoFix pretty printing named bound regions under -Zverbose
Jack Huey [Sat, 4 Jun 2022 18:31:17 +0000 (14:31 -0400)]
Fix pretty printing named bound regions under -Zverbose

2 years agoAuto merge of #97191 - wesleywiser:main_thread_name, r=ChrisDenton
bors [Sat, 4 Jun 2022 20:27:53 +0000 (20:27 +0000)]
Auto merge of #97191 - wesleywiser:main_thread_name, r=ChrisDenton

Call the OS function to set the main thread's name on program init

Normally, `Thread::spawn` takes care of setting the thread's name, if
one was provided, but since the main thread wasn't created by calling
`Thread::spawn`, we need to call that function in `std::rt::init`.

This is mainly useful for system tools like debuggers and profilers
which might show the thread name to a user. Prior to these changes, gdb
and WinDbg would show all thread names except the main thread's name to
a user. I've validated that this patch resolves the issue for both
debuggers.

2 years agoIterate over `maybe_unused_trait_imports` when checking dead trait imports
Elliot Roberts [Tue, 31 May 2022 23:59:28 +0000 (16:59 -0700)]
Iterate over `maybe_unused_trait_imports` when checking dead trait imports

2 years agoAdded test for #97732
Chase Wilson [Sat, 4 Jun 2022 18:33:56 +0000 (13:33 -0500)]
Added test for #97732

2 years agoDon't generate "Impls on Foreign Types" for std
Jacob Hoffman-Andrews [Sat, 4 Jun 2022 18:03:45 +0000 (11:03 -0700)]
Don't generate "Impls on Foreign Types" for std

Hack: many traits and types in std are re-exported from core or alloc. In
general, rustdoc is capable of recognizing these implementations as being
on local types. However, in at least one case, rustdoc gets confused and
labels an implementation as being on a foreign type. To make sure that
confusion doesn't pass on to the reader, consider all implementations in
std, core, and alloc to be on local types.

2 years agoAuto merge of #97529 - Urgau:bootstrap-check-cfg-features, r=Mark-Simulacrum
bors [Sat, 4 Jun 2022 17:47:14 +0000 (17:47 +0000)]
Auto merge of #97529 - Urgau:bootstrap-check-cfg-features, r=Mark-Simulacrum

Use new cargo argument in bootstrap for cfg checking

This PR use new cargo argument in bootstrap for doing cfg checking.

Follow-up to https://github.com/rust-lang/rust/pull/97044 and https://github.com/rust-lang/rust/pull/97214.

r? `@Mark-Simulacrum`

2 years agoupdate tests
Pietro Albini [Sat, 4 Jun 2022 17:38:51 +0000 (19:38 +0200)]
update tests

2 years agoFixed premature assertions that caused -Z randomize-layout to fail on alloc
Chase Wilson [Sat, 4 Jun 2022 17:33:01 +0000 (12:33 -0500)]
Fixed premature assertions that caused -Z randomize-layout to fail on alloc

2 years agoaddress review comments
Pietro Albini [Sat, 4 Jun 2022 17:24:41 +0000 (19:24 +0200)]
address review comments

2 years agobump sysinfo version
Pietro Albini [Sat, 4 Jun 2022 16:59:07 +0000 (18:59 +0200)]
bump sysinfo version

2 years agoFix stacked borrows invalidation in rustc_data_structures sip128
Nilstrieb [Fri, 3 Jun 2022 20:03:21 +0000 (22:03 +0200)]
Fix stacked borrows invalidation in rustc_data_structures sip128

It creates the src pointer first, which is then invalidated by a
unique borrow of the destination pointer. Swap the borrows around
to fix this. Found with miri.

2 years agoAdapt rustc_data_structures tests to run in strict miri
Nilstrieb [Fri, 3 Jun 2022 20:01:56 +0000 (22:01 +0200)]
Adapt rustc_data_structures tests to run in strict miri

Some tests took too long and owning_ref is fundamentally flawed,
so don't run these tests or run them with a shorter N. This makes
miri with `-Zmiri-strict-provenance` usable to find UB.

2 years agoAuto merge of #97137 - Kobzol:ci-llvm-pgo-pid, r=Mark-Simulacrum
bors [Sat, 4 Jun 2022 14:30:36 +0000 (14:30 +0000)]
Auto merge of #97137 - Kobzol:ci-llvm-pgo-pid, r=Mark-Simulacrum

Add PID to LLVM PGO profile path

This is a continuation of https://github.com/rust-lang/rust/pull/97110, which adds PID to the filename pattern of LLVM profiles. It also adds some metrics to the pgo.sh script, so that we can observe how many profiles there are and how large are they.

r? `@lqd`

2 years agoUpdate src/test/debuginfo/thread-names.rs
Wesley Wiser [Fri, 3 Jun 2022 15:36:54 +0000 (11:36 -0400)]
Update src/test/debuginfo/thread-names.rs

Co-authored-by: Chris Denton <ChrisDenton@users.noreply.github.com>