Commit graph

164941 commits

Author SHA1 Message Date
Jakub Beránek
21e488c00a
Rollup merge of #144676 - tiif:dev_guide_unstable_bound, r=BoxyUwU
Add documentation for unstable_feature_bound

There is more detail and explanation in https://hackmd.io/``````@tiif/Byd3mq7Ige``````

Original PR that implemented this: rust-lang/rust#140399

r? ``````@BoxyUwU`````` to nominate for types team discussion
2025-08-06 15:55:43 +02:00
bors
dc0bae1db7 Auto merge of #143684 - nikic:llvm-21, r=cuviper
Update to LLVM 21

Timeline: LLVM 21.1.0 is scheduled to release on Aug 26th. Rust 1.90 branches on Aug 1st and releases September 18.

Depends on:
 * [x] https://github.com/llvm/llvm-project/issues/147781
 * [x] https://github.com/llvm/llvm-project/issues/147935
 * [x] https://github.com/llvm/llvm-project/issues/139443
 * [x] https://github.com/llvm/llvm-project/pull/148207
 * [x] https://github.com/llvm/llvm-project/pull/148607
 * [x] https://github.com/llvm/llvm-project/pull/149046
 * [x] https://github.com/llvm/llvm-project/issues/149097
 * [x] https://github.com/rust-lang/rust/pull/144116

r? `@ghost`
2025-08-06 04:36:54 +00:00
Nikita Popov
e6c0e63bd5 Use runtimes build for host compiler-rt build
The project build for compiler-rt is deprecated.

The runtimes build will use the just-built clang. As such, we
also need to pass --gcc-toolchain to the runtimes build, so that
it can find the GCC installation.
2025-08-05 15:43:51 +02:00
bors
213d946a38 Auto merge of #144303 - Kobzol:bootstrap-tool-cleanup, r=jieyouxu
Consolidate staging for `rustc_private` tools

This PR continues bootstrap refactoring, this time by consolidating staging for `Mode::ToolRustc` tools. This refactoring was in the critical path of refactoring `test`/`dist`/`clippy`/`doc` steps, and getting rid of the rmeta/rlib sysroot copy, because tools are pervasive and they are being used for a lot of things in bootstrap.

The main idea is to explicitly model the fact that a stage N `Mode::ToolRustc` tool always works with two different compilers:
- Stage N-1 rustc (`build_compiler`) builds stage N rustc (`target_compiler`)
- Rlib artifacts from stage N rustc are copied to the sysroot of stage N-1 rustc
- Stage N-1 rustc builds the (stage N) tool itself, the tool links to the rlib artifacts of the stage N rustc

Before, the code often used `compiler`, which meant sometimes the build compiler, sometimes the target compiler, and sometimes neither (looking at you, `download-rustc`). This is especially annoying when you get to a situation where you have an install step that invokes a dist step that invokes a tool build step, where *some* compiler is being propagated through, without it being clear what does that compiler represent. This refactoring hopefully makes that clearer and more explicit. It also gets rid of a few `builder.ensure(Rustc(...))` calls within bootstrap, which is always nice.

`Rustdoc` needs to be handled a bit specially, because it acts as a compiler itself, I documented that in the changes.

It wasn't practical to do these refactorings in multiple PRs, so I did it all in one PR. The meat of the change is 9ee6d1c1ed112c3dcfb5684b33772b136df0dca3.

I tested manually that `x build rustdoc` and `x build miri` still works even with `download-rustc`, although I cannot promise any extra support for `download-rustc`, IMO we will just have to reimplement it from scratch in a different way.

As usually, I did some drive-by refactorings to bootstrap, trying to document and clarify things, add more step metadata and tests.

Since these changes broke Cargo, which was incorrectly using `Mode::ToolRustc`, I also changed cargo to `ToolTarget` in this PR.

Best reviewed commit-by-commit (note that I renamed `link_compiler` to `target_compiler`, in accordance to the rest of bootstrap, in the last commit).

