Commit graph

148695 commits

Author SHA1 Message Date
bors
75da570d78 Auto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisa
Use the object crate for metadata reading

This allows sharing the metadata reader between cg_llvm, cg_clif and other codegen backends.

This is not currently useful for rlib reading with cg_spirv ([rust-gpu](https://github.com/EmbarkStudios/rust-gpu/)) as it uses tar rather than ar as .rlib format, but it is useful for dylib reading required for loading proc macros. (cc `@eddyb)`

The object crate is already trusted as dependency of libstd through backtrace. As far as I know it supports reading all object file formats used by targets for which we support rust dylibs with crate metadata, but I am not certain. If this happens to not be the case, I could keep using LLVM for reading dylib metadata.

Marked as WIP for a perf run and as it is based on #83637.
2021-05-14 12:58:58 +00:00
Alan Egerton
67e8f12307
Expose Concurrent (private type in public i'face) 2021-05-14 13:28:56 +01:00
ayushmishra2005
27defcd14f Addressed PR coments 2021-05-14 17:30:26 +05:30
Ian Jackson
88ccaa77f1 panic abort after fork test: Disable on android
And link to the issue.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-14 11:39:51 +01:00
bors
36a4d14c7e Auto merge of #85236 - nikic:update-llvm-submodule, r=cuviper
Update LLVM submodule

This merges recent changes from the upstream LLVM 12 branch. One of them is intended to address #84958.
2021-05-14 09:10:11 +00:00
bors
69b352ef77 Auto merge of #85233 - FabianWolff:issue-85227, r=petrochenkov
Improve error message for non-exhaustive matches on non-exhaustive enums

This pull request fixes #85227. For an enum marked with `#[non_exhaustive]` and not defined in the current crate, the error message for non-exhaustive matches now mentions the fact that the enum is marked as non-exhaustive:
```
error[E0004]: non-exhaustive patterns: `_` not covered
  --> main.rs:12:11
   |
12 |     match e {
   |           ^ pattern `_` not covered
   |
   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
   = note: the matched value is of type `E`, which is marked as non-exhaustive
```
2021-05-14 06:53:45 +00:00
Jacob Hoffman-Andrews
73a5c1f944 Toggle-wrap items differently than top-doc.
This makes sure things like trait methods get wrapped at the
`<h3><code>` level rather than at the `.docblock` level. Also it ensures
that only the actual top documentation gets the `.top-doc` class.
2021-05-13 23:09:24 -07:00
bors
91f2e2d218 Auto merge of #85190 - mati865:update-cc, r=Mark-Simulacrum
Update cc crate

To pull in this fix: 801a87bf2f
2021-05-14 04:12:40 +00:00
Dr. Chat
69acee3ffe Add asm!() support for PowerPC64 2021-05-13 22:31:47 -05:00
ayushmishra2005
34055a932b Improve match statements 2021-05-14 08:57:33 +05:30
Christiaan Dirkx
5353c5c3fb Move std::memchr to sys_common 2021-05-14 03:54:46 +02:00
bors
754d17121d Auto merge of #85195 - Mark-Simulacrum:variant-by-idx, r=petrochenkov
Store VariantIdx to distinguish enum variants

This saves ~24% of the instructions on the match-stress-enum benchmark, but I'm not 100% sure that this is OK - if we ever compare two constructors across enums (e.g., a Result and an Option), then this is obviously insufficient; I can experiment with continuing to store the DefId for comparison purposes in that case.
2021-05-14 00:59:01 +00:00
Luqman Aden
3fe1d7f789 Only pass --[no-]gc-sections if linker is GNU ld.
LinkerFlavor::Gcc does not always mean GNU ld specifically. And in the
case of at least the solaris ld in illumos, that flag is unrecognized
and will cause the linking step to fail.
2021-05-13 16:55:33 -07:00
bors
17f30e5451 Auto merge of #84107 - Amanieu:global_asm2, r=nagisa
Add support for const operands and options to global_asm!

On x86, the default syntax is also switched to Intel to match asm!.

Currently `global_asm!` only supports `const` operands and the `att_syntax` option. In the future, `sym` operands will also be supported. However there is no plan to support any of the other operand types or options since they don't make sense in the context of `global_asm!`.

r? `@nagisa`
2021-05-13 22:17:43 +00:00
Amanieu d'Antras
a7ed6a5196 Fix tests 2021-05-13 23:09:54 +01:00
Amanieu d'Antras
d9cf2ce28f Update compiler_builtins to 0.1.43 2021-05-13 22:32:44 +01:00
Amanieu d'Antras
40d9da4d8c global_asm! consts do not depend on other items 2021-05-13 22:31:58 +01:00
Amanieu d'Antras
bb6bec1d55 Clarify error message when both asm! and global_asm! are unsupported 2021-05-13 22:31:58 +01:00
Amanieu d'Antras
0df83f8e5e Update global_asm! documentation 2021-05-13 22:31:58 +01:00
Amanieu d'Antras
5a229e0e20 Add tests for global_asm! 2021-05-13 22:31:58 +01:00
Amanieu d'Antras
5918ee4317 Add support for const operands and options to global_asm!
On x86, the default syntax is also switched to Intel to match asm!
2021-05-13 22:31:57 +01:00
Camelid
c34e7c60f5 Fix v0 symbol mangling bug 2021-05-13 13:11:38 -07:00
Jacob Hoffman-Andrews
b615c0c854 rustdoc: use focus for search navigation
Rather than keeping track of highlighted element inside the JS, take
advantage of `.focus()` and the :focus CSS pseudo-class.

This required wrapping each row of results in one big <a> tag (because
anchors can be focused, but table rows cannot). That in turn required
moving from a table layout to a div layout with float.

This makes it so Ctrl+Enter opens links in new tabs, and using the arrow
keys to navigate off the bottom of the page scrolls the rest of the page
into view. It also simplifies the keyboard event handling. It eliminates
the need for click handlers on the search results, and for tracking
mouse movements.

This changes the UI treatment of mouse hovering. A hovered element now
gets a light grey background, but does not change the focused element.
It's possible to have two highlighted search results: one that is
focused (via keyboard) and one that is hovered (via mouse). Pressing
enter will activate the focused link; clicking will activate the hovered
link. This matches up with how Firefox and Chrome handle suggestions in
their URL bar, and avoids stray mouse movements changing the focus.

Selecting tabs is now done with left/right arrows while any search
result is focused. The visibility of results on each search tab is
controlled with the "active" class, rather than by setting display: none
directly. Note that the old code kept track of highlighted search
element when tabbing back and forth. The new code doesn't.
2021-05-13 12:49:14 -07:00
bors
6d395a1c29 Auto merge of #85186 - nikomatsakis:issue-83538-polluted-cache, r=jackh726
have on_completion record subcycles

have on_completion record subcycles

Rework `on_completion` method so that it removes all
provisional cache entries that are "below" a completed
node (while leaving those entries that are not below
the node).

This corrects an imprecise result that could in turn lead
to an incremental compilation failure. Under the old
scheme, if you had:

* A depends on...
   * B depends on A
   * C depends on...
       * D depends on C
 * T: 'static

then the provisional results for A, B, C, and D would all
be entangled. Thus, if A was `EvaluatedToOkModuloRegions`
(because of that final condition), then the result for C and
D would also be demoted to "ok modulo regions".

In reality, though, the result for C depends only on C and itself,
and is not dependent on regions. If we happen to evaluate the
cycle starting from C, we would never reach A, and hence the
result would be "ok".

Under the new scheme, the provisional results for C and D
are moved to the permanent cache immediately and are not affected
by the result of A.

Fixes #83538

r? `@Aaron1011`
2021-05-13 19:36:46 +00:00
Ian Jackson
6369637a19 Tolerate SIGTRAP for panic abort after panic::always_abort
Some platforma (eg ARM64) apparently generate SIGTRAP for panic abort!

See eg
  https://github.com/rust-lang/rust/pull/81858#issuecomment-840702765

This is probably a bug, but we don't want to entangle this MR with it.
When it's fixed, this commit should be reverted.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-13 18:42:52 +01:00
Ian Jackson
f6a4963cc8 Use SIGUSR1 rather than SIGTRAP for "allocated after fork"
Some platforma (eg ARM64) apparently generate SIGTRAP for panic abort!

See eg
  https://github.com/rust-lang/rust/pull/81858#issuecomment-840702765

This is probably a bug, but (i) we want to avoid that bug rather than
trying to fix it now and (ii) it would better to use a signal that is
less at risk of strangeness.

I grepped the rust-lang/rut codebase for SIGUSR and there were no hits.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-13 18:38:25 +01:00
Noah Lev
4672520e74 Use my real name 2021-05-13 10:34:30 -07:00
bors
952c5732c2 Auto merge of #85258 - GuillaumeGomez:rollup-kzay7o5, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - #85068 (Fix diagnostic for cross crate private tuple struct constructors)
 - #85175 (Rustdoc cleanup)
 - #85177 (add BITS associated constant to core::num::Wrapping)
 - #85240 (Don't suggest adding `'static` lifetime to arguments)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-13 16:06:08 +00:00
Ian Jackson
b36a3162fe
Change "etc." to "and similar"
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-05-13 15:02:02 +01:00
Guillaume Gomez
3761ada94e
Rollup merge of #85240 - Aaron1011:no-suggest-static, r=davidtwco
Don't suggest adding `'static` lifetime to arguments

Fixes #69350

This is almost always the wrong this to do
2021-05-13 15:54:14 +02:00
Guillaume Gomez
16c825485f
Rollup merge of #85177 - tspiteri:wrapping-bits, r=joshtriplett
add BITS associated constant to core::num::Wrapping

This keeps `Wrapping` synchronized with the primitives it wraps as for the #32463 `wrapping_int_impl` feature.
2021-05-13 15:54:13 +02:00
Guillaume Gomez
5aa40dda85
Rollup merge of #85175 - GuillaumeGomez:rustdoc-cleanup, r=jsha
Rustdoc cleanup

Part of https://github.com/rust-lang/rust/issues/83332. The goal of this PR is to remove a few unused things:

 * The "loading content" things are now unneeded.
 * Some toggle CSS rules were still there.
 * Some parts of the JS had a different indent, fixed it.

r? `@jsha`
2021-05-13 15:54:11 +02:00
Guillaume Gomez
3db335b934
Rollup merge of #85068 - luqmana:78708-xcrate-diag, r=estebank
Fix diagnostic for cross crate private tuple struct constructors

Fixes #78708.

There was already some limited support for certain cross-crate scenarios but that didn't handle a tuple struct rexported from an inner module for example (e.g. the NonZero* types as seen in #85049).

```Rust
➜  cat bug.rs
fn main() {
    let _x = std::num::NonZeroU32(12);
    let n = std::num::NonZeroU32::new(1).unwrap();
    match n {
        std::num::NonZeroU32(i) => {},
    }
}
```

**Before:**
<details>

```Rust
➜  rustc +nightly bug.rs
error[E0423]: expected function, tuple struct or tuple variant, found struct `std::num::NonZeroU32`
   --> bug.rs:2:14
    |
2   |       let _x = std::num::NonZeroU32(12);
    |                ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `std::num::NonZeroU32 { 0: val }`
    |
   ::: /home/luqman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/nonzero.rs:148:1
[snip]
error[E0532]: expected tuple struct or tuple variant, found struct `std::num::NonZeroU32`
   --> bug.rs:5:9
    |
5   |           std::num::NonZeroU32(i) => {},
    |           ^^^^^^^^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `std::num::NonZeroU32 { 0 }`
    |
   ::: /home/luqman/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/nonzero.rs:148:1
[snip]

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0423, E0532.
For more information about an error, try `rustc --explain E0423`.
```
</details>

**After:**
<details>

```Rust
➜  /rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc bug.rs
error[E0423]: cannot initialize a tuple struct which contains private fields
   --> bug.rs:2:14
    |
2   |     let _x = std::num::NonZeroU32(12);
    |              ^^^^^^^^^^^^^^^^^^^^
    |
note: constructor is not visible here due to private fields
   --> /rust/library/core/src/num/nonzero.rs:148:1
[snip]
error[E0532]: cannot match against a tuple struct which contains private fields
 --> bug.rs:5:9
  |
5 |         std::num::NonZeroU32(i) => {},
  |         ^^^^^^^^^^^^^^^^^^^^
  |
note: constructor is not visible here due to private fields
 --> bug.rs:5:30
  |
5 |         std::num::NonZeroU32(i) => {},
  |                              ^ private field

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0423, E0532.
For more information about an error, try `rustc --explain E0423`.
```
</details>

One question is if we should only collect the needed info for the cross-crate case after encountering an error instead of always doing it. Perf run perhaps to gauge the impact.
2021-05-13 15:54:10 +02:00
bors
d2df620789 Auto merge of #85110 - RalfJung:no-rustc_args_required_const, r=oli-obk
Remove rustc_args_required_const attribute

Now that stdarch no longer needs it (thanks `@Amanieu!),` we can kill the `rustc_args_required_const` attribute. This means that lifetime extension of references to temporaries is the only remaining job that promotion is performing. :-)

r? `@oli-obk`
Fixes https://github.com/rust-lang/rust/issues/69493
2021-05-13 13:37:32 +00:00
Guillaume Gomez
812994e40d Fix display for "implementors" section 2021-05-13 15:23:47 +02:00
Ralf Jung
c61e8face0 fix test suite 2021-05-13 15:01:09 +02:00
Ralf Jung
2a245e0226 update stdarch 2021-05-13 15:01:09 +02:00
Ellen
aec611c08d wow 2021-05-13 14:00:04 +01:00
Rafael Kraut
a56d0e2f6e
swap function order for better read flow
When having the order

```
foo.bar(); // we can now use this method since i32 implements the Foo trait

[...]

impl Foo for i32
```

the `// we can now use this method` comment is less clear to me.
2021-05-13 13:22:24 +02:00
bjorn3
6381aaf8ae Use DefaultMetadataLoader in the hotplug_codegen_backend test 2021-05-13 13:03:59 +02:00
bors
17b60b8738 Auto merge of #83129 - LeSeulArtichaut:thir-unsafeck, r=nikomatsakis
Introduce the beginning of a THIR unsafety checker

This poses the foundations for the THIR unsafety checker, so that it can be implemented incrementally:
- implements a rudimentary `Visitor` for the THIR (which will definitely need some tweaking in the future)
- introduces a new `-Zthir-unsafeck` flag which tells the compiler to use THIR unsafeck instead of MIR unsafeck
- implements detection of unsafe functions
- adds revisions to the UI tests to test THIR unsafeck alongside MIR unsafeck

This uses a very simple query design, where bodies are unsafety-checked on a body per body basis. This however has some big flaws:
- the unsafety-checker builds the THIR itself, which means a lot of work is duplicated with MIR building constructing its own copy of the THIR
- unsafety-checking closures is currently completely wrong: closures should take into account the "safety context" in which they are created, here we are considering that closures are always a safe context

I had intended to fix these problems in follow-up PRs since they are always gated under the `-Zthir-unsafeck` flag (which is explicitely noted to be unsound).

r? `@nikomatsakis`
cc https://github.com/rust-lang/project-thir-unsafeck/issues/3 https://github.com/rust-lang/project-thir-unsafeck/issues/7
2021-05-13 10:49:29 +00:00
Ellen
7e952ec039 completion uwu 2021-05-13 11:37:32 +01:00
Niko Matsakis
89c58eac68 have on_completion record subcycles
Rework `on_completion` method so that it removes all
provisional cache entries that are "below" a completed
node (while leaving those entries that are not below
the node).

This corrects an imprecise result that could in turn lead
to an incremental compilation failure. Under the old
scheme, if you had:

* A depends on...
     * B depends on A
     * C depends on...
         * D depends on C
     * T: 'static

then the provisional results for A, B, C, and D would all
be entangled. Thus, if A was `EvaluatedToOkModuloRegions`
(because of that final condition), then the result for C and
D would also be demoted to "ok modulo regions".

In reality, though, the result for C depends only on C and itself,
and is not dependent on regions. If we happen to evaluate the
cycle starting from C, we would never reach A, and hence the
result would be "ok".

Under the new scheme, the provisional results for C and D
are moved to the permanent cache immediately and are not affected
by the result of A.
2021-05-13 05:58:21 -04:00
Niko Matsakis
c7cb72828d introduce a unit testing feature rustc_evaluate_where_clauses
This attribute will cause us to invoke evaluate on every where clause of an
invoked function and to generate an error with the result.

Without this, it is very difficult to observe the effects of invoking the trait
evaluator.
2021-05-13 04:49:20 -04:00
bors
703f2e1685 Auto merge of #85041 - mibac138:suggest-generics, r=estebank
Suggest adding a type parameter for impls

Add a new suggestion upon encountering an unknown type in a `impl` that suggests adding a new type parameter. This diagnostic suggests to add a new type parameter even though it may be a const parameter, however after adding the parameter and running rustc again a follow up error steers the user to change the type parameter to a const parameter.

```rust
struct X<const C: ()>();
impl X<C> {}
```
suggests
```
error[E0412]: cannot find type `C` in this scope
 --> bar.rs:2:8
  |
1 | struct X<const C: ()>();
  | ------------------------ similarly named struct `X` defined here
2 | impl X<C> {}
  |        ^
  |
help: a struct with a similar name exists
  |
2 | impl X<X> {}
  |        ^
help: you might be missing a type parameter
  |
2 | impl<C> X<C> {}
  |     ^^^
```
After adding a type parameter the code now becomes
```rust
struct X<const C: ()>();
impl<C> X<C> {}
```
and the error now fully steers the user towards the correct code
```
error[E0747]: type provided when a constant was expected
 --> bar.rs:2:11
  |
2 | impl<C> X<C> {}
  |           ^
  |
help: consider changing this type parameter to be a `const` generic
  |
2 | impl<const C: ()> X<C> {}
  |      ^^^^^^^^^^^
```
r? `@estebank`
Somewhat related #84946
2021-05-13 08:08:20 +00:00
bors
72d07257ed Auto merge of #84732 - DrChat:asm_powerpc, r=Amanieu
Add asm!() support for PowerPC

This includes GPRs and FPRs only.
Note that this does not include PowerPC64.

For my reference, this was mostly duplicated from PR #73214.
2021-05-13 05:40:55 +00:00
ayushmishra2005
267450a814 removed compilation error 2021-05-13 10:34:41 +05:30
ayushmishra2005
0cee527869 Miner code formatting 2021-05-13 10:22:17 +05:30
Rich Kadel
aed8ef5a4d coverageinfo query needs to use the same MIR as codegen
I ran into an error trying to fix dead block coverage and realized the
`coverageinfo` query is getting a different MIR compared to the
codegenned MIR, which can sometimes be a problem during mapgen.

I changed that query to use the `InstandeDef` (which includes the
generic parameter substitutions, prosibly specific to const params)
instead of the `DefId` (without unknown/default const substitutions).
2021-05-12 20:27:07 -07:00
bors
631e989738 Auto merge of #83759 - SkiFire13:fix-diag, r=estebank
Handle more span edge cases in generics diagnostics

This should fix invalid suggestions that didn't account for empty bracket pairs (`<>`) or type bindings.
2021-05-13 03:19:13 +00:00