Commit Graph

18538 Commits

Author SHA1 Message Date
Michael Goulet
dce44faf5b Revert "Make ClosureOutlivesRequirement not rely on an unresolved type"
This reverts commit a6b5f95fb0.
2022-10-27 16:15:11 +00:00
Julien Cretin
dad28ad6d5 Add multivalue target feature to WASM target 2022-10-27 18:08:30 +02:00
Michael Goulet
2f9794b84a remove _types from ocx method names 2022-10-27 15:43:37 +00:00
Michael Goulet
ce11ae5d0d Address some more nits 2022-10-27 15:43:33 +00:00
Michael Goulet
d793d80cf7 (almost) Always use ObligationCtxt when dealing with canonical queries 2022-10-27 15:43:33 +00:00
Maybe Waffle
dc53c8f25f Update tooling 2022-10-27 18:41:26 +04:00
Michael Woerister
9117ea9758 Introduce UnordMap, UnordSet, and UnordBag (see MCP 533)
MCP 533: https://github.com/rust-lang/compiler-team/issues/533

Also, as an example, substitute UnordMap for FxHashMap in
used_trait_imports query result.
2022-10-27 13:23:26 +00:00
Matthias Krüger
f9dfb6e32f
Rollup merge of #103544 - Nilstrieb:no-recovery-pls, r=compiler-errors
Add flag to forbid recovery in the parser

To start the effort of fixing #103534, this adds a new flag to the parser, which forbids the parser from doing recovery, which it shouldn't do in macros.

This doesn't add any new checks for recoveries yet and is just here to bikeshed the names for the functions here before doing more.

r? `@compiler-errors`
2022-10-27 15:03:58 +02:00
Matthias Krüger
4a01cab4b7
Rollup merge of #103524 - petrochenkov:modchild4, r=cjgillot
rustc_metadata: Add struct and variant constructors to module children at encoding time

instead of decoding time.

Continuation of https://github.com/rust-lang/rust/pull/95899.
The last time it caused some ICEs from generator use, but not everything seems ok.
2022-10-27 15:03:57 +02:00
Matthias Krüger
16e74c78a1
Rollup merge of #103255 - oli-obk:opaque_wrong_eq_relation, r=compiler-errors
Clean up hidden type registration

work on https://github.com/rust-lang/rust/issues/101186

Actually passing down the relation and using it instead of `eq` for the hidden type comparison has *no* effect whatsoever and allows for no further improvements at the call sites. I decided the increased complexity was not worth it and thus did not include that change in this PR.

r? `@compiler-errors`
2022-10-27 15:03:55 +02:00
Maybe Waffle
a17ccfa621 Accept TyCtxt instead of TyCtxtAt in Ty::is_* functions
Functions in answer:

- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`
2022-10-27 15:06:08 +04:00
bors
0da281b606 Auto merge of #103623 - matthiaskrgr:rollup-318yc1t, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #103035 (Even nicer errors from assert_unsafe_precondition)
 - #103106 (Try to say that memory outside the AM is always exposed)
 - #103475 (Make param index generation a bit more robust)
 - #103525 (Move a wf-check into the site where the value is instantiated)
 - #103564 (library: allow some unused things in Miri)
 - #103586 (Process registered region obligation in `resolve_regions_with_wf_tys`)
 - #103592 (rustdoc: remove redundant CSS selector `.notable-traits .notable`)
 - #103593 (Remove an unused parser function (`Expr::returns`))
 - #103611 (Add test for issue 103574)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-27 10:05:16 +00:00
Matthias Krüger
0f0c044228
Rollup merge of #103593 - compiler-errors:nit-remove-returns, r=fee1-dead
Remove an unused parser function (`Expr::returns`)

I removed the only usage in #97474
2022-10-27 09:25:12 +02:00
Matthias Krüger
bf53e712c0
Rollup merge of #103586 - compiler-errors:issue-103573, r=jackh726
Process registered region obligation in `resolve_regions_with_wf_tys`

Fixes #103573
2022-10-27 09:25:11 +02:00
Matthias Krüger
2bd49c34e5
Rollup merge of #103525 - oli-obk:const_impl_on_non_const_trait, r=lcnr
Move a wf-check into the site where the value is instantiated

r? ``@lcnr``
2022-10-27 09:25:10 +02:00
Matthias Krüger
d7ad6ad9ad
Rollup merge of #103475 - oli-obk:generic_param_indices, r=lcnr
Make param index generation a bit more robust

r? ````@lcnr````

While not really necessary for closure and anon const ids, it's strictly more correct
2022-10-27 09:25:09 +02:00
bors
9dd3d29ec8 Auto merge of #103601 - compiler-errors:no-opaque-probe-in-nll-relate, r=oli-obk
Remove `commit_if_ok` probe from NLL type relation

It was not really necessary to add the `commit_if_ok` in #100092 -- I added it to protect us against weird inference error messages due to recursive RPIT calls, but we are always on the error path when this happens anyways, and I can't come up with an example that makes this manifest.

Fixes #103599

r? `@oli-obk` since you reviewed #100092, feel free to re-roll.

🅱️ 📢  beta-nominating this since it's on beta (which forks in ~a week~ two days 😨) -- worst case we could revert the original PR on beta and land this on nightly, to give it some extra soak time...
2022-10-27 07:24:39 +00:00
Jakob Degen
c4c4c566d0 Replace mir_map.0 dump with built phase change dump 2022-10-27 00:21:57 -07:00
Byron Zhong
20a8427a11 Remove redundant braces 2022-10-27 01:41:24 -05:00
Byron Zhong
c0472a5450 Fix E0433 diagnostics ignoring typo suggestions and outputing wrong message 2022-10-27 00:49:39 -05:00
Wesley Wiser
7c6345d175 Allow use of -Clto=thin with -Ccodegen-units=1 in general
The current logic to ignore ThinLTO when `-Ccodegen-units=1` makes sense
for local ThinLTO but even in this scenario, a user may still want
(non-local) ThinLTO for the purpose of optimizing dependencies into the
final crate which is being compiled with 1 CGU.

The previous behavior was even more confusing because if you were
generating a binary (`--emit=link`), then you would get ThinLTO but if
you asked for LLVM IR or bytecode, then it would silently change to
using regular LTO.

With this change, we only override the defaults for local ThinLTO if you
ask for a single output such as LLVM IR or bytecode and in all other
cases honor the requested LTO setting.
2022-10-26 21:03:28 -04:00
Michael Goulet
b1cc95da23 Remap early bound lifetimes too 2022-10-27 00:28:54 +00:00
Yuki Okushi
132883e455
Rollup merge of #103598 - tshepang:token-kind-docs, r=jackh726
rustc_lexer::TokenKind improve docs
2022-10-27 08:30:59 +09:00
Yuki Okushi
6e1de0e9aa
Rollup merge of #103549 - maurer:llvm-main, r=cuviper
llvm-16: Don't initialize removed legacy passes

LLVM removed initialization for legacy passes:
https://reviews.llvm.org/D136615
2022-10-27 08:30:56 +09:00
Michael Goulet
901649eeb7 No need to probe when relating opaques in nll_relate 2022-10-26 22:10:12 +00:00
Tshepang Mbambo
b66f92197a rustc_lexer::TokenKind improve docs 2022-10-26 23:32:14 +02:00
nils
da407ed38f
Fix typo
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2022-10-26 22:06:35 +02:00
Michael Goulet
d380d0387d remove unused parser fn 2022-10-26 19:19:44 +00:00
Nilstrieb
796114a5b0
Add documentation 2022-10-26 21:09:28 +02:00
Michael Goulet
db3b01d2bf Process registered region obligation in resolve_regions_with_wf_tys 2022-10-26 16:06:54 +00:00
bors
0a6b941df3 Auto merge of #103572 - Dylan-DPC:rollup-a8bnxrw, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #95710 (Stabilize arbitrary_enum_discriminant, take 2)
 - #102706 (Support excluding the generation of the standalone docs)
 - #103428 (Removed verbose printing from the `PrettyPrinter` when printing constants)
 - #103543 (Update books)
 - #103546 (interpret: a bit of cast cleanup)
 - #103554 (rustdoc: add visible focus outline to rustdoc-toggle)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-26 14:12:16 +00:00
Xiretza
2eeb7802b3 Remove #[suggestion_*] attributes 2022-10-26 15:04:09 +02:00
Xiretza
cd621be782 Convert all #[suggestion_*] attributes to #[suggestion(style = "...")]
Using the following command:

find compiler/ -type f -name '*.rs' -exec perl -i -gpe \
    's/(#\[\w*suggestion)_(short|verbose|hidden)\(\s*(\S+,)?/\1(\3style = "\2",/g' \
    '{}' +
2022-10-26 15:04:09 +02:00
Xiretza
20f2958b8a Add "tool-only" suggestion style 2022-10-26 15:04:09 +02:00
Xiretza
368c4a35b9 Add style= parameter to suggestion attributes 2022-10-26 15:04:09 +02:00
Oli Scherer
de5517c3ae Remove unneeded sub-comparison 2022-10-26 12:47:04 +00:00
Vadim Petrochenkov
34eb73c72d privacy: Rename "accessibility levels" to "effective visibilities"
And a couple of other naming tweaks

Related to https://github.com/rust-lang/rust/issues/48054
2022-10-26 16:34:53 +04:00
Dylan DPC
709462bfe1
Rollup merge of #103546 - RalfJung:cast, r=oli-obk
interpret: a bit of cast cleanup

r? `@oli-obk`
2022-10-26 17:32:55 +05:30
Dylan DPC
ffde0f722e
Rollup merge of #103428 - SarthakSingh31:issue-94187, r=compiler-errors
Removed verbose printing from the `PrettyPrinter` when printing constants

Partially solves #94187 by completing the first step described in [this comment](https://github.com/rust-lang/rust/issues/94187#issuecomment-1282339909).
2022-10-26 17:32:54 +05:30
Dylan DPC
5b6455318a
Rollup merge of #95710 - fee1-dead-contrib:stabilize_arbitrary_enum_discriminant, r=joshtriplett
Stabilize arbitrary_enum_discriminant, take 2

Documentation has been updated in https://github.com/rust-lang/reference/pull/1055. cc #86860 for previous stabilization report.

Not yet marks https://github.com/rust-lang/rust/issues/60553 as done: need documentation in the rust reference.
2022-10-26 17:32:53 +05:30
mejrs
fae0be5d50 fix tracking hash test 2022-10-26 13:42:41 +02:00
bors
43dd3d514b Auto merge of #103284 - compiler-errors:const-sad, r=oli-obk
Revert "Unify tcx.constness and param env constness checks"

Too much of a perf regression https://github.com/rust-lang/rust/pull/102975#issuecomment-1282702513, and an attempt in #103263 didn't fix it except for just a tiny bit.

This change isn't really needed (see https://github.com/rust-lang/rust/pull/102830#issuecomment-1272514096), so this should be an easy revert.
2022-10-26 11:29:15 +00:00
bors
629a414d7b Auto merge of #103562 - Dylan-DPC:rollup-sheepp5, r=Dylan-DPC
Rollup of 10 pull requests

Successful merges:

 - #102951 (suggest type annotation for local statement initialed by ref expression)
 - #103209 (Diagnostic derives: allow specifying multiple alternative suggestions)
 - #103287 (Use a faster allocation size check in slice::from_raw_parts)
 - #103416 (Name the `impl Trait` in region bound suggestions)
 - #103430 (Workaround unstable stmt_expr_attributes for method receiver expressions)
 - #103444 (Remove extra type error after missing semicolon error)
 - #103520 (rustc_middle: Rearrange resolver outputs structures slightly)
 - #103533 (Use &self instead of &mut self for cast methods)
 - #103536 (Remove `rustc_driver::set_sigpipe_handler()`)
 - #103542 (Pinning tests for some `macro_rules!` errors discussed in the lang meeting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-26 07:58:28 +00:00
Dylan DPC
d159124dbd
Rollup merge of #103536 - Enselic:remove-set_sigpipe_handler, r=tmiasko
Remove `rustc_driver::set_sigpipe_handler()`

Its usage was removed in https://github.com/rust-lang/rust/pull/102587 and https://github.com/rust-lang/rust/pull/103495, so we do not need to keep it around any longer. According to [preliminary input](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Find.20.60rustc_driver.60.20dependent.20projects.3F/near/304490764), we do not need to worry about any deprecation cycle for this explicitly unstable API, and can just straight up remove it.

PR that added `set_sigpipe_handler`: https://github.com/rust-lang/rust/pull/49606

Tracking issue for `unix_sigpipe`: #97889

Migration instructions for any remaining clients
---

Change from

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

extern crate rustc_driver;

fn main() {
    rustc_driver::set_sigpipe_handler();
    // ...
```

