Commit Graph

248121 Commits

Author SHA1 Message Date
clubby789
8e45d0fe49 Cancel parsing ever made during recovery 2024-03-06 21:59:03 +00:00
bors
bfe762e0ed Auto merge of #121967 - nikic:libllvm-linker-script, r=Mark-Simulacrum
Replace libLLVM symlink with linker script

It turns out that the libLLVM-N.so -> libLLVM.so.N.1 symlink is also needed when projects like miri link against librustc_driver.so. As such, we have to distribute it in real rustup components like rustc-dev, rather than only for download-ci-llvm.

To avoid actually distributing symlinks (which are not supported or not fully supported by the rustup infrastructure) replace it with a linker script that does the same thing instead.

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

r? `@cuviper`
2024-03-06 14:51:49 +00:00
bors
3314d5ce4c Auto merge of #121956 - ChrisDenton:srwlock, r=joboet
Windows: Implement condvar, mutex and rwlock using futex

Well, the Windows equivalent: [`WaitOnAddress`,](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitonaddress) [`WakeByAddressSingle`](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-wakebyaddresssingle) and [`WakeByAddressAll`](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-wakebyaddressall).

Note that Windows flavoured futexes can be different sizes (1, 2, 4 or 8 bytes). I took advantage of that in the `Mutex` implementation.

I also edited the Mutex implementation a bit more than necessary. I was having trouble keeping in my head what 0, 1 and 2 meant so I replaced them with consts.

I *think* we're maybe spinning a bit much. `WaitOnAddress` seems to be looping quite a bit too. But for now I've keep the implementations the same. I do wonder if it'd be worth reducing or removing our spinning on Windows.

This also adds a new shim to miri, because of course it does.

