]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #85211 - Aaron1011:metadata-invalid-span, r=michaelwoerister
bors [Fri, 14 May 2021 16:58:30 +0000 (16:58 +0000)]
Auto merge of #85211 - Aaron1011:metadata-invalid-span, r=michaelwoerister

Preserve `SyntaxContext` for invalid/dummy spans in crate metadata

Fixes #85197

We already preserved the `SyntaxContext` for invalid/dummy spans in the
incremental cache, but we weren't doing the same for crate metadata.
If an invalid (lo/hi from different files) span is written to the
incremental cache, we will decode it with a 'dummy' location, but keep
the original `SyntaxContext`. Since the crate metadata encoder was only
checking for `DUMMY_SP` (dummy location + root `SyntaxContext`),
the metadata encoder would treat it as a normal span, encoding the
`SyntaxContext`. As a result, the final span encoded to the metadata
would change across sessions, even if the crate itself was unchanged.

This could lead to an 'unstable fingerprint' ICE under the following conditions:
1. We compile a crate with an invalid span using incremental compilation. The metadata encoder discards the `SyntaxContext` since the span is invalid, while the incremental cache encoder preserves the `SyntaxContext`
2. From another crate, we execute a foreign query, decoding the invalid span from the metadata as `DUMMY_SP` (e.g. with `SyntaxContext::root()`). This span gets hashed into the query fingerprint. So far, this has always happened through the `optimized_mir` query.
3. We recompile the first crate using our populated incremental cache, without changing anything. We load the (previously) invalid span from our incremental cache - it gets converted to a span with a dummy (but valid) location, along with the original `SyntaxContext`. This span gets written out to the crate metadata - since it now has a valid location, we preserve its `SyntaxContext`.
4. We recompile the second crate, again using a populated incremental cache. We now re-run the foreign query `optimized_mir` - the foreign crate hash is unchanged, but we end up decoding a different span (it now ha a non-root `SyntaxContext`). This results in the fingerprint changing, resulting in an ICE.

This PR updates our encoding of spans in the crate metadata to mirror
the encoding of spans into the incremental cache. We now always encode a
`SyntaxContext`, and encode location information for spans with a
non-dummy location.

3 years agoRemove support for floating-point constants in asm!
Amanieu d'Antras [Wed, 28 Apr 2021 23:59:15 +0000 (00:59 +0100)]
Remove support for floating-point constants in asm!

Floating-point constants aren't very useful anyways and this simplifies
the code since the type check can now be done in typeck.

3 years agoAdd tests where asm! is properly in unsafe block
Smitty [Fri, 14 May 2021 13:22:30 +0000 (09:22 -0400)]
Add tests where asm! is properly in unsafe block

3 years agoFix toggle position on mobile
Guillaume Gomez [Fri, 14 May 2021 12:36:34 +0000 (14:36 +0200)]
Fix toggle position on mobile

3 years agoCheck for inline assembly in THIR unsafeck
Smitty [Thu, 13 May 2021 14:20:51 +0000 (10:20 -0400)]
Check for inline assembly in THIR unsafeck

3 years agoAuto merge of #83640 - bjorn3:shared_metadata_reader, r=nagisa
bors [Fri, 14 May 2021 12:58:58 +0000 (12:58 +0000)]
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.

3 years agoAddressed PR coments
ayushmishra2005 [Fri, 14 May 2021 12:00:26 +0000 (17:30 +0530)]
Addressed PR coments

3 years agopanic abort after fork test: Disable on android
Ian Jackson [Fri, 14 May 2021 10:38:25 +0000 (11:38 +0100)]
panic abort after fork test: Disable on android

And link to the issue.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoAuto merge of #85236 - nikic:update-llvm-submodule, r=cuviper
bors [Fri, 14 May 2021 09:10:11 +0000 (09:10 +0000)]
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.

