Commit Graph

15575 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
211637d080 Auto merge of #99730 - lcnr:bound-vars-anon, r=jackh726
anonymize all bound vars, not just regions

fixes #98702

r? types
2022-07-29 21:38:36 +00:00
Nika Layzell
6d1650fe45 proc_macro: use crossbeam channels for the proc_macro cross-thread bridge
This is done by having the crossbeam dependency inserted into the
proc_macro server code from the server side, to avoid adding a
dependency to proc_macro.

In addition, this introduces a -Z command-line option which will switch
rustc to run proc-macros using this cross-thread executor. With the
changes to the bridge in #98186, #98187, #98188 and #98189, the
performance of the executor should be much closer to same-thread
execution.

In local testing, the crossbeam executor was substantially more
performant than either of the two existing CrossThread strategies, so
they have been removed to keep things simple.
2022-07-29 17:38:12 -04:00
Camille GILLOT
2134dd3b48 Remove useless closure. 2022-07-29 22:11:23 +02:00
Camille GILLOT
a09b7ebfd3 Use DefKind instead of FnKind for recursion lint. 2022-07-29 18:10:43 +02: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
Gimgim
d0e881eefe Add diagnostic when using public instead of pub 2022-07-29 19:21:30 +05:30
Obei Sideg
254b89d209 Recover from c++ style enum struct
new error message: `enum` and `struct` are mutually exclusive
new suggestion: replace `enum struct` with `enum`
2022-07-29 13:56:54 +03:00
lcnr
d3ad264a91 remove some manual hash stable impls 2022-07-29 12:48:28 +02: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
Michael Goulet
7cdd937bb8 dont call type ascription 'cast' 2022-07-29 07:02:52 +00:00
lcnr
1436fa9e90 optimize bound vars replacement :3 2022-07-29 08:45:06 +02: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
Michael Goulet
16f49800db Document check_region_obligations_and_report_errors, simplify a call to resolve_regions 2022-07-29 06:17:17 +00:00
Michael Goulet
dec29b1582 Adjust an expr span to account for macros 2022-07-29 06:02:11 +00:00
Nicholas Nethercote
332dffb1f9 Remove TreeAndSpacing.
A `TokenStream` contains a `Lrc<Vec<(TokenTree, Spacing)>>`. But this is
not quite right. `Spacing` makes sense for `TokenTree::Token`, but does
not make sense for `TokenTree::Delimited`, because a
`TokenTree::Delimited` cannot be joined with another `TokenTree`.

This commit fixes this problem, by adding `Spacing` to `TokenTree::Token`,
changing `TokenStream` to contain a `Lrc<Vec<TokenTree>>`, and removing the
`TreeAndSpacing` typedef.

The commit removes these two impls:
- `impl From<TokenTree> for TokenStream`
- `impl From<TokenTree> for TreeAndSpacing`

These were useful, but also resulted in code with many `.into()` calls
that was hard to read, particularly for anyone not highly familiar with
the relevant types. This commit makes some other changes to compensate:
- `TokenTree::token()` becomes `TokenTree::token_{alone,joint}()`.
- `TokenStream::token_{alone,joint}()` are added.
- `TokenStream::delimited` is added.

This results in things like this:
```rust
TokenTree::token(token::Semi, stmt.span).into()
```
changing to this:
```rust
TokenStream::token_alone(token::Semi, stmt.span)
```
This makes the type of the result, and its spacing, clearer.

