Commit Graph

240829 Commits

Author SHA1 Message Date
Guillaume Gomez
54d6bded30
Rollup merge of #118802 - ehuss:remove-edition-preview, r=TaKO8Ki
Remove edition umbrella features.

In the 2018 edition, there was an "umbrella" feature `#[feature(rust_2018_preview)]` which was used to enable several other features at once. This umbrella mechanism was not used in the 2021 edition and likely will not be used in 2024 either. During 2018 users reported that setting the feature was awkward, especially since they already needed to opt-in via the edition mechanism.

This PR removes this mechanism because I believe it will not be used (and will clean up and simplify the code). I believe that there are better ways to handle features and editions. In short:

- For highly experimental features, that may or may not be involved in an edition, they can implement regular feature gates like `tcx.features().my_feature`.
- For experimental features that *might* be involved in an edition, they should implement gates with `tcx.features().my_feature && span.at_least_rust_20xx()`. This requires the user to still specify `#![feature(my_feature)]`, to avoid disrupting testing of other edition features which are ready and have been accepted within the edition.
- For experimental features that have graduated to definitely be part of an edition, they should implement gates with `tcx.features().my_feature || span.at_least_rust_20xx()`, or just remove the feature check altogether and just check `span.at_least_rust_20xx()`.
- For relatively simple changes, they can skip the whole feature gating thing and just check `span.at_least_rust_20xx()`, and rely on the instability of the edition itself (which requires `-Zunstable-options`) to gate it.

I am working on documenting all of this in the rustc-dev-guide.
2023-12-11 11:40:36 +01:00
bors
8b1ba11cb1 Auto merge of #117116 - calebzulawski:repr-simd-packed, r=workingjubilee
Implement repr(packed) for repr(simd)

This allows creating vectors with non-power-of-2 lengths that do not have padding.  See rust-lang/portable-simd#319
2023-12-11 08:07:20 +00:00
bors
c13187c998 Auto merge of #118494 - nnethercote:default_configuration-fill_well_known, r=Mark-Simulacrum
Rearrange `default_configuration` and `CheckCfg::fill_well_known`.

There are comments saying these two functions should be kept in sync, but they have very different structures, process symbols in different orders, and there are some inconsistencies.

This commit reorders them so they're both mostly processing symbols in alphabetical order, which makes cross-checking them a lot easier. The commit also adds some macros to factor out repetitive code patterns.

The commit also moves the handling of `sym::test` out of `build_configuration` into `default_configuration`, where all the other symbols are handled.

r? `@bjorn3`
2023-12-11 06:10:44 +00:00
bors
e299752868 Auto merge of #118032 - RalfJung:char-u32, r=Mark-Simulacrum
guarantee that char and u32 are ABI-compatible

In https://github.com/rust-lang/rust/pull/116894 we added a guarantee that `char` has the same alignment as `u32`, but there is still one axis where these types could differ: function call ABI. So let's nail that down as well: in a function signature, `char` and `u32` are completely equivalent.

This is a new stable guarantee, so it will need t-lang approval.
2023-12-11 04:13:19 +00:00
bors
1cb200cfeb Auto merge of #118810 - Kobzol:revert-mcp-510-bootstrap, r=nnethercote
Revert using MCP510 in bootstrap

This reverts commit 40c3d351ad. The commit started dogfooding MCP510 to enable `lld` when building the compiler , but it broke tests, because we don't pass `-Zunstable-options` on enough places. This PR hotfixes that, and temporarily makes the "self-contained" option.. not very self-contained. I'll send a proper fix later, but I want to unblock rustc developres that use `lld` locally.

r? `@nnethercote` (who discovered the problem)
2023-12-11 02:15:56 +00:00
bors
a9cb8ee821 Auto merge of #114571 - nnethercote:improve-print_tts, r=petrochenkov
Improve `print_tts`

By slightly changing the meaning of `tokenstream::Spacing` we can greatly improve the output of `print_tts`.

r? `@ghost`
2023-12-11 00:03:56 +00:00
Nicholas Nethercote
22b534de4f Rearrange default_configuration and CheckCfg::fill_well_known.
There are comments saying these two functions should be kept in sync,
but they have very different structures, process symbols in different
orders, and there are some inconsistencies.