3 years agoAuto merge of #85233 - FabianWolff:issue-85227, r=petrochenkov
bors [Fri, 14 May 2021 06:53:45 +0000 (06:53 +0000)]
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
```

3 years agoAuto merge of #85190 - mati865:update-cc, r=Mark-Simulacrum
bors [Fri, 14 May 2021 04:12:40 +0000 (04:12 +0000)]
Auto merge of #85190 - mati865:update-cc, r=Mark-Simulacrum

Update cc crate

To pull in this fix: https://github.com/alexcrichton/cc-rs/commit/801a87bf2f31ad1ad8bd7e8fa4f5a52b0e2b4c00

3 years agoAdd asm!() support for PowerPC64
Dr. Chat [Fri, 14 May 2021 03:31:47 +0000 (22:31 -0500)]
Add asm!() support for PowerPC64

3 years agoImprove match statements
ayushmishra2005 [Fri, 14 May 2021 03:27:33 +0000 (08:57 +0530)]
Improve match statements

3 years agoAuto merge of #85195 - Mark-Simulacrum:variant-by-idx, r=petrochenkov
bors [Fri, 14 May 2021 00:59:01 +0000 (00:59 +0000)]
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.

3 years agoAuto merge of #84107 - Amanieu:global_asm2, r=nagisa
bors [Thu, 13 May 2021 22:17:43 +0000 (22:17 +0000)]
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`

3 years agoFix tests
Amanieu d'Antras [Thu, 13 May 2021 22:09:54 +0000 (23:09 +0100)]
Fix tests

3 years agoUpdate compiler_builtins to 0.1.43
Amanieu d'Antras [Sun, 2 May 2021 21:14:31 +0000 (22:14 +0100)]
Update compiler_builtins to 0.1.43

3 years agoglobal_asm! consts do not depend on other items
Amanieu d'Antras [Mon, 26 Apr 2021 19:27:27 +0000 (20:27 +0100)]
global_asm! consts do not depend on other items

3 years agoClarify error message when both asm! and global_asm! are unsupported
Amanieu d'Antras [Mon, 26 Apr 2021 18:49:26 +0000 (19:49 +0100)]
Clarify error message when both asm! and global_asm! are unsupported

3 years agoUpdate global_asm! documentation
Amanieu d'Antras [Wed, 21 Apr 2021 14:21:33 +0000 (15:21 +0100)]
Update global_asm! documentation

3 years agoAdd tests for global_asm!
Amanieu d'Antras [Tue, 13 Apr 2021 17:11:11 +0000 (18:11 +0100)]
Add tests for global_asm!

3 years agoAdd support for const operands and options to global_asm!
Amanieu d'Antras [Sun, 11 Apr 2021 19:51:28 +0000 (20:51 +0100)]
Add support for const operands and options to global_asm!

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

3 years agoAuto merge of #85186 - nikomatsakis:issue-83538-polluted-cache, r=jackh726
bors [Thu, 13 May 2021 19:36:46 +0000 (19:36 +0000)]
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`

3 years agoTolerate SIGTRAP for panic abort after panic::always_abort
Ian Jackson [Thu, 13 May 2021 17:41:18 +0000 (18:41 +0100)]
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>
3 years agoUse SIGUSR1 rather than SIGTRAP for "allocated after fork"
Ian Jackson [Thu, 13 May 2021 17:38:25 +0000 (18:38 +0100)]
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>
3 years agoUse my real name
Noah Lev [Thu, 13 May 2021 17:34:30 +0000 (10:34 -0700)]
Use my real name

3 years agoAuto merge of #85258 - GuillaumeGomez:rollup-kzay7o5, r=GuillaumeGomez
bors [Thu, 13 May 2021 16:06:08 +0000 (16:06 +0000)]
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

3 years agoChange "etc." to "and similar"
Ian Jackson [Thu, 13 May 2021 14:02:02 +0000 (15:02 +0100)]
Change "etc." to "and similar"

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
3 years agoRollup merge of #85240 - Aaron1011:no-suggest-static, r=davidtwco
Guillaume Gomez [Thu, 13 May 2021 13:54:14 +0000 (15:54 +0200)]
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

3 years agoRollup merge of #85177 - tspiteri:wrapping-bits, r=joshtriplett
Guillaume Gomez [Thu, 13 May 2021 13:54:13 +0000 (15:54 +0200)]
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.

3 years agoRollup merge of #85175 - GuillaumeGomez:rustdoc-cleanup, r=jsha
Guillaume Gomez [Thu, 13 May 2021 13:54:11 +0000 (15:54 +0200)]
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`

