]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoSet LLVM_INCLUDE_TESTS=OFF when building LLVM
Nikita Popov [Sat, 7 Aug 2021 15:23:12 +0000 (17:23 +0200)]
Set LLVM_INCLUDE_TESTS=OFF when building LLVM

When LLVM_INCLUDE_TESTS is enabled (by default), LLVM requires
Python 3.6 for the lit test runner, otherwise only Python 3.0 is
required.

As we have many docker images using Ubuntu 16.04, which only has
Python 3.5, this avoids the need to install a newer Python version
for them.

2 years agoUse llvm.compiler.used insetad of llvm.used
Nikita Popov [Sat, 7 Aug 2021 15:04:32 +0000 (17:04 +0200)]
Use llvm.compiler.used insetad of llvm.used

The #[used] attribute explicitly only requires symbols to be
retained in object files, but allows the linker to drop them
if dead. This corresponds to llvm.compiler.used semantics.

The motivation to change this *now* is that https://reviews.llvm.org/D97448
starts emitting #[used] symbols into unique sections with
SHF_GNU_RETAIN flag. This triggers a bug in some version of gold,
resulting in the ARGV_INIT_ARRAY symbol part of the .init_array
section to be incorrectly placed.

2 years agoUpdate coverage LLVM IR test
Nikita Popov [Thu, 29 Jul 2021 19:12:45 +0000 (21:12 +0200)]
Update coverage LLVM IR test

This uses comdats since LLVM 13, causing various minor changes to the
output.

2 years agoUpdate powerpc64 data layout
Nikita Popov [Wed, 28 Jul 2021 20:48:45 +0000 (22:48 +0200)]
Update powerpc64 data layout

2 years agoUpdate wasm data layout
Nikita Popov [Wed, 28 Jul 2021 20:26:14 +0000 (22:26 +0200)]
Update wasm data layout

2 years agoRemove codegen/issue-83623-SIMD-PartialEq.rs
Nikita Popov [Wed, 28 Jul 2021 20:15:51 +0000 (22:15 +0200)]
Remove codegen/issue-83623-SIMD-PartialEq.rs

This has regressed due to https://bugs.llvm.org/show_bug.cgi?id=51211.
It's pretty likely that we'll have to eat this regression for this
release.

2 years agoHandle SrcMgr diagnostics
Nikita Popov [Wed, 28 Jul 2021 19:31:47 +0000 (21:31 +0200)]
Handle SrcMgr diagnostics

This is how InlineAsm diagnostics with source information are
reported now. Previously a separate InlineAsm diagnostic handler
was used.

2 years agoUpdate codegen tests for LLVM 13
Nikita Popov [Sun, 25 Jul 2021 19:54:48 +0000 (21:54 +0200)]
Update codegen tests for LLVM 13

2 years agoAuto merge of #88032 - hyd-dev:no-mangle-method, r=petrochenkov
bors [Mon, 16 Aug 2021 09:38:18 +0000 (09:38 +0000)]
Auto merge of #88032 - hyd-dev:no-mangle-method, r=petrochenkov

Fix `reachable_set` for non-function items in non-library crates

I unintentionally changed `reachable_set` to ignore non-function items when `!self.any_library` in https://github.com/rust-lang/rust/pull/86492, which can lead to "undefined reference" errors in non-library (`cdylib`/`staticlib`/`bin`) crates, for example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=6bb2c5065a9be7e40943d0541e161b5a

This PR restores the behavior of `reachable_set` for non-function items.

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

<details>
<summary>The modified test will fail with this output without the `reachable_set` change</summary>

```
---- [codegen] codegen/external-no-mangle-statics.rs#staticlib stdout ----

error in revision `staticlib`: verification with 'FileCheck' failed
status: exit status: 1
command: "/checkout/build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck" "--input-file" "/checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll" "/checkout/src/test/codegen/external-no-mangle-statics.rs" "--check-prefixes" "CHECK,NONMSVC,staticlib"
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
/checkout/src/test/codegen/external-no-mangle-statics.rs:10:11: error: CHECK: expected string not found in input
// CHECK: `@A` = local_unnamed_addr constant
          ^
/checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll:1:1: note: scanning from here
; ModuleID = 'external_no_mangle_statics.b50529d3-cgu.0'
^
/checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll:1:6: note: possible intended match here
; ModuleID = 'external_no_mangle_statics.b50529d3-cgu.0'
     ^

Input file: /checkout/build/x86_64-unknown-linux-gnu/test/codegen/external-no-mangle-statics.staticlib/external-no-mangle-statics.ll
Check file: /checkout/src/test/codegen/external-no-mangle-statics.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ; ModuleID = 'external_no_mangle_statics.b50529d3-cgu.0'
check:10'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:10'1          ?                                                   possible intended match
            2: source_filename = "external_no_mangle_statics.b50529d3-cgu.0"
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            3: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4: target triple = "x86_64-unknown-linux-gnu"
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            5:
check:10'0     ~
            6: !llvm.module.flags = !{!0, !1}
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            .
            .
            .
>>>>>>

------------------------------------------

failures:
    [codegen] codegen/external-no-mangle-statics.rs#staticlib
```
</details>

2 years agoAuto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser
bors [Mon, 16 Aug 2021 06:36:13 +0000 (06:36 +0000)]
Auto merge of #84039 - jyn514:uplift-atomic-ordering, r=wesleywiser

Uplift the invalid_atomic_ordering lint from clippy to rustc

This is mostly just a rebase of https://github.com/rust-lang/rust/pull/79654; I've copy/pasted the text from that PR below.

r? `@lcnr` since you reviewed the last one, but feel free to reassign.

---