This commit reorders them so they're both mostly processing symbols in
alphabetical order, which makes cross-checking them a lot easier. The
commit also adds some macros to factor out repetitive code patterns.
Plus it adds `sanitizer_cfi_normalize_{integers,pointers}` to
`fill_well_known`, which were missing.

The commit also moves the handling of `sym::test` out of
`build_configuration` into `default_configuration`, where all the other
symbols are handled.
2023-12-11 10:04:47 +11:00
Nicholas Nethercote
940c885bc4 Add a few cases with wonky formatting to stringify.rs test.
Because the spacing-based pretty-printing partially preserves that.
2023-12-11 09:36:42 +11:00
Nicholas Nethercote
4cfdbd328b Add spacing information to delimiters.
This is an extension of the previous commit. It means the output of
something like this:
```
stringify!(let a: Vec<u32> = vec![];)
```
goes from this:
```
let a: Vec<u32> = vec![] ;
```
With this PR, it now produces this string:
```
let a: Vec<u32> = vec![];
```
2023-12-11 09:36:40 +11:00
Jakub Beránek
3157f2121e
Revert "Use MCP510"
This reverts commit 40c3d351ad. The option was dogfooded for using lld with MCP510 , but it broke testing with LLD, because we don't pass `-Zunstable-options` on enough places.
2023-12-10 23:22:20 +01:00
Nicholas Nethercote
925f7fad57 Improve print_tts by changing tokenstream::Spacing.
`tokenstream::Spacing` appears on all `TokenTree::Token` instances,
both punct and non-punct. Its current usage:
- `Joint` means "can join with the next token *and* that token is a
  punct".
- `Alone` means "cannot join with the next token *or* can join with the
  next token but that token is not a punct".

The fact that `Alone` is used for two different cases is awkward.
This commit augments `tokenstream::Spacing` with a new variant
`JointHidden`, resulting in:
- `Joint` means "can join with the next token *and* that token is a
  punct".
- `JointHidden` means "can join with the next token *and* that token is a
  not a punct".
- `Alone` means "cannot join with the next token".