These changes also simplifies `Cursor` and `CursorRef`, because they no longer
need to distinguish between `next` and `next_with_spacing`.
2022-07-29 15:52:15 +10:00
Michael Goulet
77f7a833dd Do not allow bad projection term to leak into the type checker 2022-07-29 05:48:40 +00:00
Michael Goulet
940ec1e517 Remove parent_pat from TopInfo 2022-07-29 05:44:05 +00:00
Nicholas Nethercote
74e9a29f6e Remove some late check_* functions.
They're not used by rustc or clippy.
2022-07-29 15:30:12 +10:00
Nicholas Nethercote
6dced80b86 Remove visit_name from the AST visitor.
Because the default is empty and it's never overridden. This means
`walk_ident` can also be removed, because it does nothing.
2022-07-29 15:28:32 +10:00
Nicholas Nethercote
ab44b5a408 Remove some early check_* functions.
They're not used by rustc or clippy.
2022-07-29 15:27:16 +10:00
Takayuki Maeda
3ae669d758 check if T is slice
fix msg
2022-07-29 14:17:26 +09:00
Takayuki Maeda
06f89b7924 implement point_at_index_if_possible 2022-07-29 14:12:17 +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
Michael Goulet
b67ba9ba20 fix ICE when computing codegen_fn_attrs on closure with non-fn parent 2022-07-29 00:41:51 +00:00
Camille GILLOT
6733bc3066 Remove guess_head_span. 2022-07-28 23:14:04 +02: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
Lokathor
2eac6f30c8
once again tidy was unhappy 2022-07-28 10:58:42 -06:00
Hudson Ayers
6dea21a4a2 location-detail: disable all location details when passed none
Prior to this fix, `-Z location-detail` provided no mechanism for
disabling all location details. This commit also adds a test case
to verify that this option continues to work as intended, and
clarifies the documentation of this option.
2022-07-28 09:45:59 -07: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
Lokathor
9cf5b2d81c
Update thumbv4t_none_eabi.rs 2022-07-28 10:43:05 -06:00
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
lcnr
c3fce8e937 anonymize all bound vars, not just regions 2022-07-28 16:13:47 +02:00
lcnr
fd59d058ec BoundVarReplacer: trait object instead of 3 fns 2022-07-28 16:13:47 +02:00
Jack Wrenn
e8a1925b64 safe transmute: use AtomicU32 State ids to appease mips
...instead of `AtomicU64`, which is unavailable.

ref: https://github.com/rust-lang/rust/pull/92268#issuecomment-1197797990
2022-07-28 13:47:11 +00:00
Maybe Waffle
620b0f1935 improve type mismatch error for functions
This also fixes the argument names in `report_closure_arg_mismatch`
(confusing expected/found)
2022-07-28 17:29:47 +04: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
bjorn3
7c6c7e8785 Introduce an ArchiveBuilderBuilder
This avoids monomorphizing all linker code for each codegen backend and
will allow passing in extra information to the archive builder from the
codegen backend.
2022-07-28 09:08:47 +00:00
bjorn3
90da3c6f2b Inline inject_dll_import_lib 2022-07-28 08:43:15 +00:00
bjorn3
7c93154a30 Move output argument from ArchiveBuilder::new to .build() 2022-07-28 08:39:19 +00: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
Jack Wrenn
aee5f31c68 safe transmute: lowercase tracing levels
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r927095154
2022-07-27 17:33:57 +00:00
Jack Wrenn
2268603046 safe transmute: tweak Nfa::union to consume params by value
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925274516
2022-07-27 17:33:57 +00:00
Jack Wrenn
4a15157bad safe transmute: don't mark user impls as unambiguous
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925243794
2022-07-27 17:33:57 +00:00
Jack Wrenn
c0d0ce95eb safe transmute: tweak tracing
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925246903
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925250811
ref: https://github.com/rust-lang/rust/pull/92268#discussion_r925255782
2022-07-27 17:33:56 +00:00
Jack Wrenn
0fa70c3b12 safe transmute: revise Hash, PartialEq impls on VariantDef, FieldDef
Exhaustively destructure parameter(s) so that changes to type
definitions will lead to compile errors, thus reminding contributors
to re-assess the assumptions underpinning these impls.

ref: https://github.com/rust-lang/rust/pull/92268/#discussion_r925241377
ref: https://github.com/rust-lang/rust/pull/92268/#discussion_r925241718
2022-07-27 17:33:56 +00:00
Jack Wrenn
18751a708a safe transmute: gracefully handle const params of wrong types
ref: https://github.com/rust-lang/rust/pull/92268/files#r925244819
2022-07-27 17:33:56 +00:00
Jack Wrenn
bc4a1dea41 Initial (incomplete) implementation of transmutability trait.
This initial implementation handles transmutations between types with specified layouts, except when references are involved.

