Commit Graph

241152 Commits

Author SHA1 Message Date
Nadrieril
de3f983bcd Make MaybeInfiniteInt rustc-independent 2023-12-11 11:20:55 +01:00
Nadrieril
24adca0a26 Move lints to their own module 2023-12-11 11:20:55 +01:00
Nadrieril
3691a0aee5 Gather rustc-specific functions around MatchCheckCtxt 2023-12-11 11:20:55 +01:00
Nadrieril
281002d42c Extract exhaustiveness into its own crate 2023-12-11 11:20:55 +01:00
Laurențiu Nicola
c47cb47adf Fix typo in cfg 2023-12-11 11:55:43 +02:00
Krasimir Georgiev
a0c5079889 llvm-wrapper: adapt for LLVM API change
LLVM commit 1d608fc755
renamed the pass.
2023-12-11 09:27:09 +00:00
Laurențiu Nicola
917be4c21a Merge commit '457b966b171b09a7e57acb710fbca29a4b3526f0' into sync-from-ra 2023-12-11 11:16:01 +02: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
Ben Kimock
79bdd24d6e Apply suggestions from code review
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-12-10 23:26:40 -05: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
Michael Howell
7162cb9550 rustdoc-search: fix fast path unboxing bindings 2023-12-10 20:53:53 -07: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
Michael Howell
92b84f849a rustdoc-search: do not treat associated type names as types
Before: http://notriddle.com/rustdoc-html-demo-6/tor-before/tor_config/

After: http://notriddle.com/rustdoc-html-demo-6/tor-after/tor_config/

Profile: http://notriddle.com/rustdoc-html-demo-6/tor-profile/

As a bit of background information: in type-based queries, a type
name that does not exist gets treated as a generic type variable.

This causes a counterintuitive behavior in the `tor_config` crate,
which has a trait with an associated type variable called `T`.

This isn't a searchable concrete type, but its name still gets stored
in the typeNameIdMap, as a convenient way to intern its name.
2023-12-10 16:52:21 -07: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
bors
457b966b17 Auto merge of #16039 - WaffleLapkin:don't-emit-missing-assoc-items-diagnostic-for-negative-impls, r=Veykril
fix: Don't emit "missing items" diagnostic for negative impls

Negative impls can't have items, so there is no reason for this diagnostic.

LMK if I should add a test somewhere. Also LMK if that's not how we usually check multiple things in an if in r-a.
2023-12-10 22:24:32 +00: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
Maybe Waffle
1630477985 fix: Don't emit "missing items" diagnostic for negative impls 2023-12-10 22:21:59 +00: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
Alex Saveau
af8dfde7f9
Remove an allocation in min_stack
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-12-10 13:28:59 -08: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
bors
4e814e3f24 Auto merge of #16078 - Veykril:fix-view-ir, r=Veykril
fix: Fix view mir, hir and eval function not working when cursor is inside macros

I broke the view ones completely by inverting the macro check by accident a few days ago but we don't talk about that.
2023-12-10 13:46:58 +00:00
Lukas Wirth
306c907425 fix: Fix view mir, hir and eval function not working when cursor is inside macros 2023-12-10 14:44:40 +01: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
Deadbeef
c4c35551d8 fix clippy 2023-12-10 13:10:46 +00: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
Deadbeef
de8f4acbf7 clean up leftover FIXME 2023-12-10 10:53:57 +00:00
Deadbeef
d464dd07ed fix tests 2023-12-10 10:42:34 +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