This *drastically* improves the output of `print_tts`. For example,
this:
```
stringify!(let a: Vec<u32> = vec![];)
```
currently produces this string:
```
let a : Vec < u32 > = vec! [] ;
```
With this PR, it now produces this string:
```
let a: Vec<u32> = vec![] ;
```
(The space after the `]` is because `TokenTree::Delimited` currently
doesn't have spacing information. The subsequent commit fixes this.)

The new `print_tts` doesn't replicate original code perfectly. E.g.
multiple space characters will be condensed into a single space
character. But it's much improved.

`print_tts` still produces the old, uglier output for code produced by
proc macros. Because we have to translate the generated code from
`proc_macro::Spacing` to the more expressive `token::Spacing`, which
results in too much `proc_macro::Along` usage and no
`proc_macro::JointHidden` usage. So `space_between` still exists and
is used by `print_tts` in conjunction with the `Spacing` field.

This change will also help with the removal of `Token::Interpolated`.
Currently interpolated tokens are pretty-printed nicely via AST pretty
printing. `Token::Interpolated` removal will mean they get printed with
`print_tts`. Without this change, that would result in much uglier
output for code produced by decl macro expansions. With this change, AST
pretty printing and `print_tts` produce similar results.

The commit also tweaks the comments on `proc_macro::Spacing`. In
particular, it refers to "compound tokens" rather than "multi-char
operators" because lifetimes aren't operators.
2023-12-11 09:19:09 +11:00
bors
d86d65bbc1 Auto merge of #118368 - GuillaumeGomez:env-flag, r=Nilstrieb
Implement `--env` compiler flag (without `tracked_env` support)

Part of https://github.com/rust-lang/rust/issues/80792.
Implementation of https://github.com/rust-lang/compiler-team/issues/653.
Not an implementation of https://github.com/rust-lang/rfcs/pull/2794.

It adds the `--env` compiler flag option which allows to set environment values used by `env!` and `option_env!`.

Important to note: When trying to retrieve an environment variable value, it will first look into the ones defined with `--env`, and if there isn't one, then only it will look into the environment variables. So if you use `--env PATH=a`, then `env!("PATH")` will return `"a"` and not the actual `PATH` value.

As mentioned in the title, `tracked_env` support is not added here. I'll do it in a follow-up PR.

r? rust-lang/compiler
2023-12-10 21:48:53 +00:00
Eric Huss
f481596ee4 Remove edition umbrella features. 2023-12-10 13:03:28 -08:00
bors
ec4176167b Auto merge of #118703 - Kobzol:bootstrap-config-unused, r=onur-ozkan
Remove unused bootstrap config option

I tried to destructure a few of the TOML config structs to find any unused fields. I found that `Rust::run_dysmutil` field is unused. This PR uses destructuring of the `Rust` struct, to find similar unused fields in the future, and also removes the unused field.

I also found one more unused field (`Dist::gpg_password_file`), it doesn't seem to be used anywhere. If you like this PR, I'll send another one that uses destructuring for all interesting TOML structs and removes that unused field.

r? `@onur-ozkan`
2023-12-10 19:48:55 +00:00
Jakub Beránek
f1c5558edc
Add ChangeInfo record 2023-12-10 20:45:07 +01:00
Jakub Beránek
ccbd88dc83
Remove unused run_dsymutil and gpg_password_file config values 2023-12-10 20:45:07 +01:00
Jakub Beránek
6badc0d840
Destructure TOML configs
This will allow us to check if all values are used
2023-12-10 20:45:07 +01:00
bors
7e452c123c Auto merge of #118791 - saethlin:use-immediate-type, r=nikic
Use immediate_backend_type when reading from a const alloc

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

r? `@nikic`
2023-12-10 17:50:15 +00:00
bors
b9068315db Auto merge of #116952 - compiler-errors:lifetime_capture_rules_2024, r=TaKO8Ki
Implement 2024-edition lifetime capture rules RFC

Implements rust-lang/rfcs#3498.
2023-12-10 15:51:39 +00:00
Caleb Zulawski
aa00baeba4 Remove codegen test that depends on optimizations 2023-12-10 09:18:26 -05:00
bors
befd1eb4ec Auto merge of #116278 - Kobzol:bootstrap-lld-mode, r=albertlarsan68,petrochenkov
Generalize LLD usage in bootstrap

The current usage of using LLD (`rust.use-lld = true`) in bootstrap is a bit messy. What it claimed:

> Indicates whether LLD will be used to link Rust crates during bootstrap on
> supported platforms. The LLD from the bootstrap distribution will be used
> and not the LLD compiled during the bootstrap.

What it did:
1) On MSVC, it did indeed use the snapshot compiler's `rust-lld`, but at the same time it was invoking a global `lld` binary (since https://github.com/rust-lang/rust/pull/102101), therefore it wouldn't work if `lld` wasn't available.
2) On other targets, it was just straight up using a global `lld` linker. If it wasn't available, it would fail.

This PR (hopefully) cleans up handling of LLD in bootstrap. It introduces a new enum called `LldMode`, which explicitly distinguishes between no LLD, external LLD and self-contained LLD. Since it's non-trivial to provide a custom path to LLD, if an external `lld` is used, the linker binary has to be named exactly `lld` and it has to be available in PATH.

