Commit Graph

264036 Commits

Author SHA1 Message Date
Matthias Krüger
d24e6b7e61
Rollup merge of #129387 - Zalathar:python-apologia, r=jieyouxu
Advise against removing the remaining Python scripts from `tests/run-make`

After some recent PRs (e.g. #129185), there are only two Python scripts left in `tests/run-make`.

Having come so far, it's tempting to try to get rid of the remaining ones. But after trying that myself, I've come to the conclusion that it's not worth the extra hassle, especially if it means pulling in an XML-parsing crate just for one test.

This PR therefore leaves behind a few signpost comments to explain why getting rid of these particular scripts has low value.
2024-08-22 08:17:22 +02:00
Matthias Krüger
28d4b8248e
Rollup merge of #129382 - tgross35:once-cell-const-into-inner, r=Noratrieb
Add `const_cell_into_inner` to `OnceCell`

`Cell` and `RefCell` have their `into_inner` methods const unstable. `OnceCell` has the same logic, so add it under the same gate.

Tracking issue: https://github.com/rust-lang/rust/issues/78729
2024-08-22 08:17:22 +02:00
Matthias Krüger
ae58bbfbce
Rollup merge of #129376 - ChaiTRex:assert_unsafe_precondition_check_language_ub, r=workingjubilee,the8472
Change `assert_unsafe_precondition` docs to refer to `check_language_ub`
2024-08-22 08:17:21 +02:00
Matthias Krüger
e7df7ba1e4
Rollup merge of #129374 - ChaiTRex:digit_unchecked_assert_unsafe_precondition, r=scottmcm
Use `assert_unsafe_precondition!` in `AsciiChar::digit_unchecked`
2024-08-22 08:17:20 +02:00
Matthias Krüger
8f2c4d18e1
Rollup merge of #129373 - samitolvanen:cfi-module-flags, r=compiler-errors
Add missing module flags for CFI and KCFI sanitizers

Set the cfi-normalize-integers and kcfi-offset module flags when Control-Flow Integrity sanitizers are used, so functions generated by the LLVM backend use the same CFI/KCFI options as rustc.

cfi-normalize-integers tells LLVM to also use integer normalization for generated functions when -Zsanitizer-cfi-normalize-integers is used.

kcfi-offset specifies the number of prefix nops between the KCFI type hash and the function entry when -Z patchable-function-entry is used. Note that LLVM assumes all indirectly callable functions use the same number of prefix NOPs with -Zsanitizer=kcfi.
2024-08-22 08:17:20 +02:00
Matthias Krüger
a8d5c6d151
Rollup merge of #128432 - g0djan:godjan/wasi_prohibit_implicit_unsafe, r=tgross35
WASI: forbid `unsafe_op_in_unsafe_fn` for `std::{os, sys}`

Part of https://github.com/rust-lang/rust/issues/127747 for WASI

try-job: test-various
2024-08-22 08:17:19 +02:00
Zalathar
34cdfc9b49 Advise against removing run-make/libtest-junit/validate_junit.py
Trying to get rid of this Python script looks tempting, because it's currently
the only Python script in the whole `run-make` suite that we actually run.

But getting rid of it would require pulling in a Rust crate to parse XML
instead, and that's probably not worth the extra hassle for a relatively-minor
test.
2024-08-22 12:13:25 +10:00
Zalathar
5fc562c5b1 Rename foo.py to my_gdb_script.py
This makes it easier for maintainers to see what the Python script is for.
2024-08-22 11:52:21 +10:00
Zalathar
7232a07f5a Explain the run-make/debugger-visualizer-dep-info Python script 2024-08-22 11:51:02 +10:00
Trevor Gross
81c00dde2b Add const_cell_into_inner to OnceCell
`Cell` and `RefCell` have their `into_inner` methods const unstable.
`OnceCell` has the same logic, so add it under the same gate.

Tracking issue: https://github.com/rust-lang/rust/issues/78729
2024-08-21 17:36:05 -05:00
Chai T. Rex
c836739529 Change assert_unsafe_precondition docs to refer to check_language_ub 2024-08-21 17:35:54 -04:00
bors
a32d4a0e82 Auto merge of #129370 - matthiaskrgr:rollup-g9117ee, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #128727 (bump conflicting_repr_hints lint to be shown in dependencies)
 - #129232 (Fix `thread::sleep` Duration-handling for ESP-IDF)
 - #129321 (Change neutral element of <fNN as iter::Sum> to neg_zero)
 - #129353 (llvm-wrapper: adapt for LLVM 20 API changes)
 - #129363 (Force `LC_ALL=C` for all run-make tests)
 - #129364 (safe transmute: gracefully bubble-up layout errors)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-21 21:33:31 +00:00
Chai T. Rex
191862d701 Use assert_unsafe_precondition! in AsciiChar::digit_unchecked 2024-08-21 16:26:35 -04:00
Sami Tolvanen
40f1d9d154 Add missing module flags for CFI and KCFI sanitizers
Set the cfi-normalize-integers and kcfi-offset module flags when
Control-Flow Integrity sanitizers are used, so functions generated by
the LLVM backend use the same CFI/KCFI options as rustc.

cfi-normalize-integers tells LLVM to also use integer normalization
for generated functions when -Zsanitizer-cfi-normalize-integers is
used.

kcfi-offset specifies the number of prefix nops between the KCFI
type hash and the function entry when -Z patchable-function-entry is
used. Note that LLVM assumes all indirectly callable functions use the
same number of prefix NOPs with -Zsanitizer=kcfi.
2024-08-21 20:23:56 +00:00
Matthias Krüger
00e109f3d4
Rollup merge of #129364 - jswrenn:transmute-layout-errs, r=compiler-errors
safe transmute: gracefully bubble-up layout errors

Changes `.unwrap()`s to `?` to avoid ICEs. Adds ui tests.

Fixes #129327

Tracking Issue: https://github.com/rust-lang/rust/issues/99571

r​? `@compiler-errors`
2024-08-21 21:58:29 +02:00
Matthias Krüger
92f0b7edeb
Rollup merge of #129363 - Urgau:run-make-lc_all-c, r=jieyouxu
Force `LC_ALL=C` for all run-make tests

This PR adds `LC_ALL=C` for all run-make tests so that they become locale independent.

Fixes #129362
r? `@jieyouxu`
2024-08-21 21:58:29 +02:00
Matthias Krüger
cdec9a0417
Rollup merge of #129353 - krasimirgg:llvm20key, r=nikic
llvm-wrapper: adapt for LLVM 20 API changes

No functional changes intended.

Adapts llvm-wrapper for the LLVM commits 0f22d47a7a and d6d8243dcd.

`@rustbot` label: +llvm-main
r? `@nikic`
2024-08-21 21:58:28 +02:00
Matthias Krüger
3fb8faa653
Rollup merge of #129321 - krtab:float_sum, r=workingjubilee
Change neutral element of <fNN as iter::Sum> to neg_zero

The neutral element used to be positive zero, but +0 + -0 = +0 so -0 seems better indicated.
2024-08-21 21:58:28 +02:00
Matthias Krüger
94b3953853
Rollup merge of #129232 - ivmarkov:master, r=workingjubilee
Fix `thread::sleep` Duration-handling for ESP-IDF

Addresses the ESP-IDF specific aspect of https://github.com/rust-lang/rust/issues/129212

#### A short summary of the problems addressed by this PR:
================================================

1. **Problem 1** - the current implementation of `std:🧵:sleep` does not properly round up the passed `Duration`

As per the documentation of `std:🧵:sleep`, the implementation should sleep _at least_ for the provided duration, but not less. Since the minimum supported resolution of the `usleep` syscall which is used with ESP-IDF is one microsecond, this means that we need to round-up any sub-microsecond nanos to one microsecond. Moreover, in the edge case where the user had passed a duration of < 1000 nanos (i.e. less than one microsecond), the current implementation will _not_ sleep _at all_.

This is addressed by this PR.

2. **Problem 2** - the implementation of `usleep` on the ESP-IDF can overflow if the passed number of microseconds is >= `u32::MAX - 1_000_000`

This is also addressed by this PR.

Extra details for Problem 2:

`u32::MAX - 1_000_000` is chosen to accommodate for the longest possible systick on the ESP IDF which is 1000ms.

The systick duration is selected when compiling the ESP IDF FreeRTOS task scheduler itself, so we can't know it from within `STD`. The default systick duration is 10ms, and might be lowered down to 1ms. (Making it longer I have never seen, but in theory it can go up to a 1000ms max, even if obviously a one second systick is unrealistic - but we are paranoid in the PR.)

While the overflow is reported upstream in the ESP IDF repo[^1], I still believe we should workaround it in the Rust wrappers as well, because it might take time until it is fixed, and they might not fix it for all released ESP IDF versions.

For big durations, rather than calling `usleep` repeatedly on the ESP-IDF in chunks of `u32::MAX - 1_000_000`us, it might make sense to call instead with 1_000_000us (one second) as this is the max period that seems to be agreed upon as a safe max period in the `usleep` POSIX spec. On the other hand, that might introduce less precision (as we need to call more times `usleep` in a loop) and, we would be fighting a theoretical problem only, as I have big doubts the ESP IDF will stop supporting durations higher than 1_000_000us - ever - because of backwards compatibility with code which already calls `usleep` on the ESP IDF with bigger durations.

[^1]: https://github.com/espressif/esp-idf/issues/14390
2024-08-21 21:58:28 +02:00
Matthias Krüger
5a93c74a02
Rollup merge of #128727 - RalfJung:conflicting-repr-future-incompat, r=lcnr
bump conflicting_repr_hints lint to be shown in dependencies

This has been a future compatibility lint for years, let's bump it up to be shown in dependencies (so that hopefully we can then make it a hard error fairly soon).

Cc https://github.com/rust-lang/rust/issues/68585
2024-08-21 21:58:27 +02:00
Jack Wrenn
e2328ebd7f safe transmute: gracefully bubble-up layout errors
Changes `.unwrap()`s to `?` to avoid ICEs. Adds ui tests.

Fixes #129327
2024-08-21 18:06:02 +00:00
bors
6b678c57b6 Auto merge of #129359 - matthiaskrgr:rollup-nyre44t, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #128627 (Special case DUMMY_SP to emit line 0/column 0 locations on DWARF platforms.)
 - #128843 (Minor Refactor: Remove a Redundant Conditional Check)
 - #129179 (CFI: Erase regions when projecting ADT to its transparent non-1zst field)
 - #129281 (Tweak unreachable lint wording)
 - #129312 (Fix stability attribute of `impl !Error for &str`)
 - #129332 (Avoid extra `cast()`s after `CStr::as_ptr()`)
 - #129339 (Make `ArgAbi::make_indirect_force` more specific)
 - #129344 (Use `bool` in favor of `Option<()>` for diagnostics)
 - #129345 (Use shorthand field initialization syntax more aggressively in the compiler)
 - #129355 (fix comment on PlaceMention semantics)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-21 17:18:07 +00:00
Urgau
b6909ce61e Force LC_ALL=C for all run-make tests 2024-08-21 19:09:25 +02:00
Krasimir Georgiev
b509b4226b llvm-wrapper: adapt for LLVM 20 API changes
No functional changes intended.

Adapts llvm-wrapper for the LLVM commits 0f22d47a7a and d6d8243dcd.
2024-08-21 16:27:31 +00:00
Matthias Krüger
9fd2832a7e
Rollup merge of #129355 - RalfJung:PlaceMention, r=compiler-errors
fix comment on PlaceMention semantics

It seems this was simply missed in https://github.com/rust-lang/rust/pull/114330.
2024-08-21 18:15:06 +02:00
Matthias Krüger
4137f3bc15
Rollup merge of #129345 - compiler-errors:scratch4, r=jieyouxu
Use shorthand field initialization syntax more aggressively in the compiler

Caught these when cleaning up #129344 and decided to run clippy to find the rest
2024-08-21 18:15:06 +02:00
Matthias Krüger
937a18daf9
Rollup merge of #129344 - compiler-errors:less-option-unit-diagnostics, r=jieyouxu
Use `bool` in favor of `Option<()>` for diagnostics

We originally only supported `Option<()>` for optional notes/labels, but we now support `bool`. Let's use that, since it usually leads to more readable code.

I'm not removing the support from the derive macro, though I guess we could error on it... 🤔
2024-08-21 18:15:05 +02:00
Matthias Krüger
be80216d2c
Rollup merge of #129339 - beetrees:make-indirect-from-ignore, r=RalfJung
Make `ArgAbi::make_indirect_force` more specific

As the method is only needed for making ignored ZSTs indirect on some ABIs, rename and add a doc-comment and `self.mode` check to make it harder to accidentally misuse. Addresses review feedback from https://github.com/rust-lang/rust/pull/125854#discussion_r1721047899.

r? ``@RalfJung``
2024-08-21 18:15:04 +02:00
Matthias Krüger
e961d6b204
Rollup merge of #129332 - cuviper:cstr-cast, r=compiler-errors
Avoid extra `cast()`s after `CStr::as_ptr()`

These used to be `&str` literals that did need a pointer cast, but that
became a no-op after switching to `c""` literals in #118566.
2024-08-21 18:15:04 +02:00
Matthias Krüger
349f29992b
Rollup merge of #129312 - tbu-:pr_str_not_impl_error, r=Noratrieb
Fix stability attribute of `impl !Error for &str`

It was introduced in bf7611d55e (#99917), which was included in Rust 1.65.0.
2024-08-21 18:15:03 +02:00
Matthias Krüger
9bb17d345a
Rollup merge of #129281 - Nadrieril:tweak-unreachable-lint-wording, r=estebank
Tweak unreachable lint wording

Some tweaks to the notes added in https://github.com/rust-lang/rust/pull/128034.

r? `@estebank`
2024-08-21 18:15:03 +02:00
Matthias Krüger
7da4b2d82a
Rollup merge of #129179 - compiler-errors:cfi-erase-transparent, r=davidtwco
CFI: Erase regions when projecting ADT to its transparent non-1zst field

The output from `FieldDef::ty` (or `TyCtxt::type_of`) may have free regions (well, `'static`) -- erase it.

Fixes #129169
Fixes #123685
2024-08-21 18:15:02 +02:00
Matthias Krüger
48c9864a05
Rollup merge of #128843 - veera-sivarajan:small-cleanup, r=davidtwco
Minor Refactor: Remove a Redundant Conditional Check

The existing code checks `where_bounds.is_empty()` twice when
it can be combined into one. Now, after combining, the refactored code reads
better and feels straightforward.

The diff doesn't make it clear. So, the current code looks like this:
``` rust
    if !where_bounds.is_empty() {
        err.help(format!(
            "consider introducing a new type parameter `T` and adding `where` constraints:\
             \n    where\n        T: {qself_str},\n{}",
            where_bounds.join(",\n"),
        ));
    }
    let reported = err.emit();
    if !where_bounds.is_empty() {
        return Err(reported);
    }
```
The proposed changes:
``` rust
    if !where_bounds.is_empty() {
        err.help(format!(
            "consider introducing a new type parameter `T` and adding `where` constraints:\
             \n    where\n        T: {qself_str},\n{}",
            where_bounds.join(",\n"),
        ));
        let reported = err.emit();
        return Err(reported);
    }
    err.emit();

```
2024-08-21 18:15:01 +02:00
Matthias Krüger
dea325e583
Rollup merge of #128627 - khuey:DUMMY_SP-line-no, r=nnethercote
Special case DUMMY_SP to emit line 0/column 0 locations on DWARF platforms.

Line 0 has a special meaning in DWARF. From the version 5 spec:

    The compiler may emit the value 0 in cases
    where an instruction cannot be attributed to any
    source line.

DUMMY_SP spans cannot be attributed to any line. However, because rustc internally stores line numbers starting at zero, lookup_debug_loc() adjusts every line number by one. Special casing DUMMY_SP to actually emit line 0 ensures rustc communicates to the debugger that there's no meaningful source code for this instruction, rather than telling the debugger to jump to line 1 randomly.
2024-08-21 18:15:01 +02:00
Tobias Bucher
123bb585f8 Fix stability attribute of impl !Error for &str
It was introduced in bf7611d55e (#99917),
which was included in Rust 1.65.0.
2024-08-21 16:21:40 +02:00
Ralf Jung
9010708d9f fix comment on PlaceMention semantics 2024-08-21 15:52:06 +02:00
bors
982c6f8721 Auto merge of #126556 - saethlin:layout-precondition, r=joboet
Add a precondition check for Layout::from_size_align_unchecked

Ran into this while looking into https://github.com/rust-lang/miri/issues/3679. This is of course not the cause of the ICE, but the reproducer doesn't encounter a precondition check and it ought to.
2024-08-21 12:50:05 +00:00
bors
59a74db37d Auto merge of #128866 - scottmcm:update-stdarch, r=tgross35
Update stdarch submodule

To pick up https://github.com/rust-lang/stdarch/pull/1624 and unblock removing support for non-array-based-simd (https://github.com/rust-lang/compiler-team/issues/621).
2024-08-21 08:18:36 +00:00
Scott McMurray
210f603651 Update stdarch submodule 2024-08-21 00:20:27 -07:00
bors
4d7c095832 Auto merge of #129331 - matthiaskrgr:rollup-rxv463w, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #128662 (Lint on tail expr drop order change in Edition 2024)
 - #128932 (skip updating when external binding is existed)
 - #129270 (Don't consider locals to shadow inner items' generics)
 - #129277 (Update annotate-snippets to 0.11)
 - #129294 (Stabilize `iter::repeat_n`)
 - #129308 (fix: simple typo in compiler directory)
 - #129309 (ctfe: make CompileTimeInterpCx type alias public)
 - #129314 (fix a broken link in `mir/mod.rs`)
 - #129318 (Remove unneeded conversion to `DefId` for `ExtraInfo`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-21 05:40:46 +00:00
Michael Goulet
0b2525c787 Simplify some redundant field names 2024-08-21 01:31:42 -04:00
Michael Goulet
25ff9b6bcb Use bool in favor of Option<()> for diagnostics 2024-08-21 01:31:11 -04:00
beetrees
0f5c6eaccc
Make ArgAbi::make_indirect_force more specific 2024-08-21 02:43:12 +01:00
Ben Kimock
e6b0f27e00 Try to golf down the amount of code in Layout 2024-08-20 18:41:07 -04:00
Josh Stone
e424e7fcaa Avoid extra cast()s after CStr::as_ptr()
These used to be `&str` literals that did need a pointer cast, but that
became a no-op after switching to `c""` literals in #118566.
2024-08-20 14:04:48 -07:00
bors
5aea14073e Auto merge of #128252 - EtomicBomb:pre-rfc, r=notriddle
modularize rustdoc's write_shared

Refactor src/librustdoc/html/render/write_shared.rs to reduce code duplication, adding unit tests

* Extract + unit test code for sorting and rendering JSON, which is duplicated 9 times in the current impl
* Extract + unit test code for encoding JSON as single quoted strings, which is duplicated twice in the current impl
* Unit tests for cross-crate information file formats
* Generic interface to add new kinds of cross-crate information files in the future
* Intended to match current behavior exactly, except for a merge info comment it adds to the bottom of cci files
* This PR is intended to reduce the review burden from my [mergeable rustdoc rfc](https://github.com/rust-lang/rfcs/pull/3662) implementation PR, which is a [small commit based on this branch](https://github.com/EtomicBomb/rust/tree/rfc). This code is agnostic to the RFC and does not include any of the flags discussed there, but cleanly enables the addition of these flags in the future because it is more modular
2024-08-20 20:23:29 +00:00
Matthias Krüger
f6312870a5
Rollup merge of #129318 - GuillaumeGomez:rm-unneeded-defid-conversion, r=notriddle
Remove unneeded conversion to `DefId` for `ExtraInfo`

I'm working on adding support for "unit test doctests" and this first cleanup came up so just sending it ahead of the rest.

r? ``@notriddle``
2024-08-20 22:22:00 +02:00
Matthias Krüger
71df480bcb
Rollup merge of #129314 - kyoto7250:fix_link_in_mir_mod, r=compiler-errors
fix a broken link in `mir/mod.rs`

I discovered that the internal link in mir/mod.rs is broken, so I will fix it. The AddCallGuards is now located under rustc_mir_transform.

The PR at that time is as follows.
c5fc2609f0
2024-08-20 22:21:59 +02:00
Matthias Krüger
b1f19caa59
Rollup merge of #129309 - RalfJung:CompileTimeInterpCx, r=compiler-errors
ctfe: make CompileTimeInterpCx type alias public

`CompileTimeMachine` is already public so there is no good reason to not also make this public.

Also add comment explaining why `CompileTimeMachine` is public.
2024-08-20 22:21:59 +02:00
Matthias Krüger
ef9fba2232
Rollup merge of #129308 - c8ef:typo, r=jieyouxu
fix: simple typo in compiler directory
2024-08-20 22:21:58 +02:00