r? `@jieyouxu`

try-job: x86_64-gnu-aux
try-job: x86_64-msvc-ext1
2025-08-05 11:34:14 +00:00
Samuel Tardieu
518e367f9e
Rollup merge of #144905 - tshepang:rdg-sync, r=jieyouxu
rustc-dev-guide subtree update

Subtree update of `rustc-dev-guide` to 1263fc2367.

Created using https://github.com/rust-lang/josh-sync.

r? ``@ghost``
2025-08-05 03:51:41 +02:00
Samuel Tardieu
99a1939884
Rollup merge of #144887 - lnicola:sync-from-ra, r=lnicola
`rust-analyzer` subtree update

Subtree update of `rust-analyzer` to 8d75311400.

Created using https://github.com/rust-lang/josh-sync.

r? `@ghost`
2025-08-05 03:51:40 +02:00
Samuel Tardieu
ebd865efc4
Rollup merge of #144813 - jieyouxu:no-top-level-tests, r=Kobzol
Add a tidy check to prevent adding UI tests directly under `tests/ui/`

This PR implements https://github.com/rust-lang/compiler-team/issues/902.

Only the last commit (adding the new check) is functional; earlier commits are just small drive-by changes to make the other ui/ui-fulldeps checks more logically contained.

r? ```@Kobzol``` (or compiler)
2025-08-05 03:51:35 +02:00
Samuel Tardieu
3ec8b67672
Rollup merge of #144779 - Kobzol:bootstrap-dot, r=jieyouxu
Implement debugging output of the bootstrap Step graph into a DOT file