In addition, this PR also dog-foods [MCP510](https://github.com/rust-lang/compiler-team/issues/510) in bootstrap.

To keep backwards compatibility somewhat, I kept the original `use-lld` flag and mapped the `true` value to `"external"`, which is how it behaved before on Linux and other non-MSVC targets.

Having the option to use an external `lld` on Linux should come in handy for testing on CI once MCP510 sets the default linker on Linux to `lld`.

Note that thanks to MCP510, currently "self-contained" means that `lld` is used from the stage N-1 compiler (before, we always used `lld` from the snapshot/stage0 compiler).

Best reviewed commit by commit.

CC `@petrochenkov`
2023-12-10 13:51:55 +00:00
Guillaume Gomez
dc2f77aad6 Add (unstable) documentation for --env command line option 2023-12-10 14:25:57 +01:00
Guillaume Gomez
d2b1f94f05 Add feature gate test for --env flag 2023-12-10 14:25:57 +01:00
Guillaume Gomez
37d68093da Add ui tests for --env option 2023-12-10 14:25:57 +01:00
Guillaume Gomez
486e55e547 Implement --env compiler flag 2023-12-10 14:25:57 +01:00
Jakub Beránek
53031b264e
Review fixes 2023-12-10 13:06:05 +01:00
bors
84f6130fe3 Auto merge of #118692 - surechen:remove_unused_imports, r=petrochenkov
remove redundant imports

detects redundant imports that can be eliminated.

for #117772 :

In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.

r? `@petrochenkov`
2023-12-10 11:55:48 +00:00
Jakub Beránek
4750e9de47
Produce an explicit error when using a self-contained lld, but we don't add it to sysroot 2023-12-10 11:21:36 +01:00
Jakub Beránek
ea769dbeb7
Add change tracker entry 2023-12-10 11:21:35 +01:00
Jakub Beránek
cbfe6327a1
Do not invoke external lld to figure out thread flags in self-contained mode 2023-12-10 11:21:35 +01:00
Jakub Beránek
50865745e1
Update config.example.toml 2023-12-10 11:21:35 +01:00
Jakub Beránek
40c3d351ad
Use MCP510 2023-12-10 11:21:35 +01:00
Jakub Beránek
48c1607bc6
Introduce LldMode and generalize parsing of use-lld 2023-12-10 11:21:35 +01:00
Jakub Beránek
d9f9e67bc1
Refactor rust(do)c linker flags 2023-12-10 11:21:33 +01:00
Jakub Beránek
b3c9ffdc77
Add is_msvc function 2023-12-10 11:20:49 +01:00
bors
c1a3919378 Auto merge of #118792 - naglis:fix-mutex-doc-typo, r=workingjubilee
Fix typo in `std::sync::Mutex` example
2023-12-10 09:02:29 +00:00
bors
42dfac5e08 Auto merge of #118788 - compiler-errors:const-pretty, r=fee1-dead
Don't print host effect param in pretty `path_generic_args`

Make `own_args_no_defaults` pass back the `GenericParamDef`, so that we can pass both the args *and* param definitions into `path_generic_args`. That allows us to use the `GenericParamDef` to filter out effect params.

This allows us to filter out the host param regardless of whether it's `sym::host` or `true`/`false`.

This also renames a couple of `const_effect_param` -> `host_effect_param`, and restores `~const` pretty printing to `TraitPredPrintModifiersAndPath`.

cc #118785
r? `@fee1-dead` cc `@oli-obk`
2023-12-10 06:59:25 +00:00
bors
61afc9c928 Auto merge of #116949 - hamza1311:stablize-arc_unwrap_or_clone, r=dtolnay
Stablize arc_unwrap_or_clone

Fixes: #93610

This likely needs FCP. I created this PR as it's stabilization is trivial and FCP can be just conducted here. Not sure how to ping the libs API team (last attempt didn't work apparently according to GH UI)
2023-12-10 05:01:00 +00:00
bors
c71c246876 Auto merge of #118550 - cjgillot:filecheck-const-prop, r=Mark-Simulacrum
Add FileCheck annotations to const_prop tests

Unblocks https://github.com/rust-lang/rust/pull/116012
Advances https://github.com/rust-lang/rust/issues/116971
2023-12-10 03:00:58 +00:00
surechen
40ae34194c remove redundant imports
detects redundant imports that can be eliminated.

for #117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
2023-12-10 10:56:22 +08:00
bors
f7253f2317 Auto merge of #118787 - GuillaumeGomez:rollup-fj5wr3q, r=GuillaumeGomez
Rollup of 5 pull requests

Successful merges:

 - #117966 (add safe compilation options)
 - #118747 (Remove extra check cfg handled by libc directly)
 - #118774 (add test for inductive cycle hangs)
 - #118775 (chore: add test case for type with generic)
 - #118782 (use `&` instead of start-process in x.ps1)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-12-10 01:02:42 +00:00