Co-authored-by: Igor null <m1el.2027@gmail.com>
2022-07-27 17:33:56 +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
Michael Goulet
1694ea1873 use check_region_obligations_and_report_errors in more places to avoid ICEs 2022-07-27 05:34:29 +00: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
Daniel Paoliello
722d67d5e7 Fix vectorcall 2022-07-26 14:11:37 -07: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
Camille GILLOT
30565e5871 Stop resolving lifetime elision on HIR. 2022-07-26 19:00:31 +02:00
Camille GILLOT
267d3620a5 Move fn parameter ribs outwards. 2022-07-26 19:00:31 +02:00
Camille GILLOT
10be0dd8df Replace LifetimeRes::Anonymous by LifetimeRes::Infer. 2022-07-26 19:00:31 +02:00
Camille GILLOT
ab63591f00 Remove the distinction between LifetimeName::Implicit and LifetimeName::Underscore. 2022-07-26 19:00:31 +02:00
Camille GILLOT
a2254d5d7c Do not produce extra lifetime parameters when not needed. 2022-07-26 19:00:30 +02:00
bjorn3
30a5eb063e Merge commit 'd3a2366ee877075c59b38bd8ced55f224fc7ef51' into sync_cg_clif-2022-07-26 2022-07-26 18:53:46 +02:00
Matthias Krüger
ddb6a46316
Rollup merge of #99729 - cjgillot:rm-unused-tuple, r=michaelwoerister
Remove unused tuple fields

Found by https://github.com/rust-lang/rust/pull/95977
2022-07-26 16:57:50 +02:00
Deadbeef
4b7a348508 ICE on RawPtrComparison check 2022-07-26 14:57:49 +00:00
Deadbeef
71e162e6ca Fix diagnostics for unfulfilled obligations 2022-07-26 14:14:21 +00:00
Deadbeef
a6f9826979 Add Self: ~const Trait to traits with #[const_trait] 2022-07-26 14:14:21 +00:00
Augie Fackler
130a1df71e 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.