to

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

#[unix_sigpipe = "sig_dfl"]
fn main() {
    // ...
```

``@rustbot`` labels +T-compiler
2022-10-26 11:29:57 +05:30
Dylan DPC
39e0e2cc24
Rollup merge of #103533 - jachris:cast-without-mut, r=oli-obk
Use &self instead of &mut self for cast methods

r? ``@oli-obk``
2022-10-26 11:29:56 +05:30
Dylan DPC
c956351f97
Rollup merge of #103520 - petrochenkov:resout, r=cjgillot
rustc_middle: Rearrange resolver outputs structures slightly

Addresses https://github.com/rust-lang/rust/pull/98106#discussion_r898427061.
I also haven't seen the motivation for moving `cstore` from its old place, so I moved it back in this PR.
r? ```@cjgillot```
2022-10-26 11:29:56 +05:30
Dylan DPC
742741f9c1
Rollup merge of #103444 - chenyukang:yukang/fix-103425-extra-diag, r=davidtwco
Remove extra type error after missing semicolon error

Fixes #103425
2022-10-26 11:29:55 +05:30
Dylan DPC
c9a04cddc0
Rollup merge of #103430 - cjgillot:receiver-attrs, r=petrochenkov
Workaround unstable stmt_expr_attributes for method receiver expressions

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

cc ``@Mark-Simulacrum`` ``@ehuss``
2022-10-26 11:29:55 +05:30
Dylan DPC
785828744c
Rollup merge of #103416 - compiler-errors:rpit-named, r=cjgillot
Name the `impl Trait` in region bound suggestions

Slightly more descriptive message
2022-10-26 11:29:54 +05:30
Dylan DPC
f2c2e582bd
Rollup merge of #103209 - Xiretza:multiple-suggestions, r=davidtwco
Diagnostic derives: allow specifying multiple alternative suggestions

This allows porting `span_suggestions()` to diagnostic structs.

Doesn't work for `multipart_suggestions()` because the rank would be reversed - the struct would specify multiple spans, each of which has multiple possible replacements, while `multipart_suggestions()` creates multiple possible replacements, each with multiple spans.
2022-10-26 11:29:53 +05:30
Dylan DPC
bf6bfcddf6
Rollup merge of #102951 - SparrowLii:type_annotation, r=estebank
suggest type annotation for local statement initialed by ref expression

In a local statement with a type declaration, if a ref expression is used on the right side and not used on the left side, in addition to removing the `&` and `&mut` on the right side, we can add them on the left side alternatively
Fixes #102892
2022-10-26 11:29:53 +05:30
bors
d49e7e7fa1 Auto merge of #103279 - compiler-errors:normalize-hack-back, r=lcnr
Add eval hack in `super_relate_consts` back

Partially reverts 01adb7e98d.

This extra eval call *still* needs to happen, for example, in `normalize_param_env_or_error` when a param-env predicate has an unnormalized constant, since the param-env candidates never get normalized during candidate assembly (everywhere else we can assume that they are normalized fully).

r? `@lcnr,` though I feel like I've assigned quite a few PRs to you in the last few days, so feel free to reassign to someone else familiar with this code if you're busy!

cc #103243 (fixes the issue, but don't want to auto-close that until a backport is performed).
2022-10-26 05:17:46 +00:00
Byron Zhong
775328c290 Modify check to output 'you might have meant' for indirect reference 2022-10-25 22:08:41 -05:00
Byron Zhong
0b936d2da7 Add check to only output 'you might have meant' when the candidate name is in the same crate 2022-10-25 22:08:41 -05:00
Byron Zhong
be61f0237b Add Span in TypoSuggestion and TypoCandidate 2022-10-25 22:08:41 -05:00
bors
a5406feb1c Auto merge of #103158 - Bryanskiy:resolve_perf, r=petrochenkov
Perf improvements for effective visibility calculating

related to https://github.com/rust-lang/rust/pull/102026
r? `@petrochenkov`
2022-10-26 02:30:18 +00:00
bors
6365e5ad9f Auto merge of #102903 - compiler-errors:region-var-leak, r=jackh726
Assert if inference vars are leaking from `InferCtxt::fully_resolve`

`InferCtxt::fully_resolve` shouldn't return unresolved inference vars without us at least being aware of it, so make it an assertion now. This should only happen in cases where we used to be returning `ReEmpty`...

cc `@jackh726`
2022-10-25 23:24:36 +00:00
Matthew Maurer
6ea75aea56 llvm-16: Don't initialize removed legacy passes
LLVM removed initialization for legacy passes:
https://reviews.llvm.org/D136615
2022-10-25 15:03:21 -07:00
Michael Howell
b205a5a67c diagnostics: do not suggest static candidates as traits to import
If it's a static candidate, then it's already implemented. Do not suggest
it a second time for implementing.
2022-10-25 14:47:13 -07:00
Ralf Jung
52fda858dd interpret: a bit of cast cleanup 2022-10-25 22:09:35 +02:00
Nilstrieb
ed14202864
Add flag to forbid recovery in the parser 2022-10-25 22:06:53 +02:00
Oli Scherer
1c26a278f3 Split diagnostic details out into a separate function and fluent files 2022-10-25 18:28:04 +00:00
Martin Nordholts
43e17454e2 Remove rustc_driver::set_sigpipe_handler()
Its usage was removed in 5e624bf4ba and 093b075d32, so we do not need to
keep it around any longer. According to [preliminary
input](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Find.20.60rustc_driver.60.20dependent.20projects.3F/near/304490764),
we do not need to worry about any deprecation cycle for this API and can
just straight up remove it.

Migration instructions for remaining clients
--------------------------------------------

Change from

```rust

extern crate rustc_driver;

fn main() {
    rustc_driver::set_sigpipe_handler();
    // ...
```

to

```rust

fn main() {
    // ...
```
2022-10-25 19:13:23 +02:00
Michael Goulet
726bf18d2d Name impl trait in region bound suggestion 2022-10-25 16:37:11 +00:00
Jannis Christopher Köhl
5378c82d80 Use &self instead of &mut self for cast methods 2022-10-25 18:31:11 +02:00
bors
bed4ad65bf Auto merge of #102340 - JakobDegen:pass-manager-simplification, r=oli-obk
Split phase change from `MirPass`

The main goal here is to simplify the pass manager logic. `MirPass` no longer contains the `phase_change` method, and `run_passes` instead accepts an `Option<PhaseChange>`. The hope is that this addresses the comments (and maybe perf regression) from #99102 .

r? `@oli-obk` cc `@RalfJung`
2022-10-25 15:55:39 +00:00
Oli Scherer
8286ea5a49 Move a wf-check into the site where the value is instantiated 2022-10-25 14:47:24 +00:00
Vadim Petrochenkov
2283a5e65b rustc_metadata: Add constructors to module children at encoding time
instead of decoding time.
2022-10-25 18:11:50 +04:00
Maybe Waffle
e93982a78f adopt to compiler changes 2022-10-25 13:47:43 +00:00
Oli Scherer
f3bd222ad9 Bubble the opaque type ordering int opaque type handling 2022-10-25 13:27:58 +00:00
Oli Scherer
196a429a67 Use the general type API instead of directly accessing register_hidden_type 2022-10-25 13:27:06 +00:00
Oli Scherer
14caf7396d Pull opaque type handling out of the type relating delegate 2022-10-25 13:27:04 +00:00
Maybe Waffle
cc752f5665 Feature gate impl_trait_in_fn_trait_return 2022-10-25 13:25:52 +00:00
Maybe Waffle
8b494f427c Allow impl Fn() -> impl Trait in return position
This allows writing the following function signatures:
```rust
fn f0() -> impl Fn() -> impl Trait;
fn f3() -> &'static dyn Fn() -> impl Trait;
```

These signatures were already allowed for common traits and associated
types, there is no reason why `Fn*` traits should be special in this
regard.
2022-10-25 13:25:51 +00:00
Bryanskiy
a9447bb9d0 Perf improvements for effective visibility calculating 2022-10-25 15:15:18 +03:00
Vadim Petrochenkov
919673ea03 rustc_middle: Rearrange resolver outputs structures slightly 2022-10-25 15:42:29 +04:00
Dylan DPC
6aea54c082
Rollup merge of #103511 - nnethercote:bb-tweaks, r=bjorn3
Codegen tweaks

Best reviewed one commit at a time.

r? `@bjorn3`
2022-10-25 14:43:16 +05:30
Dylan DPC
8ba2a651fb
Rollup merge of #103122 - ouz-a:mir-technical-debt, r=oli-obk
Remove misc_cast and validate types when casting

Continuing our work in #102675

r? ````@oli-obk````
2022-10-25 14:43:14 +05:30
Dylan DPC
8a5ce1d615
Rollup merge of #102587 - Enselic:rustc-unix_sigpipe, r=jackh726
rustc: Use `unix_sigpipe` instead of `rustc_driver::set_sigpipe_handler`

This is the first (known) step towards starting to use `unix_sigpipe` in the wild. Eventually, `rustc_driver::set_sigpipe_handler` can be removed and all clients can use `unix_sigpipe` instead.

For now we just start using `unix_sigpipe` in one place: `rustc` itself.

It is easy to manually verify this change. If you remove `#[unix_sigpipe = "sig_dfl"]` and run `./x.py build` you will get an ICE when you do `./build/x86_64-unknown-linux-gnu/stage1/bin/rustc --help | false`. Add back `#[unix_sigpipe = "sig_dfl"]` and the ICE disappears again.

PR that added `set_sigpipe_handler`: https://github.com/rust-lang/rust/pull/49606

Tracking issue for `unix_sigpipe`: #97889

Not sure exactly how to label this PR. Going with T-libs for now since this is a T-libs feature.

````@rustdoc```` labels +T-libs
2022-10-25 14:43:14 +05:30
Sarthak Singh
5e46d8675c Added helper to prevent verbose printing from the PrettyPrinter when printing constants 2022-10-25 13:05:34 +05:30
bors
31d754a1df Auto merge of #102988 - dpaoliello:inlinerawdylib, r=dpaoliello
Support raw-dylib functions being used inside inlined functions

Fixes #102714

Issue Details:
When generating the import library for `raw-dylib` symbols, we currently only use the functions and variables declared within the current crate. This works fine if all crates are static libraries or `rlib`s as the generated import library will be contained in the static library or `rlib` itself, but if a dependency is a dynamic library AND the use of a `raw-dylib` function or variable is inlined or part of a generic instantiation then the current crate won't see its dependency's import library and so linking will fail.

Fix Details:
Instead, when we generate the import library for a `dylib` or `bin` crate, we will now generate it for the symbols both for the current crate and all upstream crates. We do this in two steps so that the import library for the current crate is passed into the linker first, thus it is preferred if there are any ambiguous symbols.
2022-10-25 04:57:51 +00:00
Nicholas Nethercote
6cd35ac203 Simplify cast_shift_expr_rhs.
It's only ever used with shift operators.
2022-10-25 14:39:20 +11:00
Nicholas Nethercote
8c02f4d05d Inline and remove cast_shift_rhs.
It has a single call site.
2022-10-25 13:51:52 +11:00
Nicholas Nethercote
03f350f5a5 Clarify some cleanup stuff.
- Rearrange the match in `llbb_with_landing_pad` so the `(Some,Some)`
  cases are together.
- Add assertions to indicate two MSVC-only paths.
2022-10-25 12:07:35 +11:00
Nicholas Nethercote
a5bd5da594 Rename two TerminatorCodegenHelper methods.
`TerminatorCodegenHelper` has three methods `llblock`, `llbb`, and
`lltarget`. They're all similar, but the names given no indication of
the differences.

This commit renames `lltarget` as `llbb_with_landing_pad`, and `llblock`
as `llbb_with_cleanup`. These aren't fantastic names, but at least it's
now clear that `llbb` is the lowest-level of the three and the other two
wrap it.
2022-10-25 12:07:26 +11:00
Nicholas Nethercote
4e4092f8cc rustc_codegen_ssa: use more consistent naming.
Ensure:
- builders always have a `bx` suffix;
- backend basic blocks always have an `llbb` suffix,
- paired builders and basic blocks have consistent prefixes.
2022-10-25 12:07:23 +11:00
Daniel Paoliello
3a1ef50b34 Support raw-dylib functions being used inside inlined functions 2022-10-24 16:17:38 -07:00
Yuki Okushi
d1b00c6a74
Rollup merge of #103465 - jruderman:patch-1, r=compiler-errors
E0210 explanation: remove redundant sentence
2022-10-25 08:01:30 +09:00
Yuki Okushi
12babb623a
Rollup merge of #103409 - compiler-errors:rpitit-signature-mismatch, r=lcnr
Delay span bug when we can't map lifetimes back in `collect_trait_impl_trait_tys`

When a lifetime is late-bound in a trait signature, but early-bound in an impl signature, we already emit an error -- however, we also ICE in `collect_trait_impl_trait_tys`, so just delay a bug here.

Fixes #103407
2022-10-25 08:01:28 +09:00
Yuki Okushi
6383540130
Rollup merge of #103382 - compiler-errors:anon-apit-lt-region-ice, r=cjgillot
Don't ICE when reporting borrowck errors involving regions from `anonymous_lifetime_in_impl_trait`

The issue here is that when we have:

```
trait Trait<'a> { .. }

fn foo(arg: impl Trait) { .. }
```

The anonymous lifetime `'_` that we generate for `arg: impl Trait` doesn't end up in the argument type (which is a param) but in a where-clause of the function, in a predicate whose self type is that param ty.

Fixes #101660

r? ``@cjgillot``
2022-10-25 08:01:28 +09:00
Yuki Okushi
e47d222a94
Rollup merge of #103350 - clubby789:refer-to-assoc-method, r=wesleywiser
Change terminology for assoc method suggestions when they are not called

Fixes #103325

```@rustbot``` label +A-diagnostics
2022-10-25 08:01:27 +09:00
Yuki Okushi
11d11e3415
Rollup merge of #103333 - chenyukang:yukang/fix-103143, r=wesleywiser
Fix assertion failed for break_last_token and trailing token

Fixes #103143
2022-10-25 08:01:27 +09:00
Michael Goulet
1727c00f1a Assert if inference vars are leaking from fully_resolve 2022-10-24 18:53:32 +00:00
mejrs
854b3166a0 Address some comments 2022-10-24 20:52:51 +02:00
Michael Goulet
fa5cf90b8d Delay span bug when we can't map lifetimes back in collect_trait_impl_trait_tys 2022-10-24 18:45:50 +00:00
Aaron Hill
7d82cadd97
Make PROC_MACRO_DERIVE_RESOLUTION_FALLBACK a hard error 2022-10-24 13:40:07 -05:00
bors
c07a6a9c0c Auto merge of #94063 - Aaron1011:pretty-print-rental, r=lcnr
Only apply `ProceduralMasquerade` hack to older versions of `rental`

The latest version of `rental` (v0.5.6) contains a fix that allows it to
compile without relying on the pretty-print back-compat hack.

Hopefully, there are no longer any crates relying on the affected
versions of the (much less popular) `procedural-masquerade` crate. This
should allow us to target the pretty-print back-compat hack specifically
to older versions of `rental`, and specifically mention upgrading to
`rental` v0.5.6 in the lint message.
2022-10-24 13:35:48 +00:00
Oli Scherer
b6824ba52a Make param index generation a bit more robust 2022-10-24 12:27:05 +00:00
Yuki Okushi
8e9d2b6971
Rollup merge of #103437 - bjorn3:sync_cg_clif-2022-10-23, r=bjorn3
Sync rustc_codegen_cranelift

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2022-10-24 19:32:28 +09:00
Yuki Okushi
779418deb4
Rollup merge of #99939 - saethlin:pre-sort-tests, r=thomcc,jackh726
Sort tests at compile time, not at startup

Recently, another Miri user was trying to run `cargo miri test` on the crate `iced-x86` with `--features=code_asm,mvex`. This configuration has a startup time of ~18 minutes. That's ~18 minutes before any tests even start to run. The fact that this crate has over 26,000 tests and Miri is slow makes a lot of code which is otherwise a bit sloppy but fine into a huge runtime issue.

Sorting the tests when the test harness is created instead of at startup time knocks just under 4 minutes out of those ~18 minutes. I have ways to remove most of the rest of the startup time, but this change requires coordinating changes of both the compiler and libtest, so I'm sending it separately.

(except for doctests, because there is no compile-time harness)
2022-10-24 19:32:25 +09:00
SparrowLii
0fca075ce8 suggest type annotation for local statement initialed by ref expression 2022-10-24 17:16:31 +08:00
Charles Lew
113e8dfb72 Port dead_code lints to be translatable. 2022-10-24 17:02:31 +08:00
Jesse Ruderman
e3a091ad6a
Remove redundant sentence 2022-10-24 00:52:26 -07:00
bors
4b5fcae32d Auto merge of #102536 - scottmcm:lookup_line-tweak, r=jackh726
Shorten the `lookup_line` code slightly

The `match` looks like it's exactly the same as `checked_sub(1)`, so we might as well see if perf says we can just do that to save a couple lines.
2022-10-24 07:24:45 +00:00
yukang
f54c336c80 fix #103425, remove extra type error after missing semicolon error 2022-10-24 09:20:07 +08:00
Jack Huey
de78c32b85 Cleanup message and bless tests 2022-10-23 19:11:25 -04:00
Jack Huey
65ef62597b Apply suggestions from code review
Use ticks around abis.

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2022-10-23 18:46:16 -04:00
Soveu
ba847cad6d Enable varargs support for calling conventions other than C or cdecl
This patch makes it possible to use varargs for calling conventions,
which are either based on C (like efiapi) or C is based
on them (for example sysv64 and win64).
2022-10-23 18:46:16 -04:00
Michael Howell
039e9b6b94
Rollup merge of #103414 - compiler-errors:rpit-print-lt, r=cjgillot
Pretty print lifetimes captured by RPIT

This specifically makes the output in #103409 change from:

```diff
  error: `impl` item signature doesn't match `trait` item signature
    --> $DIR/signature-mismatch.rs:15:5
     |
  LL |     fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
     |     ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>`
  ...
  LL |     fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
-  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>`
+  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
     |
     = note: expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>`
-               found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>>`
+               found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
     = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
     = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output

  error: aborting due to previous error
```

Along with the UI tests in this PR, which I think are all improvements!

r? `@oli-obk` though feel free to re-roll
2022-10-23 14:48:17 -07:00
Michael Howell
9f06fbd1ad
Rollup merge of #103402 - joshtriplett:niche-wrap-fix, r=oli-obk
Fix wrapped valid-range handling in ty_find_init_error

Rust's niche handling allows for wrapping valid ranges with end < start;
for instance, a valid range with start=43 and end=41 means a niche of
42. Most places in the compiler handle this correctly, but
`ty_find_init_error` assumed that `lo > 0` means the type cannot contain a
zero.

Fix it to handle wrapping ranges.
2022-10-23 14:48:17 -07:00
Michael Howell
3df030d441
Rollup merge of #103140 - chenyukang:yukang/fix-103112, r=estebank
Add diagnostic for calling a function with the same name with unresolved Macro

Fixes #103112
2022-10-23 14:48:15 -07:00
BlackHoleFox
ffccfa1eed Fix x86_64-apple-watchos-sim target to use the correct target_abi 2022-10-23 16:39:30 -05:00
Jakob Degen
be2401b8bf Split phase change from MirPass 2022-10-23 14:18:09 -07:00
BlackHoleFox
d2a3784780 Fix x86_64-apple-tvos target to use the correct target_abi 2022-10-23 15:46:43 -05:00
BlackHoleFox
79eedef984 Fix x86_64-apple-ios target to use the correct target_abi 2022-10-23 15:44:58 -05:00
Camille GILLOT
47704bbcc0 Do not consider repeated lifetime params for elision. 2022-10-23 19:36:19 +00:00
Michael Goulet
6e6fe30d0f Comment why normalization is needed for debug assertions 2022-10-23 17:23:35 +00:00
Michael Goulet
dd51b36fb2 Add normalize hack back 2022-10-23 17:23:35 +00:00
Michael Goulet
c5df620419 Annotate static lifetimes too 2022-10-23 17:21:43 +00:00
Xiretza
8bc43f99e9 Allow specifying multiple alternative suggestions
This allows porting uses of span_suggestions() to diagnostic structs.

Doesn't work for multipart_suggestions() because the rank would be
reversed - the struct would specify multiple spans, each of which has
multiple possible replacements, while multipart_suggestions() creates
multiple possible replacements, each with multiple spans.
2022-10-23 18:59:13 +02:00
ouz-a
4bd98443ed remove misc_cast and validate types 2022-10-23 18:47:16 +03:00
bors
1ca6777c01 Auto merge of #101403 - bjorn3:dylib_lto, r=Mark-Simulacrum
Enable LTO for rustc_driver.so

Alternative to https://github.com/rust-lang/rust/pull/97154

This enables LTO'ing dylibs behind a feature flag and uses this feature for compiling rustc_driver.so.
2022-10-23 15:00:31 +00:00
bjorn3
e8ac073cae Rustfmt cg_clif's build system 2022-10-23 16:43:48 +02:00
bjorn3
e54a13f18b Merge commit '266e96785ab71834b917bf474f130a6d8fdecd4b' into sync_cg_clif-2022-10-23 2022-10-23 16:22:55 +02:00
Jakub Beránek
c5c86806c8
Introduce dedicated -Zdylib-lto flag for enabling LTO on dylibs 2022-10-23 13:48:03 +02:00
bjorn3
32238ce1e2
Allow LTO for dylibs 2022-10-23 13:43:07 +02:00
bjorn3
f7f17bf220
Add missing export for the oom strategy symbol 2022-10-23 13:43:07 +02:00
bors
9be2f35a4c Auto merge of #103431 - Dylan-DPC:rollup-oozfo89, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #101293 (Recover when unclosed char literal is parsed as a lifetime in some positions)
 - #101908 (Suggest let for assignment, and some code refactor)
 - #103192 (rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`)
 - #103226 (Check `needs_infer` before `needs_drop` during HIR generator analysis)
 - #103249 (resolve: Revert "Set effective visibilities for imports more precisely")
 - #103305 (Move some tests to more reasonable places)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-23 11:33:18 +00:00
Dylan DPC
0b3e018137
Rollup merge of #103249 - petrochenkov:revaddids, r=oli-obk
resolve: Revert "Set effective visibilities for imports more precisely"

In theory the change was correct, but in practice the use of import items in HIR is limited and hacky, and it expects that (effective) visibilities for all (up to) 3 IDs of the import are set to the value reflecting (effective) visibility of the whole syntactic `use` item rather than its individual components.

Fixes https://github.com/rust-lang/rust/issues/102352
r? `@oli-obk`
2022-10-23 15:20:18 +05:30
Dylan DPC
8440b09d17
Rollup merge of #103226 - compiler-errors:delay-if-need-infer, r=lcnr
Check `needs_infer` before `needs_drop` during HIR generator analysis

This is kinda a revival of #103036, but with the understanding that after fallback, a generator-interior type will only have `needs_infer` true if there's an error that prevented int or float variable fallback to occur (modulo region variables, which are erased).

Therefore the best choice here is to delay a bug and skip the `needs_drop` call altogether.

r? `@lcnr` feel free to reassign though
2022-10-23 15:20:17 +05:30
Dylan DPC
e426874788
Rollup merge of #103192 - petrochenkov:noalltraits, r=jyn514
rustdoc: Eliminate uses of `EarlyDocLinkResolver::all_traits`

Another step to https://github.com/rust-lang/rust/pull/94857.
2022-10-23 15:20:17 +05:30
Dylan DPC
518d5ebc81
Rollup merge of #101908 - chenyukang:fix-101880, r=estebank
Suggest let for assignment, and some code refactor

Fixes #101880
2022-10-23 15:20:16 +05:30
Dylan DPC
e029c1fd43
Rollup merge of #101293 - compiler-errors:lt-is-actually-char, r=estebank
Recover when unclosed char literal is parsed as a lifetime in some positions

Fixes #101278
2022-10-23 15:20:16 +05:30
Camille GILLOT
74d4eefc13 Workaround unstable stmt_expr_attributes for method receiver expressions. 2022-10-23 09:27:12 +00:00
bors
e64f1110c0 Auto merge of #103345 - Nilstrieb:diag-flat, r=compiler-errors
Flatten diagnostic slug modules

This makes it easier to grep for the slugs in the code.

See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Localization.20infra.20interferes.20with.20grepping.20for.20error for more discussion about it.

This was mostly done with a few regexes and a bunch of manual work. This also exposes a pretty annoying inconsistency for the extra labels. Some of the extra labels are defined as additional properties in the fluent message (which makes them not prefixed with the crate name) and some of them are new fluent messages themselves (which makes them prefixed with the crate name). I don't know whether we want to clean this up at some point but it's useful to know.

r? `@davidtwco`
2022-10-23 09:06:39 +00:00
Nilstrieb
c65ebae221
Migrate all diagnostics 2022-10-23 10:09:44 +02:00
Nilstrieb
2459569776
Generate fluent message constant in a flat module for all crates
This will make it easier to grep for fluent message names.
2022-10-23 10:09:44 +02:00
bors
faab68eb29 Auto merge of #103426 - matthiaskrgr:rollup-n6dqdy8, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #103123 (Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder` )
 - #103328 (Do not suggest trivially false const predicates)
 - #103354 (Escape string literals when fixing overlong char literal)
 - #103355 (Handle return-position `impl Trait` in traits properly in `register_hidden_type`)
 - #103368 (Delay ambiguity span bug in normalize query iff not rustdoc)
 - #103388 (rustdoc: remove unused CSS class `.result-description`)
 - #103399 (Change `unknown_lint` applicability to `MaybeIncorrect`)
 - #103401 (Use functions for headings rustdoc GUI test)
 - #103412 (Fix typo in docs of `String::leak`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-23 06:20:24 +00:00
Matthias Krüger
6be917a748
Rollup merge of #103399 - smoelius:unknown-lint-maybe-incorrect, r=fee1-dead
Change `unknown_lint` applicability to `MaybeIncorrect`

This small PR changes the applicability of `unknown_lint` to `MaybeIncorrect`, because the suggested lint might not be the correct one.

Here is one example where the current applicability causes a problem. Clippy has a set of internal lints guarded by a feature called `internal`. If the feature is not enabled, then the internal lints are "unknown." In that case, running `cargo clippy --fix ...` on `clippy_utils` causes lines such as the followig
26c96e3416/src/tools/clippy/clippy_utils/src/paths.rs (L51-L52)
to be changed to
```rust
 #[expect(clippy::invalid_regex)] // internal lints do not know about all external crates
 pub const FUTURES_IO_ASYNCREADEXT: [&str; 3] = ["futures_util", "io", "AsyncReadExt"];
```
which is not correct.
2022-10-23 08:14:33 +02:00
Matthias Krüger
72f75d18b1
Rollup merge of #103368 - compiler-errors:normalization-ambiguity-bug, r=oli-obk
Delay ambiguity span bug in normalize query iff not rustdoc

Oli and I decided that the compiler debt of adding another usage of `tcx.sess.opts.actually_rustdoc` is fine, because we don't really want to add more complexity to the normalize query, and moving rustdoc to use fulfill normalization (`fully_normalize`, i.e. not use the normalize query) is unnecessary overhead given that it's skipping binders and stuff.

r? oli-obk

Fixes #102827
Fixes #103181
2022-10-23 08:14:32 +02:00
Matthias Krüger
ff689a1404
Rollup merge of #103355 - compiler-errors:rpitit-default-check, r=oli-obk
Handle return-position `impl Trait` in traits properly in `register_hidden_type`

The bounds that we get by calling `bound_explicit_item_bounds` from an RPITIT have projections, not opaques, but when we're *registering* an opaque, we want to treat it like an opaque.

Coincidentally fixes #102688 as well, which makes sense, since that was failing because we were inferring an opaque type to be equal to itself (opaque cycle error => "cannot resolve opaque type").

Fixes #103352

r? ```@oli-obk```
2022-10-23 08:14:31 +02:00
Matthias Krüger
b656f5e9a6
Rollup merge of #103354 - clubby789:escape-string-literals, r=compiler-errors
Escape string literals when fixing overlong char literal

Fixes #103323

````@rustbot```` label +A-diagnostics +A-suggestion-diagnostics
2022-10-23 08:14:31 +02:00
Matthias Krüger
1a077420f8
Rollup merge of #103328 - compiler-errors:trivial-false-const-sugg, r=jackh726
Do not suggest trivially false const predicates

Pass through constness to `predicate_can_apply` and don't suggest other impls if it's satisfied but not const.

Fixes #103267
2022-10-23 08:14:30 +02:00
Matthias Krüger
5290d5e321
Rollup merge of #103123 - compiler-errors:early-binder-iter, r=cjgillot
Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder`

Makes working with bounds lists a bit easier, which I seem to do a lot.

Specifically, means that we don't need to do `.transpose_iter().map(|(pred, _)| *pred)` every time we want to iterate through an `EarlyBinder<&'tcx [(Predicate, Span)]>` (and even then, still have to call `subst` later), which was a very awkward idiom imo.
2022-10-23 08:14:30 +02:00
bors
6c9c2d862d Auto merge of #102660 - camsteffen:uninhabited-perf, r=oli-obk
Remove ParamEnv from uninhabited query
2022-10-23 03:39:43 +00:00
Josh Triplett
36662dfc83 Fix wrapped valid-range handling in ty_find_init_error
Rust's niche handling allows for wrapping valid ranges with end < start;
for instance, a valid range with start=43 and end=41 means a niche of
42. Most places in the compiler handle this correctly, but
ty_find_init_error assumed that `lo > 0` means the type cannot contain a
zero.

Fix it to handle wrapping ranges.

Add a test to cover this case.
2022-10-23 00:33:06 +01:00
Michael Goulet
4216caed31 filter candidates in pick probe for diagnostics 2022-10-22 20:50:01 +00:00
Michael Goulet
c0cda2b278 Pretty print lifetimes captured by RPIT 2022-10-22 20:29:40 +00:00
bors
6e95b6da88 Auto merge of #103240 - BelovDV:issue-102290, r=petrochenkov
Add architectures to fn create_object_file

Fixes #102290

r? `@petrochenkov`
2022-10-22 19:14:34 +00:00
Cameron Steffen
2928e9ef2c Introduce InhabitedPredicate 2022-10-22 13:20:06 -05:00
bors
289b2b8cf9 Auto merge of #103398 - Dylan-DPC:rollup-cj6w00o, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #102602 (Slightly tweak comments wrt `lint_overflowing_range_endpoint`)
 - #103190 (rustdoc: render bounds of cross-crate GAT params)
 - #103224 (Allow semicolon after closure within parentheses in macros)
 - #103280 ((#102929) Implement `String::leak` (attempt 2))
 - #103329 (Add a forgotten check for NonNull::new_unchecked's precondition)
 - #103346 (Adjust argument type for mutable with_metadata_of (#75091))
 - #103360 (Reduce false positives in msys2 detection)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-22 13:40:59 +00:00
Samuel Moelius
62b65b5ede Change unknown_lint applicability to MaybeIncorrect 2022-10-22 07:17:36 -04:00
Dylan DPC
ada50112ba
Rollup merge of #103224 - compiler-errors:semi-after-closure-in-macro, r=fee1-dead
Allow semicolon after closure within parentheses in macros

#88546 added some parsing logic that if we're parsing a closure, and we're within parentheses, and a semicolon follows, then we must be parsing something erroneous like: `f(|| a; b)`, so it replaces the closure body with an error expression. However, it's valid to parse those tokens if we're within a macro, as in #103222.

This is a bit unsatisfying fix. Is there a more robust way of checking that we're within a macro?

I would also be open to removing this "_It is likely that the closure body is a block but where the braces have been removed_" check altogether at the expense of more verbose errors, since it seems very suspicious in the first place...

Fixes #103222.
2022-10-22 16:28:08 +05:30
Dylan DPC
16c3b64794
Rollup merge of #102602 - WaffleLapkin:linty_action, r=estebank
Slightly tweak comments wrt `lint_overflowing_range_endpoint`

From the review: https://github.com/rust-lang/rust/pull/101986#discussion_r975610611

It _seemed_ that the lint was not emitted when the `if` check failed, but _actually_ this happens already in a special case and the lint is emitted outside of this function, if this function doesn't. I've cleared up the code/comments a bit, so it's more obvious :)

r? ```@estebank```
2022-10-22 16:28:07 +05:30
bors
f8c86c82bf Auto merge of #103231 - ecnelises:le_fix, r=lcnr
Remove byte swap of valtree hash on big endian

This addresses problem reported in #103183. The code was originally introduced in e14b34c386. (see https://github.com/rust-lang/rust/pull/96591)

On big-endian environment, this operation sequence actually put the other half from 128-bit result, thus we got different hash result on LE and BE.
2022-10-22 10:53:17 +00:00
bors
26c96e3416 Auto merge of #103227 - lcnr:bye-bye-unevaluated-const, r=oli-obk
stop using `ty::UnevaluatedConst` directly

best reviewed commit by commit.

simplifies #99798 because we now don't have to expand `ty::UnevaluatedConst` to `ty::Const`.
I also remember some other places where using `ty::UnevaluatedConst` directly was annoying and caused issues, though I don't quite remember what they were rn '^^

r? `@oli-obk` cc `@JulianKnodt`
2022-10-22 07:49:33 +00:00
Michael Goulet
3d7b1f0d18 Don't erroneously deny semicolons after closure expr within parentheses in a macro 2022-10-22 06:59:49 +00:00
Michael Goulet
0270b50eb0 Recover unclosed char literal being parsed as lifetime 2022-10-22 06:57:12 +00:00
Michael Goulet
aa8931c612 Introduce subst_iter and subst_iter_copied on EarlyBinder 2022-10-22 06:52:12 +00:00
Michael Goulet
134de38e4d nit: Inline may_need_drop 2022-10-22 06:50:00 +00:00
Michael Goulet
5b06898d21 Check needs_infer before needs_drop in HIR generator analysis 2022-10-22 06:50:00 +00:00
Deadbeef
988e75bb65 Stabilize arbitrary_enum_discriminant, take 2 2022-10-22 13:54:39 +08:00
bors
3022afe3d1 Auto merge of #103196 - Nilstrieb:no-meta-query, r=cjgillot
Get rid of native_library projection queries

They don't seem particularly useful as I don't expect native libraries to change frequently.

Maybe they do provide significant value of keeping incremental compilation green though, I'm not sure.
2022-10-22 05:08:51 +00:00
Michael Goulet
4accf838f6 Note scope of TAIT more accurately 2022-10-22 03:09:49 +00:00
Michael Goulet
e025306fa0 Don't ICE on regions from anonymous_lifetime_in_impl_trait 2022-10-22 03:00:58 +00:00
Aaron Hill
10dad22b66
Only apply ProceduralMasquerade hack to older versions of rental
The latest version of `rental` (v0.5.6) contains a fix that allows it to
compile without relying on the pretty-print back-compat hack.

Hopefully, there are no longer any crates relying on the affected
versions of the (much less popular) `procedural-masquerade` crate. This
should allow us to target the pretty-print back-compat hack specifically
to older versions of `rental`, and specifically mention upgrading to
`rental` v0.5.6 in the lint message.
2022-10-21 21:36:00 -05:00
bors
eecde5850c Auto merge of #103172 - pcwalton:deduced-param-attrs, r=oli-obk
Introduce deduced parameter attributes, and use them for deducing `readonly` on indirect immutable freeze by-value function parameters.

Introduce deduced parameter attributes, and use them for deducing `readonly` on
indirect immutable freeze by-value function parameters.

Right now, `rustc` only examines function signatures and the platform ABI when
determining the LLVM attributes to apply to parameters. This results in missed
optimizations, because there are some attributes that can be determined via
analysis of the MIR making up the function body. In particular, `readonly`
could be applied to most indirectly-passed by-value function arguments
(specifically, those that are freeze and are observed not to be mutated), but
it currently is not.

This patch introduces the machinery that allows `rustc` to determine those
attributes. It consists of a query, `deduced_param_attrs`, that, when
evaluated, analyzes the MIR of the function to determine supplementary
attributes. The results of this query for each function are written into the
crate metadata so that the deduced parameter attributes can be applied to
cross-crate functions. In this patch, we simply check the parameter for
mutations to determine whether the `readonly` attribute should be applied to
parameters that are indirect immutable freeze by-value.  More attributes could
conceivably be deduced in the future: `nocapture` and `noalias` come to mind.

Adding `readonly` to indirect function parameters where applicable enables some
potential optimizations in LLVM that are discussed in [issue 103103] and [PR
103070] around avoiding stack-to-stack memory copies that appear in functions
like `core::fmt::Write::write_fmt` and `core::panicking::assert_failed`. These
functions pass a large structure unchanged by value to a subfunction that also
doesn't mutate it. Since the structure in this case is passed as an indirect
parameter, it's a pointer from LLVM's perspective. As a result, the
intermediate copy of the structure that our codegen emits could be optimized
away by LLVM's MemCpyOptimizer if it knew that the pointer is `readonly
nocapture noalias` in both the caller and callee. We already pass `nocapture
noalias`, but we're missing `readonly`, as we can't determine whether a
by-value parameter is mutated by examining the signature in Rust. I didn't have
much success with having LLVM infer the `readonly` attribute, even with fat
LTO; it seems that deducing it at the MIR level is necessary.

No large benefits should be expected from this optimization *now*; LLVM needs
some changes (discussed in [PR 103070]) to more aggressively use the `noalias
nocapture readonly` combination in its alias analysis. I have some LLVM patches
for these optimizations and have had them looked over. With all the patches
applied locally, I enabled LLVM to remove all the `memcpy`s from the following
code:

```rust
fn main() {
    println!("Hello {}", 3);
}
```

which is a significant codegen improvement over the status quo. I expect that if this optimization kicks in in multiple places even for such a simple program, then it will apply to Rust code all over the place.

[issue 103103]: https://github.com/rust-lang/rust/issues/103103

[PR 103070]: https://github.com/rust-lang/rust/pull/103070
2022-10-22 02:28:05 +00:00
clubby789
ed40d46159 Properly escape quotes when suggesting switching between char/string literals 2022-10-22 02:37:15 +01:00
Matthias Krüger
ed430ca5fe
Rollup merge of #103351 - oli-obk:tilde_const_impls, r=fee1-dead
Require Drop impls to have the same constness on its bounds as the bounds on the struct have

r? ``@fee1-dead``
2022-10-22 00:14:02 +02:00
Matthias Krüger
7ee0aeacaf
Rollup merge of #103339 - Rageking8:fix-some-typos, r=fee1-dead
Fix some typos
2022-10-22 00:14:00 +02:00
Matthias Krüger
ebfdf735ac
Rollup merge of #102635 - lcnr:incoherent_auto_trait_objects, r=jackh726
make `order_dependent_trait_objects` show up in future-breakage reports

tried to change it to a hard error in #102474 but breaking the more than 1000 dependents of `traitobject` doesn't feel great 😅

This lint has existed since more than 3 years now and the way this is currently implemented is buggy and will break with #102472. imo we should upgrade it to also report for dependencies and maybe also backport this to beta. Then after maybe 2-3 stable versions I would like to finally convert this lint to a hard error.
2022-10-22 00:13:59 +02:00
Michael Goulet
9f6b9dd644 Delay ambiguity span bug in normalize query iff not rustdoc 2022-10-21 18:53:16 +00:00
bors
57e2c06a8d Auto merge of #101077 - sunshowers:signal-mask-inherit, r=sunshowers
Change process spawning to inherit the parent's signal mask by default

Previously, the signal mask was always reset when a child process is
started. This breaks tools like `nohup` which expect `SIGHUP` to be
blocked for all transitive processes.

With this change, the default behavior changes to inherit the signal mask.

This also changes the signal disposition for `SIGPIPE` to only be changed if the `#[unix_sigpipe]` attribute isn't set.
2022-10-21 18:09:03 +00:00
bors
ba9d01be67 Auto merge of #98450 - lqd:doc-metadata, r=lqd,GuillaumeGomez
Remove more attributes from metadata

A lot of the attributes that are currently stored in the metadata aren't used at all. The biggest metadata usage comes from the doc attributes currently but they are needed by rustdoc so we only removed the ones that cannot be used in downstream crates (doc comments on private items).

r? `@ghost`
2022-10-21 15:27:56 +00:00
Michael Goulet
419fde7a38 Handle RPITITs properly in register_hidden_type 2022-10-21 14:57:01 +00:00
Oli Scherer
d6cf8934db Require Drop impls to have the same constness on its bounds as the bounds on the struct have 2022-10-21 14:22:13 +00:00
Oli Scherer
349ba6bb51 Remove needless special cases and dead code 2022-10-21 14:21:44 +00:00
clubby789
717bf35366 Different suggestions for when associated functions are referred to 2022-10-21 14:38:44 +01:00
bors
657f246812 Auto merge of #103344 - Dylan-DPC:rollup-d1rpfvx, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #102287 (Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`)
 - #102922 (Filtering spans when emitting json)
 - #103051 (translation: doc comments with derives, subdiagnostic-less enum variants, more derive use)
 - #103111 (Account for hygiene in typo suggestions, and use them to point to shadowed names)
 - #103260 (Fixup a few tests needing asm support)
 - #103321 (rustdoc: improve appearance of source page navigation bar)

Failed merges:

 - #103209 (Diagnostic derives: allow specifying multiple alternative suggestions)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-21 12:41:09 +00:00
Dylan DPC
3055eb9b26
Rollup merge of #103260 - cuviper:needs-asm-support, r=fee1-dead
Fixup a few tests needing asm support
2022-10-21 17:29:59 +05:30
Dylan DPC
41a1cfdbaf
Rollup merge of #103111 - cjgillot:shadow-label, r=estebank
Account for hygiene in typo suggestions, and use them to point to shadowed names

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

r? `@estebank`
2022-10-21 17:29:59 +05:30
Dylan DPC
e11511dfa6
Rollup merge of #103051 - davidtwco:translation-tidying-up, r=compiler-errors
translation: doc comments with derives, subdiagnostic-less enum variants, more derive use

- Adds support for `doc` attributes in the diagnostic derives so that documentation comments don't result in the derive failing.
- Adds support for enum variants in the subdiagnostic derive to not actually correspond to an addition to a diagnostic.
- Made use of the derive in more places in the `rustc_ast_lowering`, `rustc_ast_passes`, `rustc_lint`, `rustc_session`, `rustc_infer` - taking advantage of recent additions like eager subdiagnostics, multispan suggestions, etc.

cc #100717
2022-10-21 17:29:58 +05:30
Dylan DPC
0a0e9f73af
Rollup merge of #102922 - kper:bugfix/102902-filtering-json, r=oli-obk
Filtering spans when emitting json

According to the issue #102902, we shouldn't emit spans which have an empty span and no suggested replacement.
2022-10-21 17:29:58 +05:30
Dylan DPC
66d91d8276
Rollup merge of #102287 - compiler-errors:unused-must-use-also-supertrait, r=fee1-dead
Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`

Given `impl Trait`, if one of its supertraits has a `#[must_use]`, then trigger the lint. This means that, for example, `-> impl ExactSizeIterator` also triggers the `must_use` on `trait Iterator`, which fixes #102183.

This might need `@rust-lang/lang` sign-off, since it changes the behavior of the lint, so cc'ing them.
2022-10-21 17:29:57 +05:30
Rageking8
62a2a1d257 fix some typos 2022-10-21 18:04:00 +08:00
Kitsu
6a065f78c4 Fix unreachable_pub suggestion for enum with fields 2022-10-21 12:56:12 +03:00
bors
0940040c04 Auto merge of #103310 - lcnr:rustc_hir_typeck, r=compiler-errors
move hir typeck into separate crate

second part https://github.com/rust-lang/compiler-team/issues/529

I avoided pretty much anything that wasn't just a simple move + path adjustment. Left fixmes for methods which are at an odd place

r? `@compiler-errors`
2022-10-21 09:52:18 +00:00
Patrick Walton
da630ac79d Introduce deduced parameter attributes, and use them for deducing readonly on
indirect immutable freeze by-value function parameters.

Right now, `rustc` only examines function signatures and the platform ABI when
determining the LLVM attributes to apply to parameters. This results in missed
optimizations, because there are some attributes that can be determined via
analysis of the MIR making up the function body. In particular, `readonly`
could be applied to most indirectly-passed by-value function arguments
(specifically, those that are freeze and are observed not to be mutated), but
it currently is not.

This patch introduces the machinery that allows `rustc` to determine those
attributes. It consists of a query, `deduced_param_attrs`, that, when
evaluated, analyzes the MIR of the function to determine supplementary
attributes. The results of this query for each function are written into the
crate metadata so that the deduced parameter attributes can be applied to
cross-crate functions. In this patch, we simply check the parameter for
mutations to determine whether the `readonly` attribute should be applied to
parameters that are indirect immutable freeze by-value.  More attributes could
conceivably be deduced in the future: `nocapture` and `noalias` come to mind.

Adding `readonly` to indirect function parameters where applicable enables some
potential optimizations in LLVM that are discussed in [issue 103103] and [PR
103070] around avoiding stack-to-stack memory copies that appear in functions
like `core::fmt::Write::write_fmt` and `core::panicking::assert_failed`. These
functions pass a large structure unchanged by value to a subfunction that also
doesn't mutate it. Since the structure in this case is passed as an indirect
parameter, it's a pointer from LLVM's perspective. As a result, the
intermediate copy of the structure that our codegen emits could be optimized
away by LLVM's MemCpyOptimizer if it knew that the pointer is `readonly
nocapture noalias` in both the caller and callee. We already pass `nocapture
noalias`, but we're missing `readonly`, as we can't determine whether a
by-value parameter is mutated by examining the signature in Rust. I didn't have
much success with having LLVM infer the `readonly` attribute, even with fat
LTO; it seems that deducing it at the MIR level is necessary.

No large benefits should be expected from this optimization *now*; LLVM needs
some changes (discussed in [PR 103070]) to more aggressively use the `noalias
nocapture readonly` combination in its alias analysis. I have some LLVM patches
for these optimizations and have had them looked over. With all the patches
applied locally, I enabled LLVM to remove all the `memcpy`s from the following
code:

```rust
fn main() {
    println!("Hello {}", 3);
}
```

which is a significant codegen improvement over the status quo. I expect that
if this optimization kicks in in multiple places even for such a simple
program, then it will apply to Rust code all over the place.

[issue 103103]: https://github.com/rust-lang/rust/issues/103103

[PR 103070]: https://github.com/rust-lang/rust/pull/103070
2022-10-21 02:33:15 -07:00
Nicolas Barrios
770538ef9b
Add fix suggestions for E0199, E0200, and E0569 2022-10-20 20:08:27 -04:00
Michael Goulet
6e21b7a9b7 Do not suggest trivially false const predicates 2022-10-20 23:24:45 +00:00
Guillaume Gomez
ae5108a1ed Add code comments and documentation 2022-10-20 22:44:10 +00:00
Guillaume Gomez
72d6fde130 Remove doc comments only for private items or some specific doc comments 2022-10-20 22:44:10 +00:00
Guillaume Gomez
b12b65c1b7 Add missing @local_only on attributes 2022-10-20 22:44:10 +00:00
Rain
a52c79e859 Change process spawning to inherit the parent's signal mask by default
Previously, the signal mask is always reset when a child process is
started. This breaks tools like `nohup` which expect `SIGHUP` to be
blocked.

With this change, the default behavior changes to inherit the signal mask.

This also changes the signal disposition for `SIGPIPE` to only be
changed if the `#[unix_sigpipe]` attribute isn't set.
2022-10-20 14:53:38 -07:00
lcnr
adc700b089 update doc links 2022-10-20 23:47:49 +02:00
Matthias Krüger
f9944a9d2c
Rollup merge of #103319 - fee1-dead-contrib:improve_tilde_const_msg, r=oli-obk
Improve "`~const` is not allowed here" message

r? `@oli-obk`
2022-10-20 22:42:42 +02:00
Matthias Krüger
801e32647e
Rollup merge of #103315 - RalfJung:interpret-switchint-ice, r=bjorn3
interpret: remove an incorrect assertion

This fixes an ICE in Miri, [reported](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/SwitchInt.20with.20no.20targets.3F) by `@saethlin.` The faulty assertion was introduced by 432535da2b, when a previously correct assertion checking that the `otherwise` target exists got replaced by this assertion checking that at least one more target beyond `otherwise` exists.

Sadly we don't have a small reproducer so I don't think we can easily add a testcase.
2022-10-20 22:42:41 +02:00
Matthias Krüger
be4816fbf0
Rollup merge of #103230 - nnethercote:clarify-startup, r=jyn514
Clarify startup

A small follow-up to #102769.

r? `@jyn514`
2022-10-20 22:42:38 +02:00
Matthias Krüger
7ee4b218a8
Rollup merge of #103221 - TaKO8Ki:fix-103202, r=oli-obk
Fix `SelfVisitor::is_self_ty` ICE

Fixes #103202
2022-10-20 22:42:38 +02:00
Deadbeef
ebf5028574 Improve "~const is not allowed here" message 2022-10-20 19:32:16 +00:00
Michael Goulet
8509819aef Elaborate supertrait bounds when triggering unused_must_use on impl Trait 2022-10-20 17:31:01 +00:00
Ralf Jung
bf14e3196b interpret: remove an incorrect assertion 2022-10-20 19:06:34 +02:00
bors
5ffa67d730 Auto merge of #103092 - petrochenkov:weaklto, r=wesleywiser
linker: Fix weak lang item linking with combination windows-gnu + LLD + LTO

In https://github.com/rust-lang/rust/pull/100404 this logic was originally disabled for MSVC due to issues with LTO, but the same issues appear on windows-gnu with LLD because that LLD uses the same underlying logic as MSVC LLD, just with re-syntaxed command line options.

So this PR just disables it for LTO builds in general.
2022-10-20 16:20:50 +00:00
lcnr
8eb2b75a11 add increased recursion limit 2022-10-20 18:03:28 +02:00
lcnr
fb3ab13a1c rustc_hir_typeck: fix paths and partially mv files 2022-10-20 17:53:14 +02:00
lcnr
f468a90bad rustc_hir_typeck: move whole files 2022-10-20 17:53:14 +02:00
yukang
eb68e27e4c fix rust-lang#101880: suggest let for assignment, and some code refactor 2022-10-20 22:54:02 +08:00
bors
542febd2d3 Auto merge of #103290 - matthiaskrgr:rollup-ngozai3, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #103197 (Stabilize proc_macro::Span::source_text)
 - #103251 (Fix item declaration highlighting)
 - #103262 (Adjusting test to needs-unwind, with linking issue)
 - #103268 (rustdoc: remove no-op CSS `nav.sub { font-size: 1rem }`)
 - #103272 (Remove extra spaces in docs)
 - #103276 (Erase regions before checking for `Default` in uninitialized binding error)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-10-20 13:33:50 +00:00
yukang
2414357374 fix assertion failed for break_last_token and trailing token 2022-10-20 20:16:27 +08:00
Nikita Popov
783301298f Don't use usub.with.overflow intrinsic
The canonical form of a usub.with.overflow check in LLVM are
separate sub + icmp instructions, rather than a usub.with.overflow
intrinsic. Using usub.with.overflow will generally result in worse
optimization potential.

The backend will attempt to form usub.with.overflow when it comes
to actual instruction selection. This is not fully reliable, but
I believe this is a better tradeoff than using the intrinsic in
IR.

Fixes #103285.
2022-10-20 12:47:17 +02:00
bors
53728ff751 Auto merge of #103185 - chenyukang:yukang/fix-span-next-point, r=davidtwco
Fix the bug of next_point in source_map

There is a bug in `next_point`, the new span won't move to next position when be called in the first time.

For this reason, our current code is working like this:
1. When we really want to move to the next position, we called two times of `next_point`
2. Some code which use `next_point` actually done the same thing with `shrink_to_hi`

This fix make sure when `next_point` is called, span will move with the width at least 1, and also work correctly in the scenario of multiple bytes.

Ref: https://github.com/rust-lang/rust/pull/103140#discussion_r997710998

r? `@davidtwco`
2022-10-20 10:40:09 +00:00
Kevin Per
28d0312b7d Implement assertions and fixes to not emit empty spans without suggestions 2022-10-20 08:25:31 +00:00
Matthias Krüger
e29ecb70af
Rollup merge of #103276 - compiler-errors:default-on-uninit-ice, r=TaKO8Ki
Erase regions before checking for `Default` in uninitialized binding error

Fixes #103250
2022-10-20 07:58:58 +02:00
bors
4b3b731b55 Auto merge of #103220 - compiler-errors:deny-infers, r=lcnr
Deny hashing ty/re/ct inference variables

cc `@cjgillot` and https://github.com/rust-lang/rust/pull/102695#issuecomment-1275706528
r? `@lcnr`

best reviewed one commit at a time, mostly because the second commit that fixes `ClosureOutlivesRequirement` is mostly noise because of losing its `<'tcx>` lifetime parameter.
2022-10-20 05:56:56 +00:00
Takayuki Maeda
9a9e2fe15f check if impl_self is Some 2022-10-20 14:10:52 +09:00
yukang
f90bf50d47 fix span for suggestion 2022-10-20 11:55:30 +08:00
yukang
1225c3f6b8 fix #103112, add diagnostic for calling a function with the same name when a Macro is not found 2022-10-20 11:55:30 +08:00
Michael Goulet
43f2c37f93 Note discrepancies in constness calculation 2022-10-20 03:44:12 +00:00
Michael Goulet
ab36a2fe16 Revert "Unify tcx.constness and param env constness checks"
This reverts commit bef8681a18.
This reverts commit c646c4d403.
2022-10-20 03:44:12 +00:00
bors
ebdde35dce Auto merge of #103205 - spastorino:fix-rpits-lifetime-remapping, r=cjgillot
Do anonymous lifetimes remapping correctly for nested rpits

Closes #103141

r? `@cjgillot` `@nikomatsakis`

This fixes a stable to stable regression that in my opinion is `P-critical` so, we probably want to backport it all the way up to stable.
2022-10-20 03:07:17 +00:00
bors
cb9467515b Auto merge of #102417 - oli-obk:opaque_lifetimes2, r=jackh726
Require lifetime bounds for opaque types in order to allow hidden types to capture said lifetimes

fixes #96996

cc `@aliemjay`
2022-10-20 00:22:17 +00:00
Michael Goulet
c5c9f74829 Erase regions before checking for default in uninitialized binding error 2022-10-19 23:36:28 +00:00
Santiago Pastorino
49ce8a22b0
Do anonymous lifetimes remapping correctly for nested rpits 2022-10-19 16:49:39 -03:00
Santiago Pastorino
fb5475887f
Extract orig_opt_local_def_id as a function 2022-10-19 16:49:39 -03:00
Matthias Krüger
12775ce16a
Rollup merge of #103239 - m-ou-se:unstable-abi-fn-impl-check, r=lcnr
Allow #[unstable] impls for fn() with unstable abi.

This allows `#[unstable]` trait impls for `extern "unwind-C" fn()`, based on the fact that that abi and therefore that type is unstable.

See https://github.com/rust-lang/rust/pull/101263#issuecomment-1283099947
2022-10-19 21:38:41 +02:00
Matthias Krüger
e500dcb8cb
Rollup merge of #103223 - compiler-errors:deref-sugg-slow, r=wesleywiser
Use already checked RHS ty for LHS deref suggestions

There's no reason to do the `check_lhs_assignable` and RHS `check_expr_with_hint` in that order, so invert them and use the typeck results to avoid exponential blowup on error.

Fixes #103219
2022-10-19 21:38:40 +02:00
Josh Stone
f8e157b33f Fixup a few tests needing asm support 2022-10-19 11:34:00 -07:00
Michael Goulet
6b0ef9c810 Deny const variables as well 2022-10-19 17:11:40 +00:00
Michael Goulet
1e2eb97c6e Don't call own_existential_vtable_entries on unresolved trait ref 2022-10-19 17:11:40 +00:00
Michael Goulet
a6b5f95fb0 Make ClosureOutlivesRequirement not rely on an unresolved type 2022-10-19 17:10:59 +00:00
Michael Goulet
91af4f5d0b Don't hash non-fresh Ty::Infer or RegionKind::Infer 2022-10-19 17:10:58 +00:00
Vadim Petrochenkov
ba4834c092 resolve: Revert "Set effective visibilities for imports more precisely" 2022-10-19 18:42:47 +04:00
nils
ccc54613c3
Get rid of native_library projection queries
They don't seem particularly useful as I don't expect
native libraries to change frequently.
2022-10-19 16:21:21 +02:00
bors
4b8f431995 Auto merge of #103214 - Nilstrieb:set-theory, r=petrochenkov
Use Set instead of Vec in transitive_relation

Helps with #103195. It doesn't fix the underlying quadraticness but it makes it _a lot_ faster to an extent where even doubling the amount of nested references still takes less than two seconds (50s on nightly).

I want to see whether this causes regressions (because the vec was usually quite small) or improvements (as lookup for bigger sets is now much faster) in real code.
2022-10-19 13:53:06 +00:00
yukang
eb8aa9759d Add testcase for next_point, fix more trivial issues in find_width_of_character_at_span 2022-10-19 21:08:00 +08:00
Daniil Belov
5642a751ec Add architectures to fn create_object_file 2022-10-19 15:45:51 +03:00
Mara Bos
c4f829b2e5 Allow #[unstable] impl for fn() -> UnstableType.
(But not fn() -> !, which is stable.)
2022-10-19 13:34:18 +02:00
nils
d45f025c90
Use Set instead of Vec in transitive_relation 2022-10-19 12:50:28 +02:00
Mara Bos
ead96f7f74 Allow #[unstable] impls for fn() with unstable abi. 2022-10-19 12:41:35 +02:00
Mara Bos
e60016eb55 Split is_stable from rustc_target::spec::abi::is_enabled. 2022-10-19 12:41:11 +02:00
Vadim Petrochenkov
175474549c rustdoc: Eliminate uses of EarlyDocLinkResolver::all_traits 2022-10-19 12:55:38 +04:00
Dylan DPC
32159e3fa4
Rollup merge of #103216 - cjgillot:issue-103210, r=jackh726
Consider patterns in fn params in an `Elided(Infer)` lifetime rib.

Fixes https://github.com/rust-lang/rust/issues/103210
2022-10-19 14:05:54 +05:30
Dylan DPC
02d6135b5f
Rollup merge of #103182 - Nilstrieb:query-desc-cleanup, r=oli-obk
Clean up query descriptions

Use the same tense everywhere and prefer display over debug, as these descriptions are user facing.
2022-10-19 14:05:53 +05:30
Dylan DPC
48c5e0c262
Rollup merge of #103034 - nathanwhit:let-chains-rhs-temporaries, r=wesleywiser
Let expressions on RHS shouldn't be terminating scopes

Fixes #100276.

Before this PR, we were unconditionally marking the RHS of short-circuiting binary expressions as a terminating scope.

In the case of a let chain where the `let` expression was on the RHS, this meant that temporaries within the `let` expr would only live until the end of the expression. Since this only affected the RHS, this led to surprising behavior ([example](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d1b0a5d1f01882f9c89c2194a75eb19f)).

After this PR, we only mark the RHS as a terminating scope if it is not a `let` expression.
2022-10-19 14:05:52 +05:30
Dylan DPC
5c2c476ad1
Rollup merge of #102863 - compiler-errors:call-suggestion-on-unimplemented, r=nagisa
Standardize "use parentheses to call" suggestions between typeck and trait selection

1. Suggest calling constructors, since they're basically `FnDef`s but they have a different def kind and hir representation, so we were leaving them out.
2. Standardize the call suggestions between trait fulfillment errors and type mismatch. In the type mismatch suggestion, we suggest `/* Ty */` as the placeholder for an arg, and not the parameter's name, which is less helpful.
3. Use `predicate_must_hold_modulo_regions` instead of matching on `EvaluationResult` -- this might cause some suggestions to be filtered out, but we really shouldn't be suggesting a call if it "may" hold, only when it "must" hold.
4. Borrow some logic from `extract_callable_info` to generalize this suggestion to fn pointers, type parameters, and opaque types.

Fixes #102852
2022-10-19 14:05:51 +05:30
lcnr
b93713fb99 manually inline and rm visit_abstract_const_expr 2022-10-19 10:15:46 +02:00
lcnr
c5c6ef7029 stop folding UnevaluatedConst 2022-10-19 10:15:46 +02:00
Qiu Chaofan
7b5a366c2a Remove byte swap of valtree hash on big endian 2022-10-19 14:55:33 +08:00
Nicholas Nethercote
5d716fd0e9 Add a comment to Compiler.
It took me a while to work this out.
2022-10-19 17:37:50 +11:00
Nicholas Nethercote
cf13d9143d Clarify run_in_thread_pool_with_globals.
- Make the structure of the two variants more similar.
- Add some comments.
- Move various conditional `use` items inside the function that uses
  them.
- Inline some closures.
2022-10-19 17:37:48 +11:00