Commit Graph

269283 Commits

Author SHA1 Message Date
Matthias Krüger
93bf791e8b
Rollup merge of #129248 - compiler-errors:raw-ref-deref, r=nnethercote
Taking a raw ref (`&raw (const|mut)`) of a deref of pointer (`*ptr`) is always safe

T-opsem decided in https://github.com/rust-lang/reference/pull/1387 that `*ptr` is only unsafe if the place is accessed. This means that taking a raw ref of a deref expr is always safe, since it doesn't constitute a read.

This also relaxes the `DEREF_NULLPTR` lint to stop warning in the case of raw ref of a deref'd nullptr, and updates its docs to reflect that change in the UB specification.

This does not change the behavior of `addr_of!((*ptr).field)`, since field projections still require the projection is in-bounds.

I'm on the fence whether this requires an FCP, since it's something that is guaranteed by the reference you could ostensibly call this a bugfix since we were counting truly safe operations as unsafe. Perhaps someone on opsem has a strong opinion? cc `@rust-lang/opsem`
2024-10-24 10:35:39 +02:00
Ralf Jung
282f291b7d rustc_feature::Features: explain what that 'Option<Symbol>' is about 2024-10-24 08:15:28 +02:00
David
33941d3ba5
sanitizer.md: LeakSanitizer is not supported on aarch64 macOS 2024-10-24 11:42:11 +05:30
Zalathar
3dfc352145 Replace an FTP link in comments with an equivalent HTTPS link 2024-10-24 17:02:11 +11:00
bors
8aca4bab08 Auto merge of #131951 - notriddle:notriddle/sha256-compile-time, r=GuillaumeGomez
rustdoc: hash assets at rustdoc build time

Since sha256 is slow enough to show up on small benchmarks, we can save time by embedding the hash in the executable.

Addresses https://github.com/rust-lang/rust/pull/131934#issuecomment-2424213861
2024-10-24 05:48:56 +00:00
Rain
7f74c894b0 [musl] use posix_spawn if a directory change was requested
Currently, not all libcs have the `posix_spawn_file_actions_addchdir_np` symbol
available to them. So we attempt to do a weak symbol lookup for that function.
But that only works if libc is a dynamic library -- with statically linked musl
binaries the symbol lookup would never work, so we would never be able to use it
even if the musl in use supported the symbol.

Now that Rust has a minimum musl version of 1.2.3, all supported musl versions
now include this symbol, so we can unconditionally expect it to be there. This
symbol was added to libc in https://github.com/rust-lang/libc/pull/3949 -- use
it here.

I couldn't find any tests for whether the posix_spawn path is used, but I've
verified with cargo-nextest that this change works. This is a substantial
improvement to nextest's performance with musl. On my workstation with a Ryzen
7950x, against https://github.com/clap-rs/clap at
61f5ee514f8f60ed8f04c6494bdf36c19e7a8126:

Before:

```
     Summary [   1.071s] 879 tests run: 879 passed, 0 skipped
```

After:

```
     Summary [   0.392s] 879 tests run: 879 passed, 0 skipped
```

Fixes #99740.
2024-10-23 22:11:55 -07:00
bors
55b7f8e800 Auto merge of #132094 - Zalathar:rollup-5r1ppqt, r=Zalathar
Rollup of 10 pull requests

Successful merges:

 - #130225 (Rename Receiver -> LegacyReceiver)
 - #131169 (Fix `target_vendor` in QNX Neutrino targets)
 - #131623 (misc cleanups)
 - #131756 (Deeply normalize `TypeTrace` when reporting type error in new solver)
 - #131898 (minor `*dyn` cast cleanup)
 - #131909 (Prevent overflowing enum cast from ICEing)
 - #131930 (Don't allow test revisions that conflict with built in cfgs)
 - #131956 (coverage: Pass coverage mappings to LLVM as separate structs)
 - #132076 (HashStable for rustc_feature::Features: stop hashing compile-time constant)
 - #132088 (Print safety correctly in extern static items)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-24 03:24:50 +00:00
Stuart Cook
7e2bbc30b3
Rollup merge of #132088 - compiler-errors:extern-static, r=jieyouxu
Print safety correctly in extern static items

Fixes #132080