3 years agoRollup merge of #85068 - luqmana:78708-xcrate-diag, r=estebank
Guillaume Gomez [Thu, 13 May 2021 13:54:10 +0000 (15:54 +0200)]
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.

3 years agoAuto merge of #85110 - RalfJung:no-rustc_args_required_const, r=oli-obk
bors [Thu, 13 May 2021 13:37:32 +0000 (13:37 +0000)]
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

3 years agoFix display for "implementors" section
Guillaume Gomez [Thu, 13 May 2021 13:23:47 +0000 (15:23 +0200)]
Fix display for "implementors" section

3 years agofix test suite
Ralf Jung [Wed, 12 May 2021 15:08:45 +0000 (17:08 +0200)]
fix test suite

3 years agoupdate stdarch
Ralf Jung [Wed, 12 May 2021 14:22:27 +0000 (16:22 +0200)]
update stdarch

3 years agoswap function order for better read flow
Rafael Kraut [Thu, 13 May 2021 11:22:24 +0000 (13:22 +0200)]
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.

3 years agoUse DefaultMetadataLoader in the hotplug_codegen_backend test
bjorn3 [Thu, 13 May 2021 11:03:59 +0000 (13:03 +0200)]
Use DefaultMetadataLoader in the hotplug_codegen_backend test

3 years agoAuto merge of #83129 - LeSeulArtichaut:thir-unsafeck, r=nikomatsakis
bors [Thu, 13 May 2021 10:49:29 +0000 (10:49 +0000)]
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

3 years agohave on_completion record subcycles
Niko Matsakis [Tue, 11 May 2021 09:40:42 +0000 (05:40 -0400)]
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.

3 years agointroduce a unit testing feature `rustc_evaluate_where_clauses`
Niko Matsakis [Wed, 12 May 2021 15:46:14 +0000 (11:46 -0400)]
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.

3 years agoAuto merge of #85041 - mibac138:suggest-generics, r=estebank
bors [Thu, 13 May 2021 08:08:20 +0000 (08:08 +0000)]
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

3 years agoAuto merge of #84732 - DrChat:asm_powerpc, r=Amanieu
bors [Thu, 13 May 2021 05:40:55 +0000 (05:40 +0000)]
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.

3 years agoremoved compilation error
ayushmishra2005 [Thu, 13 May 2021 05:04:41 +0000 (10:34 +0530)]
removed compilation error

3 years agoMiner code formatting
ayushmishra2005 [Thu, 13 May 2021 04:52:17 +0000 (10:22 +0530)]
Miner code formatting

