Commit Graph

217969 Commits

Author SHA1 Message Date
Matthias Krüger
baf6a72155
Rollup merge of #108344 - Alexendoo:test-105700, r=compiler-errors
Fix test filename for #105700

The test is for #105700 rather than #21102
2023-02-22 20:05:59 +01:00
Matthias Krüger
2ad6a39fea
Rollup merge of #108342 - lcnr:opaque-tys, r=oli-obk
apply query response: actually define opaque types

not sure whether this fixes any code considering that #107891 doesn't break anything, but this is currently wrong as the `eq` there should just always fail right now.

We can definitely hit this code if we remove the `replace_opaque_types_with_inference_vars` hack. Doing so without this PR causes a few tests to ICE, e.g.

bd4a96a12d/tests/ui/impl-trait/issue-99642.rs (L1-L7)

r? `@oli-obk`
2023-02-22 20:05:59 +01:00
Matthias Krüger
783617b5e4
Rollup merge of #108315 - clubby789:dead-code-in-closure, r=compiler-errors
Lint dead code in closures and generators

Fixes #108296

I think this might be a potentially breaking change, but restores the behaviour of pre-1.64.

`@rustbot` label +A-lint
2023-02-22 20:05:58 +01:00
Matthias Krüger
4d9effc65c
Rollup merge of #108176 - compiler-errors:bad-lexical-region-resolve-bug, r=oli-obk
Don't delay `ReError` bug during lexical region resolve

Lexical region resolution returns a list of `RegionResolutionError` which don't necessarily correspond to diagnostics being emitted. The compiler may, validly, throw away these resolution errors and do something else. Therefore it's not valid to use `ReError` during lifetime resolution, since we may actually be on a totally fine compilation path.

For example, the `implied_bounds_entailment` lint runs region resolution twice, and only emits an error if it fails both times. If we delay a bug and create a `ReError` during this first run, then we will ICE.

Fixes #108170

----

Side-note: this is conceptually equivalent to how we can't necessarily delay bugs or create `ty::Error` during trait solving/fulfillment, since the compiler is allowed to throw away these fulfillment errors to do other things. It's only once we actually emit an error (`report_region_errors` / `report_fulfillment_errors`)
2023-02-22 20:05:58 +01:00
Matthias Krüger
0982eab839
Rollup merge of #107736 - tgross35:atomic-as-ptr, r=m-ou-se
Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893)

Originally discussed in https://github.com/rust-lang/rust/issues/66893#issuecomment-1419198623

~~This uses #107706 as a base to avoid a merge conflict once that gets rolled up (so disregard const changes in the diff until it does)~~ all merged & rebased

`@rustbot` label +T-libs-api
r? m-ou-se
2023-02-22 20:05:57 +01:00
clubby789
c7a4f387fd Lint dead code in closures 2023-02-22 15:27:19 +00:00
bors
b869e84e58 Auto merge of #103042 - davidtwco:translation-distributed-ftl, r=oli-obk
errors: generate typed identifiers in each crate

Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter.

There are advantages and disadvantages to this change..

