Commit Graph

15420 Commits

Author SHA1 Message Date
Miguel Guarniz
25bdc8965e Change maybe_body_owned_by to take local def id
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:25:58 -04:00
bors
5dda74a48c Auto merge of #99467 - BelovDV:add_option_link_arg, r=petrochenkov
flag '-l link-arg=___ was added

#99427
2022-07-29 15:36:52 +00:00
bors
2f847b81a0 Auto merge of #99892 - JohnTitor:rollup-qi4fem8, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #99686 (add suggestion when there is a impl of external trait on pointer with wrong coherence rules)
 - #99760 (doc/rustc: describe the uefi target platforms)
 - #99766 (Htmldocck: Substitute the doc channel when blessing)
 - #99781 (Use String::from_utf8_lossy in CStr demo)
 - #99803 (Update mentions to `rustc_metadata::rmeta::Lazy`)
 - #99845 (Remove `$` prefix for bash scripts in doc)
 - #99850 (rustdoc: Remove more Clean trait implementations)
 - #99872 (Clone the `src/llvm-project` submodule if profiling is enabled)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-29 09:57:44 +00:00
bors
7dfdd64433 Auto merge of #99667 - ouz-a:some_branch, r=oli-obk
Optimize `UnDerefer`

Addresses the performance [issues](https://github.com/rust-lang/rust/pull/98145#issuecomment-1183548597) faced here.

r? `@oli-obk`
2022-07-29 07:11:50 +00:00
Yuki Okushi
fd3610ed2e
Rollup merge of #99803 - JohnTitor:update-lazy-docs, r=compiler-errors
Update mentions to `rustc_metadata::rmeta::Lazy`

While working on https://github.com/rust-lang/rustc-dev-guide/pull/1411, I noticed there are still some mentions of `Lazy`. This updates them to `LazyValue`, `LazyArray`, or `LazyTable`.

r? ````@compiler-errors````

Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-29 15:40:01 +09:00
Yuki Okushi
a573adf3cb
Rollup merge of #99686 - vincenzopalazzo:macros/impl_on_ptr, r=compiler-errors
add suggestion when there is a impl of external trait on pointer with wrong coherence rules

Closes https://github.com/rust-lang/rust/issues/99572

This will try to improve the node in the error message by suggesting a general solution because the solution, in this case, is application depended.

I'm not super happy regarding the code quality, but I'm happy to have feedback on it.

`@rustbot` r? `@compiler-errors`
2022-07-29 15:39:57 +09:00
bors
ea6ab1bd84 Auto merge of #99660 - PrestonFrom:issue_99265, r=compiler-errors
Generate correct suggestion with named arguments used positionally

Address issue #99265 by checking each positionally used argument
to see if the argument is named and adding a lint to use the name
instead. This way, when named arguments are used positionally in a
different order than their argument order, the suggested lint is
correct.

For example:
```
println!("{b} {}", a=1, b=2);
```
This will now generate the suggestion:
```
println!("{b} {a}", a=1, b=2);
```

Additionally, this check now also correctly replaces or inserts
only where the positional argument is (or would be if implicit).
Also, width and precision are replaced with their argument names
when they exists.

Since the issues were so closely related, this fix for issue #99265
also fixes issue #99266.

Fixes #99265
Fixes #99266
2022-07-29 04:23:08 +00:00
bors
9de7474830 Auto merge of #99512 - nikic:llvm-15-fixes, r=cuviper
LLVM 15 compatibility fixes

These are LLVM 15 compatibility fixes split out from #99464. There are three changes here:

 * Emit elementtype attribtue for ldrex/strex intrinsics. This is requires as part of the opaque pointers migration.
 * Make more tests compatible with opaque pointers. These are either new or aren't run on x86.
 * Remove a test for `#[rustc_allocator]`. Since #99574 there are more requirement on the function signature. I dropped the test entirely, since we already test the effect of the attribute elsewhere.
 * The main change: When a worker thread emits an error, wait for other threads to finish before unwinding the main thread and exiting. Otherwise workers may end up using globals for which destructors have already been run. This was probably never quite correct, but became an active problem with LLVM 15, because it started using global dtors in critical places, as part of ManagedStatic removal.

Fixes #99432 (and probably also #95679).

r? `@cuviper`
2022-07-29 01:35:15 +00:00
bors
9067d5277d Auto merge of #99863 - Dylan-DPC:rollup-lq9w047, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #99628 (add more docs regarding ideographic numbers)
 - #99689 (Revert `write!` and `writeln!` to late drop temporaries)
 - #99807 (Fix PermissionDenied UI tests on WSL)
 - #99817 (rustdoc: remove Clean trait impls for more items)
 - #99851 (Fix small typo in Cargo.toml comment)
 - #99856 (fix: remove fake no_dead_strip for osx)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-28 19:12:21 +00:00
Dylan DPC
55f041e1f6
Rollup merge of #99856 - csmoe:osx-no-dead-strip, r=bjorn3
fix: remove fake no_dead_strip for osx

Closes https://github.com/rust-lang/rust/issues/99788

Link arg `-no_dead_strip` doesn't exist on OSX at all.
The `no_gc_sections` function was never called before export-executable-symols implementation, and `export-executable-symbols` still works, so we just remove it.
r? `@bjorn3`
2022-07-28 22:14:51 +05:30
bors
36f4f4aa38 Auto merge of #99780 - Nilstrieb:mir-opt-test-line-no, r=oli-obk
Use line numbers relative to the function in mir-opt tests

As shown in #99770, the line numbers can be a big source of needless and confusing diffs. This PR adds a new flag `-Zmir-pretty-relative-line-numbers` to make them relative to the function declaration, which avoids most needless diffs from attribute changes.

`@JakobDegen` told me that there has been a zulip conversation about disabling line numbers with mixed opinions, so I'd like to get some feedback here, for this hopefully better solution.

r? rust-lang/wg-mir-opt
2022-07-28 16:22:19 +00:00
csmoe
03f9efedb1 fix: remove fake no_dead_strip for osx 2022-07-28 22:22:13 +08:00
Dylan DPC
71b0e95b82
Rollup merge of #99846 - TaKO8Ki:refactor-UnresolvedImportError, r=davidtwco
Refactor `UnresolvedImportError`

This patch changes the type of `note` field in `UnresolvedImportError` to `Option<String>`.
2022-07-28 16:38:35 +05:30
Dylan DPC
3a37c9a47e
Rollup merge of #99837 - TaKO8Ki:avoid-symbol-to-string-conversions, r=fee1-dead
Avoid `Symbol` to `String` conversions

follow-up to #99508
2022-07-28 16:38:34 +05:30
Dylan DPC
91b8b9ba4b
Rollup merge of #99714 - ouz-a:issue_57961, r=oli-obk
Fix regression introduced with #99383

Fixes #99642
2022-07-28 16:38:30 +05:30
ouz-a
bd24b4006c type alias covers whole return 2022-07-28 13:52:49 +03:00
Nilstrieb
7cf7ead0bc Use line numbers relative to function in mir opt tests
This adds a new option, `-Zmir-pretty-relative-line-numbers`, that
is then used in compiletest for the mir-opt tests.
2022-07-28 11:59:54 +02:00
ouz-a
bd52f58e3b create type alias 2022-07-28 12:56:57 +03:00
Takayuki Maeda
2ce42eb79c remove an unnecessary line break 2022-07-28 18:28:29 +09:00
Takayuki Maeda
089471b129 change the type of note field to Option<String> 2022-07-28 18:17:55 +09:00
Preston From
1b2e05e212 Use more idiomatic rust, comment for lint logic 2022-07-28 00:10:19 -06:00
Takayuki Maeda
3cbc94427c avoid Symbol to String conversions 2022-07-28 10:20:55 +09:00
bors
ada80a13b9 Auto merge of #99725 - lcnr:dedup-region_bound_pairs, r=compiler-errors
use `FxIndexSet` for `region_bound_pairs`

should help with #99217 and might generally be a perf improvement.

r? types
2022-07-27 22:02:14 +00:00
Vincenzo Palazzo
1e584d2d6d add suggestion when there is a impl of external trait on pointer
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2022-07-27 21:53:37 +00:00
bors
2643b16468 Auto merge of #99816 - GuillaumeGomez:rollup-tyobksa, r=GuillaumeGomez
Rollup of 7 pull requests

Successful merges:

 - #94247 (Fix slice::ChunksMut aliasing)
 - #99358 (Allow `ValTree::try_to_raw_bytes` on `u8` array)
 - #99651 (Deeply deny fn and raw ptrs in const generics)
 - #99710 (lint: add bad opt access internal lint)
 - #99717 (Add some comments to the docs issue template to clarify)
 - #99728 (Clean up HIR-based lifetime resolution)
 - #99812 (Fix headings colors)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-27 18:22:33 +00:00
Guillaume Gomez
c37ee1a7e0
Rollup merge of #99728 - cjgillot:ast-lifetimes-anon-clean, r=petrochenkov
Clean up HIR-based lifetime resolution

Based on https://github.com/rust-lang/rust/pull/97313.

Fixes #98932.

r? `@petrochenkov`
2022-07-27 17:55:07 +02:00
Guillaume Gomez
dda74fe8c9
Rollup merge of #99710 - davidtwco:internal-lint-opts, r=lcnr
lint: add bad opt access internal lint

Prompted by [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/sess.2Ecrate_types.28.29.20vs.20sess.2Eopts.2Ecrate_types/near/290682847).

Some command-line options accessible through `sess.opts` are best accessed through wrapper functions on `Session`, `TyCtxt` or otherwise, rather than through field access on the option struct in the `Session`.

Adds a new lint which triggers on those options that should be accessed through a wrapper function so that this is prohibited. Options are annotated with a new attribute `rustc_lint_opt_deny_field_access` which can specify the error message (i.e. "use this other function instead") to be emitted.

A simpler alternative would be to simply rename the options in the option type so that it is clear they should not be used, however this doesn't prevent uses, just discourages them. Another alternative would be to make the option fields private, and adding accessor functions on the option types, however the wrapper functions sometimes rely on additional state from `Session` or `TyCtxt` which wouldn't be available in an function on the option type, so the accessor would simply make the field available and its use would be discouraged too.

**Leave a comment if there's an option I should add this to.**
2022-07-27 17:55:05 +02:00
Guillaume Gomez
9e7b7d5e1c
Rollup merge of #99651 - compiler-errors:fn-and-raw-ptr-in-const-generics, r=oli-obk
Deeply deny fn and raw ptrs in const generics

I think this is right -- just because we wrap a fn ptr in a wrapper type does not mean we should allow it in a const parameter.

We now reject both of these in the same way:

```
#![feature(adt_const_params)]

#[derive(Eq, PartialEq)]
struct Wrapper();

fn foo<const W: Wrapper>() {}

fn foo2<const F: fn()>() {}
```

This does regress one test (`src/test/ui/consts/refs_check_const_eq-issue-88384.stderr`), but I'm not sure it should've passed in the first place.

cc: ``@b-naber`` who introduced that test^
fixes #99641
2022-07-27 17:55:04 +02:00
Guillaume Gomez
4ce1b0f936
Rollup merge of #99358 - compiler-errors:issue-99325, r=oli-obk
Allow `ValTree::try_to_raw_bytes` on `u8` array

Fixes #99325

cc `@b-naber` I think who touched this last in 705d818bd5
2022-07-27 17:55:03 +02:00
bors
da5b546d2e Auto merge of #99731 - ehuss:let-chain-bracket-check, r=compiler-errors
Remove let-chain close brace check.

#98633 added some checks to forbid let-expressions that aren't in a let chain. This check looks at the preceding token to determine if it is a valid let-chain position. One of those tokens it checks is the close brace `}`. However, to my understanding, it is not possible for a let chain to be preceded by a close brace. This PR removes the check to avoid any confusion.

This is a followup to the discussion at https://github.com/rust-lang/rust/pull/98633#pullrequestreview-1030962803. It wasn't clear what issues the original PR ran into, but I have run the full set of CI tests and nothing failed.  I also can't conceive of a situation where this would be possible.  This doesn't reject any valid code, I'm just removing it to avoid confusion to anyone looking at this code in the future.
2022-07-27 15:32:01 +00:00
Nikita Popov
c87e20bab0 Also wait on other threads if a WorkerFatalError occurs
This means that codegen_aborted may be set when new codegen
requests arrive, so drop some related assertions. The new work
will simply be ignored.
2022-07-27 16:19:07 +02:00
Nikita Popov
b00d0fa0c9 Reliably signal coordinator thread on panic during ongoing codegen
Replace the separate AbortCodegenOnDrop guard by integrating this
functionality into OngoingCodegen (or rather, the Coordinator part
of it). This ensures that we send a CodegenAborted message and
wait for workers to finish even if the panic occurs outside
codegen_crate() (e.g. inside join_codegen()).

This requires some minor changes to the handling of CodegenAborted,
as it can now occur when the main thread is LLVMing rather than
Codegenning.
2022-07-27 16:19:07 +02:00
Nikita Popov
f653d3ab30 Add elementtype attributes for llvm.arm.ldrex/strex intrinsics
These intrinsics (and a few more, but there are the only ones
exposed by stdarch) require an elementtype attribute in LLVM 15.
2022-07-27 16:19:07 +02:00
ouz-a
8716eae3b1 add tests and comment 2022-07-27 14:43:46 +03:00
Yuki Okushi
645a88374a
Update mentions to rustc_metadata::rmeta::Lazy
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2022-07-27 20:09:46 +09:00
David Wood
7bab769b58 lint: add bad opt access internal lint
Some command-line options accessible through `sess.opts` are best
accessed through wrapper functions on `Session`, `TyCtxt` or otherwise,
rather than through field access on the option struct in the `Session`.

Adds a new lint which triggers on those options that should be accessed
through a wrapper function so that this is prohibited. Options are
annotated with a new attribute `rustc_lint_opt_deny_field_access` which
can specify the error message (i.e. "use this other function instead")
to be emitted.

A simpler alternative would be to simply rename the options in the
option type so that it is clear they should not be used, however this
doesn't prevent uses, just discourages them. Another alternative would
be to make the option fields private, and adding accessor functions on
the option types, however the wrapper functions sometimes rely on
additional state from `Session` or `TyCtxt` which wouldn't be available
in an function on the option type, so the accessor would simply make the
field available and its use would be discouraged too.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-27 11:24:27 +01:00
David Wood
f5e005f0ca session: disable internal lints for rustdoc
If an internal lint uses `typeck_results` or similar queries then that
can result in rustdoc checking code that it shouldn't (e.g. from other
platforms) and emit compilation errors.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-27 11:24:27 +01:00
Yuki Okushi
e0f88b3e9c
Rollup merge of #99789 - TaKO8Ki:use-pluralize-macro, r=compiler-errors
Refactor: use `pluralize!`