r? spastorino or anyone really
2024-10-24 14:19:58 +11:00
Stuart Cook
006a14230f
Rollup merge of #132076 - RalfJung:feature-hashing, r=nnethercote,Mark-Simulacrum
HashStable for rustc_feature::Features: stop hashing compile-time constant

It seems like back in 542bc75dea this was added as "hash the boolean value of each lang feature", but then in 1487bd6a17 this got split into first hashing a sequence of `bool`s (representing all the features) and then hashing all the feature names... but the list of feature names is a compile-time constant, so it seems entirely unnecessary to hash them?

Cc `@Mark-Simulacrum` who wrote the second of the commits mentioned above.
Cc `@nnethercote`
2024-10-24 14:19:57 +11:00
Stuart Cook
8f354fc94a
Rollup merge of #131956 - Zalathar:llvm-counters, r=compiler-errors,Swatinem
coverage: Pass coverage mappings to LLVM as separate structs

Instead of trying to cram *N* different kinds of coverage mapping data into a single list for FFI, pass *N* different lists of simpler structs.

This avoids the need to fill unused fields with dummy values, and avoids the need to tag structs with their underlying kind. It also lets us call the dedicated LLVM constructors for each different mapping type, instead of having to go through the complex general-purpose constructor.

Even though this adds multiple new structs to the FFI surface area, the resulting C++ code is simpler and shorter.

---

I've structured this mostly as a single atomic patch, rather than a series of incremental changes, because that avoids the need to make fiddly fixes to code that is about to be deleted anyway.
2024-10-24 14:19:57 +11:00
Stuart Cook
f7f411dd4e
Rollup merge of #131930 - clubby789:revision-cfg-collide, r=jieyouxu
Don't allow test revisions that conflict with built in cfgs

Fixes #128964

Sorry `@heysujal` I started working on this about 1 minute before your comment by complete coincidence 😅
2024-10-24 14:19:56 +11:00
Stuart Cook
4b02d642dd
Rollup merge of #131909 - clubby789:enum-overflow-cast, r=compiler-errors
Prevent overflowing enum cast from ICEing

Fixes #131902
2024-10-24 14:19:56 +11:00
Stuart Cook
4c0bab3192
Rollup merge of #131898 - lukas-code:ptr-cast-cleanup, r=compiler-errors
minor `*dyn` cast cleanup

Small follow-up to https://github.com/rust-lang/rust/pull/130234 to remove a redundant check and clean up comments. No functional changes.

Also, explain why casts cannot drop the principal even though coercions can, and add a test because apparently we didn't have one already.

r? `@WaffleLapkin` or `@compiler-errors`
2024-10-24 14:19:55 +11:00
Stuart Cook
ad43be310f
Rollup merge of #131756 - compiler-errors:deeply-normalize-type-err, r=lcnr
Deeply normalize `TypeTrace` when reporting type error in new solver

Normalize the values that come from the `TypeTrace` for various type mismatches.

Side-note: We can't normalize the `TypeError` itself bc it may come from instantiated binders, so it may reference values from within the probe...

r? lcnr
2024-10-24 14:19:55 +11:00
Stuart Cook
77f2c57b3f
Rollup merge of #131623 - matthiaskrgr:clippy_sat, r=Nadrieril
misc cleanups
2024-10-24 14:19:54 +11:00
Stuart Cook
40d787234b
Rollup merge of #131169 - madsmtm:target-info-nto-vendor, r=wesleywiser
Fix `target_vendor` in QNX Neutrino targets

The `x86_64-pc-nto-qnx710` and `i586-pc-nto-qnx700` targets have `pc` in their target triple names, but the vendor was set to the default `"unknown"`.

CC target maintainers `@flba-eb,` `@gh-tr,` `@jonathanpallant` and `@japaric`
2024-10-24 14:19:53 +11:00
Stuart Cook
9c73bcfa8d
Rollup merge of #130225 - adetaylor:rename-old-receiver, r=wesleywiser
Rename Receiver -> LegacyReceiver

As part of the "arbitrary self types v2" project, we are going to replace the current `Receiver` trait with a new mechanism based on a new, different `Receiver` trait.

This PR renames the old trait to get it out the way. Naming is hard. Options considered included:
* HardCodedReceiver (because it should only be used for things in the standard library, and hence is sort-of hard coded)
* LegacyReceiver
* TargetLessReceiver
* OldReceiver

