Commit Graph

15978 Commits

Author SHA1 Message Date
Christopher Durham
767239f740 Reenable early feature-gates as future-compat warnings 2022-08-17 06:53:18 -05:00
Christopher Durham
e9e46c95ce Don't treat stashed warnings as errors 2022-08-17 06:07:33 -05:00
bors
86c6ebee8f Auto merge of #100644 - TaKO8Ki:rollup-n0o6a1t, r=TaKO8Ki
Rollup of 4 pull requests

Successful merges:

 - #100243 (Remove opt_remap_env_constness from rustc_query_impl)
 - #100625 (Add `IpDisplayBuffer` helper struct.)
 - #100629 (Use `merged_ty` method instead of rewriting it every time)
 - #100630 (rustdoc JSON: Fix ICE with `pub extern crate self as <self_crate_name>`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-16 21:10:08 +00:00
Takayuki Maeda
033387a6af
Rollup merge of #100629 - GuillaumeGomez:merged-ty, r=compiler-errors
Use `merged_ty` method instead of rewriting it every time

`merged_ty` [source code](https://doc.rust-lang.org/nightly/nightly-rustc/src/rustc_typeck/check/coercion.rs.html#1331-1333) is quite literally the same, so instead of rewriting it, makes more sense to use the method instead.

r? `@compiler-errors`
2022-08-17 05:08:04 +09:00
Takayuki Maeda
e6d47925af
Rollup merge of #100243 - kckeiks:remove-macros-in-query-system, r=cjgillot
Remove opt_remap_env_constness from rustc_query_impl

1st task off #96524.

r? `@cjgillot`
2022-08-17 05:08:02 +09:00
bors
5746c752f4 Auto merge of #100626 - Dylan-DPC:rollup-mwbm7kj, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #99942 (Fix nonsense non-tupled `Fn` trait error)
 - #100609 (Extend invalid floating point literal suffix suggestion)
 - #100610 (Ast and parser tweaks)
 - #100613 (compiletest: fix typo in runtest.rs)
 - #100616 (⬆️ rust-analyzer)
 - #100622 (Support 128-bit atomics on all aarch64 targets)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-16 18:07:02 +00:00
Guillaume Gomez
1f7d1eae96 Use merged_ty method instead of rewriting it every time 2022-08-16 15:33:46 +02:00
Dylan DPC
35bd1d64cf
Rollup merge of #100622 - taiki-e:aarch64-atomic-128, r=Amanieu
Support 128-bit atomics on all aarch64 targets

Some aarch64 targets currently set `max_atomic_width` to 64, but aarch64 always supports 128-bit atomics.

r? `@Amanieu`
2022-08-16 18:16:16 +05:30
Dylan DPC
2e78db3858
Rollup merge of #100610 - nnethercote:ast-and-parser-tweaks, r=spastorino
Ast and parser tweaks

r? `@spastorino`
2022-08-16 18:16:13 +05:30
Dylan DPC
cf5c7645ac
Rollup merge of #100609 - chenyukang:fix-100527, r=davidtwco
Extend invalid floating point literal suffix suggestion

Fixes #100527
2022-08-16 18:16:12 +05:30
Dylan DPC
070de4bc48
Rollup merge of #99942 - compiler-errors:nonsense-un-tupled-fn-trait-error, r=cjgillot
Fix nonsense non-tupled `Fn` trait error

Given this code:

```rust
#![feature(unboxed_closures)]

fn a<F: Fn<usize>>(f: F) {}

fn main() {
    a(|_: usize| {});
}
```

We currently emit this error:
```
error[E0631]: type mismatch in closure arguments
 --> src/main.rs:6:5
  |
6 |     a(|_: usize| {});
  |     ^ ---------- found signature of `fn(usize) -> _`
  |     |
  |     expected signature of `fn(usize) -> _`
  |
note: required by a bound in `a`
 --> src/main.rs:3:9
  |
3 | fn a<F: Fn<usize>>(f: F) {}
  |         ^^^^^^^^^ required by this bound in `a`

For more information about this error, try `rustc --explain E0631`.
error: could not compile `playground` due to previous error
```
Notably, it says the same thing for "expected" and "found"!

Fix the output so that we instead emit:
```
error[E0308]: mismatched types
 --> /home/gh-compiler-errors/test.rs:6:5
  |
6 |     a(|_: usize| {});
  |     ^ types differ
  |
  = note: expected trait `Fn<usize>`
             found trait `Fn<(usize,)>`
note: required by a bound in `a`
 --> /home/gh-compiler-errors/test.rs:3:9
  |
3 | fn a<F: Fn<usize>>(f: F) {}
  |         ^^^^^^^^^ required by this bound in `a`

error: aborting due to previous error
```

The error could still use some work, namely the "mismatched types" part, but I'm leaving it a bit rough since the only way you'd ever get this error is when you're messing with `#![feature(unboxed_closures)]`.

Simply making sure we actually print out the difference in trait-refs is good enough for me. I could probably factor in some additional improvements if those are desired.
2022-08-16 18:16:11 +05:30
yukang
89a51a1a48 use proper words in help message for floating point 2022-08-16 19:12:36 +08:00
bors
a39bdb1d6b Auto merge of #99612 - yanchen4791:issue-95079-fix, r=compiler-errors
Fix #95079 unhelpful error when missing move in nested closure

Fix #95079 by adding help for missing move in nested closure
2022-08-16 11:00:25 +00:00
Taiki Endo
5bb04f30cb Support 128-bit atomics on all aarch64 targets 2022-08-16 19:52:19 +09:00
bors
14a459bf37 Auto merge of #100441 - nnethercote:shrink-ast-Attribute, r=petrochenkov
Shrink `ast::Attribute`.

r? `@ghost`
2022-08-16 07:54:22 +00:00
bors
8556e6620e Auto merge of #100611 - matthiaskrgr:rollup-rxj10ur, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #100338 (when there are 3 or more return statements in the loop)
 - #100384 (Add support for generating unique profraw files by default when using `-C instrument-coverage`)
 - #100460 (Update the minimum external LLVM to 13)
 - #100567 (Add missing closing quote)
 - #100590 (Suggest adding an array length if possible)
 - #100600 (Rename Machine memory hooks to suggest when they run)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-16 05:13:38 +00:00
Matthias Krüger
88af506e94
Rollup merge of #100600 - saethlin:rename-memory-hooks, r=RalfJung
Rename Machine memory hooks to suggest when they run

Some of the other memory hooks start with `before_` or `after_` to indicate that they run before or after a certain operation. These don't, so I was a bit confused as to when they are supposed to run.

`memory_read` can be read two ways in English, "memory was read" or "this is a memory read" so without the prefix this was especially ambiguous.
2022-08-16 06:06:00 +02:00
Matthias Krüger
76dd1663d9
Rollup merge of #100590 - TaKO8Ki:suggest-adding-array-length, r=compiler-errors
Suggest adding an array length if possible

fixes #100448
2022-08-16 06:05:59 +02:00
Matthias Krüger
fc735b05b8
Rollup merge of #100567 - Rageking8:fix-100563, r=wesleywiser
Add missing closing quote

fixes #100563
2022-08-16 06:05:58 +02:00
Matthias Krüger
0b19a185db
Rollup merge of #100460 - cuviper:drop-llvm-12, r=nagisa
Update the minimum external LLVM to 13

With this change, we'll have stable support for LLVM 13 through 15 (pending release).
For reference, the previous increase to LLVM 12 was #90175.

r? `@nagisa`
2022-08-16 06:05:57 +02:00
Matthias Krüger
f347c42461
Rollup merge of #100384 - ridwanabdillahi:instr_profile_output, r=wesleywiser
Add support for generating unique profraw files by default when using `-C instrument-coverage`

Currently, enabling the rustc flag `-C instrument-coverage` instruments the given crate and by default uses the naming scheme `default.profraw` for any instrumented profile files generated during the execution of a binary linked against this crate. This leads to multiple binaries being executed overwriting one another and causing only the last executable run to contain actual coverage results.

This can be overridden by manually setting the environment variable `LLVM_PROFILE_FILE` to use a unique naming scheme.

This PR adds a change to add support for a reasonable default for rustc to use when enabling coverage instrumentation similar to how the Rust compiler treats generating these same `profraw` files when PGO is enabled.

The new naming scheme is set to `default_%m_%p.profraw` to ensure the uniqueness of each file being generated using [LLVMs special pattern strings](https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#running-the-instrumented-program).

Today the compiler sets the default for PGO `profraw` files to `default_%m.profraw` to ensure a unique file for each run. The same can be done for the instrumented profile files generated via the `-C instrument-coverage` flag as well which LLVM has API support for.

Linked Issue: https://github.com/rust-lang/rust/issues/100381

r? `@wesleywiser`
2022-08-16 06:05:56 +02:00
Matthias Krüger
836f706d9a
Rollup merge of #100338 - lyming2007:issue-100285-fix, r=petrochenkov
when there are 3 or more return statements in the loop

emit the first 3 errors and duplicated diagnostic information
	modified:   compiler/rustc_typeck/src/check/coercion.rs
	new file:   src/test/ui/typeck/issue-100285.rs
	new file:   src/test/ui/typeck/issue-100285.stderr
2022-08-16 06:05:55 +02:00
Nicholas Nethercote
3308627016 Add some more AST node size assertions.
There is some redundancy here, but the extra assertions make it easier
to keep track of relative things, e.g. `ExprKind` is the biggest part
of `Expr`.
2022-08-16 13:01:29 +10:00
yukang
84629a5ab1 Extend invalid floating point literal suffix suggestion 2022-08-16 10:50:04 +08:00
bors
ef9810a3e2 Auto merge of #100237 - cjgillot:no-special-hash-hir, r=nagisa
Remove manual implementations of HashStable for hir::Expr and hir::Ty.

We do not need to force hashing HIR bodies inside those nodes. The contents of bodies are not accessible from the `hir_owner` query which used `hash_without_bodies`. When the content of a body is required, the access is still done using `hir_owner_nodes`, which continues hashing HIR bodies.
2022-08-16 02:32:47 +00:00
Nicholas Nethercote
9619a2e3a3 Avoid unnecessary cloning in Parser::get_ident_from_generic_arg. 2022-08-16 12:14:52 +10:00
Nicholas Nethercote
3e04fed6fa Remove {ast,hir}::WhereEqPredicate::id.
These fields are unused.
2022-08-16 12:13:23 +10:00
Miguel Guarniz
3a37f0b7ae Remove usages of opt_remap_env_constness
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-08-15 21:26:31 -04:00
Michael Goulet
8b64988575 Fix error message with non-tupled bare fn trait 2022-08-16 01:21:11 +00:00
Nicholas Nethercote
85a6cd6a47 Shrink ast::Attribute. 2022-08-16 11:10:13 +10:00
Ben Kimock
a5cc3a0557 Rename Machine memory hooks to suggest when they run 2022-08-15 19:54:43 -04:00
Yiming Lei
0471e2780f when there are 3 or more return statements in the loop
emit the first 3 errors and duplicated diagnostic information
using take of iterator for the first third return
	modified:   compiler/rustc_typeck/src/check/coercion.rs
	new file:   src/test/ui/typeck/issue-100285.rs
	new file:   src/test/ui/typeck/issue-100285.stderr
2022-08-15 13:31:14 -07:00
Takayuki Maeda
12e609ba3c use span_suggestion instead of span_suggestion_verbose 2022-08-16 03:42:58 +09:00
Yan Chen
15713e1717 Fix #95079 by adding help and suggestion for missing move in nested closure 2022-08-15 11:20:32 -07:00
Matthias Krüger
e65de39763
Rollup merge of #100586 - the8472:available_parallelism_2, r=jyn514
Reland changes replacing num_cpus with available_parallelism

Since #97925 added cgroupv1 support the problem in #97549 which lead to the previous revert should be addressed now.

Cargo has reapplied the replacement too https://github.com/rust-lang/cargo/pull/10969

Reverts 1ae4b25826 (part of #97911)
Relands #94524
2022-08-15 20:11:41 +02:00
Matthias Krüger
e14d12cb66
Rollup merge of #100559 - nnethercote:parser-simplifications, r=compiler-errors
Parser simplifications

Best reviewed one commit at a time.

r? ``@compiler-errors``
2022-08-15 20:11:38 +02:00
Matthias Krüger
17914c89ec
Rollup merge of #100528 - tux3:riscv-bitmanip-features, r=davidtwco
Support 1st group of RISC-V Bitmanip backend target features

These target features use the same names as LLVM and `is_riscv_feature_detected!`, they are:
- zba (address generation instructions)
- zbb (basic bit manipulation)
- zbc (carry-less multiplication)
- zbs (single-bit manipulation)

The extension is frozen and ratified, and I don't think we should expect LLVM to change those feature names in the future.
For reference, the specification for the B extension can be found here: https://github.com/riscv/riscv-bitmanip/releases/download/1.0.0/bitmanip-1.0.0-38-g865e7a7.pdf)

On my current project, I see a 7.6% reduction in binary size with these features on, so I have some incentive to try to silence the "unknown feature" warning from `-Ctarget-feature` =)
2022-08-15 20:11:37 +02:00
Matthias Krüger
a1fdea2b78
Rollup merge of #100514 - compiler-errors:issue-100191, r=spastorino
Delay span bug when failing to normalize negative coherence impl subject due to other malformed impls

Fixes #100191

r? ``@spastorino``
2022-08-15 20:11:36 +02:00
Matthias Krüger
e369ec871e
Rollup merge of #100458 - compiler-errors:fn-argument-span, r=estebank
Adjust span of fn argument declaration

Span of a fn argument declaration goes from:

```
fn foo(i : i32 , ...)
       ^^^^^^^^
```

to:

```
fn foo(i : i32 , ...)
       ^^^^^^^
```

That is, we don't include the extra spacing up to the trailing comma, which I think is more correct.

cc https://github.com/rust-lang/rust/pull/99646#discussion_r944568074
r? ``@estebank``

---

The two tests that had dramatic changes in their rendering I think actually are improved, though they are kinda poor spans both before and after the changes. 🤷 Thoughts?
2022-08-15 20:11:35 +02:00
Matthias Krüger
3aa5734a2c
Rollup merge of #100377 - est31:fluent_grepability, r=davidtwco
Replace - with _ in fluent slugs to improve developer workflows

This is a proposal to smoothen the compiler contribution experience in the face of the move to fluent.

## Context

The fluent project has introduced a layer of abstraction to compiler errors. Previously, people would write down error messages directly in the same file the code was located to emit them. Now, there is a slug that connects the code in the compiler to the error message in the ftl file.

You can look at 7ef610c003 to see an example of the changes:

Old:
```Rust
let msg = format!(
    "bounds on `{}` are most likely incorrect, consider instead \
        using `{}` to detect whether a type can be trivially dropped",
    predicate,
    cx.tcx.def_path_str(needs_drop)
);
lint.build(&msg).emit();
```
New (Rust side):
```Rust
lint.build(fluent::lint::drop_trait_constraints)
    .set_arg("predicate", predicate)
    .set_arg("needs_drop", cx.tcx.def_path_str(needs_drop))
    .emit();
```
New (Fluent side):
```fluent
lint-drop-trait-constraints =
    bounds on `{$predicate}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped
```

You will note that in the ftl file, the slug is slightly different from the slug in the Rust file: The ftl slug uses `-` (e.g. `lint-drop-trait-constraints`) while the rust slug uses `::` and `_` (e.g. `lint::drop_trait_constraints`). This choice was probably done due to:

* Rust not accepting `-` in identifiers (as it is an operator)
* fluent not supporting the `:` character in slug names (parse error upon attempts)
* all official fluent documentation using `-` instead of `_`

## The problem

The two different types of slugs, one with `-`, and one with `_`, cause difficulties for contributors. Imagine you don't have perfect knowledge of where stuff is in the compiler (i would say this is most people), and you encounter an error for which you think there is something you could improve that is not just a rewording.

So you want to find out where in the compiler's code that error is being emitted. The best way is via grepping.

1. you grep for the message in the compiler's source code. You discover the ftl file and find out the slug for that error.
2. That slug however contains `-` instead of `_`, so you have to manually translate the `-`'s into `_`s, and furthermore either remove the leading module name, or replace the first `-` with a `::`.
3. you do a second grep to get to the emitting location in the compiler's code.

This translation difficulty in step 2 appears also in the other direction when you want to figure out what some code in the compiler is doing and use error messages to help your understanding. Comments and variable names are way less exposed to users so [are more likely going to lie](cc3c5d2700) than error messages.

I think that at least the `-`→`_` translation which makes up most of step 2 can be removed at low cost.

## The solution

If you look closely, the practice of fluent to use `-` is only a stylistic choice and it is not enforced by fluent implementations, neither the playground nor the one the rust compiler uses, that slugs may not contain `_`. Thus, we can in fact migrate the ftl side to `_`. So now we'll have slugs like  `lint_drop_trait_constraints` on the ftl side. You only have to do one replacement now to get to the Rust slug: remove the first `_` and place a `::` in its stead. I would argue that this change is in fact useful as it allows you to control whether you want to look at the rust side of things or the ftl side of things via changing the query string only: with an increased number of translations checked into the repository, grepping for raw slugs will return the slug in many ftl files, so an explicit step to look for the source code is always useful. In the other direction (rust to fluent), you don't need a translation at all any more, as you can just take the final piece of the slug (e.g. `drop_trait_constraints`) and grep for that. The PR also adds enforcement to forbid usage of `_` in slug names. Internal slug names (those leading with a `-`) are exempt from that enforcement.

As another workflow that benefits from this change, people who add new errors don't have to do that `-` conversion either.

| Before/After | Fluent slug | Rust slug (no change) |
|--|--|--|
| Before | `lint-drop-trait-constraints` | `lint::drop_trait_constraints`|
| After | `lint_drop_trait_constraints` | `lint::drop_trait_constraints`|

Note that I've suggested this previously in the translation thread on zulip. I think it's important to think about non-translator contribution impact of fluent. I have certainly plans for more improvements, but this is a good first step.

``@rustbot`` label A-diagnostics
2022-08-15 20:11:34 +02:00
Matthias Krüger
710bd23df1
Rollup merge of #100031 - GoldsteinE:try-removing-the-field, r=michaelwoerister
improve "try ignoring the field" diagnostic

Closes #95795
2022-08-15 20:11:32 +02:00
Miguel Guarniz
ffb925c0f0 Remove opt_remap_env_constness from rustc_query_impl
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-08-15 13:49:39 -04:00
bors
9b4ea391a1 Auto merge of #100569 - matthiaskrgr:rollup-9450lzs, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #100211 (Refuse to codegen an upstream static.)
 - #100277 (Simplify format_args builtin macro implementation.)
 - #100483 (Point to generic or arg if it's the self type of unsatisfied projection predicate)
 - #100506 (change `InlineAsmCtxt` to not talk about `FnCtxt`)
 - #100534 (Make code slightly more uniform)
 - #100566 (Use `create_snapshot_for_diagnostic` instead of `clone` for `Parser`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-08-15 15:25:31 +00:00
Takayuki Maeda
4d1b5f0d99 suggest adding an array length if possible 2022-08-16 00:16:14 +09:00
The 8472
84531229bb Revert "Revert "Remove num_cpus dependency from bootstrap, build-manifest and rustc_session""
This reverts commit 1ae4b25826.
2022-08-15 16:24:07 +02:00
bors
4916e2b9e6 Auto merge of #98393 - michaelwoerister:new-cpp-like-enum-debuginfo, r=wesleywiser
debuginfo: Generalize C++-like encoding for enums.

The updated encoding should be able to handle niche layouts where more than one variant has fields (as introduced in https://github.com/rust-lang/rust/pull/94075).

The new encoding is more uniform as there is no structural difference between direct-tag, niche-tag, and no-tag layouts anymore. The only difference between those cases is that the "dataful" variant in a niche-tag enum will have a `(start, end)` pair denoting the tag range instead of a single value.

The new encoding now also supports 128-bit tags, which occur in at least some standard library types. These tags are represented as `u64` pairs so that debuggers (which don't always have support for 128-bit integers) can reliably deal with them. The downside is that this adds quite a bit of complexity to the encoding and especially to the corresponding NatVis.

The new encoding seems to increase the size of (x86_64-pc-windows-msvc) debuginfo by 10-15%. The size of binaries is not affected (release builds were built with `-Cdebuginfo=2`, numbers are in kilobytes):

EXE | before | after | relative
-- | -- | -- | --
cargo (debug) | 40453 | 40450 | +0%
ripgrep (debug) | 10275 | 10273 | +0%
cargo (release) | 16186 | 16185 | +0%
ripgrep (release) | 4727 | 4726 | +0%

PDB | before | after | relative
-- | -- | -- | --
cargo (debug) | 236524 | 261412 | +11%
ripgrep (debug) | 53140 | 59060 | +11%
cargo (release) | 148516 | 169620 | +14%
ripgrep (release) | 10676 | 11804 | +11%

Given that the new encoding is more general, this is to be expected. Only platforms using C++-like debuginfo are affected -- which currently is only `*-pc-windows-msvc`.

*TODO*
- [x] Properly update documentation
- [x] Add regression tests for new optimized enum layouts as introduced by #94075.

r? `@wesleywiser`
2022-08-15 12:59:53 +00:00
Matthias Krüger
fece51174b
Rollup merge of #100566 - TaKO8Ki:use-create-snapshot-for-diagnostic, r=cjgillot
Use `create_snapshot_for_diagnostic` instead of `clone` for `Parser`

follow-up to #98020
2022-08-15 10:28:14 +02:00
Matthias Krüger
748925bf1b
Rollup merge of #100534 - Rageking8:Rageking8-refactor1, r=compiler-errors
Make code slightly more uniform
2022-08-15 10:28:13 +02:00
Matthias Krüger
a5cdb6566b
Rollup merge of #100506 - lcnr:fnctxt-yeet, r=compiler-errors
change `InlineAsmCtxt` to not talk about `FnCtxt`

wip for https://github.com/rust-lang/compiler-team/issues/529. this currently uses both the `FnCtxt` and is used by `check_mod_item_types`. This should be the only thing blocking that MCP afaict.

I am still unsure whether `rustc_hir_typeck` should depend on `rustc_hir_analysis` to use the `InlineAsmCtxt`. I think that's the best solution for now, so that's what I will go for

r? `@compiler-errors`
2022-08-15 10:28:12 +02:00
Matthias Krüger
ee63d09bd6
Rollup merge of #100483 - compiler-errors:point-to-projection-too, r=jyn514
Point to generic or arg if it's the self type of unsatisfied projection predicate

We do this for `TraitPredicate`s in `point_at_type_arg_instead_of_call_if_possible` and `point_at_arg_instead_of_call_if_possible`, so also do it for `ProjectionPredicate`.

Improves spans for a lot of unit tests.
2022-08-15 10:28:11 +02:00