#### Advantages
- Changing a diagnostic now only recompiles the crate for that diagnostic and those crates that depend on it, rather than `rustc_error_messages` and all crates thereafter.
- This approach can be used to support first-party crates that want to supply translatable diagnostics (e.g. `rust-lang/thorin` in https://github.com/rust-lang/rust/pull/102612#discussion_r985372582, cc `@JhonnyBillM)`
- We can extend this a little so that tools built using rustc internals (like clippy or rustdoc) can add their own diagnostic resources (much more easily than those resources needing to be available to `rustc_error_messages`)

#### Disadvantages
- Crates can only refer to the diagnostic messages defined in the current crate (or those from dependencies), rather than all diagnostic messages.
- `rustc_driver` (or some other crate we create for this purpose) has to directly depend on *everything* that has error messages.
  - It already transitively depended on all these crates.

#### Pending work
- [x] I don't know how to make `rustc_codegen_gcc`'s translated diagnostics work with this approach - because `rustc_driver` can't depend on that crate and so can't get its resources to provide to the diagnostic emission. I don't really know how the alternative codegen backends are actually wired up to the compiler at all.
- [x] Update `triagebot.toml` to track the moved FTL files.

r? `@compiler-errors`
cc #100717
2023-02-22 15:14:22 +00:00
Alex Macleod
4fba0c0449 Fix test filename for #105700 2023-02-22 13:08:13 +00:00
lcnr
cff59f80e4 apply query response: actually define opaque types 2023-02-22 13:28:01 +01:00
bors
3b4d6e0804 Auto merge of #108339 - GuillaumeGomez:rollup-4z02kas, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #108110 (Move some `InferCtxt` methods to `EvalCtxt` in new solver)
 - #108168 (Fix ICE on type alias in recursion)
 - #108230 (Convert a hard-warning about named static lifetimes into lint "unused_lifetimes")
 - #108239 (Fix overlapping spans in removing extra arguments)
 - #108246 (Add an InstCombine for redundant casts)
 - #108264 (no-fail-fast support for tool testsuites)
 - #108310 (rustdoc: Fix duplicated attributes for first reexport)
 - #108318 (Remove unused FileDesc::get_cloexec)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-22 12:04:45 +00:00
Guillaume Gomez
0d0de4971e
Rollup merge of #108318 - tmiasko:rm-get_cloexec, r=the8472
Remove unused FileDesc::get_cloexec
2023-02-22 10:35:10 +01:00
Guillaume Gomez
8d33b780ff
Rollup merge of #108310 - GuillaumeGomez:fix-reexports-duplicated-attributes, r=notriddle
rustdoc: Fix duplicated attributes for first reexport

Fixes #108281.

r? ``@notriddle``
2023-02-22 10:35:10 +01:00
Guillaume Gomez
8fd47a614b
Rollup merge of #108264 - jchecahi:tool-testsuite-ignores-no-fail-fast, r=ozkanonur
no-fail-fast support for tool testsuites

~~This commit adds a change to pass "--no-fail-fast" flag to `cargo test` inside `tool::prepare_tool_cargo()` so there is no need to do it manually in each `Step` trait implementation in src/bootstrap/test.rs.~~

~~Also, removes the flag from test.rs where prepare_tool_cargo() is called so cargo doesn't complain because the flag has been passed twice.~~

This commit adds `--no-fail-fast` flag to each `cargo test`
command in each tool Step trait implementation (`miri`, `rustfmt` and `clippy`).

Fixes #108261
2023-02-22 10:35:09 +01:00
Guillaume Gomez
4658210565
Rollup merge of #108246 - saethlin:instcombine-redundant-casts, r=compiler-errors
Add an InstCombine for redundant casts

`@rustbot` label +A-mir-opt
2023-02-22 10:35:09 +01:00
Guillaume Gomez
437f210af5
Rollup merge of #108239 - clubby789:overlapping-spans, r=compiler-errors
Fix overlapping spans in removing extra arguments

Fixes #108225

Each span is already extended to include the previous comma, so extending to the *next* comma is unecessary and causes an ICE with assertions on.

``@rustbot`` label +A-diagnostics
2023-02-22 10:35:08 +01:00
Guillaume Gomez
a32c500400
Rollup merge of #108230 - LittleFall:enhance/warning, r=estebank
Convert a hard-warning about named static lifetimes into lint "unused_lifetimes"

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

Some changes are ported from https://github.com/rust-lang/rust/pull/98079, thanks to jeremydavis519.

r? `@estebank` `@petrochenkov`

Any feedback is appreciated!

## Actions
- [x] resolve conflicts
- [x] fix build
- [x] address review comments in last pr
- [x] update tests
2023-02-22 10:35:08 +01:00
Guillaume Gomez
89c201e3be
Rollup merge of #108168 - clubby789:recursive-type-alias, r=compiler-errors
Fix ICE on type alias in recursion

Fixes #108160
2023-02-22 10:35:07 +01:00
Guillaume Gomez
f1ad7f07f2
Rollup merge of #108110 - compiler-errors:new-solver-less-infcx, r=lcnr
Move some `InferCtxt` methods to `EvalCtxt` in new solver

Moving towards eventually making the `InferCtxt` within `EvalCtxt` private, so that we make sure not to do anything strange in the solver. This doesn't finish this work yet, just gets it started.

r? ``@lcnr``
2023-02-22 10:35:07 +01:00
David Wood
26255186e2 various: translation resources from cg backend
Extend `CodegenBackend` trait with a function returning the translation
resources from the codegen backend, which can be added to the complete
list of resources provided to the emitter.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22 09:15:54 +00:00
David Wood
a8e37507f4 errors: fix translation's run-make test
`run-make/translation` had some targets that weren't listed in `all` and
thus weren't being tested - the behaviour that should have been being
tested was basically correct fortunately.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22 09:15:54 +00:00
David Wood
d1fcf61117 errors: generate typed identifiers in each crate
Instead of loading the Fluent resources for every crate in
`rustc_error_messages`, each crate generates typed identifiers for its
own diagnostics and creates a static which are pulled together in the
`rustc_driver` crate and provided to the diagnostic emitter.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22 09:15:53 +00:00
bors
bd4a96a12d Auto merge of #108300 - oli-obk:elsa, r=eholk
Use a lock-free datastructure for source_span

follow up to the perf regression in https://github.com/rust-lang/rust/pull/105462

The main regression is likely the CStore, but let's evaluate the perf impact of this on its own
2023-02-22 08:44:30 +00:00
Jesus Checa Hidalgo
2f16355486 Add no-fail-fast support to miri, rustfmt and clippy testsuites
This commit adds `--no-fail-fast` flag to each `cargo test`
command in each tool Step trait implementation.

Fixes #108261
2023-02-22 08:29:09 +01:00
Michael Goulet
7596998d1c Move some InferCtxt methods to EvalCtxt in new solver 2023-02-22 03:22:30 +00:00
bors
f9216b7564 Auto merge of #108325 - matthiaskrgr:rollup-73qihie, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #104239 (Better debug logs for borrowck constraint graph)
 - #108202 (Make sure `test_type_match` doesn't ICE with late-bound types)
 - #108295 (Use DefKind to give more item kind information during BindingObligation note )
 - #108306 (compiletest: up deps)
 - #108313 (Fix compiletest possible crash in option only-modified)
 - #108322 (Clean ConstProp)
 - #108323 (hir-analysis: make one diagnostic translatable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-22 02:39:09 +00:00
Zhi Qi
ce2ae62d68 Convert a hard-warning about named static lifetimes into lint "unused_lifetimes"
Define the `named_static_lifetimes` lint

This lint will replace the existing hard-warning.

Replace the named static lifetime hard-warning with the new lint

Update the UI tests for the `named_static_lifetimes` lint

Remove the direct dependency on `rustc_lint_defs`

fix build

Signed-off-by: Zhi Qi <qizhi@pingcap.com>

use "UNUSED_LIFETIMES" instead

Signed-off-by: Zhi Qi <qizhi@pingcap.com>

update 1 test and fix typo

Signed-off-by: Zhi Qi <qizhi@pingcap.com>

update tests

Signed-off-by: Zhi Qi <qizhi@pingcap.com>

fix tests: add extra blank line

Signed-off-by: Zhi Qi <qizhi@pingcap.com>
2023-02-22 09:44:26 +08:00
bors
375d5ace70 Auto merge of #108302 - Kobzol:revert-107834, r=albertlarsan68
Revert #107834

This reverts commit [41c6c5d499](https://github.com/rust-lang/rust/pull/107834). Trying to check if this fixes building `rustc` for perf bot.
2023-02-21 23:24:59 +00:00
Matthias Krüger
d39fc2111b
Rollup merge of #108323 - tshepang:translatable-hir-analysis, r=compiler-errors
hir-analysis: make one diagnostic translatable
2023-02-21 23:02:02 +01:00
Matthias Krüger
82dc2ebfe3
Rollup merge of #108322 - cjgillot:clean-const-prop, r=oli-obk
Clean ConstProp

Small simplifications from the time when there that pass output lints.
2023-02-21 23:02:01 +01:00
Matthias Krüger
c21b7f6914
Rollup merge of #108313 - chenyukang:yukang/fix-only-modified, r=oli-obk
Fix compiletest possible crash in option only-modified

`fixed` files maybe removed, `unwrap` will crash in this scenario.
2023-02-21 23:02:01 +01:00
Matthias Krüger
c292def803
Rollup merge of #108306 - klensy:compiletest-up, r=wesleywiser
compiletest: up deps

update `miow` 0.3.7 -> 0.5.0 (which moved from `winapi` to `windows-rs`, [changelog](https://github.com/yoshuawuyts/miow/blob/master/CHANGELOG.md#v050---2022-11-10))
replace `lazy_static` with `once_cell` (there is slow transition to the second crate, in hope of eventually stable stdlib version, yes?)
2023-02-21 23:02:00 +01:00
Matthias Krüger
ae01430078
Rollup merge of #108295 - compiler-errors:wtf-is-this, r=cjgillot
Use DefKind to give more item kind information during BindingObligation note

The current label says "required by a bound in this". When I see that label, my immediate impression is "this... **what**?". It feels like it was cut short.

Alternative to this would be saying "in this item", but adding the item kind is strictly more informational and adds very little overhead to the existing error presentation.
2023-02-21 23:02:00 +01:00
Matthias Krüger
8a5843f07f
Rollup merge of #108202 - compiler-errors:non_lifetime_binders-type-match-ice, r=davidtwco
Make sure `test_type_match` doesn't ICE with late-bound types

Fixes #108190 (in a kind of hacky way, anyways doesn't really matter)
2023-02-21 23:01:59 +01:00
Matthias Krüger
314fe4d170
Rollup merge of #104239 - b-naber:sccs-info, r=jackh726
Better debug logs for borrowck constraint graph

It's really cumbersome to work with `RegionVar`s when trying to debug borrowck code or when trying to understand how the borrowchecker works. This PR collects some region information (behind `cfg(debug_assertions)`) for created `RegionVar`s (NLL region vars, this PR doesn't touch canonicalization) and prints the nodes and edges of the strongly connected constraints graph using representatives that use that region information (either lifetime names, locations in MIR or spans).
2023-02-21 23:01:58 +01:00
b-naber
8252a6eddf address review 2023-02-21 21:54:53 +00:00
Tshepang Mbambo
b483816d88 hir-analysis: make one diagnostic translatable 2023-02-21 22:27:16 +02:00
bors
246eae2fab Auto merge of #108307 - jedisct1:z-link-flags, r=wesleywiser
Linker: use -z <params> instead of -z<params>

The GNU linker accepts -z<params>, but this is undocumented, and not supported by other linkers.

In particular, `zig cc`, when used as the C compiler/linker (e.g. when using `cargo-zigbuild`), will not accept this undocumented syntax.

In `linker.rs`, both syntaxes are also used inconsistently.

The Go compiler used to have the same issue, but fixed it:

38607c5538
2023-02-21 18:53:34 +00:00
Tomasz Miąsko
7867aa8aee Remove unused FileDesc::get_cloexec 2023-02-21 18:52:25 +01:00
klensy
58e7470b10 replace lazy_static with once_cell 2023-02-21 19:23:16 +03:00
bors
f4c7596ac3 Auto merge of #108311 - oli-obk:invert_defines, r=lcnr
Make hidden type registration opt-in, so that each site can be reviewed on its own and we have the right defaults for trait solvers

r? `@lcnr`

pulled out of https://github.com/rust-lang/rust/pull/107891 as it is the uncontroversial part
2023-02-21 15:48:40 +00:00
yukang
6e34e651a6 Fix compiletest crash when test file path does not exist 2023-02-21 15:32:45 +00:00
Guillaume Gomez
fec6ad6058 Add regression test for #108281 2023-02-21 16:26:06 +01:00
Guillaume Gomez
f58c8aba50 Fix duplicated attributes for first reexport 2023-02-21 16:26:06 +01:00
Oli Scherer
88a7b6803b Make hidden type registration opt-in, so that each site can be reviewed on its own and we have the right defaults for trait solvers 2023-02-21 14:50:51 +00:00
Frank Denis
8e250c3c64 Linker: use -z <params> instead of -z<params>
The GNU linker accepts -z<params>, but this is undocumented, and
not supported by other linkers.

In particular, `zig cc`, when used as the C compiler/linker
(e.g. when using `cargo-zigbuild`), will not accept this
undocumented syntax.

In `linker.rs`, both syntaxes are also used inconsistently.

The Go compiler used to have the same issue, but fixed it:

38607c5538
2023-02-21 14:52:20 +01:00
Jakub Beránek
6ca499bf2b
Revert "Copy bin/* and lib/*.dylib files to stage0-sysroot"
This reverts commit 6990ab9ad2.
2023-02-21 14:41:11 +01:00
clubby789
0b9a3e29d4 Fix overlapping spans in removing extra arguments 2023-02-21 13:13:09 +00:00
bors
3200982b76 Auto merge of #108138 - compiler-errors:malformed-fn-trait, r=TaKO8Ki
Move `Fn*` traits malformedness protections to typeck

I found it strange that we were doing a custom well-formedness check just for the `Fn*` traits' `call_*` fn items. My understanding from the git history is that this is just to avoid ICEs later on in typeck.

Well, that well-formedness check isn't even implemented correctly for `FnOnce::call_once`, or `FnMut::call_mut` for that matter. Instead, this PR just makes the typeck checks more robust, and leaves it up to the call-site to report errors when lang items are implemented in funny ways.

This coincidentally fixes another ICE where a the `Add` lang item is implemented with a `add` item that's a const instead of a method.
2023-02-21 12:59:11 +00:00
klensy
1397a5ef92 compiletest: bump miow crate 2023-02-21 15:13:03 +03:00
bors
bda32a4023 Auto merge of #108301 - Dylan-DPC:rollup-70zpkt0, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #108000 (lint: don't suggest MaybeUninit::assume_init for uninhabited types)
 - #108105 (Explain the default panic hook better)
 - #108141 (Add rpitit queries)
 - #108272 (docs: wrong naming convention in struct keyword doc)
 - #108285 (remove unstable `pick_stable_methods_before_any_unstable` flag)
 - #108289 (Name placeholder in some region errors)
 - #108290 (Add a test for default trait method with RPITITs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-21 09:51:03 +00:00