Commit Graph

220880 Commits

Author SHA1 Message Date
Philipp Krones
8134414e03
Bump nightly version -> 2023-03-24 2023-03-24 13:36:15 +01:00
Philipp Krones
62cba5d971
Merge remote-tracking branch 'upstream/master' into rustup 2023-03-24 13:36:09 +01:00
yukang
64f6e4f21c Fix bad suggestion for clone/is_some in field init shorthand 2023-03-24 19:52:34 +08:00
bjorn3
8b1be44758 Update ar_archive_writer to 0.1.3
This updates object to 0.30 and fixes a bug where the symbol table
would be omitted for archives where there are object files yet none
that export any symbol. This bug could lead to linker errors for crates
like rustc_std_workspace_core which don't contain any code of their own
but exist solely for their dependencies. This is likely the cause of
the linker issues I was experiencing on Webassembly. It has been shown
to cause issues on other platforms too.

cc rust-lang/ar_archive_writer#5
2023-03-24 11:48:48 +00:00
Raphael Amorim
d13b423859 use llvm 16.0.0 instead of 16.0.0-rc4 2023-03-24 12:36:30 +01:00
bors
f421586eed Auto merge of #109216 - martingms:unicode-case-lut-shrink, r=Mark-Simulacrum
Shrink unicode case-mapping LUTs by 24k

I was looking into the binary bloat of a small program using `str::to_lowercase` and `str::to_uppercase`, and noticed that the lookup tables used for case mapping had a lot of zero-bytes in them. The reason for this is that since some characters map to up to three other characters when lower or uppercased, the LUTs store a `[char; 3]` for each character. However, the vast majority of cases only map to a single new character, in other words most of the entries are e.g. `(lowerc, [upperc, '\0', '\0'])`.
This PR introduces a new encoding scheme for these tables.

The changes reduces the size of my test binary by about 24K.

I've also done some `#[bench]`marks on unicode-heavy test data, and found that the performance of both `str::to_lowercase` and `str::to_uppercase` improves by up to 20%. These measurements are obviously very dependent on the character distribution of the data.

Someone else will have to decide whether this more complex scheme is worth it or not, I was just goofing around a bit and here's what came out of it 🤷‍♂️ No hard feelings if this isn't wanted!
2023-03-24 10:33:42 +00:00
bors
c763eceae3 Auto merge of #109552 - matthiaskrgr:rollup-03xwois, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #109406 (Remove outdated comments)
 - #109433 (Return equal for two identical projections)
 - #109495 (Implement non-const `Destruct` trait in new solver)
 - #109519 (Link against libc++ on AIX)
 - #109550 (Make helper functions private in fn_ctxt/adjust_fulfillment_errors)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-24 06:16:24 +00:00
Matthias Krüger
2cfcca629f
Rollup merge of #109550 - Nathan-Fenner:nathanf/fixme-adjust-funcs, r=compiler-errors
Make helper functions private in fn_ctxt/adjust_fulfillment_errors