These are all bad names, but fortunately this will be temporary. Assuming the new mechanism proceeds to stabilization as intended, the legacy trait will be removed altogether.

Although we expect this trait to be used only in the standard library, we suspect it may be in use elsehwere, so we're landing this change separately to identify any surprising breakages.

It's known that this trait is used within the Rust for Linux project; a patch is in progress to remove their dependency.

This is a part of the arbitrary self types v2 project,
https://github.com/rust-lang/rfcs/pull/3519
https://github.com/rust-lang/rust/issues/44874

r? `@wesleywiser`
2024-10-24 14:19:53 +11:00
许杰友 Jieyou Xu (Joe)
464b2425d8 compiletest: suppress Windows Error Reporting (WER) for run-make tests 2024-10-24 11:03:22 +08:00
Michael Goulet
4217b8702d Deeply normalize type trace in type error reporting 2024-10-24 02:48:28 +00:00
Michael Goulet
1920c66a8d Plumb through param_env to note_type_err 2024-10-24 02:48:08 +00:00
Michael Goulet
d8dc31fd3d Consider param-env candidates even if they have errors 2024-10-24 01:48:44 +00:00
Michael Goulet
4e1b3ab0e7 Print safety correctly in extern static items 2024-10-24 00:41:27 +00:00
Michael Howell
a53655a023 rustdoc: adjust spacing and typography in header 2024-10-23 19:15:23 -04:00
bors
b8bb2968ce Auto merge of #132079 - fmease:rollup-agrd358, r=fmease
Rollup of 9 pull requests

Successful merges:

 - #130991 (Vectorized SliceContains)
 - #131928 (rustdoc: Document `markdown` module.)
 - #131955 (Set `signext` or `zeroext` for integer arguments on RISC-V and LoongArch64)
 - #131979 (Minor tweaks to `compare_impl_item.rs`)
 - #132036 (Add a test case for #131164)
 - #132039 (Specialize `read_exact` and `read_buf_exact` for `VecDeque`)
 - #132060 ("innermost", "outermost", "leftmost", and "rightmost" don't need hyphens)
 - #132065 (Clarify documentation of `ptr::dangling()` function)
 - #132066 (Fix a typo in documentation of `pointer::sub_ptr()`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-23 22:28:57 +00:00
Matthias Krüger
d84d659cb5 clone range in a more obvious way 2024-10-23 22:22:58 +02:00
Matthias Krüger
464f4057c2 fix some manual_map 2024-10-23 22:22:56 +02:00
Matthias Krüger
dab76eccdf fix a couple clippy:complexitys
double_parens
 filter_map_identity
 needless_question_mark
 redundant_guards
2024-10-23 22:15:59 +02:00
León Orell Valerian Liehr
fbe33e35af
Rollup merge of #132066 - tifv:ptr-docs-typo, r=Amanieu
Fix a typo in documentation of `pointer::sub_ptr()`

Just a typo in docs.
2024-10-23 22:11:06 +02:00
León Orell Valerian Liehr
b0a8e4e030
Rollup merge of #132065 - tifv:dangling-docs, r=Noratrieb
Clarify documentation of `ptr::dangling()` function

Also fixes the safety comment in `NonNull::dangling()` function.

Fixes #132004.
2024-10-23 22:11:06 +02:00
León Orell Valerian Liehr
8b1141a5c3
Rollup merge of #132060 - joshtriplett:innermost-outermost, r=jieyouxu
"innermost", "outermost", "leftmost", and "rightmost" don't need hyphens

These are all standard dictionary words and don't require hyphenation.

-----

Encountered an instance of this in error messages and it bugged me, so I
figured I'd fix it across the entire codebase.
2024-10-23 22:11:05 +02:00
León Orell Valerian Liehr
28aacb3d03
Rollup merge of #132039 - a1phyr:vecdeque_read_exact, r=Noratrieb
Specialize `read_exact` and `read_buf_exact` for `VecDeque`
2024-10-23 22:11:05 +02:00
León Orell Valerian Liehr
f3d4887a4a
Rollup merge of #132036 - DianQK:test-131164, r=jieyouxu
Add a test case for #131164