While we're here, we also emit allocator attributes on
__rust_alloc_zeroed. This should allow LLVM to perform more
optimizations for zeroed blocks, and probably fixes #90032. [This
comment](https://github.com/rust-lang/rust/issues/24194#issuecomment-308791157)
mentions "weird UB-like behaviour with bitvec iterators in
rustc_data_structures" so we may need to back this change out if things
go wrong.

The new test cases require LLVM 15, so we copy them into LLVM
14-supporting versions, which we can delete when we drop LLVM 14.
2022-07-26 09:43:28 -04:00
bjorn3
017e1726ff Remove dead code from cg_llvm 2022-07-26 11:29:18 +00:00
Daniil Belov
7d4a98e61a Lib kind -l link-arg:
arbitrary link argument like -C link-arg, but respecting relative order to other `-l` options, unstable
2022-07-26 13:55:27 +03:00
bors
2614e437f5 Auto merge of #99753 - Dylan-DPC:rollup-k046940, r=Dylan-DPC
Rollup of 5 pull requests

Successful merges:

 - #99618 (handle consts with param/infer in `const_eval_resolve` better)
 - #99666 (Restore `Opaque` behavior to coherence check)
 - #99692 (interpret, ptr_offset_from: refactor and test too-far-apart check)
 - #99739 (Remove erroneous E0133 code from an error message.)
 - #99748 (Use full type name instead of just saying `impl Trait` in "captures lifetime" error)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-26 10:35:25 +00:00
Dylan DPC
ad32667bc8
Rollup merge of #99748 - compiler-errors:better-impl-trait-printing, r=fee1-dead
Use full type name instead of just saying `impl Trait` in "captures lifetime" error

I think this is very useful, especially when there's >1 `impl Trait`, and it just means passing around a bit more info that we already have access to.
2022-07-26 14:27:00 +05:30
Dylan DPC
962da8bdce
Rollup merge of #99739 - nnethercote:rm-E0133, r=Dylan-DPC
Remove erroneous E0133 code from an error message.

This error message is about `derive` and `packed`, but E0133 is for
"Unsafe code was used outside of an unsafe function or block".

r? ``@estebank``
2022-07-26 14:26:59 +05:30
Dylan DPC
deab13c681
Rollup merge of #99692 - RalfJung:too-far, r=oli-obk
interpret, ptr_offset_from: refactor and test too-far-apart check

We didn't have any tests for the "too far apart" message, and indeed that check mostly relied on the in-bounds check and was otherwise probably not entirely correct... so I rewrote that check, and it is before the in-bounds check so we can test it separately.
2022-07-26 14:26:58 +05:30
Dylan DPC
99350de0d5
Rollup merge of #99666 - compiler-errors:issue-99663, r=lcnr
Restore `Opaque` behavior to coherence check

Fixes #99663.

This broke in 84c3fcd2a0. I'm not exactly certain that adding this behavior back is necessarily correct, but at least the UI test I provided may stimulate some thoughts.

I think delaying a bug here is certainly not correct in the case of opaques -- if we want to change coherence behavior for opaques, then we should at least be emitting a new error.

r? ``@lcnr``
2022-07-26 14:26:57 +05:30
Dylan DPC
a39c00ee8d
Rollup merge of #99618 - compiler-errors:uhh-idk, r=lcnr
handle consts with param/infer in `const_eval_resolve` better

This PR addresses [this thread here](https://github.com/rust-lang/rust/pull/99449#discussion_r924141230). Was this the change you were looking for ``@lcnr?``

Interestingly, one test has begun to pass. Was that expected?

r? ``@lcnr``
2022-07-26 14:26:56 +05:30
Michael Goulet
5e8f1e80d8 Check that RPITs constrained by a recursive call in a closure are compatible 2022-07-26 07:46:30 +00:00
Michael Goulet
90939e6bce Revert "Do not allow typeck children items to constrain outer RPITs"
This reverts commit e8d9f38141.
2022-07-26 07:46:30 +00:00
Michael Goulet
82ad5c95b6 Revert "use opaque_ty_origin_unchecked instead of destructuring HIR"
This reverts commit 5a4601fea5.
2022-07-26 07:46:30 +00:00
bors
96b9bb4620 Auto merge of #99677 - pietroalbini:pa-fix-97786-perf-regression, r=Mark-Simulacrum
Remove new allocations from `imported_source_files`

https://github.com/rust-lang/rust/pull/97786 introduced a [large performance regression](https://github.com/rust-lang/rust/pull/97786#issuecomment-1176552836). After some local investigation it turns out the allocations performed by my change were the cause of the perf regression. This PR refactors my change to remove those allocations.
2022-07-26 07:29:29 +00:00
Michael Goulet
91e91d83be Allow try_to_raw_bytes on u8 array 2022-07-26 07:05:31 +00:00
Michael Goulet
b248647ef0 Address nits, move substs replacement to separate function 2022-07-26 06:43:50 +00:00
Michael Goulet
d3492ca852 Use real opaque type instead of just saying impl Trait 2022-07-26 06:19:58 +00:00
Preston From
1a08b17044 Use Span::from_inner and make changes to precision inner span clearer 2022-07-25 23:23:33 -06:00
Michael Goulet
58f107ab56 Use TraitEngine in more places that don't specifically need FulfillmentCtxt::new_in_snapshot 2022-07-26 04:55:06 +00:00
bors
b629c85bd7 Auto merge of #99745 - JohnTitor:rollup-lvrie64, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #98211 (Implement `fs::get_path` for FreeBSD.)
 - #99353 (Slightly improve mismatched GAT where clause error)
 - #99593 (Suggest removing the tuple struct field for the unwrapped value)
 - #99615 (Remove some explicit `self.infcx` for `FnCtxt`, which already derefs into `InferCtxt`)
 - #99711 (Remove reachable coverage without counters)
 - #99718 (Avoid `&str`/`Symbol` to `String` conversions)
 - #99720 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-26 04:28:41 +00:00
Yuki Okushi
a572f061c7
Rollup merge of #99720 - bjorn3:sync_cg_clif-2022-07-25, r=bjorn3
Sync rustc_codegen_cranelift

This time most of the changes are bugfixes. No exciting new features to report. Thanks `@matthiaskrgr` for reporting a bunch of crashes!

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2022-07-26 13:12:24 +09:00
Yuki Okushi
85afb90788
Rollup merge of #99718 - TaKO8Ki:avoid-&str-symbol-to-string-conversions, r=michaelwoerister
Avoid `&str`/`Symbol` to `String` conversions

follow-up to #99342 and #98668
2022-07-26 13:12:23 +09:00
Yuki Okushi
3c1eef2e91
Rollup merge of #99711 - tmiasko:coverage, r=wesleywiser
Remove reachable coverage without counters

Remove reachable coverage without counters to maintain invariant that
either there is no coverage at all or there is a live coverage counter
left that provides the function source hash.

The motivating example would be a following closure:

```rust
    let f = |x: bool| {
        debug_assert!(x);
    };
```

Which, with span changes from #93967, with disabled debug assertions,
after the final CFG simplifications but before removal of dead blocks,
gives rise to MIR:

```rust
fn main::{closure#0}(_1: &[closure@a.rs:2:13: 2:22], _2: bool) -> () {
    debug x => _2;
    let mut _0: ();

    bb0: {
        Coverage::Expression(4294967295) = 1 - 2;
        return;
    }

    ...
}
```

Which also makes the initial instrumentation quite suspect, although
this pull request doesn't attempt to address that aspect directly.

Fixes #98833.

r? ``@wesleywiser`` ``@richkadel``
2022-07-26 13:12:22 +09:00
Yuki Okushi
2744c0ef18
Rollup merge of #99615 - compiler-errors:remove-some-explicit-infcx, r=lcnr
Remove some explicit `self.infcx` for `FnCtxt`, which already derefs into `InferCtxt`

The use of `self.infcx.method_on_infcx` vs `self.method_on_infcx` when `self` is a `FnCtxt` is a bit inconsistent, so I'm moving some `self.infcx` usages I found to just use autoderef
2022-07-26 13:12:21 +09:00
Yuki Okushi
d89e99a805
Rollup merge of #99593 - TaKO8Ki:suggest-removing-tuple-struct-field, r=compiler-errors
Suggest removing the tuple struct field for the unwrapped value

fixes #99416
2022-07-26 13:12:20 +09:00
Yuki Okushi
2944454540
Rollup merge of #99353 - compiler-errors:gat-where-clause-mismatch, r=cjgillot
Slightly improve mismatched GAT where clause error

This makes the error reporting a bit more standardized between `where` on GATs and functions.

cc #99206 (`@BoxyUwU),` don't want to mark this as as "fixed" because they're still not perfect, but this is still an improvement IMO so I want to land it incrementally.

regarding "consider adding where clause to trait definition", we don't actually do that for methods as far as i can tell? i could file an issue to look into that maybe.
2022-07-26 13:12:19 +09:00
Nicholas Nethercote
6a4b1572f9 Remove erroneous E0133 code from an error message.
This error message is about `derive` and `packed`, but E0133 is for
"Unsafe code was used outside of an unsafe function or block".
2022-07-26 12:54:24 +10:00
Michael Goulet
1390220ff2 Use impl generics when suggesting fix on copy impl 2022-07-26 01:48:34 +00:00
bors
daaae25022 Auto merge of #98989 - dpaoliello:rawdylibbin, r=michaelwoerister
Enable raw-dylib for bin crates

Fixes #93842

When `raw-dylib` is used in a `bin` crate, we need to collect all of the `raw-dylib` functions, generate the import library and add that to the linker command line.

I also changed the tests so that 1) the C++ dlls are created after the Rust dlls, thus there is no chance of accidentally using them in the Rust linking process and 2) disabled generating import libraries when building with MSVC.
2022-07-26 01:47:34 +00:00
Michael Goulet
aaa9989c2f Remove some explicit self.infcx for fcx, which derefs into infcx 2022-07-26 00:40:22 +00:00
Michael Goulet
f1618e8924 handle consts with param/infer in const_eval_resolve better 2022-07-25 23:41:13 +00:00
Michael Goulet
b7cf9f72f6 Restore Opaque behavior to coherence check 2022-07-25 23:38:41 +00:00
bors
a86705942c Auto merge of #99735 - JohnTitor:rollup-d93jyr2, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #92390 (Constify a few `(Partial)Ord` impls)
 - #97077 (Simplify some code that depend on Deref)
 - #98710 (correct the output of a `capacity` method example)
 - #99084 (clarify how write_bytes can lead to UB due to invalid values)
 - #99178 (Lighten up const_prop_lint, reusing const_prop)
 - #99673 (don't ICE on invalid dyn calls)
 - #99703 (Expose size_hint() for TokenStream's iterator)
 - #99709 (`Inherited` always has `TypeckResults` available)
 - #99713 (Fix sidebar background)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-25 22:57:23 +00:00
