Commit Graph

281895 Commits

Author SHA1 Message Date
Augie Fackler
b41c232488 tests: fix up new test for nocapture -> capture(none) change
Same motivation as #136287, but for a newly introduced test. Rather than
over-constraining here, we just match the sret and accept pretty much
all other attributes.

@rustbot label llvm-main
r? @nikic
2025-02-25 17:46:05 -05:00
bors
9f48dedc97 Auto merge of #137192 - kornelski:windows-tls-lto, r=ChrisDenton
Remove obsolete Windows ThinLTO+TLS workaround

The bug #109797 has been fixed by #129079, so this workaround is no longer needed.
2025-02-21 11:43:00 +00:00
bors
a18bd8acfc Auto merge of #137346 - workingjubilee:rollup-sxu05ms, r=workingjubilee
Rollup of 12 pull requests

Successful merges:

 - #131651 (Create a generic AVR target: avr-none)
 - #134340 (Stabilize `num_midpoint_signed` feature)
 - #136473 (infer linker flavor by linker name if it's sufficiently specific)
 - #136608 (Pass through of target features to llvm-bitcode-linker and handling them)
 - #136985 (Do not ignore uninhabited types for function-call ABI purposes. (Remove BackendRepr::Uninhabited))
 - #137270 (Fix `*-win7-windows-msvc` target since 26eeac1a1e)
 - #137312 (Update references to cc_detect.rs)
 - #137318 (Workaround Cranelift not yet properly supporting vectors smaller than 128bit)
 - #137322 (Update docs for default features of wasm targets)
 - #137324 (Make x86 QNX target name consistent with other Rust targets)
 - #137338 (skip submodule updating logics on tarballs)
 - #137340 (Add a notice about missing GCC sources into source tarballs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-21 00:16:10 +00:00
Jubilee
4d479f9c80
Rollup merge of #137340 - Kobzol:bootstrap-dir-check, r=onur-ozkan
Add a notice about missing GCC sources into source tarballs

I didn't use `.gitkeep`, because that would be a hidden file that might not be noticed, whereas we want to let people inspecting the archive know why the sources are missing.

Inspired by https://github.com/rust-lang/rust/issues/137332.

r? `@onur-ozkan`
2025-02-20 14:58:22 -08:00
Jubilee
02ceb5fb52
Rollup merge of #137338 - onur-ozkan:137332, r=Kobzol
skip submodule updating logics on tarballs

Running submodule logic on tarballs isn't necessary since git isn't available there.

Fixes #137332
2025-02-20 14:58:21 -08:00
Jubilee
8aa75f5ec6
Rollup merge of #137324 - flba-eb:rename_qnx_target_name_i586, r=workingjubilee
Make x86 QNX target name consistent with other Rust targets

Rename target to be consistent with other Rust targets: Use `i686` instead of `i586`
See also
- #136495
- #109173

CC: `@jonathanpallant` `@japaric` `@gh-tr` `@samkearney`
2025-02-20 14:58:21 -08:00
Jubilee
3d5e77353d
Rollup merge of #137322 - alexcrichton:update-wasm-docs, r=jieyouxu
Update docs for default features of wasm targets

LLVM 20 enabled the `nontrapping-fptoint` and `bulk-memory` features by default, so this updates the corresponding documentation for the `wasm32-*` targets (which all point to `wasm32-unknown-unknown`).

Closes #137315 with a doc update for the doc part.
2025-02-20 14:58:20 -08:00
Jubilee
8d5eb73ea6
Rollup merge of #137318 - bjorn3:cg_clif_abi_workaround, r=workingjubilee
Workaround Cranelift not yet properly supporting vectors smaller than 128bit

While it would technically be possible to workaround this in cg_clif, it quickly becomes very messy and would likely cause correctness issues. Working around it in rustc instead is much simper and won't have any negative impact for code running on stable as vectors smaller than 128bit can only be made on nightly using core::simd or #[repr(simd)].
2025-02-20 14:58:19 -08:00
Jubilee
0d47366f0b
Rollup merge of #137312 - jmqd:master, r=clubby789
Update references to cc_detect.rs

The locations of these file references have since been changed.
This is a simple change to update the references to this `cc_detect.rs`
file.
2025-02-20 14:58:19 -08:00
Jubilee
f24b140976
Rollup merge of #137270 - QianNangong:master, r=ChrisDenton
Fix `*-win7-windows-msvc` target since 26eeac1a1e