Use `pluralize!` in more places
2022-07-27 19:05:36 +09:00
Yuki Okushi
faa6f6b159
Rollup merge of #99769 - bjorn3:sync_cg_clif-2022-07-26, r=bjorn3
Sync rustc_codegen_cranelift

I did a large refactoring of the intrinsics module to remove the intrinsic_match macro which is not very clear to other people. This also enables rustfmt to run on this code. While I already did a sync yesterday, I am going to do another sync again to avoid potential conflicts as those will likely be painful to resolve.

r? ``@ghost``

``@rustbot`` label +A-codegen +A-cranelift +T-compiler
2022-07-27 19:05:34 +09:00
Yuki Okushi
28b44ff5d4
Rollup merge of #99704 - fee1-dead-contrib:add_self_tilde_const_trait, r=oli-obk
Add `Self: ~const Trait` to traits with `#[const_trait]`

r? `@oli-obk`
2022-07-27 19:05:33 +09:00
Yuki Okushi
3b780fc279
Rollup merge of #99079 - compiler-errors:issue-99073, r=oli-obk
Check that RPITs constrained by a recursive call in a closure are compatible

Fixes #99073

Adapts a similar visitor pattern to `find_opaque_ty_constraints` (that we use to check TAITs), but with some changes:
0. Only walk the "OnlyBody" children, instead of all items in the RPIT's defining scope
1. Only walk through the body's children if we found a constraining usage
2. Don't actually do any inference, just do a comparison and error if they're mismatched