Two helper functions in `rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs` were previously made `pub` impl members, because they were also used in `rustc_hir_typeck/src/fn_ctxt/check.rs` (see #107746).

However, that's no longer the case, so the FIXME suggesting they be made private can now be implemented.
2023-03-24 07:13:06 +01:00
Matthias Krüger
4378369b6a
Rollup merge of #109519 - bzEq:aix-llvm-c++, r=cuviper
Link against libc++ on AIX

LLVM on AIX currently is utilizing runtimes in llvm-project, such as libc++, libc++abi and libunwind.
2023-03-24 07:13:05 +01:00
Matthias Krüger
2270bde01f
Rollup merge of #109495 - compiler-errors:new-solver-destruct, r=eholk,lcnr
Implement non-const `Destruct` trait in new solver

Makes it so that we can call stdlib methods like `Option::map` in **non-const** environments, since *many* stdlib methods have `Destruct` bounds 😅

This doesn't bother to implement `const Destruct` yet, but it shouldn't be too hard to do so. Just didn't bother since we already don't have much support for const traits in the new solver anyways. I'd be happy to add skeleton support for `const Destruct`, though, if the reviewer desires.
2023-03-24 07:13:05 +01:00
Matthias Krüger
98254c5cc7
Rollup merge of #109433 - chenyukang:yukang/fix-109188-ice, r=lcnr
Return equal for two identical projections

Fixes #109188
2023-03-24 07:13:04 +01:00
Matthias Krüger
936377a0aa
Rollup merge of #109406 - WaffleLapkin:🥛, r=cuviper
Remove outdated comments

What the title said
2023-03-24 07:13:04 +01:00
Nathan Fenner
d4d1cc4db6 Make helper functions private 2023-03-23 20:24:37 -07:00
bors
4c0f5008ce Auto merge of #109547 - matthiaskrgr:rollup-zczqgdk, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #108629 (rustdoc: add support for type filters in arguments and generics)
 - #108924 (panic_immediate_abort requires abort as a panic strategy)
 - #108961 (Refine error spans for const args in hir typeck)
 - #108986 (sync LVI tests)
 - #109142 (Add block-based mutex unlocking example)
 - #109368 (fix typo in the creation of OpenOption for RustyHermit)
 - #109493 (Return nested obligations from canonical response var unification)
 - #109515 (Add AixLinker to support linking on AIX)
 - #109536 (resolve: Rename some cstore methods to match queries and add comments)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-24 02:29:48 +00:00
Matthias Krüger
4d21d302a1
Rollup merge of #109536 - petrochenkov:qcstore3, r=cjgillot
resolve: Rename some cstore methods to match queries and add comments

about costs associated with replacing them with query calls.

Supersedes https://github.com/rust-lang/rust/pull/108346.
r? `@cjgillot`
2023-03-24 01:22:07 +01:00
Matthias Krüger
686bd46d8a
Rollup merge of #109515 - bzEq:aix-linker, r=petrochenkov
Add AixLinker to support linking on AIX

AIX linker has a different cli style from other existing linkers.
It is documented in https://www.ibm.com/docs/en/aix/7.1?topic=l-ld-command.
2023-03-24 01:22:07 +01:00
Matthias Krüger
1c7ef3b483
Rollup merge of #109493 - compiler-errors:new-solver-vars-obligations, r=lcnr
Return nested obligations from canonical response var unification

Handle alias-eq obligations being emitted from `instantiate_and_apply_query_response` in:
* `EvalCtxt` - by processing the nested obligations in the next loop by `new_goals`
* `FulfillCtxt` - by adding the nested obligations to the fulfillment's pending obligations
* `InferCtxt::evaluate_obligation` - ~~by returning `EvaluationResult::EvaluatedToAmbig` (boo 👎, see the FIXME)~~ same behavior as above, since we use fulfillment and `select_where_possible`

The only one that's truly sketchy is `evaluate_obligation`, but it's not hard to modify this behavior moving forward.

From #109037, I think a smaller repro could be crafted if I were smarter, but I am not, so I just took this from #105878.

r? `@lcnr` cc `@BoxyUwU`
2023-03-24 01:22:06 +01:00
Matthias Krüger
cca2630bc9
Rollup merge of #109368 - hermitcore:typo, r=cuviper
fix typo in the creation of OpenOption for RustyHermit

Due to this typo we have to build a workaround for issue hermitcore/libhermit-rs#191.

RustyHermit is a tier 3 platform and backward compatibility does not have to be guaranteed.
2023-03-24 01:22:06 +01:00
Matthias Krüger
605a4fc7ab
Rollup merge of #109142 - the8472:mutex-block-docs, r=cuviper
Add block-based mutex unlocking example

This modifies the existing example in the Mutex docs to show both `drop()` and block based early unlocking.

Alternative to #81872, which is getting closed.
2023-03-24 01:22:05 +01:00
Matthias Krüger
cfd8105f3f
Rollup merge of #108986 - fortanix:raoul/sync_lvi_patches, r=cuviper
sync LVI tests

The LVI tests for the `x86_64-fortanix-unknown-sgx` target have gotten out of sync. LVI is still mitigated correctly, but the LVI tests need minor modifications. Other (non LVI-related) tests fail when the target applies LVI mitigations as they assume the generated code contains forbidden instructions such as `retq`. These tests are ignored for the sgx environment.

cc: `@jethrogb`
2023-03-24 01:22:05 +01:00
Matthias Krüger
eb82a5a0c8
Rollup merge of #108961 - compiler-errors:refine-ct-errors, r=BoxyUwU
Refine error spans for const args in hir typeck

Improve just a couple of error messages having to do with mismatched consts.

r? `@ghost` i'll put this up when the dependent commits are merged
2023-03-24 01:22:04 +01:00
Matthias Krüger
d9c05b853d
Rollup merge of #108924 - tmiasko:panic-immediate-abort, r=thomcc
panic_immediate_abort requires abort as a panic strategy

Guide `panic_immediate_abort` users away from `-Cpanic=unwind` and towards `-Cpanic=abort` to avoid an accidental use of the feature with the unwind strategy, e.g., on a targets where unwind is the default.

The `-Cpanic=unwind` combination doesn't offer the same benefits, since the code would still be generated under the assumption that functions implemented in Rust can unwind.
2023-03-24 01:22:04 +01:00
Matthias Krüger
eb46afb216
Rollup merge of #108629 - notriddle:notriddle/item-type-advanced, r=GuillaumeGomez
rustdoc: add support for type filters in arguments and generics

This makes sense, since the search index has the information in it, and it's more useful for function signature searches since a function signature search's item type is, by definition, some type of function (there's more than one, but not very many).
2023-03-24 01:22:03 +01:00
bors
c72c914d21 Auto merge of #10489 - samueltardieu:issue-10476, r=giraffate
New lint: detect unnecessary struct building

Fixes #10476.

Running this lint on the top 500 crates produced one hit (in `rust-lang/rust-bindgen`) and [a PR has been submitted there](https://github.com/rust-lang/rust-bindgen/pull/2440).

changelog: [`unnecessary_struct_initialization`]: new lint
2023-03-24 00:12:02 +00:00
bors
cf073ec2cb Auto merge of #109202 - compiler-errors:new-solver-fast-reject-faster-2, r=lcnr
Don't pass `TreatProjections` separately to `fast_reject`

Don't pass `TreatProjections` separately to `fast_reject`, and instead use the original approach of switching on two variants of `TreatParams` (undoes this: https://github.com/rust-lang/rust/pull/108830#pullrequestreview-1330371417).

Fixes the regression introduced in https://github.com/rust-lang/rust/pull/108830#issuecomment-1468116419
2023-03-23 23:53:56 +00:00
Michael Goulet
b605d0740f Deeply check WF for RPITITs 2023-03-23 23:37:22 +00:00
Michael Howell
95ef91c573 rustdoc: remove old content hack for theme switching
This is based on the compatibility data for `window.matchMedia` and
`MediaQueryList`'s `EventTarget` implementation.

https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList#browser_compatibility

https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia#browser_compatibility

  * EventTarget would require us to drop support for all Chrome
    versions before 39. However, we already require Chrome 49,
    because rustdoc requires [CSS variables].
  * EventTarget would also limit us to Firefox 55, but since #106502
    rustdoc only supports Firefox > 68.
  * EventTarget limits us to Mobile Safari version 14, but #102404
    shows that our CSS is broken in Safari versions before 15.5.

[CSS variables]: https://developer.mozilla.org/en-US/docs/Web/CSS/--*#browser_compatibility
2023-03-23 14:25:43 -07:00
Michael Howell
ba3d6055ad rustdoc: clean up storage.js
This converts a few functions to more compact versions of
themselves, and moves `RUSTDOC_MOBILE_BREAKPOINT` to main.js where
it's actually used.
2023-03-23 14:19:50 -07:00
bors
1459b3128e Auto merge of #109538 - matthiaskrgr:rollup-ct58npj, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #106964 (Clarify `Error::last_os_error` can be weird)
 - #107718 (Add `-Z time-passes-format` to allow specifying a JSON output for `-Z time-passes`)
 - #107880 (Lint ambiguous glob re-exports)
 - #108549 (Remove issue number for `link_cfg`)
 - #108588 (Fix the ffi_unwind_calls lint documentation)
 - #109231 (Add `try_canonicalize` to `rustc_fs_util` and use it over `fs::canonicalize`)
 - #109472 (Add parentheses properly for method calls)
 - #109487 (Move useless_anynous_reexport lint into unused_imports)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-23 21:16:57 +00:00
Samuel "Sam" Tardieu
d7d3dbf060 New lint: detect unnecessary struct building 2023-03-23 20:56:45 +01:00
Camille GILLOT
5f9c004d35 Separate find_*_stability. 2023-03-23 19:52:27 +00:00
Camille GILLOT
17f1db672e Extract parse_stability and parse_unstability. 2023-03-23 19:49:38 +00:00
Michael Goulet
1680334928 Use fulfillment in InferCtxt::evaluate_obligation 2023-03-23 19:22:32 +00:00
Michael Goulet
6c6bd01421 Note type mismatch on ConstArgHasType 2023-03-23 19:09:34 +00:00
Michael Goulet
2bab422393 Return nested obligations from canonical response var unification 2023-03-23 19:00:04 +00:00
Michael Goulet
fc0cbe8340 Don't split up TreatProjections and TreatParams anymore 2023-03-23 18:57:02 +00:00
Matthias Krüger
3961ef5bc8
Rollup merge of #109487 - GuillaumeGomez:move-useless-reexport-check, r=petrochenkov
Move useless_anynous_reexport lint into unused_imports

As mentioned in https://github.com/rust-lang/rust/pull/109003, this check should have been merged with `unused_imports` in the start.

r? `@petrochenkov`
2023-03-23 19:55:46 +01:00
Matthias Krüger
dddede4a24
Rollup merge of #109472 - MU001999:patch-3, r=eholk
Add parentheses properly for method calls

Fixes #109436
2023-03-23 19:55:46 +01:00
Matthias Krüger
2a39cf560f
Rollup merge of #109231 - Zoxc:fs-non-canon, r=eholk
Add `try_canonicalize` to `rustc_fs_util` and use it over `fs::canonicalize`

This adds `try_canonicalize` which tries to call `fs::canonicalize`, but falls back to `std::path::absolute` if it fails. Existing `canonicalize` calls are replaced with it. `fs::canonicalize` is not guaranteed to work on Windows.
2023-03-23 19:55:45 +01:00
Matthias Krüger
fc5516b782
Rollup merge of #108588 - ehuss:lint-docs-produces, r=eholk
Fix the ffi_unwind_calls lint documentation

This fixes the [`ffi_unwind_calls`](https://doc.rust-lang.org/nightly/rustc/lints/listing/allowed-by-default.html#ffi-unwind-calls) documentation to show its output correctly. Currently it is showing the text `{{produces}}` which is not how it should look.

This fixes it by not ignoring the example. I'm not sure why it was ignored, as the way the lint currently works it doesn't seem to require external linkage. This also fixes several mistakes in the example:

* There is no `ffi_unwind_calls` feature.
* Denies the lint (which is otherwise allow be default).
* Removes the `mod impl` which is not valid Rust syntax, and doesn't appear to be needed anyways.

The output now looks like:

```
warning: call to foreign function with FFI-unwind ABI
  --> lint_example.rs:10:14
   |
10 |     unsafe { foo(); }
   |              ^^^^^ call to foreign function with FFI-unwind ABI
   |
note: the lint level is defined here
  --> lint_example.rs:2:9
   |
2  | #![warn(ffi_unwind_calls)]
   |         ^^^^^^^^^^^^^^^^

warning: call to function pointer with FFI-unwind ABI
  --> lint_example.rs:12:14
   |
12 |     unsafe { ptr(); }
   |              ^^^^^ call to function pointer with FFI-unwind ABI

```

This also includes some updates to the lint-docs tool to help with this issue:

* Adds a check if a lint documentation has `{{produces}}` with an ignored example, and generates an error.
* All instances of a lint are now displayed. Previously it only showed the first time the lint fires. Some examples may trigger a lint multiple times, and they are all now displayed.
2023-03-23 19:55:45 +01:00
Matthias Krüger
5a017d3a57
Rollup merge of #108549 - clubby789:fix-link-cfg-issue, r=eholk
Remove issue number for `link_cfg`

Fixes #72059

Per #37406 and its [unstable book entry](https://doc.rust-lang.org/beta/unstable-book/language-features/link-cfg.html), this is an internal feature, and therefore perma-unstable and not being tracked
2023-03-23 19:55:44 +01:00
Matthias Krüger
bacf059f57
Rollup merge of #107880 - jieyouxu:issue-107563, r=petrochenkov
Lint ambiguous glob re-exports

Attempts to fix #107563.

We currently already emit errors for ambiguous re-exports when two names are re-exported *specifically*, i.e. not from glob exports. This PR attempts to emit deny-by-default lints for ambiguous glob re-exports.
2023-03-23 19:55:43 +01:00
Matthias Krüger
acd7f878ae
Rollup merge of #107718 - Zoxc:z-time, r=nnethercote
Add `-Z time-passes-format` to allow specifying a JSON output for `-Z time-passes`

This adds back the `-Z time` option as that is useful for [my rustc benchmark tool](https://github.com/Zoxc/rcb), reverting https://github.com/rust-lang/rust/pull/102725. It now uses nanoseconds and bytes as the units so it is renamed to `time-precise`.
2023-03-23 19:55:43 +01:00
Matthias Krüger
aeabe34d79
Rollup merge of #106964 - workingjubilee:crouching-ioerror-hidden-documentation, r=ChrisDenton
Clarify `Error::last_os_error` can be weird

Fundamentally, querying the OS for error codes is a process that is deeply subject to the whims of chance and fortune. We can account for OS, but not for every combination of platform APIs. A compiled binary may not recognize new errors introduced years later. We should clarify a few especially odd situations, and what they mean: We can effectively promise nothing... if you ask for Rust to decode errors where none have occurred.

This allows removing mention of ErrorKind::Uncategorized.
That error variant is hidden deliberately, so we should not explicitly mention it.

This fixes #106937.

Since you had an opinion also: Does this solution seem acceptable?
r? ``@ChrisDenton``
2023-03-23 19:55:42 +01:00
Michael Goulet
e55f73ae47 Refine error spans for const args in hir typeck 2023-03-23 18:51:30 +00:00
bors
e216300876 Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk
Add `CastKind::Transmute` to MIR

~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~

Includes lowering `transmute` calls to it, so it's used.

Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
2023-03-23 18:43:04 +00:00
bors
58eb9964cc Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk
Add `CastKind::Transmute` to MIR

~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~

Includes lowering `transmute` calls to it, so it's used.

Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
2023-03-23 18:43:04 +00:00
Vadim Petrochenkov
1cec923fbb rustc_metadata: Freeze cstore after the full crate list is queried 2023-03-23 20:44:48 +04:00
Vadim Petrochenkov
71927ad083 resolve: Rename some cstore methods to match queries and add comments
about costs associated with replacing them with query calls.
2023-03-23 20:44:02 +04:00
Guillaume Gomez
87ea9941d5 Remove span method from AttributesExt trait 2023-03-23 17:37:29 +01:00