That commit make it failed to build `std` with `*-win7-windows-msvc` so fix it.
2025-02-20 14:58:18 -08:00
Jubilee
8c9e3749a1
Rollup merge of #136985 - zachs18:backend-repr-remove-uninhabited, r=workingjubilee
Do not ignore uninhabited types for function-call ABI purposes. (Remove BackendRepr::Uninhabited)

Accepted MCP: https://github.com/rust-lang/compiler-team/issues/832

Fixes #135802

Do not consider the inhabitedness of a type for function call ABI purposes.

* Remove the [`rustc_abi::BackendRepr::Uninhabited`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_abi/enum.BackendRepr.html) variant
  * Instead calculate the `BackendRepr` of uninhabited types "normally" (as though they were not uninhabited "at the top level", but still considering inhabitedness of variants to determine enum layout, etc)
* Add an `uninhabited: bool` field to [`rustc_abi::LayoutData`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_abi/struct.LayoutData.html) so inhabitedness of a `LayoutData` can still be queried when necessary (e.g. when determining if an enum variant needs a tag value allocated to it).

This should not affect type layouts (size/align/field offset); this should only affect function call ABI, and only of uninhabited types.

cc ``@RalfJung``
2025-02-20 14:58:18 -08:00
Jubilee
6d74563b20
Rollup merge of #136608 - kulst:ptx_target_features, r=bjorn3
Pass through of target features to llvm-bitcode-linker and handling them

When using the llvm-bitcode-linker (`linker-flavor=llbc`) target-features are not passed through and are not handled by it.
The llvm-bitcode-linker is mainly used as a self contained linker to link llvm bitcode for the nvptx64 target. It uses `llvm-link`, `opt` and `llc` internally. To produce a `.ptx` file of a specific ptx-version it is necessary to pass the version to llc with the `--mattr` option. Without explicitly setting it, the emitted `.ptx`-version is the minimum supported version of the `--target-cpu`.