This is an implementation of https://github.com/rust-lang/compiler-team/issues/390.

As mentioned, in general this turns an unconditional runtime panic into a (compile time) lint failure. It has no false positives, and the only false negatives I'm aware of are if `Ordering` isn't specified directly and is comes from an argument/constant/whatever.

As a result of it having no false positives, and the alternative always being strictly wrong, it's on as deny by default. This seems right.

In the [zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Uplift.20the.20.60invalid_atomic_ordering.60.20lint.20from.20clippy/near/218483957) `@joshtriplett` suggested that lang team should FCP this before landing it. Perhaps libs team cares too?

---

Some notes on the code for reviewers / others below

## Changes from clippy

The code is changed from [the implementation in clippy](https://github.com/rust-lang/rust-clippy/blob/68cf94f6a66e47234e3adefc6dfbe806cd6ad164/clippy_lints/src/atomic_ordering.rs) in the following ways:

1. Uses `Symbols` and `rustc_diagnostic_item`s instead of string literals.
    - It's possible I should have just invoked Symbol::intern for some of these instead? Seems better to use symbol, but it did require adding several.
2. The functions are moved to static methods inside the lint struct, as a way to namespace them.
    - There's a lot of other code in that file — which I picked as the location for this lint because `@jyn514` told me that seemed reasonable.
3. Supports unstable AtomicU128/AtomicI128.
    - I did this because it was almost easier to support them than not — not supporting them would have (ideally) required finding a way not to give them a `rustc_diagnostic_item`, which would have complicated an already big macro.
    - These don't have tests since I wasn't sure if/how I should make tests conditional on whether or not the target has the atomic... This is to a certain extent an issue of 64bit atomics too, but 128-bit atomics are much less common. Regardless, the existing tests should be *more* than thorough enough here.
4. Minor changes like:
    - grammar tweaks ("loads cannot have `Release` **and** `AcqRel` ordering" => "loads cannot have `Release` **or** `AcqRel` ordering")
    - function renames (`match_ordering_def_path` => `matches_ordering_def_path`),
    - avoiding clippy-specific helper methods that don't exist in rustc_lint and didn't seem worth adding for this case (for example `cx.struct_span_lint` vs clippy's `span_lint_and_help` helper).

## Potential issues

(This is just about the code in this PR, not conceptual issues with the lint or anything)

1. I'm not sure if I should have used a diagnostic item for `Ordering` and its variants (I couldn't figure out how really, so if I should do this some pointers would be appreciated).
    - It seems possible that failing to do this might possibly mean there are more cases this lint would miss, but I don't really know how `match_def_path` works and if it has any pitfalls like that, so maybe not.

2. I *think* I deprecated the lint in clippy (CC `@flip1995` who asked to be notified about clippy changes in the future in [this comment](https://github.com/rust-lang/rust/pull/75671#issuecomment-718731659)) but I'm not sure if I need to do anything else there.
    - I'm kind of hoping CI will catch if I missed anything, since `x.py test src/tools/clippy` fails with a lot of errors with and without my changes (and is probably a nonsense command regardless). Running `cargo test` from src/tools/clippy also fails with unrelated errors that seem like refactorings that didnt update clippy? So, honestly no clue.

3. I wasn't sure if the description/example I gave good. Hopefully it is. The example is less thorough than the one from clippy here: https://rust-lang.github.io/rust-clippy/master/index.html#invalid_atomic_ordering. Let me know if/how I should change it if it needs changing.

4. It pulls in the `if_chain` crate. This crate was already used in clippy, and seems like it's used elsewhere in rustc, but I'm willing to rewrite it to not use this if needed (I'd prefer not to, all things being equal).

2 years agoOnly run expensive calculations if the method name is recognized
Joshua Nelson [Wed, 14 Jul 2021 00:18:43 +0000 (20:18 -0400)]
Only run expensive calculations if the method name is recognized

2 years agoUplift the `invalid_atomic_ordering` lint from clippy to rustc
Thom Chiovoloni [Wed, 2 Dec 2020 23:16:12 +0000 (15:16 -0800)]
Uplift the `invalid_atomic_ordering` lint from clippy to rustc

- Deprecate clippy::invalid_atomic_ordering
- Use rustc_diagnostic_item for the orderings in the invalid_atomic_ordering lint
- Reduce code duplication
- Give up on making enum variants diagnostic items and just look for
`Ordering` instead

  I ran into tons of trouble with this because apparently the change to
  store HIR attrs in a side table also gave the DefIds of the
  constructor instead of the variant itself. So I had to change
  `matches_ordering` to also check the grandparent of the defid as well.

- Rename `atomic_ordering_x` symbols to just the name of the variant
- Fix typos in checks - there were a few places that said "may not be
  Release" in the diagnostic but actually checked for SeqCst in the lint.
- Make constant items const
- Use fewer diagnostic items
- Only look at arguments after making sure the method matches

  This prevents an ICE when there aren't enough arguments.

- Ignore trait methods
- Only check Ctors instead of going through `qpath_res`

  The functions take values, so this couldn't ever be anything else.

- Add if_chain to allowed dependencies
- Fix grammar
- Remove unnecessary allow

2 years agoAuto merge of #87696 - ssomers:btree_lazy_iterator_cleanup, r=Mark-Simulacrum
bors [Mon, 16 Aug 2021 03:45:26 +0000 (03:45 +0000)]
Auto merge of #87696 - ssomers:btree_lazy_iterator_cleanup, r=Mark-Simulacrum

BTree: merge the complication introduced by #81486 and #86031

Also:
- Deallocate the last few tree nodes as soon as an `into_iter` iterator steps beyond the end, instead of waiting around for the drop of the iterator (just to share more code).
- Symmetric code for backward iteration.
- Mark unsafe the methods on dying handles, modelling dying handles after raw pointers: it's the caller's responsibility to use them safely.

r? `@Mark-Simulacrum`

2 years agoAuto merge of #80357 - c410-f3r:new-hir-let, r=matthewjasper
bors [Mon, 16 Aug 2021 00:31:42 +0000 (00:31 +0000)]
Auto merge of #80357 - c410-f3r:new-hir-let, r=matthewjasper

Introduce `hir::ExprKind::Let` - Take 2

Builds on #68577 and depends on #79328.

cc #53667

2 years agoAuto merge of #87590 - Amanieu:deprecate_llvm_asm, r=nagisa
bors [Sun, 15 Aug 2021 21:22:02 +0000 (21:22 +0000)]
Auto merge of #87590 - Amanieu:deprecate_llvm_asm, r=nagisa

Deprecate llvm_asm!

We would like to remove `llvm_asm!` from the compiler once `asm!` is stabilized. This PR deprecates `llvm_asm!` to encourage any remaining users to migrate to `asm!` (or if `asm!` is not supported for their target, to add this support to rustc).

The only remaining user of `llvm_asm!` in the standard library was `black_box`, which has been rewritten to use volatile operations when `asm!` is not available on the current target.

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

cc `@RalfJung` for the changes to `black_box` which might affect Miri.

r? `@nagisa`

2 years agoIntroduce hir::ExprKind::Let - Take 2
Caio [Sun, 8 Aug 2021 14:49:13 +0000 (11:49 -0300)]
Introduce hir::ExprKind::Let - Take 2

2 years agoUse correct drop scopes for if expressions
Matthew Jasper [Thu, 25 Feb 2021 22:37:22 +0000 (22:37 +0000)]
Use correct drop scopes for if expressions

2 years agoAuto merge of #87982 - m-ou-se:non-fmt-panic-assert-str, r=cjgillot
bors [Sun, 15 Aug 2021 17:57:39 +0000 (17:57 +0000)]
Auto merge of #87982 - m-ou-se:non-fmt-panic-assert-str, r=cjgillot

Add automatic migration for assert!(.., string).

Fixes part of #87313.

2 years agoAuto merge of #87792 - GuillaumeGomez:ci-fetch, r=pietroalbini
bors [Sun, 15 Aug 2021 14:02:40 +0000 (14:02 +0000)]
Auto merge of #87792 - GuillaumeGomez:ci-fetch, r=pietroalbini

Remove git fetch from CI

https://github.com/rust-lang/rust/pull/86623 added a call to `git fetch`, which is problematic for releases.

r? `@pietroalbini`

2 years agoFix ui tests for llvm_asm! deprecation
Amanieu d'Antras [Thu, 29 Jul 2021 17:45:13 +0000 (19:45 +0200)]
Fix ui tests for llvm_asm! deprecation

2 years agoAllow the use of the deprecated llvm_asm! in black_box
Amanieu d'Antras [Wed, 11 Aug 2021 23:18:53 +0000 (00:18 +0100)]
Allow the use of the deprecated llvm_asm! in black_box

2 years agoDeprecate llvm_asm!
Amanieu d'Antras [Thu, 29 Jul 2021 14:51:32 +0000 (16:51 +0200)]
Deprecate llvm_asm!

2 years agoAuto merge of #86692 - dns2utf8:parallelize_rustdoc-gui_tests, r=GuillaumeGomez
bors [Sun, 15 Aug 2021 10:56:35 +0000 (10:56 +0000)]
Auto merge of #86692 - dns2utf8:parallelize_rustdoc-gui_tests, r=GuillaumeGomez

Run rustdoc-gui tests in parallel

I hid the passing tests and only show the failed ones in alphabetical order:
![image](https://user-images.githubusercontent.com/739070/123663020-84e63100-d825-11eb-9b35-0a8c30cd219c.png)

Also this PR cuts down the execution time from ~40 to ~9 seconds

2 years agoAuto merge of #87975 - m-ou-se:unused-import-attributes, r=nagisa
bors [Sun, 15 Aug 2021 07:40:53 +0000 (07:40 +0000)]
Auto merge of #87975 - m-ou-se:unused-import-attributes, r=nagisa

Include attributes in removal span for unused imports.

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

2 years agoAuto merge of #87974 - steffahn:slice_split_size_hints, r=dtolnay
bors [Sun, 15 Aug 2021 04:48:42 +0000 (04:48 +0000)]
Auto merge of #87974 - steffahn:slice_split_size_hints, r=dtolnay

Test and fix `size_hint` for slice’s [r]split* iterators

Adds extensive test (of `size_hint`) for all the _[r]split*_ iterators.
Fixes `size_hint` upper bound for _split_inclusive*_ iterators which was one higher than necessary for non-empty slices.
Fixes `size_hint` lower bound for _[r]splitn*_ iterators when _n == 0_, which was one too high.

**Lower bound being one too high was a logic error, violating the correctness condition of `size_hint`.**

_Edit:_ I’ve opened an issue for that bug, so this PR fixes #87978

2 years agoAuto merge of #87581 - Amanieu:asm_clobber_abi, r=nagisa
bors [Sat, 14 Aug 2021 22:29:27 +0000 (22:29 +0000)]
Auto merge of #87581 - Amanieu:asm_clobber_abi, r=nagisa

Add support for clobber_abi to asm!

This PR adds the `clobber_abi` feature that was proposed in #81092.

Fixes #81092

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

r? `@nagisa`

2 years agoMore spacing between the different blocks of results
Stefan Schindler [Sat, 14 Aug 2021 21:36:17 +0000 (23:36 +0200)]
More spacing between the different blocks of results

2 years agoImplement a finish method for the status_bar and some cleanup
Stefan Schindler [Sat, 14 Aug 2021 21:19:28 +0000 (23:19 +0200)]
Implement a finish method for the status_bar and some cleanup

2 years agoAuto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk
bors [Sat, 14 Aug 2021 19:59:08 +0000 (19:59 +0000)]
Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk

Run RemoveZsts pass at mir-opt-level=1

per https://github.com/rust-lang/rust/pull/83177#issuecomment-803942217

This pass removes assignments to ZST places.

Perf (from https://github.com/rust-lang/rust/pull/83177#issuecomment-803442557): https://perf.rust-lang.org/compare.html?start=41b315a470d583f6446599984ff9ad3bd61012b2&end=bd5d1b96f0c64c9938feea831789e1b5bb2cd4a2

r? `@oli-obk`

2 years agoFix `reachable_set` for non-function items in non-library crates
hyd-dev [Sat, 14 Aug 2021 15:24:33 +0000 (23:24 +0800)]
Fix `reachable_set` for non-function items in non-library crates

2 years agoAuto merge of #87324 - asquared31415:named-asm-labels, r=Amanieu
bors [Sat, 14 Aug 2021 17:33:38 +0000 (17:33 +0000)]
Auto merge of #87324 - asquared31415:named-asm-labels, r=Amanieu

Lint against named asm labels

This adds a deny-by-default lint to prevent the use of named labels in inline `asm!`.  Without a solution to #81088 about whether the compiler should rewrite named labels or a special syntax for labels, a lint against them should prevent users from writing assembly that could break for internal compiler reasons, such as inlining or anything else that could change the number of actual inline assembly blocks emitted.

This does **not** resolve the issue with rewriting labels, that still needs a decision if the compiler should do any more work to try to make them work.

2 years agoAuto merge of #87913 - a1phyr:vec_spec_clone_from, r=dtolnay
bors [Sat, 14 Aug 2021 14:52:33 +0000 (14:52 +0000)]
Auto merge of #87913 - a1phyr:vec_spec_clone_from, r=dtolnay

Specialize `Vec::clone_from` for `Copy` types

This should improve performance and reduce code size.

This also improves `clone_from` for `String`, `OsString` and `PathBuf`.

2 years agoAuto merge of #87375 - fee1-dead:move-constness-to-traitpred, r=oli-obk
bors [Sat, 14 Aug 2021 12:06:34 +0000 (12:06 +0000)]
Auto merge of #87375 - fee1-dead:move-constness-to-traitpred, r=oli-obk

Try filtering out non-const impls when we expect const impls

**TL;DR**: Associated types on const impls are now bounded; we now disallow calling a const function with bounds when the specified type param only has a non-const impl.

r? `@oli-obk`

2 years agoAuto merge of #87600 - JohnTitor:classify-ui-tests, r=petrochenkov
bors [Sat, 14 Aug 2021 09:25:33 +0000 (09:25 +0000)]
Auto merge of #87600 - JohnTitor:classify-ui-tests, r=petrochenkov

Move some UI tests to more suitable subdirs

The classifui result: https://gist.github.com/JohnTitor/c9e00840990b5e4a8fc562ec3571e427/e06c42226c6038da91e403c33b9947843420cf44

Some notes:
- backtrace-debuginfo.rs: previously I skipped this, I'm still not sure what the best dir is. Any ideas?
- estr-subtyping.rs: Seems a quite old test so removed, shouldn't?
- deref-suggestion.rs: moved to inference as `suggestions` is not an ideal dir.
- issue-43023.rs: a bit misclassified, moved to `derives`

cc #73494
r? `@petrochenkov`

2 years agoAuto merge of #85020 - lrh2000:named-upvars, r=tmandry
bors [Sat, 14 Aug 2021 07:01:36 +0000 (07:01 +0000)]
Auto merge of #85020 - lrh2000:named-upvars, r=tmandry

Name the captured upvars for closures/generators in debuginfo

Previously, debuggers print closures as something like
```
y::main::closure-0 (0x7fffffffdd34)
```
The pointer actually references to an upvar. It is not very obvious, especially for beginners.

It's because upvars don't have names before, as they are packed into a tuple. This PR names the upvars, so we can expect to see something like
```
y::main::closure-0 {_captured_ref__b: 0x[...]}
```

r? `@tmandry`
Discussed at https://github.com/rust-lang/rust/pull/84752#issuecomment-831639489 .

2 years agoAuto merge of #88006 - GuillaumeGomez:update-browser-ui-test-dep, r=notriddle
bors [Sat, 14 Aug 2021 04:09:22 +0000 (04:09 +0000)]
Auto merge of #88006 - GuillaumeGomez:update-browser-ui-test-dep, r=notriddle

Update browser-ui-test package version

r? `@notriddle`

2 years agoAuto merge of #87997 - sl4m:update-favicon-order, r=GuillaumeGomez
bors [Sat, 14 Aug 2021 01:12:22 +0000 (01:12 +0000)]
Auto merge of #87997 - sl4m:update-favicon-order, r=GuillaumeGomez

Updates favicon order of precedence as it matters to Chrome

Hi, this updates #75438 to fix an order of precedence issue for Chrome. Unfortunately, the last favicon defined wins when it comes to Chrome, hence the primary icon being placed last. I [brought it up](https://bugs.chromium.org/p/chromium/issues/detail?id=1104663) with the Chromium team last year, but so far it's a non-issue.

I've created an example website that mimics the behaviour in Chrome. https://sl4m.github.io/chrome-favicon/

This is what I'm seeing at the moment when viewing https://doc.rust-lang.org/core/index.html in Chrome. It's falling back to the PNG.

<img width="80" alt="Screenshot 2021-08-12 at 21 11 58" src="https://user-images.githubusercontent.com/47347/129304041-b598213e-fcd3-4df1-addb-e6feac6c35b1.png">

2 years agoAuto merge of #87478 - jackh726:issue-84931, r=estebank
bors [Fri, 13 Aug 2021 22:28:01 +0000 (22:28 +0000)]
Auto merge of #87478 - jackh726:issue-84931, r=estebank

Point to where clause for GATs to add bound

Fixes #84931

r? `@estebank`

2 years agoPoint to where clause for GATs
jackh726 [Mon, 26 Jul 2021 02:12:34 +0000 (22:12 -0400)]
Point to where clause for GATs

2 years agoAuto merge of #86492 - hyd-dev:no-mangle-method, r=petrochenkov
bors [Fri, 13 Aug 2021 19:47:03 +0000 (19:47 +0000)]
Auto merge of #86492 - hyd-dev:no-mangle-method, r=petrochenkov

Associated functions that contain extern indicator or have `#[rustc_std_internal_symbol]` are reachable

Previously these fails to link with ``undefined reference to `foo'``:

<details>
<summary>Example 1</summary>

```rs
struct AssocFn;

impl AssocFn {
    #[no_mangle]
    fn foo() {}
}

fn main() {
    extern "Rust" {
        fn foo();
    }
    unsafe { foo() }
}
```
([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=f1244afcdd26e2a28445f6e82ca46b50))
</details>

<details>
<summary>Example 2</summary>

```rs
#![crate_name = "lib"]
#![crate_type = "lib"]

struct AssocFn;

impl AssocFn {
    #[no_mangle]
    fn foo() {}
}
```
```rs
extern crate lib;

fn main() {
    extern "Rust" {
        fn foo();
    }
    unsafe { foo() }
}
```
</details>

But I believe they should link successfully, because this works:
<details>

```rs
#[no_mangle]
fn foo() {}

fn main() {
    extern "Rust" {
        fn foo();
    }
    unsafe { foo() }
}
```
([Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=789b3f283ee6126f53939429103ed98d))
</details>

This PR fixes the problem, by adding associated functions that have "custom linkage" to `reachable_set`, just like normal functions.

I haven't tested whether #76211 and [Miri](https://github.com/rust-lang/miri/issues/1837) are fixed by this PR yet, but I'm submitting this anyway since this fixes the examples above.

I added a `run-pass` test that combines my two examples above, but I'm not sure if that's the right way to test this. Maybe I should add / modify an existing codegen test (`src/test/codegen/export-no-mangle.rs`?) instead?

2 years agoAuto merge of #87984 - m-ou-se:closure-lint-wording, r=Aaron1011
bors [Fri, 13 Aug 2021 16:57:34 +0000 (16:57 +0000)]
Auto merge of #87984 - m-ou-se:closure-lint-wording, r=Aaron1011

Closure lint wording

Some small changes to the wording of the closure migration lint.

r? `@Aaron1011`

2 years agoUpdate tests for new closure migration lint wording.
Mara Bos [Thu, 12 Aug 2021 19:13:00 +0000 (21:13 +0200)]
Update tests for new closure migration lint wording.

2 years agoUpdate closure migration diagnostic wording.
Mara Bos [Thu, 12 Aug 2021 19:12:12 +0000 (21:12 +0200)]
Update closure migration diagnostic wording.

2 years agoAuto merge of #88009 - GuillaumeGomez:rollup-f194yyk, r=GuillaumeGomez
bors [Fri, 13 Aug 2021 14:16:12 +0000 (14:16 +0000)]
Auto merge of #88009 - GuillaumeGomez:rollup-f194yyk, r=GuillaumeGomez

Rollup of 4 pull requests

Successful merges:

 - #87795 (Avoid ICE caused by suggestion)
 - #87966 (Fix `command-create-pidfd` test inside unprivileged Docker containers)
 - #87969 (Revert "Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov")
 - #88005 (Add rustdoc GUI test for headers)

Failed merges:

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

2 years agoRollup merge of #88005 - GuillaumeGomez:headers-gui-tests, r=notriddle
Guillaume Gomez [Fri, 13 Aug 2021 13:29:12 +0000 (15:29 +0200)]
Rollup merge of #88005 - GuillaumeGomez:headers-gui-tests, r=notriddle

Add rustdoc GUI test for headers

Add test for #87861.

r? ``@notriddle``

2 years agoRollup merge of #87969 - Aaron1011:revert-stmt-id, r=petrochenkov
Guillaume Gomez [Fri, 13 Aug 2021 13:29:12 +0000 (15:29 +0200)]
Rollup merge of #87969 - Aaron1011:revert-stmt-id, r=petrochenkov

Revert "Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov"

Fixes #87877

This change interacts badly with `noop_flat_map_stmt`,
which synthesizes multiple statements with the same `NodeId`.

I'm working on a better fix that will still allow us to
remove this special case. For now, let's revert the change
to fix the ICE.

This reverts commit a4262cc9841d91d48ef994b36eab323e615a7083, reversing
changes made to 8ee962f88e1be7e29482b13c7776c26b98a93bf7.

2 years agoRollup merge of #87966 - pietroalbini:fix-pidfd-test, r=m-ou-se
Guillaume Gomez [Fri, 13 Aug 2021 13:29:11 +0000 (15:29 +0200)]
Rollup merge of #87966 - pietroalbini:fix-pidfd-test, r=m-ou-se

Fix `command-create-pidfd` test inside unprivileged Docker containers

In `src/test/ui/command/command-create-pidfd.rs` (added #81825), the detection code to skip the test on unsupported platforms doesn't account for unprivileged Docker containers (CI uses privileged containers), which leads to a test failure as you can't call the `clone3` syscall in that environment. This PR enhances the detection code to also consider unprivileged containers.

2 years agoRollup merge of #87795 - estebank:erase-lifetimes-in-suggestion, r=oli-obk
Guillaume Gomez [Fri, 13 Aug 2021 13:29:10 +0000 (15:29 +0200)]
Rollup merge of #87795 - estebank:erase-lifetimes-in-suggestion, r=oli-obk

Avoid ICE caused by suggestion

When suggesting dereferencing something that can be iterable in a `for`
loop, erase lifetimes and use a fresh `ty::ParamEnv` to avoid 'region
constraints already solved' panic.

Fix #87657, fix #87709, fix #87651.

2 years agoImprove wording, correct -> tight.
Frank Steffahn [Fri, 13 Aug 2021 12:41:50 +0000 (14:41 +0200)]
Improve wording, correct -> tight.

2 years agoUpdate browser-ui-test package version
Guillaume Gomez [Fri, 13 Aug 2021 12:52:28 +0000 (14:52 +0200)]
Update browser-ui-test package version

2 years agoAdd rustdoc GUI test for headers
Guillaume Gomez [Fri, 13 Aug 2021 12:23:13 +0000 (14:23 +0200)]
Add rustdoc GUI test for headers

2 years agoFix Cargo.lock and ui test
Deadbeef [Fri, 13 Aug 2021 11:30:33 +0000 (11:30 +0000)]
Fix Cargo.lock and ui test

2 years agoUse is_diagnostic_item instead of get_diagnostic_item.
Mara Bos [Thu, 12 Aug 2021 17:21:46 +0000 (19:21 +0200)]
Use is_diagnostic_item instead of get_diagnostic_item.

2 years agoUpdate non-fmt-panic tests.
Mara Bos [Thu, 12 Aug 2021 17:15:47 +0000 (19:15 +0200)]
Update non-fmt-panic tests.

2 years agoConsistent use of `impl Trait` arguments in the test's helper function.
Frank Steffahn [Fri, 13 Aug 2021 10:02:03 +0000 (12:02 +0200)]
Consistent use of `impl Trait` arguments in the test's helper function.

2 years agonon_fmt_panic: machine app. suggestion for assert with string msg.
Mara Bos [Thu, 12 Aug 2021 17:14:54 +0000 (19:14 +0200)]
non_fmt_panic: machine app. suggestion for assert with string msg.

2 years agomake check less conservative and add explanation
Deadbeef [Tue, 27 Jul 2021 01:51:57 +0000 (09:51 +0800)]
make check less conservative and add explanation

2 years agoBless test
Deadbeef [Mon, 26 Jul 2021 10:02:18 +0000 (18:02 +0800)]
Bless test

2 years agoMake assoc types work with `?const `opt=out
Deadbeef [Mon, 26 Jul 2021 09:25:01 +0000 (17:25 +0800)]
Make assoc types work with `?const `opt=out

2 years agoallow incomplete features for now
Deadbeef [Mon, 26 Jul 2021 08:53:36 +0000 (16:53 +0800)]
allow incomplete features for now

2 years agoMoved ui test
Deadbeef [Mon, 26 Jul 2021 06:04:55 +0000 (14:04 +0800)]
Moved ui test

2 years agoFix tests
Deadbeef [Mon, 26 Jul 2021 04:29:18 +0000 (12:29 +0800)]
Fix tests

2 years agoFix call-generic-method-nonconst test
Deadbeef [Mon, 26 Jul 2021 04:06:55 +0000 (12:06 +0800)]
Fix call-generic-method-nonconst test

2 years agoDon't transform predicates in Inherited
Deadbeef [Mon, 26 Jul 2021 04:06:32 +0000 (12:06 +0800)]
Don't transform predicates in Inherited

2 years agohandle the case when container is not impl
Deadbeef [Mon, 26 Jul 2021 03:34:43 +0000 (11:34 +0800)]
handle the case when container is not impl

2 years agoFix assoc-type test
Deadbeef [Mon, 26 Jul 2021 03:13:23 +0000 (11:13 +0800)]
Fix assoc-type test

2 years agoPass constness to SelectionContext
Deadbeef [Mon, 26 Jul 2021 02:52:17 +0000 (10:52 +0800)]
Pass constness to SelectionContext

2 years agoTry to fix problem
Deadbeef [Sat, 24 Jul 2021 15:32:43 +0000 (23:32 +0800)]
Try to fix problem

2 years agoRelate impl
Deadbeef [Sat, 24 Jul 2021 12:11:38 +0000 (20:11 +0800)]
Relate impl

2 years agoMake selection and evaluation caches use constness
Deadbeef [Sat, 24 Jul 2021 11:12:24 +0000 (19:12 +0800)]
Make selection and evaluation caches use constness

2 years agofmt
Deadbeef [Sat, 24 Jul 2021 07:48:51 +0000 (15:48 +0800)]
fmt

2 years agoInherited use constness and assoc change predicate
Deadbeef [Sat, 24 Jul 2021 06:34:53 +0000 (14:34 +0800)]
Inherited use constness and assoc change predicate

2 years agofmt
Deadbeef [Thu, 22 Jul 2021 16:07:56 +0000 (00:07 +0800)]
fmt

2 years agoFilter non-const impls when we expect a const one
Deadbeef [Thu, 22 Jul 2021 16:01:47 +0000 (00:01 +0800)]
Filter non-const impls when we expect a const one

2 years agomove Constness into TraitPredicate
Deadbeef [Thu, 22 Jul 2021 13:56:07 +0000 (21:56 +0800)]
move Constness into TraitPredicate

2 years agoAuto merge of #87956 - m-ou-se:closure-migration-macro-body, r=Aaron1011
bors [Fri, 13 Aug 2021 08:31:26 +0000 (08:31 +0000)]
Auto merge of #87956 - m-ou-se:closure-migration-macro-body, r=Aaron1011

Fix closure migration suggestion when the body is a macro.

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

Before:
```
warning: changes to closure capture in Rust 2021 will affect drop order
 --> src/main.rs:5:13
  |
5 |     let _ = || panic!(a.0);
  |             ^^^^^^^^^^---^
  |                       |
  |                       in Rust 2018, closure captures all of `a`, but in Rust 2021, it only captures `a.0`
6 | }
  | - in Rust 2018, `a` would be dropped here, but in Rust 2021, only `a.0` would be dropped here alongside the closure
  |

help: add a dummy let to cause `a` to be fully captured
  |
20~     ($msg:expr $(,)?) => ({ let _ = &a;
21+         $crate::rt::begin_panic($msg)
22~     }),
  |
```

After:
```
warning: changes to closure capture in Rust 2021 will affect drop order
 --> src/main.rs:5:13
  |
5 |     let _ = || panic!(a.0);
  |             ^^^^^^^^^^---^
  |                       |
  |                       in Rust 2018, closure captures all of `a`, but in Rust 2021, it only captures `a.0`
6 | }
  | - in Rust 2018, `a` would be dropped here, but in Rust 2021, only `a.0` would be dropped here alongside the closure
  |
help: add a dummy let to cause `a` to be fully captured
  |
5 |     let _ = || { let _ = &a; panic!(a.0) };
  |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

2 years agoAuto merge of #87954 - flip1995:clippyup, r=Manishearth
bors [Fri, 13 Aug 2021 05:30:37 +0000 (05:30 +0000)]
Auto merge of #87954 - flip1995:clippyup, r=Manishearth

Update Clippy

r? `@Manishearth`

2 years agoUpdates favicon order of precedence as it matters to Chrome
skim [Fri, 13 Aug 2021 04:08:14 +0000 (21:08 -0700)]
Updates favicon order of precedence as it matters to Chrome

2 years agoAuto merge of #87927 - spastorino:use-def-id-typeckresults, r=oli-obk
bors [Fri, 13 Aug 2021 02:49:45 +0000 (02:49 +0000)]
Auto merge of #87927 - spastorino:use-def-id-typeckresults, r=oli-obk

Make concrete_opaque_types be FxHashSet<DefId>

r? `@oli-obk`

`@bors` rollup=always

2 years agoAuto merge of #87980 - Manishearth:rollup-vkuix3y, r=Manishearth
bors [Thu, 12 Aug 2021 23:48:16 +0000 (23:48 +0000)]
Auto merge of #87980 - Manishearth:rollup-vkuix3y, r=Manishearth

Rollup of 4 pull requests

Successful merges:

 - #87916 (Implement `black_box` using intrinsic)
 - #87922 (Add c_enum_min_bits target spec field, use for arm-none and thumb-none targets)
 - #87953 (Improve formatting of closure capture migration suggestion for multi-line closures.)
 - #87965 (Silence non_fmt_panic from external macros.)

Failed merges:

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

2 years agoRewrite test from previous commit but without using macros.
Frank Steffahn [Thu, 12 Aug 2021 20:44:40 +0000 (22:44 +0200)]
Rewrite test from previous commit but without using macros.

2 years agoAuto merge of #87916 - nbdd0121:black_box, r=nagisa
bors [Thu, 12 Aug 2021 21:04:07 +0000 (21:04 +0000)]
Auto merge of #87916 - nbdd0121:black_box, r=nagisa

Implement `black_box` using intrinsic

Introduce `black_box` intrinsic, as suggested in https://github.com/rust-lang/rust/pull/87590#discussion_r680468700.

This is still codegenned as empty inline assembly for LLVM. For MIR interpretation and cranelift it's treated as identity.

cc `@Amanieu` as this is related to inline assembly
cc `@bjorn3` for rustc_codegen_cranelift changes
cc `@RalfJung` as this affects MIRI

r? `@nagisa` I suppose

2 years agoImprove fallback span for closure migration lint.
Mara Bos [Thu, 12 Aug 2021 18:35:54 +0000 (20:35 +0200)]
Improve fallback span for closure migration lint.

2 years agoImprove comment in closure migration code.
Mara Bos [Thu, 12 Aug 2021 18:28:34 +0000 (20:28 +0200)]
Improve comment in closure migration code.

2 years agoRollup merge of #87965 - m-ou-se:non-fmt-panic-external, r=estebank
Manish Goregaokar [Thu, 12 Aug 2021 17:04:16 +0000 (10:04 -0700)]
Rollup merge of #87965 - m-ou-se:non-fmt-panic-external, r=estebank

Silence non_fmt_panic from external macros.

This stops the non_fmt_panic lint from triggering if a macro from another crate is entirely responsible. In those cases there's nothing that the current crate can/should do.

See also https://github.com/rust-lang/rust/issues/87621#issuecomment-890311054

2 years agoRollup merge of #87953 - m-ou-se:closure-migration-multiline-formatting, r=petrochenkov
Manish Goregaokar [Thu, 12 Aug 2021 17:04:15 +0000 (10:04 -0700)]
Rollup merge of #87953 - m-ou-se:closure-migration-multiline-formatting, r=petrochenkov

Improve formatting of closure capture migration suggestion for multi-line closures.

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

Before:
```
help: add a dummy let to cause `a` to be fully captured
  |
5 ~     let _ = || { let _ = &a;
6 +         dbg!(a.0);
7 ~     };
  |
```

After:
```
help: add a dummy let to cause `a` to be fully captured
  |
5 ~     let _ = || {
6 +         let _ = &a;
7 +         dbg!(a.0);
8 ~     };
  |
```

2 years agoRollup merge of #87922 - Manishearth:c-enum-target-spec, r=nagisa,eddyb
Manish Goregaokar [Thu, 12 Aug 2021 17:04:14 +0000 (10:04 -0700)]
Rollup merge of #87922 - Manishearth:c-enum-target-spec, r=nagisa,eddyb

Add c_enum_min_bits target spec field, use for arm-none and thumb-none targets

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

<s>Haven't tested this yet, still playing around.</s>

This seems to fix the issue.

2 years agoRollup merge of #87916 - nbdd0121:black_box, r=nagisa
Manish Goregaokar [Thu, 12 Aug 2021 17:04:07 +0000 (10:04 -0700)]
Rollup merge of #87916 - nbdd0121:black_box, r=nagisa

Implement `black_box` using intrinsic

Introduce `black_box` intrinsic, as suggested in https://github.com/rust-lang/rust/pull/87590#discussion_r680468700.

This is still codegenned as empty inline assembly for LLVM. For MIR interpretation and cranelift it's treated as identity.

cc `@Amanieu` as this is related to inline assembly
cc `@bjorn3` for rustc_codegen_cranelift changes
cc `@RalfJung` as this affects MIRI

r? `@nagisa` I suppose

2 years agoApply c_enum_min_bits = 8 to (arm|thumb)-none- platforms
Manish Goregaokar [Tue, 10 Aug 2021 19:06:59 +0000 (12:06 -0700)]
Apply c_enum_min_bits = 8 to (arm|thumb)-none- platforms

2 years agoAdd c_enum_min_bits to target spec
Manish Goregaokar [Tue, 10 Aug 2021 18:34:13 +0000 (18:34 +0000)]
Add c_enum_min_bits to target spec

2 years agoAdd tests for `#[no_mangle]` in `impl` blocks that looks like generic `impl` blocks...
hyd-dev [Thu, 12 Aug 2021 16:11:44 +0000 (00:11 +0800)]
Add tests for `#[no_mangle]` in `impl` blocks that looks like generic `impl` blocks but are actually not

2 years agoAdd test or unused import removal suggestion with attributes.
Mara Bos [Thu, 12 Aug 2021 15:35:57 +0000 (17:35 +0200)]
Add test or unused import removal suggestion with attributes.

2 years agoInclude attributes in removal span for unused imports.
Mara Bos [Thu, 12 Aug 2021 15:35:37 +0000 (17:35 +0200)]
Include attributes in removal span for unused imports.

2 years agoTest and fix size_hint for slice's [r]split* iterators
Frank Steffahn [Thu, 12 Aug 2021 15:09:17 +0000 (17:09 +0200)]
Test and fix size_hint for slice's [r]split* iterators

Adds extensive test for all the [r]split* iterators.
Fixes size_hint upper bound for split_inclusive* iterators which was one higher than necessary for non-empty slices.
Fixes size_hint lower bound for [r]splitn* iterators when n==0, which was one too high.

2 years agoImplement `black_box` using intrinsic
Gary Guo [Tue, 10 Aug 2021 10:50:33 +0000 (11:50 +0100)]
Implement `black_box` using intrinsic

The new implementation allows some `memcpy`s to be optimized away,
so the uninit value in ui/sanitize/memory.rs is constructed directly
onto the return place. Therefore the sanitizer now says that the
value is allocated by `main` rather than `random`.

2 years agoAdjust `check_no_mangle` and `check_export_name` to warn/error on `#[no_mangle]`...
hyd-dev [Tue, 10 Aug 2021 18:41:57 +0000 (02:41 +0800)]
Adjust `check_no_mangle` and `check_export_name` to warn/error on `#[no_mangle]`/`#[export_name]` on trait methods

2 years agoAuto merge of #87963 - GuillaumeGomez:rollup-e54sbez, r=GuillaumeGomez
bors [Thu, 12 Aug 2021 13:24:29 +0000 (13:24 +0000)]
Auto merge of #87963 - GuillaumeGomez:rollup-e54sbez, r=GuillaumeGomez

Rollup of 4 pull requests

Successful merges:

 - #87819 (Use a more accurate span on assoc types WF checks)
 - #87863 (Fix Windows Command::env("PATH"))
 - #87885 (Link to edition guide instead of issues for 2021 lints.)
 - #87941 (Fix/improve rustdoc-js tool)

Failed merges:

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

2 years agoRevert "Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov"
Aaron Hill [Thu, 12 Aug 2021 13:23:56 +0000 (08:23 -0500)]
Revert "Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov"

Fixes #87877

This change interacts badly with `noop_flat_map_stmt`,
which synthesizes multiple statements with the same `NodeId`.

I'm working on a better fix that will still allow us to
remove this special case. For now, let's revert the change
to fix the ICE.

This reverts commit a4262cc9841d91d48ef994b36eab323e615a7083, reversing
changes made to 8ee962f88e1be7e29482b13c7776c26b98a93bf7.

2 years agofix command-create-pidfd test inside unprivileged docker containers
Pietro Albini [Thu, 12 Aug 2021 09:28:06 +0000 (11:28 +0200)]
fix command-create-pidfd test inside unprivileged docker containers

2 years agoSilence non_fmt_panic from external macros.
Mara Bos [Thu, 12 Aug 2021 12:33:30 +0000 (14:33 +0200)]
Silence non_fmt_panic from external macros.