Yuki Okushi
b37b39db82
Rollup merge of #99709 - lcnr:rm-MaybeTypeckResults, r=compiler-errors
`Inherited` always has `TypeckResults` available
2022-07-26 07:14:51 +09:00
Yuki Okushi
2973b00ca6
Rollup merge of #99673 - RalfJung:interpret-invalid-dyn, r=oli-obk
don't ICE on invalid dyn calls

Due to https://github.com/rust-lang/rust/issues/50781 this is actually reachable.
Fixes https://github.com/rust-lang/miri/issues/2432

r? ``@oli-obk``
2022-07-26 07:14:49 +09:00
Yuki Okushi
74be487ca0
Rollup merge of #99178 - Dajamante:clean_up, r=oli-obk
Lighten up const_prop_lint, reusing const_prop

r? `@oli-obk`
2022-07-26 07:14:48 +09:00
Yuki Okushi
29892759f6
Rollup merge of #97077 - ouz-a:Optimize-backend, r=oli-obk
Simplify some code that depend on Deref

Now that we can assume #97025 works, it's safe to expect Deref is always in the first place of projections. With this, I was able to simplify some code that depended on Deref's place in projections. When we are able to move Derefer before `ElaborateDrops` successfully we will be able to optimize more places.

r? `@oli-obk`
2022-07-26 07:14:44 +09:00
bors
6dbae3ad19 Auto merge of #97313 - cjgillot:ast-lifetimes-anon, r=petrochenkov
Resolve function lifetime elision on the AST

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