----

r? `@oli-obk` -- you know all this impl-trait stuff best... is this the right approach? I can explain the underlying issue better if you'd like, in case that might reveal a better solution. Not sure if it's possible to gather up the closure's defining usages of the RPIT while borrowck'ing the outer function, that might be a better place to put this check...
2022-07-27 19:05:32 +09:00
David Wood
1b8e4b9391 lint: add comment about diag lints in group
Add a brief comment explaining why the diagnostic migration lints aren't
included in the `rustc::internal` diagnostic group.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-27 10:59:10 +01:00
Yuki Okushi
7f608e99dc
Rollup merge of #99759 - bjorn3:remove_llvm_dead_code, r=nikic
Remove dead code from cg_llvm

Found while working on https://github.com/rust-lang/rust/pull/97485
2022-07-27 11:52:56 +09:00
Yuki Okushi
fe51d07b99
Rollup merge of #99712 - davidtwco:translation-migrate-passes-2, r=compiler-errors
passes: port more of `check_attr` module

Continues from #99213.

Port more diagnostics in `rustc_passes::check_attr` to using the diagnostic derive and translation machinery.

r? `@compiler-errors`
2022-07-27 11:52:55 +09:00
Yuki Okushi
3ca1c3100d
Rollup merge of #99698 - compiler-errors:no-doc-hidden, r=cjgillot
Prefer visibility map parents that are not `doc(hidden)` first

