Commit Graph

264871 Commits

Author SHA1 Message Date
Lukas Wirth
6b15103152 Allow xtask::reformat to work without rustup 2024-08-30 16:17:45 +02:00
Lukas Wirth
e69d57f16f Revert "fix: do not assume rustup is installed in xtask codegen"
This reverts commit 7d9e4fcc07e5de94e37b73436147cdbbaa35dbdc.
2024-08-30 16:15:01 +02:00
bors
9fc8eae53b Auto merge of #18008 - Veykril:inlay-hints-resolve, r=Veykril
internal: Improve inlay hint resolution reliability

The payload now ships the range the inlay hint ought to be triggered for instead of trying to estimate it from its position which is somewhat brittle
2024-08-30 13:59:05 +00:00
Lukas Wirth
be33a2e1bd Improve inlay hint resolution reliability 2024-08-30 15:57:52 +02:00
bors
27979adbda Auto merge of #18005 - rami3l:fix/for-completion-in-impl, r=Veykril
fix(ide-completion): fix handling of `for` in `impl T for A` in function body

Closes #17787.
2024-08-30 13:45:04 +00:00
rami3l
9afdc3a1d2
fix(ide-completion): fix handling of for in impl T for A in function body 2024-08-30 21:39:53 +08:00
bors
e77de38415 Auto merge of #18003 - ChayimFriedman2:addr_of-static-mut, r=Veykril
Do not report missing unsafe on `addr_of[_mut]!(EXTERN_OR_MUT_STATIC)`

The compiler no longer does as well; see https://github.com/rust-lang/rust/pull/125834.

Also require unsafe when accessing `extern` `static` (other than by `addr_of!()`).

Fixes #17978.
2024-08-30 07:55:50 +00:00
bors
a729229a21 Auto merge of #17999 - ShoyuVanilla:issue-17998, r=Veykril
fix: `std::error::Error` is object unsafe

Fixes #17998

I tried to get generic predicates of assoc function itself, not inherited from the parent here;

0ae42bd425/crates/hir-ty/src/object_safety.rs (L420-L442)

But this naive equality check approach doesn't work when the assoc function has one or more generic paramters like;

```rust
trait Foo {}
trait Bar: Foo {
    fn bar(&self);
}
```

because the generic predicates of the parent, `Bar` is `[^1.0 implements Foo]` and the generic predicates of `fn bar` is `[^1.1 implements Foo]`, which are different.

This PR implements a correct logic for filtering out parent generic predicates for this.
2024-08-30 05:53:23 +00:00
bors
16a29ced15 Auto merge of #17982 - IvarWithoutBones:generate-impl-indent, r=Veykril
fix: consider indentation in the "Generate impl" and "Generate trait impl" assists

This makes the generated impl's indentation match the ADT it targets, improving formatting when using nested modules inside of the same file or when defining types inside of a function. See the added tests for an example.

At first I tried to call some of the convenient helpers that delegate to `IndentLevel::increase_indent` on the generated impl, but as the comment on that function notes it does not indent the first token, making it inapplicable here. I hope the solution in this PR is acceptable, please let me know if I missed something :)
2024-08-30 05:38:59 +00:00
Ivar Scholten
29ecaa1edf fix: consider indentation in the "Generate impl" and "Generate trait impl" assists
This makes the generated impl's indentation match the ADT it targets, improving formatting when
using nested modules inside of the same file or when defining types inside of a function.
2024-08-29 22:12:25 +02:00
Chayim Refael Friedman
0dfe40f0a3 Do not report missing unsafe on addr_of[_mut]!(EXTERN_OR_MUT_STATIC)
The compiler no longer does as well; see https://github.com/rust-lang/rust/pull/125834.
2024-08-29 22:58:26 +03:00
Chayim Refael Friedman
8bb235baa2 Add diagnostic for accessing an extern static 2024-08-29 22:12:12 +03:00
Shoyu Vanilla
92f27dc57d fix: std::error::Error is object unsafe 2024-08-30 02:00:38 +09:00
bors
28142e4018 Auto merge of #17814 - ShoyuVanilla:object-safety, r=Veykril
feat: Implement object safety and its hovering hint