The upstream has already been fixed, but it won't be backported to LLVM 19.

r? jieyouxu or compiler

try-job: x86_64-gnu-stable
2024-10-23 22:11:04 +02:00
León Orell Valerian Liehr
6b70ff44bc
Rollup merge of #131979 - compiler-errors:compare-pred-entail, r=fmease
Minor tweaks to `compare_impl_item.rs`

1. Stop using the `InstantiatedPredicates` struct for `hybrid_preds` in `compare_impl_item.rs`, since we never actually push anything into the `spans` part of it.
2. Remove redundant impl args and don't do useless identity substitution, prefer calling `instantiate_identity`.
2024-10-23 22:11:04 +02:00
León Orell Valerian Liehr
a144561608
Rollup merge of #131955 - SpriteOvO:riscv-int-arg-attr, r=workingjubilee
Set `signext` or `zeroext` for integer arguments on RISC-V and LoongArch64

This PR contains 3 commits:

- the first one introduces a new function `adjust_for_rust_abi` in `rustc_target`, and moves the x86 specific adjustment code into it;
- the second one adds RISC-V specific adjustment code into it, which sets `signext` or `zeroext` attribute for integer arguments.
- **UPDATE**: added the 3rd commit to apply the same adjustment for LoongArch64.
2024-10-23 22:11:03 +02:00
León Orell Valerian Liehr
8af1851b0a
Rollup merge of #131928 - aDotInTheVoid:wait-we-support-this, r=GuillaumeGomez
rustdoc: Document `markdown` module.

Rustdoc markdown handling is currently split between:

- html::markdown, which contains all the meaty login
- markdown, which is only used for when rustdoc renders a standalone markdown file

Adds module-level doc-comment to markdown, and rename the function so it's clear that it's doing IO (instead of just rendering to a string).
2024-10-23 22:11:03 +02:00
León Orell Valerian Liehr
af2c7dffda
Rollup merge of #130991 - LaihoE:vectorized_slice_contains, r=Noratrieb
Vectorized SliceContains

Godbolt for the u32 case: https://rust.godbolt.org/z/exT9xYWGs

Unsure about:
- Should align_to be used? It didn't seem to matter in my benchmark but maybe I was lucky with alignment?
- Should u8/i8 also be implemented? Currently uses memchr (SWAR)

Some benchmarks on x86 (contains called on an array with no matches, worst case may be slightly worse):