Lifetime elision for functions is purely syntactic in nature, so can be resolved on the AST.
This PR replicates the elision logic and diagnostics on the AST, and replaces HIR-based resolution by a `delay_span_bug`.

This refactor allows for more consistent diagnostics, which don't have to guess the original code from HIR.

r? `@petrochenkov`
2022-07-25 20:02:55 +00:00
Eric Huss
2ce2870749 Remove let-chain close brace check. 2022-07-25 11:19:29 -07:00
Camille GILLOT
9450f822fb Unused tuple fields in rustc_resolve. 2022-07-25 19:45:26 +02:00
Camille GILLOT
ec83476748 Unused tuple fields in rustc_infer. 2022-07-25 19:45:10 +02:00
Camille GILLOT
3148ea31eb Update file description. 2022-07-25 19:19:23 +02:00
Camille GILLOT
3c5048d2ec Report elision failures on the AST. 2022-07-25 19:19:23 +02:00
lcnr
2e796acf33 use FxIndexSet for region_bound_pairs 2022-07-25 18:39:34 +02:00
David Wood
76cf6bd03e passes: port more of check_attr module
Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-25 15:11:22 +01:00
ouz-a
a5c895e1d8 remove clone 2022-07-25 17:08:54 +03:00
bjorn3
7a3ed235eb Merge commit 'c19edfd71a1d0ddef86c2c67fdb40718d40a72b4' into sync_cg_clif-2022-07-25 2022-07-25 16:07:57 +02:00
bors
dc2d232c74 Auto merge of #85673 - csmoe:export-exe-sym, r=bjorn3
RFC-2841: add codegen flag export symbols from executable

Closes #84161
r? `@nikomatsakis` `@Mark-Simulacrum`
2022-07-25 14:04:40 +00:00
Aïssata
e6518296dc removed CanConstProp + Visitor 2022-07-25 13:54:49 +00:00
Takayuki Maeda
051e98b7bf avoid &str/Symbol to String conversions 2022-07-25 22:40:00 +09:00
Takayuki Maeda
bf1a5e72f4 remove is_local_span as it is no longer used 2022-07-25 22:37:14 +09:00