I would like to be able to explicitly set the ptx version as [some llvm problems only occur in earlier `.ptx`-versions](https://github.com/llvm/llvm-project/issues/112998).

Therefore this pull request adds support for passing target features to llvm-bitcode-linker and handling them.
I was not quite sure if adding these features to `rustc_target/src/target_features.rs` is necessary or not. If so I will gladly add these.

    r? ``@kjetilkjeka``
2025-02-20 14:58:17 -08:00
Jubilee
921ef32467
Rollup merge of #136473 - usamoi:infer_linker_hints, r=petrochenkov
infer linker flavor by linker name if it's sufficiently specific

Fix: `rustc` does not infer `llvm-bitcode-linker` uses `llbc` linker flavor if targeting `nvptx64-nvidia-cuda`.
2025-02-20 14:58:16 -08:00
Jubilee
480a72d601
Rollup merge of #134340 - Urgau:stabilize-num_midpoint_signed, r=scottmcm
Stabilize `num_midpoint_signed` feature

This PR proposes that we stabilize the signed variants of [`iN::midpoint`](https://github.com/rust-lang/rust/issues/110840#issue-1684506201), the operation is equivalent to doing `(a + b) / 2` in a sufficiently large number.

The stabilized API surface would be:

```rust
/// Calculates the middle point of `self` and `rhs`.
///
/// `midpoint(a, b)` is `(a + b) / 2` as if it were performed in a
/// sufficiently-large signed integer type. This implies that the result is
/// always rounded towards zero and that no overflow will ever occur.

impl i{8,16,32,64,128,size} {
    pub const fn midpoint(self, rhs: Self) -> Self;
}
```

T-libs-api previously stabilized the unsigned (and float) variants in #131784, the signed variants were left out because of the rounding that should be used in case of negative midpoint.

This stabilization proposal proposes that we round towards zero because:
 - it makes the obvious `(a + b) / 2` in a sufficiently-large number always true
   - using another rounding for the positive result would be inconsistent with the unsigned variants
 - it makes `midpoint(-a, -b)` == `-midpoint(a, b)` always true
 - it is consistent with `midpoint(a as f64, b as f64) as i64`
 - it makes it possible to always suggest `midpoint` as a replacement for `(a + b) / 2` expressions *(which we may want to do as a future work given the 21.2k hits on [GitHub Search](https://github.com/search?q=lang%3Arust+%2F%5C%28%5Ba-zA-Z_%5D*+%5C%2B+%5Ba-zA-Z_%5D*%5C%29+%5C%2F+2%2F&type=code&p=1))*

`@scottmcm` mentioned a drawback in https://github.com/rust-lang/rust/pull/132191#issuecomment-2439891200:
> I'm torn, because rounding towards zero makes it "wider" than other values, which `>> 1` avoids -- `(a + b) >> 1` has the nice behaviour that `midpoint(a, b) + 2 == midpoint(a + 2, b + 2)`.
>
> But I guess overall sticking with `(a + b) / 2` makes sense as well, and I do like the negation property 🤷

Which I think is outweigh by the advantages cited above.

Closes #110840
cc `@rust-lang/libs-api`
cc `@scottmcm`
r? `@dtolnay`
2025-02-20 14:58:16 -08:00
Jubilee
9de94b4f8f
Rollup merge of #131651 - Patryk27:avr-unknown-unknown, r=tgross35
Create a generic AVR target: avr-none

This commit removes the `avr-unknown-gnu-atmega328` target and replaces it with a more generic `avr-none` variant that must be specialized using `-C target-cpu` (e.g. `-C target-cpu=atmega328p`).

Seizing the day, I'm adding myself as the maintainer of this target - I've been already fixing the bugs anyway, might as well make it official 🙂

Related discussions:
- https://github.com/rust-lang/rust/pull/131171
- https://github.com/rust-lang/compiler-team/issues/800

try-job: x86_64-gnu-debug
2025-02-20 14:58:15 -08:00
Jakub Beránek
c0bea5d92d Add a notice about missing GCC sources in source tarballs 2025-02-20 21:06:25 +01:00
onur-ozkan
d2203ad59c skip submodule updating logics on tarballs
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-02-20 22:49:38 +03:00
Jakub Beránek
953515131b Improve error message when a submodule directory is missing completely 2025-02-20 20:43:57 +01:00
Ralf Jung
e3f5db07e0 fine-tune comment 2025-02-20 13:41:24 -06:00
zachs18
6493cd8699 Adjust LayoutData::uninhabited doc comment.
Co-authored-by: Jubilee <workingjubilee@gmail.com>
2025-02-20 13:41:24 -06:00
Zachary S
58ebf6afdd Add test that uninhabited repr(transparent) type has same function return ABI as wrapped type.
Fix codegen of uninhabited PassMode::Indirect return types.

Add codegen test for uninhabited PassMode::Indirect return types.

Enable optimizations for uninhabited return type codegen test
2025-02-20 13:41:11 -06:00
Zachary S
bcfde13d51 Update check to reflect that non-ZST uninhabited types should not be PassMode::Ignore. 2025-02-20 13:41:11 -06:00
Zachary S
c33fb5ae85 Update ui tests with LayoutData { uninhabited: ... } etc 2025-02-20 13:40:41 -06:00
Zachary S
7ba3d7b54e Remove BackendRepr::Uninhabited, replaced with an uninhabited: bool field in LayoutData.
Also update comments that refered to BackendRepr::Uninhabited.
2025-02-20 13:27:32 -06:00
bors
f04bbc60f8 Auto merge of #136771 - scottmcm:poke-slice-iter-next, r=joboet
Simplify `slice::Iter::next` enough that it inlines

Inspired by this zulip conversation: <https://rust-lang.zulipchat.com/#narrow/channel/189540-t-compiler.2Fwg-mir-opt/topic/Feedback.20on.20a.20MIR.20optimization.20idea/near/498579990>

~~Draft for now because it needs #136735 to get the codegen tests to pass.~~
2025-02-20 18:20:40 +00:00
Florian Bartels
32a1ff1aaf Make x86 QNX target name consistent with other Rust targets 2025-02-20 17:10:32 +00:00
Alex Crichton
c2aed39ea7 Update docs for default features of wasm targets
LLVM 20 enabled the `nontrapping-fptoint` and `bulk-memory` features by
default, so this updates the corresponding documentation for the
`wasm32-*` targets (which all point to `wasm32-unknown-unknown`).

cc #137315
2025-02-20 08:18:22 -08:00
bjorn3
18c210c786 Workaround Cranelift not yet properly supporting vectors smaller than 128bit
While it would technically be possible to workaround this in cg_clif, it
quickly becomes very messy and would likely cause correctness issues.
Working around it in rustc instead is much simper and won't have any
negative impact for code running on stable as vectors smaller than
128bit can only be made on nightly using core::simd or #[repr(simd)].
2025-02-20 15:06:56 +00:00
Patryk Wychowaniec
d5128f9274
avr-rjmp-offset: Explain .target_cpu() 2025-02-20 15:05:06 +01:00
bors
28b83ee596 Auto merge of #137123 - Zalathar:user-type-span, r=oli-obk
Don't store a redundant span in user-type projections

While experimenting with some larger changes, I noticed that storing this span here is unnecessary, because it is also present in the corresponding `CanonicalUserTypeAnnotation` and can be retrieved via the annotation's ID.
2025-02-20 12:19:14 +00:00
usamoi
c23bf48e4f infer linker flavor by linker name if it's sufficiently specific 2025-02-20 19:46:48 +08:00
Jordan McQueen
81ab20f34e Update references to cc_detect.rs
The locations of these files have since been changed. This is a simple
change to update the references to these files.
2025-02-20 10:41:29 +00:00
Zalathar
8bb574fdd3 Don't store a redundant span in user-type projections
This span is already present in the corresponding
`CanonicalUserTypeAnnotation`, and can be retrieved via the annotation's ID.
2025-02-20 20:37:17 +11:00
Zalathar
a64efc72d0 Avoid a useless clone of UserTypeProjection 2025-02-20 20:31:06 +11:00
Zalathar
bf3bb5fd37 Flatten the check for ref/non-ref bindings 2025-02-20 20:31:06 +11:00
Zalathar
849b0920b1 Partly flatten the user-type loop in TypeVerifier::visit_local_decl 2025-02-20 20:31:06 +11:00
bors
c62239aeb3 Auto merge of #137058 - scottmcm:trunc-unchecked, r=nikic
Emit `trunc nuw` for unchecked shifts and `to_immediate_scalar`

- For shifts this shrinks the IR by no longer needing an `assume` while still providing the UB information
- Having this on the `i8`→`i1` truncations will hopefully help with some places that have to load `i8`s or pass those in LLVM structs without range information
2025-02-20 09:05:22 +00:00
bors
eeb9035117 Auto merge of #137023 - Kobzol:bump-sccache, r=marcoieni
Bump sccache in CI to 0.9.1

We haven't updated the used sccache version for years, it has accrued a bunch of fixes and features in the meantime. It now supports the `--show-adv-stats` flag, which gives a more detailed summary of the results of caching. And it can also cache Rust code, which could be useful in the future (https://github.com/rust-lang/rust/pull/136942 - although now there are no large wins).

It also supports caching PGO now, but since the PGO profiles are always different, it won't make any real difference.

https://github.com/rust-lang/rust/pull/133076 previously tried to update the version to 0.3 (CC `@klensy)`

r? `@marcoieni`
2025-02-20 05:59:04 +00:00
bors
6d3c050de8 Auto merge of #137295 - matthiaskrgr:rollup-tdu3t39, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #135296 (interpret: adjust vtable validity check for higher-ranked types)
 - #137106 (Add customized compare for Link in rustdoc)
 - #137253 (Restrict `bevy_ecs` `ParamSet` hack)
 - #137262 (Make fewer crates depend on `rustc_ast_ir`)
 - #137263 (Register `USAGE_OF_TYPE_IR_INHERENT`, remove inherent usages)
 - #137266 (MIR visitor tweaks)
 - #137269 (Pattern Migration 2024: properly label `&` patterns whose subpatterns are from macro expansions)
 - #137277 (stabilize `inherent_str_constructors`)
 - #137281 (Tweak "expected ident" parse error to avoid talking about doc comments)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-20 02:39:28 +00:00
Matthias Krüger
ed45c1187f
Rollup merge of #137281 - estebank:doc-comment-syntax-error, r=compiler-errors
Tweak "expected ident" parse error to avoid talking about doc comments

When encountering a doc comment without an identifier after, we'd unconditionally state "this doc comment doesn't document anything", swallowing the *actual* error which is that the thing *after* the doc comment wasn't expected. Added a check that the found token is something that "conceptually" closes the previous item before emitting that error, otherwise just complain about the missing identifier.

In both of the following cases, the syntax error follows a doc comment:
```
error: expected identifier, found keyword `Self`
  --> $DIR/doc-before-bad-variant.rs:4:5
   |
LL | enum TestEnum {
   |      -------- while parsing this enum
...
LL |     Self,
   |     ^^^^ expected identifier, found keyword
   |
   = help: enum variants can be `Variant`, `Variant = <integer>`, `Variant(Type, ..., TypeN)` or `Variant { fields: Types }`
```
```
error: expected identifier, found `<`
  --> $DIR/doc-before-syntax-error.rs:2:1
   |
LL | <>
   | ^ expected identifier
```

Fix #71982.
2025-02-20 00:55:16 +01:00
Matthias Krüger
be73ea82ce
Rollup merge of #137277 - m4rch3n1ng:stabilize-inherent-str-constructors, r=tgross35
stabilize `inherent_str_constructors`

fcp done in https://github.com/rust-lang/rust/issues/131114#issuecomment-2668859969.

tracking issue: #131114
closes: #131114
2025-02-20 00:55:16 +01:00
Matthias Krüger
704a024688
Rollup merge of #137269 - dianne:fix-ref-pat-label-span, r=davidtwco
Pattern Migration 2024: properly label `&` patterns whose subpatterns are from macro expansions

See the failing test output in the first commit for an example of what this going wrong looks like. The error/lint diagnostic tries to point to just the `&` or `&mut` of reference patterns when labeling the causes, to make the output clearer (#134394). The trimming there wasn't quite right though: it used the interior of the reference pattern as a cutoff and extended backwards to find where to trim the pattern's span, but this breaks if the `&` and the interior are from different sources. This PR instead trims by starting at the start of the pattern and ending at the final character of the `&` (or `&mut`, `ref`, `ref mut`, or `mut`, depending on what the error/lint is labeling); that way, there's no opportunity for failure from mixing sources.

I'm not 100% happy with this approach, but I'm also not sure what the best practices are as far as hacky `SourceMap` munching goes, so please let me know if something else would be preferred.

Since `SourceMap::span_through_char` can't change the syntax context of the span, I've also removed a call to `Span::with_ctxt` (we care about the edition of the span in question since this is a hard error in Rust 2024). If we want to be extra safe in case that changes, I can re-add it or track error hardness separately in the `rust_2024_migration_desugared_pats` table.
2025-02-20 00:55:15 +01:00
Matthias Krüger
10ba57516f
Rollup merge of #137266 - nnethercote:mir-visitor-tweaks, r=compiler-errors
MIR visitor tweaks

Some minor improvements I found while looking at this code.

r? `@tmandry`
2025-02-20 00:55:14 +01:00
Matthias Krüger
4981994588
Rollup merge of #137263 - compiler-errors:inherentless, r=lcnr
Register `USAGE_OF_TYPE_IR_INHERENT`, remove inherent usages

I implemented a lint to discourage the usage of `rustc_type_ir::inherent` but never actually enabled it. People started using `rustc_type_ir::inherent` methods through globs, lol.

r? fmease or reassign as you please
2025-02-20 00:55:14 +01:00
Matthias Krüger
80e861c142
Rollup merge of #137262 - compiler-errors:ast-ir-begone, r=lcnr
Make fewer crates depend on `rustc_ast_ir`

I think it simplifies the crate graph and also exposes people less to confusion if downstream crates don't interact with `rustc_ast_ir` directly and instead just use its functionality reexported through more familiar paths.

r? oli-obk since you introduced ast-ir
2025-02-20 00:55:13 +01:00
Matthias Krüger
4f84ba1a20
Rollup merge of #137253 - compiler-errors:bevy-hack, r=jackh726
Restrict `bevy_ecs` `ParamSet` hack

This limits the bevy WF hack to only apply to ADTs named `ParamSet` that come from crates named `bevy_ecs`, and references to the latter.

Previously, we were applying it to all ADTs that contained the substring `"ParamSet"`. This could show up anywhere in the ADT name, and it could come from any crate. It's a bit concerning since other code could theoretically begin to rely on this behavior too (though I don't expect it to)

This simplifies the logic a bit and turns it into a visitor.

r? `@jackh726`
2025-02-20 00:55:13 +01:00
Matthias Krüger
8ccfd06e46
Rollup merge of #137106 - chenyukang:yukang-fix-sidebar-sort, r=notriddle
Add customized compare for Link in rustdoc

Maybe some other types in sidebar need to be sorted in this way, maybe add this crate `natord` is ok?

r?  clubby789

Fixes #137098
2025-02-20 00:55:12 +01:00
Matthias Krüger
6055793062
Rollup merge of #135296 - lukas-code:dyn-leak-check, r=compiler-errors
interpret: adjust vtable validity check for higher-ranked types

## What

Transmuting between trait objects where a generic argument or associated type only differs in bound regions (not bound at or above the trait object's binder) is now UB. For example

* transmuting between `&dyn Trait<for<'a> fn(&'a u8)>` and `&dyn Trait<fn(&'static u8)>` is UB.
* transmuting between `&dyn Trait<Assoc = for<'a> fn(&'a u8)>` and `&dyn Trait<Assoc = fn(&'static u8)>` is UB.
* transmuting between `&dyn Trait<for<'a> fn(&'a u8) -> (&'a u8, &'static u8)>` and `&dyn Trait<for<'a> fn(&'a u8) -> (&'static u8, &'a u8)>` is UB.

Transmuting between subtypes (in either direction) is still allowed, which means that bound regions that are bound at or above the trait object's binder can still be changed:

* transmuting between `&dyn for<'a> Trait<fn(&'a u8)>` and `&dyn for Trait<fn(&'static u8)>` is fine.
* transmuting between `&dyn for<'a> Trait<dyn Trait<fn(&'a u8)>>` and `&dyn for Trait<dyn Trait<fn(&'static u8)>>` is fine.

## Why

Very similar to https://github.com/rust-lang/rust/issues/120217 and https://github.com/rust-lang/rust/issues/120222, changing a trait object's generic argument to a type that only differs in bound regions can still affect the vtable layout and lead to segfaults at runtime (for an example see `src/tools/miri/tests/fail/validity/dyn-transmute-inner-binder.rs`).

Since we already already require that the trait object predicates must be equal modulo bound regions, it is only natural to extend this check to also require type equality considering bound regions.

However, it also makes sense to allow transmutes between a type and a subtype thereof. For example `&dyn for<'a> Trait<&'a u8>` is a subtype of `&dyn Trait<&'static ()>` and they are guaranteed to have the same vtable, so it makes sense to allow this transmute. So that's why bound lifetimes that are bound to the trait object itself are treated as free lifetime for the purpose of this check.

Note that codegen already relies on the property that subtyping cannot change the the vtable and this is asserted here (note the leak check): 251206c27b/compiler/rustc_codegen_ssa/src/base.rs (L106-L153)

Furthermore, we allow some pointer-to-pointer casts like `*const dyn for<'a> Trait<&'a u8>` to `*const Wrapper<dyn Trait<&'static u8>>` that instantiate the trait object binder and are currently lowered to a single pointer-to-pointer cast in MIR (`CastKind::PtrToPtr`) and *not* an unsizing coercion (`CastKind::PointerCoercion(Unsize)`), so the current MIR lowering of these would be UB if we didn't allow subtyping transmutes.

---

fixes https://github.com/rust-lang/rust/issues/135230
cc `@rust-lang/opsem`
r? `@compiler-errors` for the implementation
2025-02-20 00:55:11 +01:00
bors
4e1356b959 Auto merge of #137290 - matthiaskrgr:rollup-a7xdbi4, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #120580 (Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants)
 - #132268 (Impl TryFrom<Vec<u8>> for String)
 - #136093 (Match Ergonomics 2024: update old-edition behavior of feature gates)
 - #136344 (Suggest replacing `.` with `::` in more error diagnostics.)
 - #136690 (Use more explicit and reliable ptr select in sort impls)
 - #136815 (CI: Stop /msys64/bin from being prepended to PATH in msys2 shell)
 - #136923 (Lint `#[must_use]` attributes applied to methods in trait impls)
 - #137155 (Organize `OsString`/`OsStr` shims)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-19 23:29:37 +00:00
Matthias Krüger
3964bb131b
Rollup merge of #137155 - thaliaarchi:wtf8-organize, r=ChrisDenton
Organize `OsString`/`OsStr` shims

Synchronize the `bytes.rs` and `wtf8.rs` shims for `OsString`/`OsStr` so they're easier to diff between each other. This is mostly ordering items the same between the two. I tried to minimize moves and went for the average locations between the files.

With them in the same order, it is clear that `FromInner<_>` is not implemented for `bytes::Buf` and `Clone::clone_from` is not implemented for `wtf8::Buf`, but they are for the other. Fix that.

I added #[inline] to all inherent methods of the `OsString`/`OsStr` shims, because it seemed that was already the rough pattern. `bytes.rs` has more inlining than `wtf8.rs`, so I added the corresponding ones to `wtf8.rs`. Then, the common missing ones have no discernible pattern to me. They're not divided by non-allocating/allocating. Perhaps the pattern is that UTF-8 validation isn't inlined? Since these types are merely the inner values in `OsStr`/`OsString`, I put inline on all methods and let those public types dictate inlining. I have not inspected codegen or run benchmarks.

Also, touch up some (private) documentation comments.

r? ``````@ChrisDenton``````
2025-02-19 21:16:12 +01:00