Resolves #17779

- [x] Fill missing implementations
- [x] Hover rendering
- [x] Implement object safety's own test suite, like layout
- [x] Add test cases (from rustc maybe)
- [x] Clean up ugly codes
- [x] Add doc string
2024-08-29 13:24:54 +00:00
Shoyu Vanilla
a54a7a8a6a feat: Implement object safety 2024-08-29 22:22:21 +09:00
bors
23bea2b273 Auto merge of #17975 - IvarWithoutBones:dont-assume-rustup, r=Veykril
fix: do not assume rustup is installed in xtask codegen

When formatting generated code the xtask crate attempts to run `rustup run stable rustfmt`, which fails if `rustup` is not installed. This results in test failures when another source manages the compiler toolchain, for example when using Nix (or any other distro-specific packaging solution):
* xtask::codegen::grammar::test
* xtask::codegen::assists_doc_tests::test

With this PR xtask will first attempt to run `rustup run stable rustfmt`, and if that fails just plain `rustfmt`. It still validates a stable version is being used. This allows `cargo test` to pass on systems that do not use `rustup`.
2024-08-29 10:27:39 +00:00
bors
34e7e7954c Auto merge of #17993 - ChayimFriedman2:convert-to-tuple-attrs, r=Veykril
Consider field attributes when converting from tuple to named struct and the opposite

Fixes #17983.

I tried to use the `SourceChangeBuilder::make_mut()` API, but it duplicated the attribute...
2024-08-29 08:28:46 +00:00
bors
cd377d90db Auto merge of #17991 - ChayimFriedman2:extract-variable-ref, r=Veykril
fix: Don't add reference when it isn't needed for the "Extract variable" assist

I.e. don't generate `let var_name = &foo()`. Because it always irritates me when I need to fix that.

Anything that creates a new value don't need a reference. That excludes mostly field accesses and indexing.

I had a thought that we can also not generate a reference for fields and indexing as long as the type is `Copy`, but sometimes people impl `Copy` even when they don't want to copy the values (e.g. a large type), so I didn't do that.
2024-08-29 08:14:04 +00:00
bors
b6d0fd03e1 Auto merge of #17987 - ChayimFriedman2:column-macro, r=Veykril
fix: Fix name resolution of shadowed builtin macro

Fixes #17969.
2024-08-29 07:59:12 +00:00
bors
e0625d5c08 Auto merge of #17988 - darichey:fix-scip-def, r=Veykril
Fix incorrect symbol definitions in SCIP output

The SCIP output incorrectly marks some symbols as definitions because it doesn't account for the file ID when comparing the token's range to its definition's range.