naglis
7d50a39763 Fix typo in std::sync::Mutex example 2023-12-10 02:21:53 +02:00
bors
8cd8d31369 Auto merge of #118069 - onur-ozkan:bypass_bootstrap_lock, r=Mark-Simulacrum
allow bypassing the build directory lock

As bootstrap locks its entire build directory, parallel bootstrapping for anything becomes impossible. This change enables developers to bypass the locking mechanism (with `--bypass-bootstrap-lock` flag) when it is unnecessary for their specific use case.

more context: https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Build.20.28miri.3F.29.20sysroots.20in.20parallel

cc `@saethlin`
2023-12-09 23:02:05 +00:00
Ben Kimock
b0a580112b Use immediate_backend_type when reading from a const alloc 2023-12-09 17:13:11 -05:00
bors
06e02d5b25 Auto merge of #118308 - Nadrieril:sound-exhaustive-patterns-take-3, r=compiler-errors
Don't warn an empty pattern unreachable if we're not sure the data is valid

Exhaustiveness checking used to be naive about the possibility of a place containing invalid data. This could cause it to emit an "unreachable pattern" lint on an arm that was in fact reachable, as in https://github.com/rust-lang/rust/issues/117119.

This PR fixes that. We now track whether a place that is matched on may hold invalid data. This also forced me to be extra precise about how exhaustiveness manages empty types.

Note that this now errs in the opposite direction: the following arm is truly unreachable (because the binding causes a read of the value) but not linted as such. I'd rather not recommend writing a `match ... {}` that has the implicit side-effect of loading the value. [Never patterns](https://github.com/rust-lang/rust/issues/118155) will solve this cleanly.
```rust
match union.value {
    _x => unreachable!(),
}
```

I recommend reviewing commit by commit. I went all-in on the test suite because this went through a lot of iterations and I kept everything. The bit I'm least confident in is `is_known_valid_scrutinee` in `check_match.rs`.

Fixes https://github.com/rust-lang/rust/issues/117119.
2023-12-09 19:03:03 +00:00
Michael Goulet
afa35e90ef Print constness in TraitPredPrintModifiersAndPath 2023-12-09 17:55:07 +00:00
Michael Goulet
7467c3a45c s/const_effect/host_effect 2023-12-09 17:43:08 +00:00
Michael Goulet
f1bf874fb1 Don't print host effect param in pretty path_generic_args 2023-12-09 17:42:33 +00:00
onur-ozkan
6860654d82 allow bypassing the build directory lock
As bootstrap locks its entire build directory, parallel bootstrapping
for anything becomes impossible. This change enables developers to bypass
the locking mechanism when it is unnecessary for their specific use case.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-12-09 20:12:40 +03:00
bors
c722d5191c Auto merge of #117771 - tmandry:fuchsia-gha, r=Mark-Simulacrum
Build Fuchsia in CI

Fittingly, when I first put this up it was failing due to discovering an ICE in clippy (looks like fixed in https://github.com/rust-lang/rust-clippy/pull/11760), probably more fallout from recent type system changes. Other recent regressions this would have caught include

- #117455 and #117493
- #117602

Originally we discussed basing this on cargotest, but they ended up not sharing anything. Fuchsia has its own tool to manage checkouts and its own build system. What it requires is a fully "install"ed toolchain with a host and fuchsia target. We share logic from the dist-various-2 builder to build the fuchsia target.

Right now this runs clippy and skips linking a bunch of targets, since most issues we catch are in the frontend. In theory we could probably get the build CPU time down quite a bit with this approach, but right now some linked targets are creeping into the dependencies anyway and we don't have a good way of preventing that yet.

The approach is basically to get a checkout at a pinned commit and then run a [script](https://fuchsia-review.git.corp.google.com/c/fuchsia/+/943833/6/scripts/rust/build_fuchsia_from_rust_ci.sh) at a predetermined location. I would like to update that pin every few weeks. Partial checkouts are used to minimize clone time, but we don't filter out prebuilt packages.

r? `@Mark-Simulacrum`

Based on discussion in [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/Putting.20Fuchsia.20in.20crater).
2023-12-09 17:00:54 +00:00