3 years ago`coverageinfo` query needs to use the same MIR as codegen
Rich Kadel [Wed, 12 May 2021 03:56:23 +0000 (20:56 -0700)]
`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).

3 years agoAuto merge of #83759 - SkiFire13:fix-diag, r=estebank
bors [Thu, 13 May 2021 03:19:13 +0000 (03:19 +0000)]
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.

3 years agoBump nightly version
Andy Wang [Wed, 12 May 2021 22:19:00 +0000 (23:19 +0100)]
Bump nightly version

3 years agoRename `RealFileName::Named` to `LocalPath`
Andy Wang [Tue, 4 May 2021 12:37:28 +0000 (13:37 +0100)]
Rename `RealFileName::Named` to `LocalPath`

3 years agoOnly deal with LocalPath in conversion
Andy Wang [Tue, 4 May 2021 12:34:19 +0000 (13:34 +0100)]
Only deal with LocalPath in conversion

3 years agoRename span_to_string to span_to_diagnostic_string
Andy Wang [Tue, 4 May 2021 11:06:02 +0000 (12:06 +0100)]
Rename span_to_string to span_to_diagnostic_string

3 years agoSimplified body_span and filtered span code
Rich Kadel [Tue, 11 May 2021 08:13:52 +0000 (01:13 -0700)]
Simplified body_span and filtered span code

Some code cleanup extracted from future (but unfinished) commit to fix
coverage in attr macro functions.

3 years agoSpanview needs the relevant body_span used for coverage
Rich Kadel [Mon, 10 May 2021 06:08:31 +0000 (23:08 -0700)]
Spanview needs the relevant body_span used for coverage

The coverage body_span doesn't always match the function body_span.

3 years agoDon't suggest adding `'static` lifetime to arguments
Aaron Hill [Thu, 13 May 2021 01:39:37 +0000 (21:39 -0400)]
Don't suggest adding `'static` lifetime to arguments

Fixes #69350

This is almost always the wrong this to do

3 years agoAuto merge of #82069 - Aaron1011:verbose-in-macro, r=estebank
bors [Thu, 13 May 2021 00:31:39 +0000 (00:31 +0000)]
Auto merge of #82069 - Aaron1011:verbose-in-macro, r=estebank

Show macro name in 'this error originates in macro' message

When there are multiple macros in use, it can be difficult to tell
which one was responsible for producing an error.

3 years agoShow macro name in 'this error originates in macro' message
Aaron Hill [Sat, 13 Feb 2021 19:52:25 +0000 (14:52 -0500)]
Show macro name in 'this error originates in macro' message

When there are multiple macros in use, it can be difficult to tell
which one was responsible for producing an error.

3 years agoAuto merge of #85218 - kornelski:pointerinline, r=scottmcm
bors [Wed, 12 May 2021 21:50:27 +0000 (21:50 +0000)]
Auto merge of #85218 - kornelski:pointerinline, r=scottmcm

#[inline(always)] on basic pointer methods

Retryng #85201 with only inlining pointer methods. The goal is to make pointers behave just like pointers in O0, mainly to reduce overhead in debug builds.

cc `@scottmcm`

3 years agoPreserve `SyntaxContext` for invalid/dummy spans in crate metadata
Aaron Hill [Wed, 12 May 2021 04:10:41 +0000 (00:10 -0400)]
Preserve `SyntaxContext` for invalid/dummy spans in crate metadata

Fixes #85197

We already preserved the `SyntaxContext` for invalid/dummy spans in the
incremental cache, but we weren't doing the same for crate metadata.
If an invalid (lo/hi from different files) span is written to the
incremental cache, we will decode it with a 'dummy' location, but keep
the original `SyntaxContext`. Since the crate metadata encoder was only
checking for `DUMMY_SP` (dummy location + root `SyntaxContext`),
the metadata encoder would treat it as a normal span, encoding the
`SyntaxContext`. As a result, the final span encoded to the metadata
would change across sessions, even if the crate itself was unchanged.

This PR updates our encoding of spans in the crate metadata to mirror
the encoding of spans into the incremental cache. We now always encode a
`SyntaxContext`, and encode location information for spans with a
non-dummy location.

3 years agoUpdate LLVM submodule
Nikita Popov [Wed, 12 May 2021 19:15:39 +0000 (21:15 +0200)]
Update LLVM submodule

3 years agoAuto merge of #85188 - RalfJung:miri, r=RalfJung
bors [Wed, 12 May 2021 18:55:22 +0000 (18:55 +0000)]
Auto merge of #85188 - RalfJung:miri, r=RalfJung

update Miri

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

3 years agoupdate Miri
Ralf Jung [Wed, 12 May 2021 18:29:33 +0000 (20:29 +0200)]
update Miri

3 years agoImprove error message for non-exhaustive matches on non-exhaustive enums
Fabian Wolff [Wed, 12 May 2021 17:25:12 +0000 (19:25 +0200)]
Improve error message for non-exhaustive matches on non-exhaustive enums

3 years agoAuto merge of #85231 - GuillaumeGomez:rollup-hufe4gz, r=GuillaumeGomez
bors [Wed, 12 May 2021 16:14:30 +0000 (16:14 +0000)]
Auto merge of #85231 - GuillaumeGomez:rollup-hufe4gz, r=GuillaumeGomez

Rollup of 5 pull requests

Successful merges:

 - #84793 (Recover from invalid `struct` item syntax)
 - #85117 (Move global click handlers to per-element ones.)
 - #85141 (Update documentation for SharedContext::maybe_collapsed_doc_value)
 - #85174 (Fix border radius for doc code blocks in rustdoc)
 - #85205 (Update books)

Failed merges:

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

3 years agoRollup merge of #85205 - ehuss:update-books, r=ehuss
Guillaume Gomez [Wed, 12 May 2021 15:19:30 +0000 (17:19 +0200)]
Rollup merge of #85205 - ehuss:update-books, r=ehuss

Update books

## nomicon

4 commits in 8551afbb2ca6f5ea37fe58380318b209785e4e02..55de6fa3c1f331774da19472c9ee57d2ae9eb039
2021-04-01 21:58:50 +0900 to 2021-05-12 00:31:01 +0900
- Clarify some of the language around marking traits safe/unsafe. (rust-lang-nursery/nomicon#268)
- Use pointer 'add' instead of 'offset' (rust-lang-nursery/nomicon#265)
- Adjust Vec to build on stable Rust (rust-lang-nursery/nomicon#223)
- Update link to c++ atomic ordering docs (rust-lang-nursery/nomicon#264)

## reference

3 commits in d23f9da8469617e6c81121d9fd123443df70595d..5aa457bf1b54bd2cd5d4cf49797f29299bdf89a7
2021-04-28 11:16:44 -0700 to 2021-05-05 08:39:22 -0700
- Explicitly state result of compound assignment (rust-lang-nursery/reference#1013)
- Adjust the definition of `target_family` (rust-lang-nursery/reference#1006)
- Fix typo in `Traits` (rust-lang-nursery/reference#1012)

## book

2 commits in 50dd06cb71beb27fdc0eebade5509cdcc1f821ed..55a26488ddefc8433e73a2e8352d70f7a5c7fc2b
2021-04-23 13:21:54 -0500 to 2021-05-09 12:03:18 -0500
- Past-tensify "lead" -&gt; "led" (rust-lang/book#2717)
- Merge pull request rust-lang/book#2718 from rust-lang/update-rustc

## rust-by-example

2 commits in e0a721f5202e6d9bec0aff99f10e44480c0da9e7..5f8c6da200ada77760a2fe1096938ef58151c9a6
2021-04-27 09:32:15 -0300 to 2021-04-29 08:08:01 -0300
- Fix Typo in LRBE section; closes rust-lang/rust-by-example#1434 (rust-lang/rust-by-example#1437)
- Add some tests to cargo/test.md. Partially addresses rust-lang/rust-by-example#1304 (rust-lang/rust-by-example#1438)

## rustc-dev-guide

3 commits in e72b43a64925ce053dc7830e21c1a57ba00499bd..1e6c7fbda4c45e85adf63ff3f82fa9c870b1447f
2021-04-27 12:35:37 -0700 to 2021-05-10 13:38:24 +0900
- Unified CPU Requirements (rust-lang/rustc-dev-guide#1126)
- add 'waiting-for-review' incantation to main contrib page (rust-lang/rustc-dev-guide#1124)
- Link to Zulip search for finding the most recent check-in (rust-lang/rustc-dev-guide#1118)

3 years agoRollup merge of #85174 - GuillaumeGomez:doc-code-block-border-radius, r=jsha
Guillaume Gomez [Wed, 12 May 2021 15:19:29 +0000 (17:19 +0200)]
Rollup merge of #85174 - GuillaumeGomez:doc-code-block-border-radius, r=jsha

Fix border radius for doc code blocks in rustdoc

In #85148, I made an invalid change on the border radius of the doc code blocks (look in the top left and bottom left corners of the code blocks).

Before this fix:

![Screenshot from 2021-05-11 11-14-59](https://user-images.githubusercontent.com/3050060/117791459-a4f86b80-b24a-11eb-8ac3-facc719c799a.png)

After this fix:

![Screenshot from 2021-05-11 11-05-29](https://user-images.githubusercontent.com/3050060/117791482-a9bd1f80-b24a-11eb-8c38-a01989595f5c.png)

r? `@jsha`

3 years agoRollup merge of #85141 - GuillaumeGomez:maybe_collapsed_doc_value-doc, r=jsha
Guillaume Gomez [Wed, 12 May 2021 15:19:28 +0000 (17:19 +0200)]
Rollup merge of #85141 - GuillaumeGomez:maybe_collapsed_doc_value-doc, r=jsha

Update documentation for SharedContext::maybe_collapsed_doc_value

Fixes #85120.

The `doc-collapse` was removed, however, the main crate is always "collapsed", meaning that this function is still needed. I updated the documentation instead to avoid misleading readers.

r? `@jsha`

3 years agoRollup merge of #85117 - jsha:bubble-bubble-toil-and-trouble, r=GuillaumeGomez
Guillaume Gomez [Wed, 12 May 2021 15:19:27 +0000 (17:19 +0200)]
Rollup merge of #85117 - jsha:bubble-bubble-toil-and-trouble, r=GuillaumeGomez

Move global click handlers to per-element ones.

In rustdoc's main.js, we had an onclick handler for the whole document that would dispatch to handlers for various elements. This change attaches the handlers to the elements that trigger them, instead. This simplifies the code and avoids reimplementing the browser's bubbling functionality.

As part of this change, change from a class to an id for help button.

Move the handlers and associated code for highlighting source lines into source-script.js (and factor out a shared regex).

Demo at https://hoffman-andrews.com/rust/bubble-bubble-toil-and-trouble/std/string/struct.String.html

Note: this conflicts with / depends on #85074. Once that's merged I'll rebase this and resolve conflicts.

Part of #83332. Thanks to `@Manishearth` for the [suggestion to not reimplement bubbling](https://github.com/rust-lang/rust/issues/83332#issuecomment-803497509).

r? `@GuillaumeGomez`

3 years agoRollup merge of #84793 - estebank:parse-struct-field-default, r=davidtwco
Guillaume Gomez [Wed, 12 May 2021 15:19:25 +0000 (17:19 +0200)]
Rollup merge of #84793 - estebank:parse-struct-field-default, r=davidtwco

Recover from invalid `struct` item syntax

Parse unsupported "default field const values":

```rust
struct S {
    field: Type = const_val,
}
```

Recover from small `:` typo and provide suggestion:

```rust
struct S {
    field; Type,
    field2= Type,
}
```

3 years agoadd check that simd_shuffle arguments are constants
Ralf Jung [Tue, 11 May 2021 08:17:25 +0000 (10:17 +0200)]
add check that simd_shuffle arguments are constants

3 years agoentirely remove rustc_args_required_const attribute
Ralf Jung [Sun, 9 May 2021 12:21:33 +0000 (14:21 +0200)]
entirely remove rustc_args_required_const attribute

3 years agorustc_args_required_const is no longer a promotion site
Ralf Jung [Sun, 9 May 2021 12:04:34 +0000 (14:04 +0200)]
rustc_args_required_const is no longer a promotion site

3 years agoAuto merge of #84730 - sexxi-goose:rox-auto-trait, r=nikomatsakis
bors [Wed, 12 May 2021 13:33:32 +0000 (13:33 +0000)]
Auto merge of #84730 - sexxi-goose:rox-auto-trait, r=nikomatsakis

Add auto traits and clone trait migrations for RFC2229

This PR
- renames the existent RFC2229 migration `disjoint_capture_drop_reorder` to `disjoint_capture_migration`
- add additional migrations for auto traits and clone trait

Closes rust-lang/project-rfc-2229#29
Closes rust-lang/project-rfc-2229#28

r? `@nikomatsakis`

3 years agoBless tests.
Camille GILLOT [Tue, 11 May 2021 16:45:57 +0000 (18:45 +0200)]
Bless tests.

3 years agoUse () for analysis.
Camille GILLOT [Tue, 11 May 2021 12:50:54 +0000 (14:50 +0200)]
Use () for analysis.

3 years agoUse () for codegen queries.
Camille GILLOT [Tue, 11 May 2021 12:39:04 +0000 (14:39 +0200)]
Use () for codegen queries.

3 years agoUse () for all_traits.
Camille GILLOT [Tue, 11 May 2021 12:22:02 +0000 (14:22 +0200)]
Use () for all_traits.

3 years agoUse () for visible_parent_map.
Camille GILLOT [Tue, 11 May 2021 12:16:48 +0000 (14:16 +0200)]
Use () for visible_parent_map.

3 years agoUse () for lang items.
Camille GILLOT [Tue, 11 May 2021 11:50:41 +0000 (13:50 +0200)]
Use () for lang items.

3 years agoUse () for privacy.
Camille GILLOT [Tue, 11 May 2021 11:49:00 +0000 (13:49 +0200)]
Use () for privacy.

3 years agoUse () for typeck_item_bodies.
Camille GILLOT [Tue, 11 May 2021 11:39:31 +0000 (13:39 +0200)]
Use () for typeck_item_bodies.

3 years agoUse () for inherent_impls.
Camille GILLOT [Tue, 11 May 2021 11:39:19 +0000 (13:39 +0200)]
Use () for inherent_impls.

3 years agoUse () for inferred_outlives_crate.
Camille GILLOT [Tue, 11 May 2021 10:30:59 +0000 (12:30 +0200)]
Use () for inferred_outlives_crate.

3 years agoUse () for crate_variances.
Camille GILLOT [Tue, 11 May 2021 10:29:52 +0000 (12:29 +0200)]
Use () for crate_variances.

3 years agoUse () for mir_keys.
Camille GILLOT [Tue, 11 May 2021 10:26:53 +0000 (12:26 +0200)]
Use () for mir_keys.

3 years agoUse () for lint_levels.
Camille GILLOT [Tue, 11 May 2021 10:22:11 +0000 (12:22 +0200)]
Use () for lint_levels.

3 years agoUse () for proc_macro_decls_static.
Camille GILLOT [Tue, 11 May 2021 10:12:52 +0000 (12:12 +0200)]
Use () for proc_macro_decls_static.

3 years agoUse () for plugin_registrar_fn.
Camille GILLOT [Tue, 11 May 2021 10:07:14 +0000 (12:07 +0200)]
Use () for plugin_registrar_fn.

3 years agoUse () for entry_fn.
Camille GILLOT [Tue, 11 May 2021 10:00:59 +0000 (12:00 +0200)]
Use () for entry_fn.

3 years agoUse () for HIR queries.
Camille GILLOT [Tue, 11 May 2021 09:42:01 +0000 (11:42 +0200)]
Use () for HIR queries.

3 years agoUse () in reachable_set.
Camille GILLOT [Tue, 11 May 2021 09:35:50 +0000 (11:35 +0200)]
Use () in reachable_set.

3 years agoUse () in dependency_formats.
Camille GILLOT [Tue, 11 May 2021 09:26:52 +0000 (11:26 +0200)]
Use () in dependency_formats.

3 years agoBless tests
Giacomo Stevanato [Wed, 12 May 2021 11:35:12 +0000 (13:35 +0200)]
Bless tests

3 years agoUpdate wrong-number-of-args test to cover more edge cases
Giacomo Stevanato [Wed, 12 May 2021 09:45:23 +0000 (11:45 +0200)]
Update wrong-number-of-args test to cover more edge cases

3 years agoFix diagnostics spans for missing lifetimes in edge cases
Giacomo Stevanato [Wed, 12 May 2021 09:36:38 +0000 (11:36 +0200)]
Fix diagnostics spans for missing lifetimes in edge cases

3 years agoFix diagnostics spans for missing generics in edge cases
Giacomo Stevanato [Wed, 12 May 2021 11:35:32 +0000 (13:35 +0200)]
Fix diagnostics spans for missing generics in edge cases

3 years agodbg macro: Discuss use in tests, and slightly clarify
Ian Jackson [Wed, 12 May 2021 11:09:53 +0000 (12:09 +0100)]
dbg macro: Discuss use in tests, and slightly clarify

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoAuto merge of #83813 - cbeuw:remap-std, r=michaelwoerister
bors [Wed, 12 May 2021 11:05:56 +0000 (11:05 +0000)]
Auto merge of #83813 - cbeuw:remap-std, r=michaelwoerister

Fix `--remap-path-prefix` not correctly remapping `rust-src` component paths and unify handling of path mapping with virtualized paths

This PR fixes #73167 ("Binaries end up containing path to the rust-src component despite `--remap-path-prefix`") by preventing real local filesystem paths from reaching compilation output if the path is supposed to be remapped.

`RealFileName::Named` introduced in #72767 is now renamed as `LocalPath`, because this variant wraps a (most likely) valid local filesystem path.

`RealFileName::Devirtualized` is renamed as `Remapped` to be used for remapped path from a real path via `--remap-path-prefix` argument, as well as real path inferred from a virtualized (during compiler bootstrapping) `/rustc/...` path. The `local_path` field is now an `Option<PathBuf>`, as it will be set to `None` before serialisation, so it never reaches any build output. Attempting to serialise a non-`None` `local_path` will cause an assertion faliure.

When a path is remapped, a `RealFileName::Remapped` variant is created. The original path is preserved in `local_path` field and the remapped path is saved in `virtual_name` field. Previously, the `local_path` is directly modified which goes against its purpose of "suitable for reading from the file system on the local host".

`rustc_span::SourceFile`'s fields `unmapped_path` (introduced by #44940) and `name_was_remapped` (introduced by #41508 when `--remap-path-prefix` feature originally added) are removed, as these two pieces of information can be inferred from the `name` field: if it's anything other than a `FileName::Real(_)`, or if it is a `FileName::Real(RealFileName::LocalPath(_))`, then clearly `name_was_remapped` would've been false and `unmapped_path` would've been `None`. If it is a `FileName::Real(RealFileName::Remapped{local_path, virtual_name})`, then `name_was_remapped` would've been true and `unmapped_path` would've been `Some(local_path)`.

cc `@eddyb` who implemented `/rustc/...` path devirtualisation

3 years agomake verify-channel.sh compatible with macOS
Pietro Albini [Wed, 12 May 2021 10:15:39 +0000 (12:15 +0200)]
make verify-channel.sh compatible with macOS

3 years agoAdd more precise span informations to generic types
Giacomo Stevanato [Wed, 12 May 2021 09:36:07 +0000 (11:36 +0200)]
Add more precise span informations to generic types

3 years agoFix indent in JS files
Guillaume Gomez [Tue, 11 May 2021 09:47:39 +0000 (11:47 +0200)]
Fix indent in JS files