Commit Graph

253605 Commits

Author SHA1 Message Date
Matthias Krüger
aeb4c0413c
Rollup merge of #124394 - gurry:123863-ice-unexpected-region, r=lcnr
Fix ICE on invalid const param types

Fixes ICE #123863 which occurs because the const param has a type which is not a `bool`, `char` or an integral type.

The ICEing code path begins here in `typeck_with_fallback`: cb3752d20e/compiler/rustc_hir_typeck/src/lib.rs (L167)

The `fallback` invokes the `type_of` query and that eventually ends up calling `ct_infer` from the lowering code over here:
cb3752d20e/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs (L561) and `ct_infer` ICEs at this location: cb3752d20e/compiler/rustc_hir_analysis/src/collect.rs (L392)

To fix the ICE it I'm triggering a `span_delayed_bug` before we hit `ct_infer` if the type of the const param is not one of the supported types

### Edit
On `@lcnr's` suggestion I've changed the approach to not let `ReStatic` region hit the `bug!` in `ct_infer` instead of triggering a `span_delayed_bug`.
2024-04-27 20:46:08 +02:00
Matthias Krüger
52ce43e9ac
Rollup merge of #124370 - ShE3py:substitution-part-offset, r=fee1-dead
Fix substitution parts having a shifted underline in some cases

If two suggestions parts are side by side, the underline's offset:
(WIP PR as an example, not yet pushed)
```
error: expected a pattern, found an expression
 --> ./main.rs:4:9
  |
4 |         1 + 2 => 3
  |         ^^^^^ arbitrary expressions are not allowed in patterns
  |
help: check the value in an arm guard
  |
4 |         n if n == 1 + 2 => 3
  |         ~     +++++++++++++
```
The emitter didn't take into account that the string had shrunk/grown if two substitution parts were side-by-side (surprisingly, there was only one case in the ui testsuite.)

```
help: check the value in an arm guard
  |
4 |         n if n == 1 + 2 => 3
  |         ~ +++++++++++++
```

``@rustbot`` label +A-suggestion-diagnostics
2024-04-27 20:46:07 +02:00
bors
61a1dbd751 Auto merge of #124432 - zetanumbers:non_copy_into_raw_with_alloc, r=Nilstrieb
Relax `A: Clone` bound for `rc::Weak::into_raw_and_alloc`

Makes this method to behave the same way as [`Box::into_raw_with_allocator`](https://doc.rust-lang.org/1.77.2/alloc/boxed/struct.Box.html#method.into_raw_with_allocator) and [`Vec::into_raw_parts_with_alloc`](https://doc.rust-lang.org/1.77.2/alloc/vec/struct.Vec.html#method.into_raw_parts_with_alloc).

I have also noticed the inconsistent presence and naming, should probably be addressed in the future.
2024-04-27 13:41:45 +00:00
bors
261823eee7 Auto merge of #124430 - RalfJung:miri, r=RalfJung
Miri subtree update

r? `@ghost`
2024-04-27 09:32:46 +00:00
Daria Sukhonina
255a1e9554 Relax A: Clone bound for rc::Weak::into_raw_and_alloc 2024-04-27 12:21:23 +03:00
bors
35194e76b7 Auto merge of #124428 - matthiaskrgr:rollup-sk5z4z8, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #124382 (ast: Generalize item kind visiting)
 - #124387 (thread_local: be excruciatingly explicit in dtor code)
 - #124427 (Add missing tests for an ICE)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-27 07:28:53 +00:00
Matthias Krüger
9a6bfc7bfc
Rollup merge of #124427 - gurry:122191-unhandled-type, r=matthiaskrgr
Add missing tests for an ICE

Fixes #122191
2024-04-27 07:55:38 +02:00
Matthias Krüger
7c5213cf0a
Rollup merge of #124387 - workingjubilee:use-raw-pointers-in-thread-locals, r=joboet
thread_local: be excruciatingly explicit in dtor code

Use raw pointers to accomplish internal mutability, and clearly split references where applicable. This reduces the likelihood that any of these parts are misunderstood, either by humans or the compiler's optimizations.

Fixes #124317

r? ``@joboet``
2024-04-27 07:55:38 +02:00
Matthias Krüger
cf07246ae9
Rollup merge of #124382 - petrochenkov:itemvisit, r=lcnr
ast: Generalize item kind visiting

And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).

The diff is better viewed with whitespace ignored.
2024-04-27 07:55:37 +02:00
Gurinder Singh
fc73b4c344 Add missing tests for an ICE 2024-04-27 11:02:15 +05:30
Gurinder Singh
c62bc31b16 Fix ICE on invalid const param types 2024-04-27 09:36:38 +05:30
bors
9ac33d9c33 Auto merge of #124416 - weihanglo:update-cargo, r=weihanglo
Update cargo