## Large N
![large_n_contains](https://github.com/user-attachments/assets/5be79072-970b-44be-a56c-16dc677dee46)

## Small N
![small_n_contains](https://github.com/user-attachments/assets/b8a33790-c176-459f-84f4-05feee893cd0)
2024-10-23 22:11:02 +02:00
bors
4f2f477fde Auto merge of #132070 - fmease:rollup-4i4k587, r=fmease
Rollup of 5 pull requests

Successful merges:

 - #131043 (Refactor change detection for rustdoc and download-rustc)
 - #131181 (Compiletest: Custom differ)
 - #131487 (Add wasm32v1-none target (compiler-team/#791))
 - #132054 (do not remove `.cargo` directory)
 - #132058 (CI: rfl: use rust-next temporary commit)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-23 19:26:00 +00:00
Eric Huss
df8551b60a Update rustbook to support new test linking in reference 2024-10-23 11:44:23 -07:00
Eric Huss
87fb4eaa9d Update reference 2024-10-23 11:44:23 -07:00
Eric Huss
66ebb47b04 Update Cargo.lock due to mdbook extension changes 2024-10-23 11:44:23 -07:00
rustbot
ed02421bad Update books 2024-10-23 11:44:17 -07:00
Laiho
c11bfd828e vectorized SliceContains 2024-10-23 20:14:17 +02:00
clubby789
2e3091d66c Don't allow test revisions that conflict with built in cfgs 2024-10-23 18:05:27 +00:00
Ding Xiang Fei
0689b2139f
stabilize shorter-tail-lifetimes 2024-10-24 01:56:08 +08:00
Ralf Jung
03048096f6 stop hashing compile-time constant 2024-10-23 19:46:52 +02:00
León Orell Valerian Liehr
5f0626cdb1
Rollup merge of #132058 - adetaylor:use-rust-next-in-ci, r=lqd
CI: rfl: use rust-next temporary commit

Commit c95bbb59a9b22f9b838b15d28319185c1c884329 within rust-next contains some changes required to be compatible with upcoming arbitraty self types work. Roll RFL CI forward to the latest rust-next to include that work.

Related:
https://github.com/rust-lang/rust/pull/130225
https://github.com/rust-lang/rust/issues/44874

r? ``@ojeda``

try-job: x86_64-rust-for-linux
2024-10-23 17:24:32 +02:00
León Orell Valerian Liehr
bb65499b61
Rollup merge of #132054 - onur-ozkan:cargo-config, r=Kobzol
do not remove `.cargo` directory

If vendoring isn't used bootstrap removes `.cargo` directory, which prevents developers from setting certain options in the `.cargo/config.toml` file. This was introduced in https://github.com/rust-lang/rust/pull/97513 (specifically in [this commit](345eb14f6c)). Also, since https://github.com/rust-lang/rust/pull/123942, vendoring is now possible even in git sources, which means we shouldn't remove `.cargo` directory in git sources anymore.
2024-10-23 17:24:31 +02:00
León Orell Valerian Liehr
03cb7de189
Rollup merge of #131487 - graydon:wasm32v1-none, r=alexcrichton
Add wasm32v1-none target (compiler-team/#791)

This is a preliminary implementation of the MCP discussed in [compiler-team#791](https://github.com/rust-lang/compiler-team/issues/791). It's not especially "major" but you know, process! Anyway it adds a new wasm32v1-none target which just pins down a set of wasm features. I think this is close to the consensus that emerged when discussing it on Zulip so I figured I'd sketch to see how hard it is. Turns out not very.
2024-10-23 17:24:31 +02:00
León Orell Valerian Liehr
f2675002a0
Rollup merge of #131181 - dev-ardi:custom-differ, r=jieyouxu
Compiletest: Custom differ

This adds support for a custom differ for compiletests. It’s purely visual and helps produce cleaner output when UI tests fail.

I’m using an environment variable for now since it’s experimental and I don’t want to drill the cli arguments all the way down. Also did a bit of general cleanup while I was at it.

This is how it looks [with debug info silenced](https://github.com/rust-lang/rust/pull/131182) (#131182)
`COMPILETEST_DIFF_TOOL="/usr/bin/env difft --color always --background light --display side-by-side" ./x test tests/ui/parser`
![image](https://github.com/user-attachments/assets/f740ce50-7564-4469-be0a-86e24bc50eb8)
2024-10-23 17:24:30 +02:00
León Orell Valerian Liehr
4caa60c032
Rollup merge of #131043 - liwagu:unify, r=albertlarsan68,onur-ozkan
Refactor change detection for rustdoc and download-rustc

This pull request refactors the change detection logic in the build process by consolidating redundant code into a new helper method. The key changes include the removal of duplicate logic for checking changes in directories and the addition of a new method to handle this functionality.

Refactoring and code simplification:

* [`src/bootstrap/src/core/build_steps/tool.rs`](diffhunk://#diff-dc86e288bcf7b3ca3f8c127d3568fbafc785704883bc7fc336bd185910aed5daL588-R593): Removed redundant change detection logic and replaced it with a call to the new `check_for_changes` method.
* [`src/bootstrap/src/core/config/config.rs`](diffhunk://#diff-5f5330cfcdb0a89b85ac3547b761c3a45c2534a85c4aaae8fea88c711a7a65b2R2837-R2872): Added a new method `check_for_changes` to centralize the logic for detecting changes in specified directories since a given commit.
* [`src/bootstrap/src/core/config/config.rs`](diffhunk://#diff-5f5330cfcdb0a89b85ac3547b761c3a45c2534a85c4aaae8fea88c711a7a65b2L2728-R2740): Updated the existing change detection code to use the new `check_for_changes` method.

Cleanup:

* [`src/bootstrap/src/core/build_steps/tool.rs`](diffhunk://#diff-dc86e288bcf7b3ca3f8c127d3568fbafc785704883bc7fc336bd185910aed5daL13-R13): Removed the unused import `git` from the helpers module.

   r? ``@AlbertLarsan68``
2024-10-23 17:24:30 +02:00