This means that if a symbol is referenced in a file at the same position at which it is defined in another file, that reference will be marked as a definition. I was quite surprised by how common this is. For example, `PartialEq` is defined [here](https://github.com/rust-lang/rust/blob/1.80.1/library/core/src/cmp.rs#L273) and `uuid` references it [here](https://github.com/uuid-rs/uuid/blob/1.8.0/src/lib.rs#L329). And what do you know, they're both at offset 10083! In our large monorepo, this happens for basically every common stdlib type!
2024-08-29 07:44:29 +00:00
bors
b195ff3ac0 Auto merge of #17940 - ChayimFriedman2:closure-to-fn, r=Veykril
feat: Create an assist to convert closure to freestanding fn

The assist converts all captures to parameters.

Closes #17920.

This was more work than I though, since it has to handle a bunch of edge cases...

Based on #17941. Needs to merge it first.
2024-08-29 07:21:46 +00:00
bors
f05888d2ae Auto merge of #17995 - lnicola:sync-from-rust, r=lnicola
minor: sync from downstream
2024-08-29 07:04:04 +00:00
Laurențiu Nicola
26888c31cf Merge from rust-lang/rust 2024-08-29 10:02:18 +03:00
Laurențiu Nicola
2ec71c8e85 Preparing for merge from rust-lang/rust 2024-08-29 10:02:05 +03:00
bors
266bb1fd96 Auto merge of #17994 - Veykril:proc-macro-srv-from-str-panic, r=Veykril
fix: Fix TokenStream::to_string implementation dropping quotation marks

Fixes https://github.com/rust-lang/rust-analyzer/issues/17986
We might wanna consider backporting this to beta if that's simple enough to do
2024-08-29 06:46:16 +00:00
Lukas Wirth
03d67458ee fix: Fix TokenStream::to_string implementation dropping quotation marks 2024-08-29 08:45:35 +02:00
Lukas Wirth
14ec1202e5 fix: Fix proc-macro server crashing when parsing a non-lexable string into a TokenStream 2024-08-29 08:45:19 +02:00
bors
3a14e301dd Auto merge of #17992 - Wilfred:newlines_in_logs, r=Veykril
internal: Avoid newlines in fetch errors

Most logs lines don't have newlines, ensure fetch errors follow this pattern. This makes it easier to see which log line is associated with the error.

Before:

    2024-08-28T21:11:58.431856Z ERROR FetchWorkspaceError:
    rust-analyzer failed to discover workspace

After:

    2024-08-28T21:11:58.431856Z ERROR FetchWorkspaceError: rust-analyzer failed to discover workspace
2024-08-29 04:52:11 +00:00
bors
6cf068db56 Auto merge of #129721 - workingjubilee:rollup-y2o1mnp, r=workingjubilee
Rollup of 14 pull requests

Successful merges:

 - #128192 (rustc_target: Add various aarch64 features)
 - #129170 (Add an ability to convert between `Span` and `visit::Location`)
 - #129343 (Emit specific message for time<=0.3.35)
 - #129378 (Clean up cfg-gating of ProcessPrng extern)
 - #129401 (Partially stabilize `feature(new_uninit)`)
 - #129467 (derive(SmartPointer): assume pointee from the single generic and better error messages)
 - #129494 (format code in tests/ui/threads-sendsync)
 - #129617 (Update books)
 - #129673 (Add fmt::Debug to sync::Weak<T, A>)
 - #129683 (copysign with sign being a NaN can have non-portable results)
 - #129689 (Move `'tcx` lifetime off of impl and onto methods for `CrateMetadataRef`)
 - #129695 (Fix path to run clippy on rustdoc)
 - #129712 (Correct trusty targets to be tier 3)
 - #129715 (Update `compiler_builtins` to `0.1.123`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-29 02:38:32 +00:00
Jubilee
bd66fadd79
Rollup merge of #129715 - Amjad50:update-compiler-builtins, r=tgross35
Update `compiler_builtins` to `0.1.123`

Includes https://github.com/rust-lang/compiler-builtins/pull/680 and fixes https://github.com/rust-lang/rust/issues/128386.

Fixed by not including math symbols of `compiler_builtins` into any `unix` target or `wasi`, old behavior is restored

r? tgross35
2024-08-28 19:12:56 -07:00
Jubilee
2ac56db8a2
Rollup merge of #129712 - randomPoison:trusty-tier-3-fix, r=saethlin
Correct trusty targets to be tier 3

The Trusty targets were added in https://github.com/rust-lang/rust/pull/129490, but in that PR I accidentally marked them as tier 2. This PR corrects the target metadata to mark them as tier 3.
2024-08-28 19:12:55 -07:00
Jubilee
ac5be35d58
Rollup merge of #129695 - GuillaumeGomez:fix-clippy-rustdoc-path, r=onur-ozkan
Fix path to run clippy on rustdoc

Took me a while to find out that the path clippy expected was `src/tools/rustdoc` and not `src/librustdoc`. I think it makes more sense this way as most commands rely on source paths.

r? ```@Kobzol```
2024-08-28 19:12:55 -07:00
Jubilee
472d164a49
Rollup merge of #129689 - compiler-errors:impl-lifetime, r=michaelwoerister
Move `'tcx` lifetime off of impl and onto methods for `CrateMetadataRef`

Unconstrained type and const variables are not allowed, but unconstrained lifetimes are. This is not very good style, though, and it leads to unnecessary captures of a lifetime in edition 2024 (not that it matters, but it does trigger the edition migration lint).
2024-08-28 19:12:54 -07:00
Jubilee
dfe66cf529
Rollup merge of #129683 - RalfJung:copysign, r=thomcc
copysign with sign being a NaN can have non-portable results

Follow-up to https://github.com/rust-lang/rust/pull/129559.
Cc ```@tgross35``` ```@beetrees```

There's no portable variant we can recommend instead here, is there? Something with a semantics like "if `sign` is a NaN, then return `self` unaltered, otherwise return `self` with the sign changed to that of `sign`"?
2024-08-28 19:12:54 -07:00
Jubilee
9ddb45e81a
Rollup merge of #129673 - matthewpipie:arc-weak-debug-trait, r=dtolnay
Add fmt::Debug to sync::Weak<T, A>

Currently, `sync::Weak<T>` implements `Debug`, but `sync::Weak<T, A>` does not. This appears to be an oversight, as `rc::Weak<T, A>` implements `Debug`. (Note: `sync::Weak` is the weak for `Arc`, and `rc::Weak` is the weak for `Rc`.)

This PR adds the Debug trait for `sync::Weak<T, A>`. The issue was initially brought up here: https://github.com/rust-lang/wg-allocators/issues/131
2024-08-28 19:12:54 -07:00
Jubilee
44519a371b
Rollup merge of #129617 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/book

4 commits in 04bc1396bb857f35b5dda1d773c9571e1f253304..e7d217be2a75ef1753f0988d6ccaba4d7e376259
2024-08-14 01:19:47 UTC to 2024-08-13 16:51:00 UTC

- Backport/forward port ch12 (rust-lang/book#4008)
- Found some more things to fix in ch7; I forgot to update the snapshot (rust-lang/book#4007)
- Remove redundant sentence. Send to nostarch (rust-lang/book#4006)
- Fix: typo (rust-lang/book#4003)

## rust-lang/edition-guide

5 commits in aeeb287d41a0332c210da122bea8e0e91844ab3e..eeba2cb9c37ab74118a4fb5e5233f7397e4a91f8
2024-08-19 23:28:06 UTC to 2024-08-15 15:12:33 UTC

- 2024: Add rustdoc combined doctests (rust-lang/edition-guide#320)
- Update for unsafe attributes stabilization (rust-lang/edition-guide#319)
- 2024: Add macro-fragment-specifiers. (rust-lang/edition-guide#312)
- Fix deprecated_safe_2024 link (rust-lang/edition-guide#317)
- Add 2024 unsafe functions (rust-lang/edition-guide#304)

## rust-embedded/book

1 commits in 019f3928d8b939ec71b63722dcc2e46330156441..ff5d61d56f11e1986bfa9652c6aff7731576c37d
2024-08-20 07:26:19 UTC to 2024-08-20 07:26:19 UTC

- Use aligned address to demonstrate HardFault (rust-embedded/book#374)

## rust-lang/nomicon

1 commits in 6ecf95c5f2bfa0e6314dfe282bf775fd1405f7e9..14649f15d232d509478206ee9ed5105641aa60d0
2024-08-14 14:49:09 UTC to 2024-08-14 14:49:09 UTC

- CI: Switch to merge queue (rust-lang/nomicon#459)

## rust-lang/reference

14 commits in 62cd0df95061ba0ac886333f5cd7f3012f149da1..0668397076da350c404dadcf07b6cbc433ad3743
2024-08-11 21:06:12 +0000 to 2024-08-27 21:47:20 +0000
- Update enum.md (rust-lang/reference#1354)
- Be consistent about how "Edition differences" is capitalized (rust-lang/reference#1586)
- Sync denied lints with upstream (rust-lang/reference#1589)
- const_eval: update for const-fn float stabilization (rust-lang/reference#1566)
- Add spec identifier syntax to destructors.md (rust-lang/reference#1571)
- Say that `pub(in path)` can't depend on `use` statements (rust-lang/reference#1559)
- bytes inside implicitly const-promoted expressions are immutable (rust-lang/reference#1554)
- Tweak `repr(transparent)` to mention requiring *at most* one non-1-ZST (rust-lang/reference#1568)
- operator expressions: add &raw (rust-lang/reference#1567)
- Rewrite the automatic std link translation, and switch to automatic links (rust-lang/reference#1578)
- Add some basic docs for unsafe attrs (rust-lang/reference#1539)
- don't capitalize Undefined Behavior (rust-lang/reference#1575)
- add the `const` operand to docs for inline assembly (rust-lang/reference#1556)
- Typo: 'a' to 'an' in type-coercions.md (rust-lang/reference#1572)

## rust-lang/rust-by-example

1 commits in 8f94061936e492159f4f6c09c0f917a7521893ff..859786c5bc99301bbc22fc631a5c2b341860da08
2024-08-26 10:30:48 UTC to 2024-08-26 10:30:48 UTC

- Update primitives.md with examples (rust-lang/rust-by-example#1878)

## rust-lang/rustc-dev-guide

7 commits in 43d83780db545a1ed6d45773312fc578987e3968..fa928a6d19e1666d8d811dfe3fd35cdad3b4e459
2024-08-26 14:46:50 UTC to 2024-08-12 21:07:49 UTC

- Fix x.py reference (rust-lang/rustc-dev-guide#2049)
- Update `stabilization_guide.md` (rust-lang/rustc-dev-guide#2034)
- Explain the internal `#[rustc_*]` TEST attributes used for debugging and inside tests (rust-lang/rustc-dev-guide#2046)
- missing char (rust-lang/rustc-dev-guide#2047)
- Replace direct http links to rustc-dev-guide.rust-lang.org (rust-lang/rustc-dev-guide#2044)
- Update index.html, 39. The MIR: fix typo (rust-lang/rustc-dev-guide#2043)
- Update LLVM docs (rust-lang/rustc-dev-guide#2039)
2024-08-28 19:12:53 -07:00
Jubilee
b94887a29c
Rollup merge of #129494 - tshepang:fmt-threads-sendsync, r=Nadrieril
format code in tests/ui/threads-sendsync

was thinking of fixing formatting for 1 test in the directory, but found a bunch of them to also be in need
2024-08-28 19:12:53 -07:00
Jubilee
d2418cb888
Rollup merge of #129467 - dingxiangfei2009:smart-pointer-relax-pointee, r=compiler-errors
derive(SmartPointer): assume pointee from the single generic and better error messages

Fix #129465

Actually RFC says that `#[pointee]` can be inferred when there is no ambiguity, or there is only one generic type parameter so to say.

cc ```@Darksonn```

r? ```@compiler-errors```
2024-08-28 19:12:52 -07:00
Jubilee
9d5f794312
Rollup merge of #129401 - workingjubilee:partial-initialization-of-stabilization, r=dtolnay,joboet
Partially stabilize `feature(new_uninit)`

Finished comment period: https://github.com/rust-lang/rust/issues/63291#issuecomment-2183022955

The following API has been stabilized from https://github.com/rust-lang/rust/issues/63291

```rust
impl<T> Box<T> { pub fn new_uninit() -> Box<MaybeUninit<T>> {…} }
impl<T> Rc<T> { pub fn new_uninit() -> Rc<MaybeUninit<T>> {…} }
impl<T> Arc<T> { pub fn new_uninit() -> Arc<MaybeUninit<T>> {…} }

impl<T> Box<[T]> { pub fn new_uninit_slice(len: usize) -> Box<[MaybeUninit<T>]> {…} }
impl<T> Rc<[T]> { pub fn new_uninit_slice(len: usize) -> Rc<[MaybeUninit<T>]> {…} }
impl<T> Arc<[T]> { pub fn new_uninit_slice(len: usize) -> Arc<[MaybeUninit<T>]> {…} }

impl<T> Box<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Box<T> {…} }
impl<T> Box<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Box<[T]> {…} }
impl<T> Rc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Rc<T> {…} }
impl<T> Rc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Rc<[T]> {…} }
impl<T> Arc<MaybeUninit<T>> { pub unsafe fn assume_init(self) -> Arc<T> {…} }
impl<T> Arc<[MaybeUninit<T>]> { pub unsafe fn assume_init(self) -> Arc<[T]> {…} }
```

The remaining API is split between new issues
- `new_zeroed_alloc`: https://github.com/rust-lang/rust/issues/129396
- `box_uninit_write`: https://github.com/rust-lang/rust/issues/129397

All relevant code is thus either stabilized or split out of that issue, so this closes #63291 as, with the FCP concluded, that issue has served its purpose.

try-job: x86_64-rust-for-linux
2024-08-28 19:12:52 -07:00
Jubilee
fcb6b7792d
Rollup merge of #129378 - goffrie:patch-3, r=ChrisDenton
Clean up cfg-gating of ProcessPrng extern

This removes a bit of duplication and is consistent with how `api-ms-win-core-synch-l1-2-0` externs are imported.
2024-08-28 19:12:51 -07:00
Jubilee
26f75a65d7
Rollup merge of #129343 - estebank:time-version, r=jieyouxu
Emit specific message for time<=0.3.35

```
error[E0282]: type annotations needed for `Box<_>`
  --> /home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.34/src/format_description/parse/mod.rs:83:9
   |
83 |     let items = format_items
   |         ^^^^^
...
86 |     Ok(items.into())
   |              ---- type must be known at this point
   |
   = note: this is an inference error on `time` caused by a change in Rust 1.80.0; update `time` to version `>=0.3.36`
```

Partially mitigate the fallout from https://github.com/rust-lang/rust/issues/127343. Although the biggest benefit of this would have been if we had had this in 1.80 before it became stable, the long-tail of that change will be felt for a *long* time, so better late than never.

We can also emit an even more targeted error instead of this inference failure.
2024-08-28 19:12:50 -07:00
Jubilee
2572e0e8c9
Rollup merge of #129170 - artemagvanian:span-to-location, r=celinval
Add an ability to convert between `Span` and `visit::Location`

AFAIK, there is no way to create a `Location` from a `Span` because its only field is private. This makes it impossible to use visitor methods like `visit_statement` or `visit_terminator`.

This PR adds an implementation for`From<Span>` for `Location` to fix this.

r? ```@celinval```
2024-08-28 19:12:50 -07:00
Jubilee
4c8c9e092d
Rollup merge of #128192 - mrkajetanp:feature-detect, r=Amanieu
rustc_target: Add various aarch64 features

Add various aarch64 features already supported by LLVM and Linux.
Additionally include some comment fixes to ensure consistency of feature names with the Arm ARM.
Compiler support for features added to stdarch by https://github.com/rust-lang/stdarch/pull/1614.
Tracking issue for unstable aarch64 features is https://github.com/rust-lang/rust/issues/127764.

List of added features:

- FEAT_CSSC
- FEAT_ECV
- FEAT_FAMINMAX
- FEAT_FLAGM2
- FEAT_FP8
- FEAT_FP8DOT2
- FEAT_FP8DOT4
- FEAT_FP8FMA
- FEAT_HBC
- FEAT_LSE128
- FEAT_LSE2
- FEAT_LUT
- FEAT_MOPS
- FEAT_LRCPC3
- FEAT_SVE_B16B16
- FEAT_SVE2p1
- FEAT_WFxT
- FEAT_SME
- FEAT_SME_F16F16
- FEAT_SME_F64F64
- FEAT_SME_F8F16
- FEAT_SME_F8F32
- FEAT_SME_FA64
- FEAT_SME_I16I64
- FEAT_SME_LUTv2
- FEAT_SME2
- FEAT_SME2p1
- FEAT_SSVE_FP8DOT2
- FEAT_SSVE_FP8DOT4
- FEAT_SSVE_FP8FMA

FEAT_FPMR is added in the first commit and then removed in a separate one to highlight it being removed from upstream LLVM 19. The intention is for it to be detectable at runtime through stdarch but not have a corresponding Rust compile-time feature.
2024-08-28 19:12:49 -07:00
David Richey
c2c1bd0c13 Fix incorrect symbol definitions in SCIP output 2024-08-28 19:57:26 -05:00
Amjad Alsharafi
555414e683
Update compiler_builtins to 0.1.123
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
2024-08-29 08:38:19 +08:00
Wilfred Hughes
e691f6d040 internal: Add doc comments to OpQueue 2024-08-28 16:29:18 -07:00
Nicole LeGare
d8129a1c01 Correct trusty targets to be tier 3 2024-08-28 16:15:36 -07:00
bors
acb4e8b625 Auto merge of #127537 - veluca93:struct_tf, r=BoxyUwU
Implement a first version of RFC 3525: struct target features

This PR is an attempt at implementing https://github.com/rust-lang/rfcs/pull/3525, behind a feature gate `struct_target_features`.

There's obviously a few tasks that ought to be done before this is merged; in no particular order:
- add proper error messages
- add tests
- create a tracking issue for the RFC
- properly serialize/deserialize the new target_features field in `rmeta` (assuming I even understood that correctly :-))

That said, as I am definitely not a `rustc` expert, I'd like to get some early feedback on the overall approach before fixing those things (and perhaps some pointers for `rmeta`...), hence this early PR :-)

Here's an example piece of code that I have been using for testing - with the new code, the calls to intrinsics get correctly inlined:
```rust
#![feature(struct_target_features)]

use std::arch::x86_64::*;

/*
// fails to compile
#[target_feature(enable = "avx")]
struct Invalid(u32);
*/

#[target_feature(enable = "avx")]
struct Avx {}

#[target_feature(enable = "sse")]
struct Sse();

/*
// fails to compile
extern "C" fn bad_fun(_: Avx) {}
*/

/*
// fails to compile
#[inline(always)]
fn inline_fun(_: Avx) {}
*/

trait Simd {
    fn do_something(&self);
}

impl Simd for Avx {
    fn do_something(&self) {
        unsafe {
            println!("{:?}", _mm256_setzero_ps());
        }
    }
}

impl Simd for Sse {
    fn do_something(&self) {
        unsafe {
            println!("{:?}", _mm_setzero_ps());
        }
    }
}

struct WithAvx {
    #[allow(dead_code)]
    avx: Avx,
}

impl Simd for WithAvx {
    fn do_something(&self) {
        unsafe {
            println!("{:?}", _mm256_setzero_ps());
        }
    }
}

#[inline(never)]
fn dosomething<S: Simd>(simd: &S) {
    simd.do_something();
}

fn main() {
    /*
    // fails to compile
    Avx {};
    */

    if is_x86_feature_detected!("avx") {
        let avx = unsafe { Avx {} };
        dosomething(&avx);
        dosomething(&WithAvx { avx });
    }
    if is_x86_feature_detected!("sse") {
        dosomething(&unsafe { Sse {} })
    }
}
```

Tracking:

- https://github.com/rust-lang/rust/issues/129107
2024-08-28 22:54:55 +00:00
Esteban Küber
b013a3ddf0 Emit specific message for time<0.3.35 inference failure
```
error[E0282]: type annotations needed for `Box<_>`
  --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.34/src/format_description/parse/mod.rs:83:9
   |
83 |     let items = format_items
   |         ^^^^^
...
86 |     Ok(items.into())
   |              ---- type must be known at this point
   |
   = note: this is an inference error on crate `time` caused by a change in Rust 1.80.0; update `time` to version `>=0.3.35`
```

Partially address #127343.
2024-08-28 22:53:02 +00:00
Chayim Refael Friedman
b3fcd8e6b2 Consider field attributes when converting from tuple to named struct and the opposite 2024-08-29 01:14:25 +03:00