Fixes #121949
2024-03-06 12:19:40 +00:00
bors
09bc67b915 Auto merge of #121679 - lcnr:opaque-wf-check-2, r=oli-obk
stricter hidden type wf-check [based on #115008]

Original work by `@aliemjay` in #115008. A huge thanks to them for originally figuring out this approach ❤️

Fixes https://github.com/rust-lang/rust/issues/114728
Fixes https://github.com/rust-lang/rust/issues/114572

Instead of adding the `WellFormed` obligations when relating opaque types, we now always emit such an obligation when defining the hidden type.

This causes nested opaque types which aren't wf to error, see the comment below for the described impact. I believe this change to be desirable as it significantly reduces complexity by removing special-cases.

It also caused an issue with RPITIT: in defaulted trait methods, we add a `Projection(synthetic_assoc, rpit_of_trait_method)` clause to the `param_env`. This clause is not added to the `ParamEnv` of the nested coroutines. This caused a normalization failure in `fn check_coroutine_obligations` with the new solver. I fixed that by using the env of the typeck root instead.

r? `@oli-obk`
2024-03-06 10:04:26 +00:00
bors
80399064af Auto merge of #119455 - Mark-Simulacrum:relative-spans, r=cjgillot
Embed length of offset/position into Span tag byte

This cuts the average bytes/relative span from 3.5 to 3.2 on libcore, ultimately saving ~400kb of data.
2024-03-06 05:57:56 +00:00
bors
b77e0184a9 Auto merge of #122045 - matthiaskrgr:rollup-5l3vpn7, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #121065 (Add basic i18n guidance for `Display`)
 - #121744 (Stop using Bubble in coherence and instead emulate it with an intercrate check)
 - #121829 (Dummy tweaks (attempt 2))
 - #121857 (Implement async closure signature deduction)
 - #121894 (const_eval_select: make it safe but be careful with what we expose on stable for now)
 - #122014 (Change some attributes to only_local.)
 - #122016 (will_wake tests fail on Miri and that is expected)
 - #122018 (only set noalias on Box with the global allocator)
 - #122028 (Remove some dead code)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-06 02:18:22 +00:00
bors
62415e2a95 Auto merge of #122041 - matthiaskrgr:rollup-imsmdke, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #121202 (Limit the number of names and values in check-cfg diagnostics)
 - #121301 (errors: share `SilentEmitter` between rustc and rustfmt)
 - #121658 (Hint user to update nightly on ICEs produced from outdated nightly)
 - #121846 (only compare ambiguity item that have hard error)
 - #121961 (add test for #78894 #71450)
 - #121975 (hir_analysis: enums return `None` in `find_field`)
 - #121978 (Fix duplicated path in the "not found dylib" error)
 - #121991 (Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-06 00:03:50 +00:00
bors
b6d2d841bc Auto merge of #121576 - Jarcho:visitor3, r=oli-obk
Convert the rest of the visitors to use `VisitorResult`

Continuing from #121256.
2024-03-05 21:10:59 +00:00
Matthias Krüger
4f73d2a53c
Rollup merge of #122028 - oli-obk:drop_in_place_leftovers, r=compiler-errors
Remove some dead code

drop_in_place has been a lang item, not an intrinsic, for forever
2024-03-05 22:10:03 +01:00
Matthias Krüger
b08837f180
Rollup merge of #122018 - RalfJung:box-custom-alloc, r=oli-obk
only set noalias on Box with the global allocator

As discovered in https://github.com/rust-lang/miri/issues/3341, `noalias` and custom allocators don't go well together.

rustc can now check whether a Box uses the global allocator. This replaces the previous ad-hoc and rather unprincipled check for a zero-sized allocator.

This is the rustc part of fixing that; Miri will also need a patch.
2024-03-05 22:10:02 +01:00
Matthias Krüger
076043346d
Rollup merge of #122016 - RalfJung:will_wake, r=dtolnay
will_wake tests fail on Miri and that is expected

Follow-up to https://github.com/rust-lang/rust/pull/121622
r? ```@cuviper``` ```@dtolnay```
2024-03-05 22:10:02 +01:00
Matthias Krüger
c1bb406a21
Rollup merge of #122014 - surechen:change_attributes_to_local_20240304, r=lcnr
Change some attributes to only_local.

Modified according to https://github.com/rust-lang/compiler-team/issues/505.

r? ``@lcnr``
2024-03-05 22:10:01 +01:00
Matthias Krüger
327842b4ab
Rollup merge of #121894 - RalfJung:const_eval_select, r=oli-obk
const_eval_select: make it safe but be careful with what we expose on stable for now

As this is all still nightly-only I think `````@rust-lang/wg-const-eval````` can do that without involving t-lang.

r? `````@oli-obk`````
Cc `````@Nilstrieb````` -- the updated version of your RFC would basically say that we can remove these comments about not making behavior differences visible in stable `const fn`
2024-03-05 22:10:01 +01:00
Matthias Krüger
2875b10a7e
Rollup merge of #121857 - compiler-errors:async-closure-signature-deduction, r=oli-obk
Implement async closure signature deduction

Self-explanatory from title.

Regarding the interaction between signature deduction, fulfillment, and the new trait solver: I'm not worried about implementing closure signature deduction here because:

1. async closures are unstable, and
2. I'm reasonably confident we'll need to support signature deduction in the new solver somehow (i.e. via proof trees, which seem very promising).

This is in contrast to #109338, which was closed because it generalizes signature deduction for a *stable* kind of expression (`async {}` blocks and `Future` traits), and which proliferated usage may pose a stabilization hazard for the new solver.

I'll be certain to make sure sure we revisit the closure signature deduction problem by the time that async closures are being stabilized (which isn't particularly soon) (edit: Put it into the async closure tracking issue). cc `````@lcnr`````

r? `````@oli-obk`````
2024-03-05 22:10:00 +01:00
Matthias Krüger
0783a63d34
Rollup merge of #121829 - nnethercote:dummy-tweaks-2, r=petrochenkov
Dummy tweaks (attempt 2)

r? `````@petrochenkov`````
2024-03-05 22:10:00 +01:00
Matthias Krüger
e2e8405345
Rollup merge of #121744 - oli-obk:eager_opaque_checks2, r=lcnr
Stop using Bubble in coherence and instead emulate it with an intercrate check

r? `````@compiler-errors`````

This change is kinda funny, because all I've done is reimplement `Bubble` behaviour for coherence without using `Bubble` explicitly.
2024-03-05 22:09:59 +01:00
Matthias Krüger
49ff95d550
Rollup merge of #121065 - CAD97:display-i18n, r=cuviper
Add basic i18n guidance for `Display`

I've tried to be relatively noncommittal here. The part I think is most important is to mention the concept of "display adapters" *somewhere* in the `std::fmt` documentation that has some chance of being discovered when people go looking for ways to provide context when `Display`ing their type.

Rendered:

> ### Internationalization
>
> Because a type can only have one `Display` implementation, it is often preferable to only implement `Display` when there is a single most "obvious" way that values can be formatted as text. This could mean formatting according to the "invariant" culture and "undefined" locale, or it could mean that the type display is designed for a specific culture/locale, such as developer logs.
>
> If not all values have a justifiably canonical textual format or if you want to support alternative formats not covered by the standard set of possible [formatting traits], the most flexible approach is display adapters: methods like [`str::escape_default`] or [`Path::display`] which create a wrapper implementing `Display` to output the specific display format.
>
> [formatting traits]: https://doc.rust-lang.org/nightly/std/fmt/index.html#formatting-traits
> [`str::escape_default`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.escape_default
> [`Path::display`]: https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.display

The module docs do already have a [localization header](https://doc.rust-lang.org/nightly/std/fmt/index.html#localization), so maybe this header should be l10n instead of i18n, or maybe this information should live under that header? I'm not sure, but here on the `Display` trait at least isn't a *bad* spot to put it.

The other side of this that comes up a lot is `FromStr` compatibility, but that's for a different PR.
2024-03-05 22:09:59 +01:00
Chris Denton
cf83d83c77
Add Waitable trait 2024-03-05 20:48:48 +00:00
Matthias Krüger
3d6b3d0f59
Rollup merge of #121991 - oli-obk:merge_opaque_types_defined_by_queries, r=compiler-errors
Merge impl_trait_in_assoc_types_defined_by query back into `opaque_types_defined_by`

Instead, when we're collecting opaques for associated items, we choose the right collection mode depending on whether we're collecting for an associated item of a trait impl or not.

r? ```@compiler-errors```

follow up to https://github.com/rust-lang/rust/pull/121838
2024-03-05 19:53:23 +01:00
Matthias Krüger
f5ff6d5ae5
Rollup merge of #121978 - GuillaumeGomez:dylib-duplicated-path, r=bjorn3
Fix duplicated path in the "not found dylib" error

While working on the gcc backend, I couldn't figure out why I had this error:

```
error: couldn't load codegen backend /checkout/compiler/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so/checkout/compiler/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so: cannot open shared object file: No such file or directory
```

As you can see, the path is duplicated for some reason. After investigating a bit more, I realized that `libloading::Error::LoadLibraryExW` starts with the path of the not found dylib, making it appear twice in our error afterward (because we do render it like this: `{path}{err}`, and since the `err` starts with the path...).

Thanks to `````@bjorn3````` for linking me to https://github.com/rust-lang/rust/pull/121392. :)
2024-03-05 19:53:22 +01:00
Matthias Krüger
f560806ae0
Rollup merge of #121975 - davidtwco:issue-121757, r=petrochenkov
hir_analysis: enums return `None` in `find_field`

Fixes #121757.

Unnamed union fields with enums are checked for, but if `find_field` causes an ICE then the compiler won't get to that point.
2024-03-05 19:53:21 +01:00
Matthias Krüger
5cdf870502
Rollup merge of #121961 - surechen:add_test_20240304, r=petrochenkov
add test for #78894 #71450

fixes #78894
fixes #71450
2024-03-05 19:53:21 +01:00
Matthias Krüger
152b69054c
Rollup merge of #121846 - bvanjoi:fix-121760, r=petrochenkov
only compare ambiguity item that have hard error

Fixes #121760

An easy fix, r? ``@petrochenkov``
2024-03-05 19:53:20 +01:00
Matthias Krüger
1b30268e5b
Rollup merge of #121658 - jieyouxu:ice-outdated-nightly, r=oli-obk
Hint user to update nightly on ICEs produced from outdated nightly

This is a conservative best-effort approach to detect a potentially outdated nightly; it will fallback to the regular ICE-reporting if any of the following cases are true:
- Channel is not nightly
- Version information is not available
- Version date is not parseable as a YYYY-MM-DD or is missing
- System time is at least 36 hours ahead of the user's nightly release datetime.
- Any internal features are used.

Note that I'm not sure how to make a test for this: I tested this manually by `CFG_VER_DATE="2020-02-02" ./x build library --stage 1`, and also changing the channel detection in `rustc_driver_impl` from `Some("nightly")` to `Some("nightly" | "dev")`, and then running `rustc +stage1 test.rs -Ztreat-err-as-bug=1` with a non-existent `test.rs`.

<img width="1145" alt="Screenshot 2024-02-27 at 01 12 28" src="https://github.com/rust-lang/rust/assets/39484203/eff6af2e-4b19-4a70-af57-cd739ecf0e84">

Closes #118832.
2024-03-05 19:53:20 +01:00
Matthias Krüger
9153451a91
Rollup merge of #121301 - davidtwco:rustfmt-silent-emitter, r=pnkfelix
errors: share `SilentEmitter` between rustc and rustfmt

Fixes rust-lang/rustfmt#6082.

Shares the `SilentEmitter` between rustc and rustfmt, and gives it a fallback bundle (since it can emit diagnostics in some contexts).
2024-03-05 19:53:18 +01:00
Matthias Krüger
640648b893
Rollup merge of #121202 - Urgau:check-cfg-limit-diagnostics, r=pnkfelix
Limit the number of names and values in check-cfg diagnostics

The Rust for Linux [feedback](https://github.com/rust-lang/rust/issues/82450#issuecomment-1947462977) to the check-cfg Call for Testing, revealed a weakness in the check-cfg. They are unbounded and in the case RfL they have ~20k cfgs and having them printed (even once) is unbearable.

This PR limits it to 35 (28 rustc well known + `feature` + `docsrs` + 5 custom) which feels like a good middle ground for regular users (i.e. Cargo users).

When it goes over that limit print the N first with " and X more".

``@rustbot`` label +F-check-cfg
2024-03-05 19:53:18 +01:00
bors
3c029725f5 Auto merge of #121905 - Nilstrieb:add-empty-targets, r=davidtwco
Add a `description` field to target definitions

Starts addressing https://github.com/rust-lang/rust/pull/121051#pullrequestreview-1890562844

This is the short description (`64-bit MinGW (Windows 7+)`) including the platform requirements.

The reason for doing it like this is that this PR will be quite prone to conflicts whenever targets get added, so it should be as simple as possible to get it merged. Future PRs which migrate targets are scoped to groups of targets, so they will not conflict as they can just touch these.

This moves some of the information from the rustc book into the compiler.
It cannot be queried yet, that is future work. It is also future work to fill out all the descriptions, which will coincide with the work of moving over existing target docs to the new format.

r? `@davidtwco` but anyone is also free to steal it
2024-03-05 18:44:38 +00:00
Jason Newcomb
228eb38c69 Convert ProofTreeVisitor to use VisitorResult 2024-03-05 13:30:49 -05:00
Jason Newcomb
ea9ae30671 Convert SpannedTypeVisitor to use VisitorResult 2024-03-05 13:30:46 -05:00
Jason Newcomb
be9b125d41 Convert TypeVisitor and DefIdVisitor to use VisitorResult 2024-03-05 13:28:15 -05:00
Jason Newcomb
5abfb3775d Move visitor utils to rustc_ast_ir 2024-03-05 12:38:03 -05:00
Oli Scherer
da357346e8 Merge impl_trait_in_assoc_types_defined_by query back into opaque_types_defined_by
Instead, when we're collecting opaques for associated items, we choose the right collection mode depending on whether we're collecting for an associated item of a trait impl or not.
2024-03-05 16:07:25 +00:00
Oli Scherer
5a16aebe9d Remove some dead code
drop_in_place has been a lang item, not an intrinsic, for forever
2024-03-05 16:01:15 +00:00
Nilstrieb
1db67fb854 Add a description field to target definitions
This is the short description (`64-bit MinGW (Windows 7+)`) including
the platform requirements.

The reason for doing it like this is that this PR will be quite prone to
conflicts whenever targets get added, so it should be as simple as
possible to get it merged. Future PRs which migrate targets are scoped
to groups of targets, so they will not conflict as they can just touch
these.

This moves some of the information from the rustc book into the
compiler.
It cannot be queried yet, that is future work. It is also future work to
fill out all the descriptions, which will coincide with the work of
moving over existing target docs to the new format.
2024-03-05 15:42:10 +00:00
bors
96561a8fd1 Auto merge of #121428 - okaneco:ipaddr_parse, r=cuviper
net: Don't use checked arithmetic when parsing numbers with known max digits

Add a branch to `Parser::read_number` that determines whether checked or regular arithmetic is used.

- If `max_digits.is_some()`, then we know we are parsing a `u8` or `u16` because `read_number` is only called with `Some(3)` or `Some(4)`. Both types fit within a `u32` without risk of overflow. Thus, we can use plain arithmetic to avoid extra instructions from `checked_mul` and `checked_add`.

Add benches for `IpAddr`, `Ipv4Addr`, `Ipv6Addr`, `SocketAddr`, `SocketAddrV4`, and `SocketAddrV6` parsing
2024-03-05 15:29:19 +00:00
Ralf Jung
f391c0793b only set noalias on Box with the global allocator 2024-03-05 15:03:33 +01:00
bors
c7beecf3e3 Auto merge of #121992 - jieyouxu:fix-tidy-unpaired-revision, r=onur-ozkan
tidy: split dots in filename not the entire path when checking for stray stdout/stderr files

I committed a path crime by splitting the entire path on `.`, when I meant to split on the filename. This means that any parent folders which contain `.` will cause tidy failure. Added a regression test so that doesn't happen again.

### Follow-up

- [ ] Adjust rustc-dev-guide to document assert on test name not containing dots. https://github.com/rust-lang/rustc-dev-guide/pull/1927

Fixes #121986.
2024-03-05 13:02:42 +00:00
surechen
8dd126d847 Change some attributes to only_local.
Modified according to https://github.com/rust-lang/compiler-team/issues/505.
2024-03-05 18:31:11 +08:00
bors
bdde2a80ae Auto merge of #121138 - Swatinem:grapheme-extend-ascii, r=cuviper
Add ASCII fast-path for `char::is_grapheme_extended`

I discovered that `impl Debug for str` is quite slow because it ends up doing a `unicode_data::grapheme_extend::lookup` for each char, which ends up doing a binary search.

This introduces a fast-path for ASCII chars which do not have this property.

The `lookup` is thus completely gone from profiles.

---

As a followup, maybe it’s worth implementing this fast path directly in `unicode_data` so that it can check for the lower bound directly before going to a potentially expensive binary search.
2024-03-05 10:28:55 +00:00
David Wood
2ee0409f32
errors: share SilentEmitter between rustc and rustfmt
Signed-off-by: David Wood <david@davidtw.co>
2024-03-05 10:14:36 +00:00
许杰友 Jieyou Xu (Joe)
247a080b98
Update test names to not have dots 2024-03-05 09:02:33 +00:00
Ralf Jung
960dd38abe will_wake tests fail on Miri and that is expected 2024-03-05 09:33:55 +01:00
许杰友 Jieyou Xu (Joe)
53f48ddbc7
Assert that test names cannot contain dots
This is so that we can catch stray test output files, since test names
without dots can form predictable patterns we can match on.
2024-03-05 08:11:27 +00:00
bors
41d97c8a5d Auto merge of #122012 - matthiaskrgr:rollup-bzqjj2n, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #121213 (Add an example to demonstrate how Rc::into_inner works)
 - #121262 (Add vector time complexity)
 - #121287 (Clarify/add `must_use` message for Rc/Arc/Weak::into_raw.)
 - #121664 (Adjust error `yield`/`await` lowering)
 - #121826 (Use root obligation on E0277 for some cases)
 - #121838 (Use the correct logic for nested impl trait in assoc types)
 - #121913 (Don't panic when waiting on poisoned queries)
 - #121987 (pattern analysis: abort on arity mismatch)
 - #121993 (Avoid using unnecessary queries when printing the query stack in panics)
 - #121997 (interpret/cast: make more matches on FloatTy properly exhaustive)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-05 08:02:07 +00:00
Urgau
9d9b26bca9 Limit the number of names and values in check-cfg diagnostics 2024-03-05 07:54:04 +01:00
Oli Scherer
c98be3254f Stop using Bubble in coherence and instead emulate it with an intercrate check 2024-03-05 05:52:34 +00:00
Matthias Krüger
92ff43d87b
Rollup merge of #121997 - RalfJung:cast-float-ty, r=compiler-errors
interpret/cast: make more matches on FloatTy properly exhaustive

Actually implementing these is pretty trivial (at least once all the scalar methods are added, which happens in https://github.com/rust-lang/rust/pull/121926), but I'm staying consistent with the other f16/f128 PRs. Also adding adding all the tests to Miri would be quite a lot of work.

There's probably some way to reduce the code duplication here with more use of generics... but that's a future refactor.^^

r? ```@tgross35```
2024-03-05 06:40:33 +01:00
Matthias Krüger
87dc3fc950
Rollup merge of #121993 - Zoxc:query-stack-panic-queries, r=compiler-errors
Avoid using unnecessary queries when printing the query stack in panics

This should fix https://github.com/rust-lang/rust/issues/121974. Alternative to https://github.com/rust-lang/rust/pull/121981.
2024-03-05 06:40:33 +01:00
Matthias Krüger
44bd2b5166
Rollup merge of #121987 - Nadrieril:abort-on-arity-mismatch, r=compiler-errors
pattern analysis: abort on arity mismatch

This is one more PR replacing panics by `Err()` aborts. I recently audited all the `unwrap()` calls, but I had forgotten about array accesses. (Again [discovered by rust-analyzer](https://github.com/rust-lang/rust-analyzer/issues/16746)).

r? ```@compiler-errors```
2024-03-05 06:40:33 +01:00
Matthias Krüger
c483e637f3
Rollup merge of #121913 - Zoxc:query-fix, r=compiler-errors
Don't panic when waiting on poisoned queries

This fixes a bug introduced in https://github.com/rust-lang/rust/pull/119086.
2024-03-05 06:40:32 +01:00