9 commits in c9392675917adc2edab269eea27c222b5359c637..b60a1555155111e962018007a6d0ef85207db463
2024-04-23 19:35:19 +0000 to 2024-04-26 16:37:29 +0000
- fix(toml): Remove underscore field support in 2024 (rust-lang/cargo#13804)
- fix: emit 1.77 syntax error only when msrv is incompatible (rust-lang/cargo#13808)
- docs(ref): Index differences between virtual / real manifests (rust-lang/cargo#13794)
- refactor(toml): extract dependency-to-source-id to function (rust-lang/cargo#13802)
- Add where lint was set (rust-lang/cargo#13801)
- fix(toml): Don't double-warn when underscore is used in workspace dep (rust-lang/cargo#13800)
- fix(toml): Be more forceful with underscore/dash redundancy (rust-lang/cargo#13798)
- Fix warning suppression for config.toml vs config compat symlinks (rust-lang/cargo#13793)
- Cleanup linting system (rust-lang/cargo#13797)

r? ghost
2024-04-27 02:30:40 +00:00
Jubilee
c63b0ceb94
thread_local: refine LazyKeyInner::take safety doc
Co-authored-by: joboet <jonasboettiger@icloud.com>
2024-04-26 18:28:46 -07:00
bors
80d1c8349a Auto merge of #124424 - jhpratt:rollup-o3ngkjy, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - #124341 (resolve: Remove two cases of misleading macro call visiting)
 - #124383 (Port run-make `--print=native-static-libs` to rmake.rs)
 - #124391 (`rustc_builtin_macros` cleanups)
 - #124408 (crashes: add more tests)
 - #124410 (PathBuf: replace transmuting by accessor functions)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-27 00:26:48 +00:00
Jacob Pratt
7cbba53396
Rollup merge of #124410 - RalfJung:path-buf-transmute, r=Nilstrieb
PathBuf: replace transmuting by accessor functions

The existing `repr(transparent)` was anyway insufficient as `OsString` was not `repr(transparent)`. And furthermore, on Windows it was blatantly wrong as `OsString` wraps `Wtf8Buf` which is a `repr(Rust)` type with 2 fields:

51a7396ad3/library/std/src/sys_common/wtf8.rs (L131-L146)

So let's just be honest about what happens and add accessor methods that make this abstraction-breaking act of PathBuf visible on the APIs that it pierces through.

Fixes https://github.com/rust-lang/rust/issues/124409
2024-04-26 19:25:57 -04:00
Jacob Pratt
7cb7337c1b
Rollup merge of #124408 - matthiaskrgr:loltest, r=jieyouxu
crashes: add more tests
2024-04-26 19:25:56 -04:00
Jacob Pratt
608f71ec66
Rollup merge of #124391 - nnethercote:builtin_macros-cleanups, r=fee1-dead
`rustc_builtin_macros` cleanups

Some improvements I found while looking over this code.

r? ``@fee1-dead``
2024-04-26 19:25:55 -04:00
Jacob Pratt
c8beab7f46
Rollup merge of #124383 - Urgau:port-print-native-static-libs, r=jieyouxu
Port run-make `--print=native-static-libs` to rmake.rs

This PR port the run-make `--print=native-static-libs` test to rmake.rs

The dedup was really awful in the `Makefile`, I'm glad to finally have a proper dedup detection for this.

Related to https://github.com/rust-lang/rust/issues/121876

r? `@jieyouxu`
2024-04-26 19:25:55 -04:00
Jacob Pratt
645a4d34fb
Rollup merge of #124341 - petrochenkov:nomacvisit, r=compiler-errors
resolve: Remove two cases of misleading macro call visiting

Macro calls are ephemeral, they should not add anything to the definition tree, even if their AST could contains something with identity.
Thankfully, macro call AST cannot contain anything like that, so these walks are just noops.
In majority of other places in def_collector / build_reduced_graph they are already not visited.

(Also, a minor match reformatting is included.)
2024-04-26 19:25:54 -04:00
Urgau
7688f798d5 Also support MSVC in print-native-static-libs test 2024-04-27 00:26:06 +02:00
bors
aa6a8ee270 Auto merge of #124296 - cuviper:dist-cargo-tests, r=onur-ozkan
bootstrap: keep all cargo test files in dist rustc-src

Cargo tests use some files that we would otherwise exclude, especially
the `cargo init` tests that are meant to deal with pre-existing `.git`
and `.hg` repos and their ignore files. Keeping these in our dist
tarball doesn't take much space, and allows distro builds to run these
tests successfully.
2024-04-26 22:22:47 +00:00
bors
3a74fae72d Auto merge of #3517 - RalfJung:env-vars, r=RalfJung
env: split up Windows and Unix environment variable handling

On Windows, manage them entirely outside the AM state; this also means we no longer report any data races for environment variable memory.

Fixes https://github.com/rust-lang/rust/issues/124411
2024-04-26 20:17:35 +00:00
Ralf Jung
454f09d891 env: split up Windows and Unix environment variable handling 2024-04-26 22:16:16 +02:00
Weihang Lo
c5eda4199c
Update cargo 2024-04-26 13:53:34 -04:00
Ralf Jung
26af88aced add test for concurrent env var access 2024-04-26 19:47:35 +02:00
Urgau
74cbc09fc9 Port run-make --print=native-static-libs to rmake.rs 2024-04-26 19:45:45 +02:00
bors
4d570eea02 Auto merge of #123909 - dtolnay:utf8chunks, r=joboet
Stabilize `Utf8Chunks`

Pending FCP in https://github.com/rust-lang/rust/issues/99543.

This PR includes the proposed modification in https://github.com/rust-lang/libs-team/issues/190 as agreed in https://github.com/rust-lang/rust/issues/99543#issuecomment-2050406568.
2024-04-26 17:41:24 +00:00
Ralf Jung
c47978a241 PathBuf: replace transmuting by accessor functions 2024-04-26 18:09:09 +02:00
bors
d7c89cfbf8 Auto merge of #3516 - RalfJung:pathbuf, r=RalfJung
add smoke tests for basic PathBuf interactions

I wrote these while debugging [this](https://github.com/rust-lang/miri-test-libstd/actions/runs/8849912635/job/24302962983); it turns out the issue is [more complicated](https://github.com/rust-lang/rust/issues/124409) but these tests still seemed worth keeping.
2024-04-26 15:47:17 +00:00
Ralf Jung
2935cd93c2 add smoke tests for basic PathBuf interactions 2024-04-26 17:44:37 +02:00
bors
1b3a32958b Auto merge of #122385 - lcnr:analyze-obligations-for-infer, r=compiler-errors
`obligations_for_self_ty`: use `ProofTreeVisitor` for nested goals

As always, dealing with proof trees continues to be a hacked together mess. After this PR and #124380 the only remaining blocker for core is https://github.com/rust-lang/trait-system-refactor-initiative/issues/90. There is also a `ProofTreeVisitor` issue causing an ICE when compiling `alloc` which I will handle in a separate PR. This issue likely affects coherence diagnostics more generally.

The core idea is to extend the proof tree visitor to support visiting nested candidates without using a `probe`. We then simply recurse into nested candidates if they are the only potentially applicable candidate for a given goal and check whether the self type matches the expected one.

For that to work, we need to improve `CanonicalState` to also handle unconstrained inference variables created inside of the trait solver. This is done by extending the `var_values` of `CanoncalState` with each fresh inference variables. Furthermore, we also store the state of all inference variables at the end of each probe. When recursing into `InspectCandidates` we then unify the values of all these states.

r? `@compiler-errors`
2024-04-26 15:37:05 +00:00
Matthias Krüger
60c0fa1285 crashes: add more tests 2024-04-26 17:20:16 +02:00
bors
9adafa7f8d Auto merge of #124321 - JoverZhang:run-make-support-tests, r=onur-ozkan
Add support for run-make-support unit tests to be run with bootstrap

The `run-make-support` library needs to run its unit tests to ensure it is correct.

Close #124267
2024-04-26 13:22:13 +00:00
bors
5ff8fbb2d8 Auto merge of #124393 - scottmcm:do-the-macros-still-matter, r=joboet
Convert some iter macros to normal functions

With all the MIR optimization changes that have happened since these were written, let's see if they still actually matter.

\*perf comes back\*

Well, it looks like it's not longer relevant for instruction, cycle, nor wall-time perf.  Looks like a bunch of things are maybe 10kb bigger in debug, but some are also 50k *smaller* in debug.

So I think they should switch to being normal functions as the "greatly improves performance" justification for them being macros seems to no longer be true -- probably thanks to us always building `core` with `-Z inline-mir` so the difference is negligible.
2024-04-26 11:16:05 +00:00
Jover Zhang
c028782c67 Add support for run-make-support unit tests to be run with bootstrap command
Co-authored-by: Onur Özkan <onurozkan.dev@outlook.com>
2024-04-26 15:31:18 +08:00
bors
82921058e7 Auto merge of #3515 - rust-lang:rustup-2024-04-26, r=oli-obk
Automatic Rustup
2024-04-26 05:27:00 +00:00
Scott McMurray
cd47a0ed08 Convert some iter macros to normal functions
With all the MIR optimization changes that have happened since these were written, let's see if they still actually matter.
2024-04-25 22:16:02 -07:00
The Miri Cronjob Bot
4be9c689f6 Merge from rustc 2024-04-26 05:08:12 +00:00
The Miri Cronjob Bot
4dcc2fac06 Preparing for merge from rustc 2024-04-26 04:58:30 +00:00
Nicholas Nethercote
30d6f63b4e Adjust some pubs. 2024-04-26 13:29:20 +10:00
bors
6acb9e75eb Auto merge of #120845 - petrochenkov:debmac, r=oli-obk
debuginfo: Stabilize `-Z debug-macros`, `-Z collapse-macro-debuginfo` and `#[collapse_debuginfo]`

`-Z debug-macros` is "stabilized" by enabling it by default and removing.

`-Z collapse-macro-debuginfo` is stabilized as `-C collapse-macro-debuginfo`.
It now supports all typical boolean values (`parse_opt_bool`) in addition to just yes/no.

Default value of `collapse_debuginfo` was changed from `false` to `external` (i.e. collapsed if external, not collapsed if local) - https://github.com/rust-lang/rust/issues/100758#issuecomment-1935815625 describes some debugging scenarios that motivate this default as reasonable.
`#[collapse_debuginfo]` attribute without a value is no longer supported to avoid guessing the default.

Stabilization report: https://github.com/rust-lang/rust/pull/120845#issuecomment-1939145242

Closes https://github.com/rust-lang/rust/issues/100758
Closes https://github.com/rust-lang/rust/issues/41743
Closes https://github.com/rust-lang/rust/issues/39153
2024-04-26 02:13:08 +00:00
Vadim Petrochenkov
683ad6b607 Update lldb only tests 2024-04-26 04:11:05 +03:00
bors
e59f2c544a Auto merge of #124388 - compiler-errors:rollup-v17b8fm, r=compiler-errors
Rollup of 4 pull requests

Successful merges:

 - #124076 (Stablise io_error_downcast)
 - #124378 (Keep the LIB env var in the compiler-builtins test)
 - #124379 (Remove special-casing for `SimplifiedType` for next solver)
 - #124381 (Renamed `DerivedObligation` to `WellFormedDeriveObligation`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-26 00:10:56 +00:00
Michael Goulet
88eae31261
Rollup merge of #124381 - compiler-errors:derived-for-wf, r=lcnr
Renamed `DerivedObligation` to `WellFormedDeriveObligation`

It's used when computing `WellFormed` obligations, so let's give it a less ambiguous name.
2024-04-25 20:07:41 -04:00
Michael Goulet
4494140244
Rollup merge of #124379 - compiler-errors:remove-new-solver-lookup-behavior, r=lcnr
Remove special-casing for `SimplifiedType` for next solver

It's unnecessary due to the way that we fully normalize the self type before assembly begins.

r? lcnr
2024-04-25 20:07:41 -04:00
Michael Goulet
ef5e42af59
Rollup merge of #124378 - dpaoliello:keeplib, r=jieyouxu
Keep the LIB env var in the compiler-builtins test

The `tests/run-make/compiler-builtins` test was failing for me with Visual Studio 2022, complaining that it couldn't find `kernel32.lib`.

For whatever reason, with VS 2022 we need to keep the `LIB` environment variable when invoking Cargo so that the linker can find the Windows SDK libs.
2024-04-25 20:07:41 -04:00
Michael Goulet
6f5c69e65f
Rollup merge of #124076 - NobodyXu:patch-1, r=dtolnay
Stablise io_error_downcast

Tracking issue #99262
Closes #99262

FCP completed in https://github.com/rust-lang/rust/issues/99262#issuecomment-2077374397
2024-04-25 20:07:40 -04:00
Nicholas Nethercote
8dc84fa7d1 Move some functions from rustc_expand to rustc_builtin_macros.
These functions are only used in `rustc_builtin_macros`, so it makes
sense for them to live there. This allows them to be changed from `pub`
to `pub(crate)`.
2024-04-26 09:24:33 +10:00
Nicholas Nethercote
e2d2b1c698 Introduce DeriveResolution.
Making this a proper struct, and giving its fields names, makes things
easier to understand.
2024-04-26 07:55:21 +10:00
Michael Goulet
132f8ce3dc Renamed DerivedObligation to WellFormedDeriveObligation 2024-04-25 16:55:15 -04:00