Far simpler approach to #98876.

This only fixes the case where the parent is `doc(hidden)`, not where the child is `doc(hidden)` since I don't know how to get the attrs on the import statement given a `ModChild`... I'll try to follow up with that, but this is a good first step.
2022-07-27 11:52:53 +09:00
Takayuki Maeda
ddd326fda4 use pluralize! 2022-07-27 10:09:06 +09:00
bors
4d6d601c8a Auto merge of #99574 - durin42:allocator-patch-redux, r=nikic
codegen: use new {re,de,}allocator annotations in llvm

This obviates the patch that teaches LLVM internals about
_rust_{re,de}alloc functions by putting annotations directly in the IR
for the optimizer.

The sole test change is required to anchor FileCheck to the body of the
`box_uninitialized` method, so it doesn't see the `allocalign` on
`__rust_alloc` and get mad about the string `alloca` showing up. Since I
was there anyway, I added some checks on the attributes to prove the
right attributes got set.

r? `@nikic`
2022-07-26 19:35:57 +00:00
Camille GILLOT
4b2f06b8a9 Pacify tidy. 2022-07-26 19:00:31 +02:00
Camille GILLOT
556b02704f Stop creating anonymous late lifetimes. 2022-07-26 19:00:31 +02:00
Camille GILLOT
ad1b1819eb Remove resolve_elided_lifetimes. 2022-07-26 19:00:31 +02:00