There are already a bunch of ways how we can debug bootstrap, so why not add one more =D (ideally I'd like to consolidate these approaches somewhat, ```@Shourya742``` is looking into that, but I think that this specific debugging tool is orthogonal to the rest of them, and is quite useful).

This PR adds the option to render the bootstrap step graph into the DOT format, in order to understand what steps were executed, along with their fields (`Debug` output).

Here you can see an example of the generated DOT files for the `BOOTSTRAP_TRACING=1 ./x build compiler --stage 2 --dry-run` command on x64 Linux. One is with cached deps (what this PR does), the other one without.

[bootstrap-dot.zip](https://github.com/user-attachments/files/21548679/bootstrap-dot.zip)

Visual example:
<img width="1899" height="445" alt="image" src="https://github.com/user-attachments/assets/ae40e6d2-0ea8-48bb-b77e-6b21700b95ee" />

r? ```@jieyouxu```
2025-08-05 03:51:35 +02:00
Samuel Tardieu
2e97165e92
Rollup merge of #144467 - hydro-project:users/mingwes/rustdoc-fix-cors, r=GuillaumeGomez
rustdoc template font links only emit `crossorigin` when needed

The `crossorigin` attribute may cause issues when the href is not actually cross-origin. Specifically, the tag causes the browser to send a preflight OPTIONS request to the server even if it is same-origin. Some temperamental servers may reject all CORS preflight requests even if they're actually same-origin, which causes a CORS error and prevents the fonts from loading, even later on.

This commit fixes that problem by not emitting `crossorigin` if the url appears to be relative to the same origin.
2025-08-05 03:51:32 +02:00
Jakub Beránek
ac28b5b93a
Fix splitting dylib paths 2025-08-04 12:21:27 +02:00
Jakub Beránek
2f4b40fe4e
Do not render both cached and uncached edge between two steps 2025-08-04 08:29:18 +02:00
Jakub Beránek
450040f2d3
Implement debugging output of the bootstrap Step graph into a DOT file 2025-08-04 08:29:18 +02:00
Stuart Cook
7307dc0ca1
Rollup merge of #144694 - compiler-errors:with-self-ty, r=SparrowLii
Distinguish prepending and replacing self ty in predicates

There are two kinds of functions called `with_self_ty`:
1. Prepends the `Self` type onto an `ExistentialPredicate` which lacks it in its internal representation.
2. Replaces the `Self` type of an existing predicate, either for diagnostics purposes or in the new trait solver when normalizing that self type.

This PR distinguishes these two because I often want to only grep for one of them. Namely, let's call it `with_replaced_self_ty` when all we're doing is replacing the self type.
2025-08-04 14:58:09 +10:00
The rustc-josh-sync Cronjob Bot
682a6e17e4 Merge ref '383b9c447b' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 383b9c447b
Filtered ref: 14b7b0bbd1e38402fca29ef84e5f75ee9d8cb1a9

This merge was created using https://github.com/rust-lang/josh-sync.
2025-08-04 04:25:09 +00:00
The rustc-josh-sync Cronjob Bot
b8d1af5e56 Prepare for merging from rust-lang/rust
This updates the rust-version file to 383b9c447b.
2025-08-04 04:24:59 +00:00
Stuart Cook
7fbb303147
Rollup merge of #144853 - Kivooeo:rust_-cleanup, r=Mark-Simulacrum
Remove unnecessary `rust_` prefixes

part of https://github.com/rust-lang/rust/issues/116005

Honestly, not sure if this can affect linking somehow, also I didn't touched things like `__rust_panic_cleanup` and `__rust_start_panic` which very likely will break something, so just small cleanup here

also didn't changed `rust_panic_without_hook` because it was renamed here https://github.com/rust-lang/rust/pull/144852

r? libs
2025-08-04 11:24:42 +10:00
Stuart Cook
22653b8c1e
Rollup merge of #144848 - Zalathar:ui-fulldeps, r=clubby789
For "stage 1" ui-fulldeps, use the stage 1 compiler to query target info

Testing ui-fulldeps in "stage 1" actually uses the stage 0 compiler, so that test programs can link against stage 1 rustc crates.

Unfortunately, using the stage 0 compiler causes problems when compiletest tries to obtain target information from the compiler, but the output format has changed since the last bootstrap beta bump.

We can work around this by also providing compiletest with a stage 1 compiler, and having it use that compiler to query for target information.

---

This fixes the stage 1 ui-fulldeps failure seen at https://github.com/rust-lang/rust/pull/144443#issuecomment-3146992771.
2025-08-04 11:24:41 +10:00
Stuart Cook
79e7e0359e
Rollup merge of #144811 - jieyouxu:target-maintainer-docs, r=Noratrieb
Stylize `*-lynxos178-*` target maintainer handle to make it easier to copy/paste

Apparently I forgot to submit this branch I had lying around.

Noticed while reviewing Tier 3 target platform support pages. In the same style as rust-lang/rust#139028.
2025-08-04 11:24:41 +10:00
Stuart Cook
0225f8b09c
Rollup merge of #144706 - zachs18:fix-144661, r=RalfJung
Do not give function allocations alignment in consteval and Miri.

We do not yet have a (clear and T-lang approved) design for how `#[align(N)]` on functions should affect function pointers' addresses on various platforms, so for now do not give function pointers alignment in consteval and Miri.

----

Old summary:

Not a full solution to <https://github.com/rust-lang/rust/issues/144661>, but fixes the immediate issue by making function allocations all have alignment 1 in consteval, ignoring `#[rustc_align(N)]`, so the compiler doesn't know if any offset other than 0 is non-null.

A more "principlied" solution would probably be to make function pointers to `#[instruction_set(arm::t32)]` functions be at offset 1 of an align-`max(2, align attribute)` allocation instead of at offset 0 of their allocation during consteval, and on wasm to either disallow `#[align(N)]` where N > 1, or to pad the function table such that the function pointer of a `#[align(N)]` function is a multiple of `N` at runtime.
2025-08-04 11:24:39 +10:00
Stuart Cook
2a947a0efa
Rollup merge of #144322 - Urgau:dangling-ptr-from-locals, r=oli-obk
Add lint against dangling pointers from local variables

## `dangling_pointers_from_locals`

*warn-by-default*

The `dangling_pointers_from_locals` lint detects getting a pointer to data of a local that will be dropped at the end of the function.

### Example

```rust
fn f() -> *const u8 {
    let x = 0;
    &x // returns a dangling ptr to `x`
}
```

```text
warning: a dangling pointer will be produced because the local variable `x` will be dropped
  --> $DIR/dangling-pointers-from-locals.rs:10:5
   |
LL | fn simple() -> *const u8 {
   |                --------- return type of the function is `*const u8`
LL |     let x = 0;
   |         - `x` is defined inside the function and will be drop at the end of the function
LL |     &x
   |     ^^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned
   = note: `#[warn(dangling_pointers_from_locals)]` on by default
```

### Explanation

Returning a pointer from a local value will not prolong its lifetime, which means that the value can be dropped and the allocation freed while the pointer still exists, making the pointer dangling.

If you need stronger guarantees, consider using references instead, as they are statically verified by the borrow-checker to never dangle.

------

This is related to GitHub codeql [CWE-825](https://github.com/github/codeql/blob/main/rust/ql/src/queries/security/CWE-825/AccessAfterLifetimeBad.rs) which shows examples of such simple miss-use.

It should be noted that C compilers warns against such patterns even without `-Wall`, https://godbolt.org/z/P7z98arrc.

------

`@rustbot` labels +I-lang-nominated +T-lang
cc `@traviscross`
r? compiler
2025-08-04 11:24:36 +10:00
Samuel Tardieu
d0d648d764
Rollup merge of #144843 - rust-lang:cargo_update, r=clubby789
Weekly `cargo update`

Automation to keep dependencies in `Cargo.lock` current.
r? dep-bumps

The following is the output from `cargo update`:

```txt

compiler & tools dependencies:
     Locking 14 packages to latest compatible versions
    Updating clap v4.5.41 -> v4.5.42
    Updating clap_builder v4.5.41 -> v4.5.42
    Updating jsonpath-rust v1.0.3 -> v1.0.4
    Updating libredox v0.1.6 -> v0.1.9
    Updating object v0.37.1 -> v0.37.2
    Updating redox_syscall v0.5.16 -> v0.5.17
    Updating redox_users v0.5.0 -> v0.5.2
    Updating rustc-demangle v0.1.25 -> v0.1.26
    Updating serde_json v1.0.141 -> v1.0.142
    Updating wasm-encoder v0.235.0 -> v0.236.0
    Updating wasmparser v0.235.0 -> v0.236.0
    Updating wast v235.0.0 -> v236.0.0
    Updating wat v1.235.0 -> v1.236.0
    Updating windows-targets v0.53.2 -> v0.53.3
note: pass `--verbose` to see 36 unchanged dependencies behind latest

library dependencies:
     Locking 3 packages to latest compatible versions
    Updating object v0.37.1 -> v0.37.2
    Updating rustc-demangle v0.1.25 -> v0.1.26
    Updating unwinding v0.2.7 -> v0.2.8
note: pass `--verbose` to see 2 unchanged dependencies behind latest

rustbook dependencies:
     Locking 6 packages to latest compatible versions
    Updating cc v1.2.30 -> v1.2.31
    Updating clap v4.5.41 -> v4.5.42
    Updating clap_builder v4.5.41 -> v4.5.42
    Updating redox_syscall v0.5.16 -> v0.5.17
    Updating serde_json v1.0.141 -> v1.0.142
    Updating windows-targets v0.53.2 -> v0.53.3
```
2025-08-03 21:57:01 +02:00
Samuel Tardieu
84b6025411
Rollup merge of #144805 - Zalathar:proc-res, r=jieyouxu
compiletest: Preliminary cleanup of `ProcRes` printing/unwinding

While experimenting with changes to how compiletest handles output capture, error reporting, and unwinding, I repeatedly ran in to difficulties with this core code for reporting test failures caused by a subprocess.

There should be no change in compiletest output.

r? jieyouxu
2025-08-03 21:56:57 +02:00
Samuel Tardieu
3823f0bc07
Rollup merge of #144738 - bjorn3:remove_omit_gdb_pretty_printer_section, r=jieyouxu
Remove the omit_gdb_pretty_printer_section attribute

Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
2025-08-03 21:56:56 +02:00
Kivooeo
3aeeae6d44 remove rust_ prefixes 2025-08-03 23:25:36 +05:00
Hmikihiro
277cf46d3e Remove unused functions from edit_in_place 2025-08-03 19:40:54 +09:00
Zalathar
3abbdffdbf For "stage 1" ui-fulldeps, use the stage 1 compiler to query target info
Testing ui-fulldeps in "stage 1" actually uses the stage 0 compiler, so that
test programs can link against stage 1 rustc crates.

Unfortunately, using the stage 0 compiler causes problems when compiletest
tries to obtain target information from the compiler, but the output format has
changed since the last bootstrap beta bump.

We can work around this by also providing compiletest with a stage 1 compiler,
and having it use that compiler to query for target information.
2025-08-03 18:07:54 +10:00
Lukas Wirth
0d2a7e6654
Merge pull request #20371 from Hmikihiro/migrate_generate_trait_from_impl
Migrate `generate_trait_from_impl` assist to use `SyntaxEditor`
2025-08-03 07:23:07 +00:00
Hmikihiro
b373cb1006 Migrate generate_trait_from_impl assist to use SyntaxEditor 2025-08-03 16:12:08 +09:00
Lukas Wirth
e47f791a60
Merge pull request #20368 from Hmikihiro/migrate_delegate_methods
Migrate `generate_delegate_methods` assist to use `SyntaxEditor`
2025-08-03 06:37:22 +00:00
Lukas Wirth
279b4643e8
Merge pull request #20364 from Hmikihiro/migrate_convert_from_to_tryfrom
Migrate `convert_from_to_tryfrom` assist to use `SyntaxEditor`
2025-08-03 06:36:15 +00:00
Tshepang Mbambo
f84c62112a there is still no official policy 2025-08-03 07:18:26 +02:00
Tshepang Mbambo
3bba46bb52
Merge pull request #2509 from rust-lang/tshepang-auto-toc
make toc generation fully automatic
2025-08-03 06:55:44 +02:00
Zalathar
1063b0f090 Change TestCx::error to error_prefix, which returns a string
This reduces the amount of "hidden" printing in error-reporting code, which
will be helpful when overhauling compiletest's error handling and output
capture.
2025-08-03 13:47:40 +10:00
Zalathar
d1d44d44f1 Consolidate all ProcRes unwinds into one code path 2025-08-03 13:38:08 +10:00
Zalathar
2ddf0ca9f5 Change ProcRes::print_info to format_info
This method now returns a string instead of printing directly to
(possibly-captured) stdout.
2025-08-03 13:38:07 +10:00
github-actions
97435739ff cargo update
compiler & tools dependencies:
     Locking 14 packages to latest compatible versions
    Updating clap v4.5.41 -> v4.5.42
    Updating clap_builder v4.5.41 -> v4.5.42
    Updating jsonpath-rust v1.0.3 -> v1.0.4
    Updating libredox v0.1.6 -> v0.1.9
    Updating object v0.37.1 -> v0.37.2
    Updating redox_syscall v0.5.16 -> v0.5.17
    Updating redox_users v0.5.0 -> v0.5.2
    Updating rustc-demangle v0.1.25 -> v0.1.26
    Updating serde_json v1.0.141 -> v1.0.142
    Updating wasm-encoder v0.235.0 -> v0.236.0
    Updating wasmparser v0.235.0 -> v0.236.0
    Updating wast v235.0.0 -> v236.0.0
    Updating wat v1.235.0 -> v1.236.0
    Updating windows-targets v0.53.2 -> v0.53.3
note: pass `--verbose` to see 36 unchanged dependencies behind latest

library dependencies:
     Locking 3 packages to latest compatible versions
    Updating object v0.37.1 -> v0.37.2
    Updating rustc-demangle v0.1.25 -> v0.1.26
    Updating unwinding v0.2.7 -> v0.2.8
note: pass `--verbose` to see 2 unchanged dependencies behind latest

rustbook dependencies:
     Locking 6 packages to latest compatible versions
    Updating cc v1.2.30 -> v1.2.31
    Updating clap v4.5.41 -> v4.5.42
    Updating clap_builder v4.5.41 -> v4.5.42
    Updating redox_syscall v0.5.16 -> v0.5.17
    Updating serde_json v1.0.141 -> v1.0.142
    Updating windows-targets v0.53.2 -> v0.53.3
2025-08-03 00:27:18 +00:00
bors
5b9564a189 Auto merge of #144814 - samueltardieu:rollup-qyum1hj, r=samueltardieu
Rollup of 17 pull requests

Successful merges:

 - rust-lang/rust#132748 (get rid of some false negatives in rustdoc::broken_intra_doc_links)
 - rust-lang/rust#143360 (loop match: error on `#[const_continue]` outside `#[loop_match]`)
 - rust-lang/rust#143662 ([rustdoc] Display unsafe attrs with edition 2024 `unsafe()` wrappers.)
 - rust-lang/rust#143771 (Constify some more `Result` functions)
 - rust-lang/rust#144185 (Document guarantees of poisoning)
 - rust-lang/rust#144395 (update fortanix tests)
 - rust-lang/rust#144478 (Improve formatting of doc code blocks)
 - rust-lang/rust#144614 (Fortify RemoveUnneededDrops test.)
 - rust-lang/rust#144703 ([test][AIX] ignore extern_weak linkage test)
 - rust-lang/rust#144747 (compiletest: Improve diagnostics for line annotation mismatches 2)
 - rust-lang/rust#144756 (detect infinite recursion with tail calls in ctfe)
 - rust-lang/rust#144766 (Add human readable name "Cygwin")
 - rust-lang/rust#144782 (Properly pass path to staged `rustc` to `compiletest` self-tests)
 - rust-lang/rust#144786 (Cleanup the definition of `group_type`)
 - rust-lang/rust#144796 (Add my previous commit name to .mailmap)
 - rust-lang/rust#144797 (Update safety comment for new_unchecked in niche_types)
 - rust-lang/rust#144803 (rustc-dev-guide subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-02 23:49:08 +00:00
bors
a65b04d7c9 Auto merge of #144774 - BoxyUwU:bump_1_91, r=BoxyUwU
Bump to 1.91

https://forge.rust-lang.org/release/process.html#bump-the-stable-version-number-friday-the-week-before

r? ghost
2025-08-02 20:44:34 +00:00
Lukas Wirth
f360d6ce88
Merge pull request #20351 from ChayimFriedman2/rename-self1
feat: When renaming a parameter to `self`, change callers to use method call syntax
2025-08-02 18:50:08 +00:00
Chayim Refael Friedman
ac34f3db81 When renaming a parameter to self, change callers to use method call syntax 2025-08-02 21:39:22 +03:00
Hmikihiro
e314bfaad3 Migrate generate_delegate_methods assist to use SyntaxEditor 2025-08-03 02:17:56 +09:00
Kivooeo
5ebb0dd7da update doc 2025-08-02 19:01:07 +05:00
Hmikihiro
81c4086a03 Migrate convert_from_to_tryfrom assist to use SyntaxEditor 2025-08-02 20:35:09 +09:00
Samuel Tardieu
0fcfb8bee7
Rollup merge of #144803 - tshepang:rdg-sync, r=jieyouxu
rustc-dev-guide subtree update

Subtree update of `rustc-dev-guide` to 9287205099.

Created using https://github.com/rust-lang/josh-sync.

r? `@ghost`
2025-08-02 11:24:29 +02:00
Samuel Tardieu
7a64c130f3
Rollup merge of #144782 - jieyouxu:compiletest-selftests, r=Kobzol
Properly pass path to staged `rustc` to `compiletest` self-tests

Otherwise, this can do weird things like use a global rustc, or try to use stage 0 rustc. This must be properly configured, because `compiletest` is intended to only support one compiler target spec JSON format (of the in-tree compiler).

Historically, this was probably done so before `bootstrap` was really its own thing, and `compiletest` had to be runnable as a much more "self-standing" tool.

Follow-up to rust-lang/rust#144675, as I didn't realize this until Zalathar pointed it out in [#t-infra/bootstrap > Building vs testing &#96;compiletest&#96; @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Building.20vs.20testing.20.60compiletest.60/near/532040838).

r? ````@Kobzol````
2025-08-02 11:24:27 +02:00
Samuel Tardieu
5b8118495e
Rollup merge of #144766 - Berrysoft:patch-1, r=GuillaumeGomez
Add human readable name "Cygwin"

Closes rust-lang/rust#144680
2025-08-02 11:24:26 +02:00
Samuel Tardieu
7e8ef3a818
Rollup merge of #144747 - petrochenkov:annusexp2, r=RalfJung
compiletest: Improve diagnostics for line annotation mismatches 2

Follow up to https://github.com/rust-lang/rust/pull/140622 based on feedback from https://github.com/rust-lang/rust/issues/144590.
2025-08-02 11:24:25 +02:00
Samuel Tardieu
4eddebd42b
Rollup merge of #143662 - obi1kenobi:pg/unsafe-attribute-wrappers, r=t-rustdoc
[rustdoc] Display unsafe attrs with edition 2024 `unsafe()` wrappers.

Use Rust 2024 edition representation for unsafe attributes in rustdoc HTML:
- `#[no_mangle]` -> `#[unsafe(no_mangle)]`
- `#[export_name = "foo"]` -> `#[unsafe(export_name = "foo")]`
- `#[link_section = ".text"]` -> `#[unsafe(link_section = ".text")]`

The 2024 edition representation is used regardless of the crate's own edition. This ensures that Rustaceans don't have to learn the rules of an outdated edition (e.g. that `unsafe()` wasn't always necessary) in order to understand a crate's documentation.

After some looking through the `T-rustdoc` issues, I was not able to find an existing issue for this. Apologies if I missed it.

r? ``````@aDotInTheVoid``````
2025-08-02 11:24:21 +02:00
Samuel Tardieu
fc4b3fa3f9
Rollup merge of #132748 - lolbinarycat:rustdoc-intra-doc-link-warn-more-54191, r=GuillaumeGomez
get rid of some false negatives in rustdoc::broken_intra_doc_links

rustdoc will not try to do intra-doc linking if the "path" of a link looks too much like a "real url".

however, only inline links (`[text](url)`) can actually contain a url, other types of links (reference links, shortcut links) contain a *reference* which is later resolved to an actual url.

the "path" in this case cannot be a url, and therefore it should not be skipped due to looking like a url.

fixes https://github.com/rust-lang/rust/issues/54191

to minimize the number of false positives that will be introduced, the following heuristic is used:

If there's no backticks, be lenient revert to old behavior.
This is to prevent churn by linting on stuff that isn't meant to be a link.
only shortcut links have simple enough syntax that they
are likely to be written accidentlly, collapsed and reference links
need 4 metachars, and reference links will not usually use
backticks in the reference name.
therefore, only shortcut syntax gets the lenient behavior.
here's a truth table for how link kinds that cannot be urls are handled:

|              |  is shortcut link  | not shortcut link |
|--------------|--------------------|-------------------|
| has backtick |    never ignore    |    never ignore   |
| no backtick  | ignore if url-like |    never ignore   |
2025-08-02 11:24:20 +02:00
Jieyou Xu
0b1547e9c0
Reject adding new UI tests directly under tests/ui/
As we want future UI tests to be added under a more meaningful
subdirectory instead.
2025-08-02 16:54:26 +08:00